o
    ˷e~	                     @   s   d dl mZmZmZmZmZmZmZ d dlm	Z	 er d dl
mZ dgZede	dZG dd dee Zd	ee d
ee fddZdS )    )TYPE_CHECKINGIterableListTypeVarUnioncastoverload)OneStyleAndTextTuple)SupportsIndexexplode_text_fragments_T)boundc                       s   e Zd ZdZdZdeddfddZdee ddf fd	d
ZdddeddfddZ	e
dddeddfddZe
dedee ddfddZdedef deeee f ddf fddZ  ZS )_ExplodedListz
    Wrapper around a list, that marks it as 'exploded'.

    As soon as items are added or the list is extended, the new items are
    automatically exploded as well.
    TitemreturnNc                 C   s   |  |g d S N)extend)selfr    r   R/var/www/ideatree/venv/lib/python3.10/site-packages/prompt_toolkit/layout/utils.pyappend   s   z_ExplodedList.appendlstc                    s   t  t| d S r   )superr   r   )r   r   	__class__r   r   r      s   z_ExplodedList.extendindexr
   c                 C   s   t r   )NotImplementedError)r   r   r   r   r   r   insert   s   z_ExplodedList.insertvaluec                 C      d S r   r   r   r   r   r   r   r   __setitem__$      z_ExplodedList.__setitem__c                 C   r   r   r   r    r   r   r   r!   (   r"   c                    sR   t |ts| }t||d }t |trtd|g}t |ttd| dS )zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
           zList[_T]zIterable[_T]N)
isinstanceslice	__index__tupler   r   r!   r   )r   r   r   	int_indexr   r   r   r!   ,   s   

)__name__
__module____qualname____doc__explodedr   r   r   r   r   r   r!   r%   r   __classcell__r   r   r   r   r      s"    
r   	fragmentsr   c                 C   sH   t | tr| S g }| D ]^}}}|D ]}|||g|R  qqt|S )a.  
    Turn a list of (style_str, text) tuples into another list where each string is
    exactly one character.

    It should be fine to call this function several times. Calling this on a
    list that is already exploded, is a null operation.

    :param fragments: List of (style, text) tuples.
    )r$   r   r   )r/   resultstylestringrestcr   r   r   r   <   s   
N)typingr   r   r   r   r   r   r   "prompt_toolkit.formatted_text.baser	   typing_extensionsr
   __all__r   r   r   r   r   r   r   <module>   s   $ -