
    i                        d Z ddlZddlZddlmZ  ej        d          Z ej        d          Z ej        d          Z ej        d          Z	 ej        d	          Z
 ej        d
          Z ej        d          Z ej        ej                            ddd          dz   e
j                            ddd          z   dz   ej                            ddd          z   dz   e	j                            ddd          z   dz   dz   dz   dz   ej        z   dz             Z ej        d                    d dD                                 Zdedej        ej        eef                  fdZdedefdZdS )aA  
Terminal escape sequence patterns.

This module provides regex patterns for matching terminal escape sequences. All patterns match
sequences that begin with ESC (``\x1b``). Before calling re.match with these patterns, callers
should first check that the character at the current position is ESC for optimal performance.
    N   )_SGR_PATTERNz4\x1b\]66;([^;\x07\x1b]*);([^\x07\x1b]*)(\x07|\x1b\\)a  \x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b_[^\x1b\x07]*(?:\x07|\x1b\\)|\x1bP[^\x1b\x07]*(?:\x07|\x1b\\)|\x1b\^[^\x1b\x07]*(?:\x07|\x1b\\)|\x1b[()].|\x1b[\x20-\x2f]+[\x30-\x7e]|\x1b[\x40-\x5f]|\x1b[\x30-\x3f]|\x1b[\x60-\x7e]z\x1b\[(\d*)Cz\x1b\[(\d*)Dz\x1b\[(\d*)Gz\x1b\[(\d*)[CDG]z[\x08\r]|\x1b\[(\d*)[CDG](z(?P<sgr_params>|z
(?P<hpa_n>z(?P<cforward_n>z(?P<cbackward_n>zU\x1b\]66;(?P<ts_meta>[^;\x07\x1b]*);(?P<ts_text>[^\x07\x1b]*)(?P<ts_term>\x07|\x1b\\)z(?P<other_seq>(?:z))c              #   "   K   | ]
}d | dV  dS )z(?:)N ).0_patterns     _/home/piyush/.hermes/hermes-agent/venv/lib/python3.11/site-packages/wcwidth/escape_sequences.py	<genexpr>r   W   s>        88          )z\x1b\[\d+;\d+rz
\x1b\[\d*Kz
\x1b\[\d*Jz\x1b\[\d+;\d+Hz
\x1b\[\d*Hz
\x1b\[\d*Az
\x1b\[\d*Bz
\x1b\[\d*Pz
\x1b\[\d*Mz
\x1b\[\d*Lz
\x1b\[\d*@z
\x1b\[\d+Xz
\x1b\[\d*Sz
\x1b\[\d*Tz
\x1b\[\d*dz\x1b\[\?1049[hl]z\x1b\[\?47[hl]z\x1b8z\x1bDz\x1bMz\x1bctextreturnc              #   r  K   d}t          |           }d}||k     r| |         }|dk    rl||k    r| ||         dfV  t                              | |          }|r-|                                dfV  |                                }n|dfV  |dz  }|}n|dz  }||k     ||k     r| |d         dfV  dS dS )a  
    Iterate through text, yielding segments with sequence identification.

    This generator yields tuples of ``(segment, is_sequence)`` for each part
    of the input text, where ``is_sequence`` is ``True`` if the segment is
    a recognized terminal escape sequence.

    :param text: String to iterate through.
    :returns: Iterator of (segment, is_sequence) tuples.

    .. versionadded:: 0.3.0

    Example::

        >>> list(iter_sequences('hello'))
        [('hello', False)]
        >>> list(iter_sequences('\x1b[31mred'))
        [('\x1b[31m', True), ('red', False)]
        >>> list(iter_sequences('\x1b[1m\x1b[31m'))
        [('\x1b[1m', True), ('\x1b[31m', True)]
    r   FTr   N)lenZERO_WIDTH_PATTERNmatchgroupend)r   idxtext_lensegment_startcharr   s         r   iter_sequencesr   q   s     , C4yyHM
..Cy6>>]""M#-.6666 ',,T377E {{}}d++++iikk Tl"""qMM1HC' .., xMNN#U++++++  r   c                 v    d| v rt                               d|           } t                              d|           S )a  
    Return text with all terminal escape sequences removed.

    Unknown or incomplete ESC sequences are preserved.

    :param text: String that may contain terminal escape sequences.
    :returns: The input text with all escape sequences stripped.

    .. versionadded:: 0.3.0

    .. versionchanged:: 0.7.0
       Inner text of OSC 66 (Text sizing protocol) is preserved.

    Example::

        >>> strip_sequences('\x1b[31mred\x1b[0m')
        'red'
        >>> strip_sequences('hello')
        'hello'
        >>> strip_sequences('\x1b[1m\x1b[31mbold red\x1b[0m text')
        'bold red text'
        >>> strip_sequences('\x1b]66;s=2;hello\x07')
        'hello'
        >>> strip_sequences('\x1b]8;id=34;https://example.com\x1b\\[view]\x1b]8;;\x1b\\')
        '[view]'
    z]66;z\2 )TEXT_SIZING_PATTERNsubr   )r   s    r   strip_sequencesr!      s:    6 T"&&ud33!!"d+++r   )__doc__retyping	sgr_stater   compiler   r   CURSOR_RIGHT_SEQUENCECURSOR_LEFT_SEQUENCECURSOR_HPA_SEQUENCECURSOR_MOVEMENT_SEQUENCE_HORIZONTAL_CURSOR_MOVEMENTpatternreplace_SEQUENCE_CLASSIFYjoinINDETERMINATE_EFFECT_SEQUENCEstrIteratorTupleboolr   r!   r	   r   r   <module>r5      sb    
			  $ # # # # # !bj;    RZ  2 #
?33  "rz/22  !bj11 
 &2:&9:: 
 )bj)EFF 
  RZ  &7;;	
'//\1EEF	
!)11#7H!LLM 

 !(006H!LLM 
	
 e	e
 


 !!
 $6#=>
 AEE    !+
HH   0     ! ! 61, 1,c4i1H!I 1, 1, 1, 1,h,# ,# , , , , , ,r   