o
    �õ±jX	  ã                   @  s€   d dl mZ d dlmZ d dl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dd„ZdS )é    )Úannotations)ÚIterable)ÚTYPE_CHECKINGÚTypeVarÚcastÚoverload)ÚOneStyleAndTextTuple)ÚSupportsIndexÚexplode_text_fragmentsÚ_T)Úboundc                      sd   e Zd ZdZdZddd„Zd‡ fdd„Zddd„Zeddd„ƒZ	eddd„ƒZ	d‡ 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Úitemr   ÚreturnÚNonec                 C  s   |   |g¡ d S ©N)Úextend)Úselfr   © r   úŽ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/layout/utils.pyÚappend   s   z_ExplodedList.appendÚlstúIterable[_T]c                   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"   ó   z_ExplodedList.insertÚvaluec                 C  ó   d S r   r   ©r   r   r    r   r   r   Ú__setitem__'   r   z_ExplodedList.__setitem__Úslicec                 C  r!   r   r   r"   r   r   r   r#   *   r   úSupportsIndex | sliceú_T | Iterable[_T]c                   sL   t |tƒs| ¡ }t||d ƒ}t |tƒrtd|gƒ}tƒ  |t|ƒ¡ dS )zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
        é   zlist[_T]N)Ú
isinstancer$   Ú	__index__Útupler   r   r#   r
   )r   r   r    Ú	int_indexr   r   r   r#   -   s   

)r   r   r   r   )r   r   r   r   )r   r	   r   r   r   r   )r   r	   r    r   r   r   )r   r$   r    r   r   r   )r   r%   r    r&   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úexplodedr   r   r   r   r#   Ú__classcell__r   r   r   r   r      s    

r   Ú	fragmentsr   r   ú_ExplodedList[_T]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   )r2   ÚresultÚstyleÚstringÚrestÚcr   r   r   r
   =   s   
ÿN)r2   r   r   r3   )Ú
__future__r   Úcollections.abcr   Útypingr   r   r   r   Ú"prompt_toolkit.formatted_text.baser   Útyping_extensionsr	   Ú__all__r   Úlistr   r
   r   r   r   r   Ú<module>   s    ÿ+