
    fC	                        d dl mZ d dl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
      Z G d d	ee         Zdd
Zy)    )annotations)TYPE_CHECKINGIterableListTypeVarcastoverload)OneStyleAndTextTuple)SupportsIndexexplode_text_fragments_T)boundc                  t     e Zd ZdZdZd	dZd
 fdZddZedd       Z	edd       Z		 	 	 	 	 	 d fdZ	 x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.
    Tc                (    | j                  |g       y N)extend)selfitems     V/var/www/cvtools/html/venv/lib/python3.12/site-packages/prompt_toolkit/layout/utils.pyappendz_ExplodedList.append   s    TF    c                6    t         |   t        |             y r   )superr   r   )r   lst	__class__s     r   r   z_ExplodedList.extend   s    -c23r   c                    t         r   )NotImplementedError)r   indexr   s      r   insertz_ExplodedList.insert!   s    !!r   c                     y r    r   r   values      r   __setitem__z_ExplodedList.__setitem__&   s    DGr   c                     y r   r"   r#   s      r   r%   z_ExplodedList.__setitem__)   s    FIr   c                    t        |t              s|j                         }t        ||dz         }t        |t              rt	        d|g      }t
        |   |t        |             y)zl
        Ensure that when `(style_str, 'long string')` is set, the string will be
        exploded.
           zList[_T]N)
isinstanceslice	__index__tupler   r   r%   r   )r   r   r$   	int_indexr   s       r   r%   z_ExplodedList.__setitem__,   sX     %')I)Y]3EeU#eW-EE#9%#@Ar   )r   r   returnNone)r   Iterable[_T]r.   r/   )r   r   r   r   r.   r/   )r   r   r$   r   r.   r/   )r   r*   r$   r0   r.   r/   )r   zSupportsIndex | slicer$   z_T | Iterable[_T]r.   r/   )__name__
__module____qualname____doc__explodedr   r   r    r	   r%   __classcell__)r   s   @r   r   r      sc     H4"
 G GI IB*B3DB	B Br   r   c                    t        | t              r| S g }| D ]"  ^}}}|D ]  }|j                  ||g|        $ 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   )	fragmentsresultstylestringrestcs         r   r   r   <   sa     )]+F ) -v 	-AMM5!+d+,	--   r   N)r8   r0   r.   z_ExplodedList[_T])
__future__r   typingr   r   r   r   r   r	   "prompt_toolkit.formatted_text.baser
   typing_extensionsr   __all__r   r   r   r"   r   r   <module>rC      sJ    " I I C/  T-.(BDH (BV!r   