ó
    Ð]j�0  ã                  ó$  • S r SSKJr  SSKrSSKJr  SSKJrJrJ	r	  \(       a  SSKJ
r
   " S S\5      r\R                  " S	5      r\R                  " S
5      rSr " S S\	5      r\" 5       rSS jrSS jrSS jr      SS jrSS jrSS jrg)as  
SGR (Select Graphic Rendition) state tracking for terminal escape sequences.

This module provides functions for tracking and propagating terminal styling (bold, italic, colors,
etc.) via public API propagate_sgr(), and its dependent functions, cut() and wrap(). It only has
attributes necessary to perform its functions, eg 'RED' and 'BLUE' attributes are not defined.
é    )ÚannotationsN)ÚIntEnum)ÚTYPE_CHECKINGÚIteratorÚ
NamedTuple)ÚSequencec                  ó�   • \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSr Sr!Sr"S r#g!)"Ú_SGRé   z²
SGR (Select Graphic Rendition) parameter codes.

References:
- https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- https://github.com/tehmaze/ansi/tree/master/ansi/colour
r   é   é   é   é   é   é   é   é   é	   é   é   é   é   é   é   é   é   é%   é&   é'   é(   é/   é0   é1   éZ   éa   éd   ék   © N)$Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚRESETÚBOLDÚDIMÚITALICÚ	UNDERLINEÚBLINKÚRAPID_BLINKÚINVERSEÚHIDDENÚSTRIKETHROUGHÚDOUBLE_UNDERLINEÚBOLD_DIM_OFFÚ
ITALIC_OFFÚUNDERLINE_OFFÚ	BLINK_OFFÚINVERSE_OFFÚ
HIDDEN_OFFÚSTRIKETHROUGH_OFFÚFG_BLACKÚFG_WHITEÚFG_EXTENDEDÚ
FG_DEFAULTÚBG_BLACKÚBG_WHITEÚBG_EXTENDEDÚ
BG_DEFAULTÚFG_BRIGHT_BLACKÚFG_BRIGHT_WHITEÚBG_BRIGHT_BLACKÚBG_BRIGHT_WHITEÚ__static_attributes__r(   ó    ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/wcwidth/sgr_state.pyr
   r
      s¡   † ñð €EØ€DØ
€CØ€FØ€IØ€EØ€KØ€GØ€FØ€MØÐØ€LØ€JØ€MØ€IØ€KØ€JØÐØ€HØ€HØ€KØ€JØ€HØ€HØ€KØ€JØ€OØ€OØ€OØƒOrM   r
   z\x1b\[([\d;:]*)mz\x1b\[[\d;:]*mz[0mc                  óÂ   • \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   Sr	S\S'   Sr
S\S	'   SrS\S
'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   Srg)Ú	_SGRStateéK   aÂ  
Track active SGR terminal attributes by category (immutable).

:param bold: Bold attribute (SGR 1).
:param dim: Dim/faint attribute (SGR 2).
:param italic: Italic attribute (SGR 3).
:param underline: Underline attribute (SGR 4).
:param blink: Slow blink attribute (SGR 5).
:param rapid_blink: Rapid blink attribute (SGR 6).
:param inverse: Inverse/reverse attribute (SGR 7).
:param hidden: Hidden/invisible attribute (SGR 8).
:param strikethrough: Strikethrough attribute (SGR 9).
:param double_underline: Double underline attribute (SGR 21).
:param foreground: Foreground color as tuple of SGR params, or None for default.
:param background: Background color as tuple of SGR params, or None for default.
FÚboolÚboldÚdimÚitalicÚ	underlineÚblinkÚrapid_blinkÚinverseÚhiddenÚstrikethroughÚdouble_underlineNútuple[int, ...] | NoneÚ
foregroundÚ
backgroundr(   )r)   r*   r+   r,   r-   rS   Ú__annotations__rT   rU   rV   rW   rX   rY   rZ   r[   r\   r^   r_   rL   r(   rM   rN   rP   rP   K   s„   ‡ ñð" €Dˆ$ÓØ€CˆÓØ€FˆDÓØ€IˆtÓØ€Eˆ4ÓØ€K�ÓØ€GˆTÓØ€FˆDÓØ€M�4ÓØ"Ð�dÓ"Ø)-€JÐ&Ó-Ø)-€JÐ&Ö-rM   rP   c                óÄ  • U R                   =(       dÎ    U R                  =(       d»    U R                  =(       d¨    U R                  =(       d•    U R                  =(       d‚    U R
                  =(       do    U R                  =(       d\    U R                  =(       dI    U R                  =(       d6    U R                  =(       d#    U R                  SL=(       d    U R                  SL$ )z…
Return True if any attributes are set.

:param state: The SGR state to check.
:returns: True if any attribute differs from default.
N)rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r^   r_   )Ústates    rN   Ú_sgr_state_is_activerc   o   sµ   € ð �J‰J÷ L˜%Ÿ)™)÷ L u§|¡|÷ L°u·±÷ LØ�{‰{÷LØ#×/Ñ/÷LØ38·=±=÷LØDIÇLÁL÷Là×"Ñ"÷Là&+×&<Ñ&<÷Lð ×Ñ tÐ+÷Lð 05×/?Ñ/?ÀtÐ/KðMrM   c                ó˜  • [        U 5      (       d  gU R                  S4U R                  S4U R                  S4U R                  S4U R
                  S4U R                  S4U R                  S4U R                  S	4U R                  S
4U R                  S4/
nU VVs/ s H  u  p#U(       d  M  UPM     nnnU R                  b1  UR                  SR                  S U R                   5       5      5        U R                  b1  UR                  SR                  S U R                   5       5      5        SSR                  U5       S3$ s  snnf )z¶
Generate minimal SGR sequence to restore this state from reset.

:param state: The SGR state to convert.
:returns: SGR escape sequence string, or empty string if no attributes set.
Ú Ú1Ú2Ú3Ú4Ú5Ú6Ú7Ú8Ú9Ú21Ú;c              3  ó8   #   • U  H  n[        U5      v •  M     g 7f©N©Ústr©Ú.0Úps     rN   Ú	<genexpr>Ú)_sgr_state_to_sequence.<locals>.<genexpr>‘   ó   é € Ð@Ò/?¨!œs 1Ÿv˜vÒ/?ùó   ‚c              3  ó8   #   • U  H  n[        U5      v •  M     g 7frr   rs   ru   s     rN   rx   ry   “   rz   r{   z[Úm)rc   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r^   ÚappendÚjoinr_   )rb   Ú
bool_attrsÚactiveÚcodeÚparamss        rN   Ú_sgr_state_to_sequencer„   |   s'  € ô   ×&Ñ&Øð 
�‰�SÐ˜EŸI™I sÐ+¨e¯l©l¸CÐ-@Ø	�‰˜#Ð §¡¨cÐ 2°U×5FÑ5FÈÐ4LØ	�‰˜Ð˜uŸ|™|¨SÐ1°E×4GÑ4GÈÐ3MØ	×	Ñ	 Ð&ð	€Jñ (2Ô<¢z‘|�v´V�d¡z€FÑ<ð ×ÑÑ#Ø�‰�c—h‘hÑ@¨u×/?Ò/?Ó@Ó@ÔAØ×ÑÑ#Ø�‰�c—h‘hÑ@¨u×/?Ò/?Ó@Ó@ÔAà�3—8‘8˜FÓ#Ð$ AÐ&Ð&ùó =s   ÂEÂ,Ec                ó¤  • [         R                  U 5      nU(       d  / $ UR                  S5      nU(       d  S/$ / nUR                  S5       Hz  nSU;   aN  UR                  S5       Vs/ s H  oU(       a  [	        U5      OSPM     nnUR                  [        U5      5        MW  UR                  U(       a  [	        U5      OS5        M|     U$ s  snf )aš  
Parse SGR sequence and return list of parameter values.

Handles compound sequences like ``\x1b[1;31;4m`` -> [1, 31, 4].
Empty params (e.g., ``\x1b[m``) are treated as [0] (reset).
Colon-separated extended colors like ``\x1b[38:2::255:0:0m`` are returned
as tuples: [(38, 2, 255, 0, 0)].

:param sequence: SGR escape sequence string.
:returns: List of integer parameters or tuples for colon-separated colors.
r   r   rp   Ú:)Ú_SGR_PATTERNÚmatchÚgroupÚsplitÚintr~   Útuple)Úsequencerˆ   Ú
params_strÚresultÚparamrw   Úpartss          rN   Ú_parse_sgr_paramsr’   ˜   s±   € ô ×Ñ˜xÓ(€EÞØˆ	Ø—‘˜Q“€JÞØˆsˆ
Ø*,€FØ×!Ñ! #Ö&ˆØ�%‹<ð 27·±¸SÔ1AÓBÒ1A¨A�q”S˜”V aÒ'Ñ1AˆEÐBØ�M‰Mœ% ›,Ö'à�M‰M®œ#˜eœ*°1Ö5ñ 'ð €Mùò	 Cs   Á)Cc                ó¾  •  [        U 5      n[        U[        5      (       a  gUS:X  a/  [        U 5      n[        U[        5      (       a  g[        U5      SU4$ US:X  ao  [        U 5      [        U 5      [        U 5      pen[        U[        5      (       d*  [        U[        5      (       d  [        U[        5      (       a  g[        U5      SXEU4$  g! [         a     gf = f)a%  
Parse extended color (256-color or RGB) from parameter iterator.

:param params: Iterator of remaining SGR parameters (semicolon-separated format).
:param base: Base code (38 for foreground, 48 for background).
:returns: Color tuple like (38, 5, N) or (38, 2, R, G, B), or None if malformed.
Nr   r   )ÚnextÚ
isinstancerŒ   r‹   ÚStopIteration)rƒ   ÚbaseÚmodeÚnÚrÚgÚbs          rN   Ú_parse_extended_colorr�   ¶   sË   € ðÜ�F‹|ˆÜ�dœE×"Ñ"ØØ�1‹9Ü�V“ˆAÜ˜!œU×#Ñ#ØÜ˜“I˜q !Ð$Ð$Ø�1‹9Ü˜6“l¤D¨£L´$°v³,�!ˆAÜ˜!œU×#Ñ#¤z°!´U×';Ñ';¼zÈ!ÌU×?SÑ?SØÜ˜“I˜q !¨Ð*Ð*ð	 ð øô ó ØØðús)   ‚ C £&C Á
C ÁA%C Â>C Ã
CÃCc                óú	  • [        U5      n[        U5      nU GHÝ  n[        U[        5      (       am  [	        U5      S:¼  a'  US   [
        R                  :X  a  U R                  US9n O5[	        U5      S:¼  a&  US   [
        R                  :X  a  U R                  US9n M†  U[
        R                  :X  a  [        n M¢  U[
        R                  :X  a  U R                  SS9n MÇ  U[
        R                  :X  a  U R                  SS9n Mì  U[
        R                  :X  a  U R                  SS9n GM  U[
        R                  :X  a  U R                  SS	9n GM8  U[
        R                  :X  a  U R                  SS
9n GM^  U[
        R                   :X  a  U R                  SS9n GM„  U[
        R"                  :X  a  U R                  SS9n GMª  U[
        R$                  :X  a  U R                  SS9n GMÐ  U[
        R&                  :X  a  U R                  SS9n GMö  U[
        R(                  :X  a  U R                  SS9n GM  U[
        R*                  :X  a  U R                  SSS9n GMC  U[
        R,                  :X  a  U R                  SS9n GMi  U[
        R.                  :X  a  U R                  SSS9n GM�  U[
        R0                  :X  a  U R                  SSS9n GM·  U[
        R2                  :X  a  U R                  SS9n GMÝ  U[
        R4                  :X  a  U R                  SS9n GM  U[
        R6                  :X  a  U R                  SS9n GM)  [
        R8                  Us=::  a  [
        R:                  ::  d.  O  [
        R<                  Us=::  a  [
        R>                  ::  a  O  OU R                  U4S9n GM“  [
        R@                  Us=::  a  [
        RB                  ::  d.  O  [
        RD                  Us=::  a  [
        RF                  ::  a  O  OU R                  U4S9n GMý  U[
        RH                  :X  a  U R                  SS9n GM#  U[
        RJ                  :X  a  U R                  SS9n GMI  U[
        R                  :X  a6  [M        U[
        R                  5      =n(       a  U R                  US9n GM�  GM“  U[
        R                  :X  d  GMª  [M        U[
        R                  5      =n(       d  GMÎ  U R                  US9n GMà     U $ )z»
Parse SGR sequence and return new state with updates applied.

:param state: Current SGR state.
:param sequence: SGR escape sequence string.
:returns: New SGRState with updates applied.
r   r   )r^   )r_   T)rS   )rT   )rU   )rV   )rW   )rX   )rY   )rZ   )r[   )r\   F)rS   rT   )rV   r\   )rW   rX   N)'r’   Úiterr•   rŒ   Úlenr
   rB   Ú_replacerF   r.   Ú_SGR_STATE_DEFAULTr/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rH   rI   rD   rE   rJ   rK   rC   rG   r�   )rb   r�   Úparams_listrƒ   rw   Úcolors         rN   Ú_sgr_state_updater¥   Ó   s½  € ô $ HÓ-€KÜ�+Ó€FÜˆä�aœ×ÑÜ�1‹v˜‹{˜q ™t¤t×'7Ñ'7Ó7àŸ™°!˜Ð4‘Ü�Q“˜1“  1¡¬×)9Ñ)9Ó!9àŸ™°!˜Ð4�ÙØ”—
‘
‹?Ü&ŠEà”$—)‘)‹^Ø—N‘N¨�NÐ-ŠEØ”$—(‘(‹]Ø—N‘N t�NÐ,ŠEØ”$—+‘+ÓØ—N‘N¨$�NÐ/‹EØ”$—.‘.Ó Ø—N‘N¨T�NÐ2‹EØ”$—*‘*‹_Ø—N‘N¨�NÐ.‹EØ”$×"Ñ"Ó"Ø—N‘N¨t�NÐ4‹EØ”$—,‘,ÓØ—N‘N¨4�NÐ0‹EØ”$—+‘+ÓØ—N‘N¨$�NÐ/‹EØ”$×$Ñ$Ó$Ø—N‘N°�NÐ6‹EØ”$×'Ñ'Ó'Ø—N‘N°D�NÐ9‹Eà”$×#Ñ#Ó#Ø—N‘N¨°5�NÐ9‹EØ”$—/‘/Ó!Ø—N‘N¨%�NÐ0‹EØ”$×$Ñ$Ó$Ø—N‘N¨UÀU�NÐK‹EØ”$—.‘.Ó Ø—N‘N¨¸E�NÐB‹EØ”$×"Ñ"Ó"Ø—N‘N¨5�NÐ1‹EØ”$—/‘/Ó!Ø—N‘N¨%�NÐ0‹EØ”$×(Ñ(Ó(Ø—N‘N°�NÐ7‹Eä�m‰m˜qÕ1¤D§M¡MÕ1Ü×%Ñ%¨ÕB¬d×.BÑ.BÖBØ—N‘N¨q¨d�NÐ3‹EÜ�m‰m˜qÕ1¤D§M¡MÕ1Ü×%Ñ%¨ÕB¬d×.BÑ.BÖBØ—N‘N¨q¨d�NÐ3‹EØ”$—/‘/Ó!Ø—N‘N¨d�NÐ3‹EØ”$—/‘/Ó!Ø—N‘N¨d�NÐ3‹Eà”$×"Ñ"Ó"Ü-¨f´d×6FÑ6FÓGÐGˆuÕGØŸ™°%˜Ð8“ò Hà”$×"Ñ"Ö"Ü-¨f´d×6FÑ6FÓGÐGˆu×GÐGØŸ™°%˜Ð8“ñC ðD €LrM   c                óh  • [        S U  5       5      (       a  U (       d  [        U 5      $ / n[        nU  Hz  n[        U5      n[        R                  U5       H  n[        X%R                  5       5      nM     U(       a  XC-   OUn[        U5      (       a	  U[        -   nUR                  U5        M|     U$ )aç  
Propagate SGR codes across wrapped lines.

When text with SGR styling is wrapped across multiple lines, each line
needs to be self-contained for proper display. This function:

- Ends each line with ``\x1b[0m`` if styles are active (prevents bleeding)
- Starts each subsequent line with the active style restored

:param lines: List of text lines, possibly containing SGR sequences.
:returns: List of lines with SGR codes propagated.

Example::

    >>> propagate_sgr(['\x1b[31mhello', 'world\x1b[0m'])
    ['\x1b[31mhello\x1b[0m', '\x1b[31mworld\x1b[0m']

This is useful in cases of making special editors and viewers, and is used for the
default modes (propagate_sgr=True) of :func:`wcwidth.wrap` and :func:`wcwidth.clip`.

When wrapping and clipping text containing SGR sequences, maybe a previous line enabled the BLUE
color--if we are viewing *only* the line following, we would want the carry over the BLUE color,
and all lines with sequences should end with terminating reset (``\x1b[0m``).
c              3  óL   #   • U  H  n[         R                  U5      v •  M     g 7frr   )Ú_SGR_QUICK_CHECKÚsearch)rv   Úlines     rN   rx   Ú propagate_sgr.<locals>.<genexpr>>  s   é € Ð?º°Ô×&Ñ& t×,Ð,ºùs   ‚"$)ÚanyÚlistr¢   r„   r‡   Úfinditerr¥   r‰   rc   Ú
_SGR_RESETr~   )Úlinesr�   rb   rª   Úprefixrˆ   Úoutput_lines          rN   Úpropagate_sgrr³   $  s›   € ô4 Ñ?¹Ó?×?Ñ?ÆuÜ�E‹{Ðà€FÜ€Eãˆä'¨Ó.ˆô "×*Ñ*¨4Ö0ˆEÜ% e¯[©[«]Ó;ŠEñ 1ö (.�f’m°4ˆÜ ×&Ñ&Ø%¬
Ñ2ˆKà�‰�kÖ"ñ ð €MrM   )rb   rP   ÚreturnrR   )rb   rP   r´   rt   )r�   rt   r´   zlist[int | tuple[int, ...]])rƒ   zIterator[int | tuple[int, ...]]r—   r‹   r´   r]   )rb   rP   r�   rt   r´   rP   )r°   zSequence[str]r´   z	list[str])r-   Ú
__future__r   ÚreÚenumr   Útypingr   r   r   r   r
   Úcompiler‡   r¨   r¯   rP   r¢   rc   r„   r’   r�   r¥   r³   r(   rM   rN   Ú<module>rº      sª   ðñõ #ó 
Ý ç 6Ñ 6æÝô&ˆ7ô &ðZ �zŠzÐ-Ó.€ð —:’:Ð/Ó0Ð ð €
ô.�
ô .ñB “[Ð ô
Mô'ô8ð<Ø+ðØ36ðàôô:Nõb/rM   