
    q"h`                        S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJrJrJrJrJrJrJrJrJr  SSKJrJrJrJrJr  SS	KJrJr  SS
KJr  \(       a
  SSK J!r!J"r"J#r#  \" S5      r$ " S S\5      r%\\\%   \\%\\&\'4   4   \\%\&\&4   4   r(\" 5        " S S\5      5       r) " S S5      r* " S S5      r+\,S:X  Ga  S SK-J!r!  S SK.J/r/  S SK0J1r1  Sr2\1Rf                  " S5      r4\!" 5       r \ Rk                  S5        \ Rm                  S5        \ Rm                  S5        \ Rm                  \/" \2SSS 95        \ Rm                  5         \ Rm                  S!5        \7" \ Rq                  \45      5      r9\ Rm                  \95        \ Rm                  5         \ Rm                  S"5        \ Rm                  \45        \ Rm                  S#5        g$g$)%    )IntEnum)	lru_cache)filterfalse)	getLogger)
attrgetter)
TYPE_CHECKINGDictIterableList
NamedTupleOptionalSequenceTupleTypeUnion   )_is_single_cell_widthscached_cell_lencell_lenget_character_cell_sizeset_cell_size)Result	rich_repr)Style)ConsoleConsoleOptionsRenderResultrichc                   X    \ 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)ControlType#   zDNon-printable control codes which typically translate to ANSI codes.r                        	   
                      N)__name__
__module____qualname____firstlineno____doc__BELLCARRIAGE_RETURNHOMECLEARSHOW_CURSORHIDE_CURSORENABLE_ALT_SCREENDISABLE_ALT_SCREEN	CURSOR_UPCURSOR_DOWNCURSOR_FORWARDCURSOR_BACKWARDCURSOR_MOVE_TO_COLUMNCURSOR_MOVE_TOERASE_IN_LINESET_WINDOW_TITLE__static_attributes__r1       J/var/www/html/env/lib/python3.13/site-packages/pip/_vendor/rich/segment.pyr    r    #   sY    NDODEKKIKNONMrH   r    c                      \ rS rSr% Sr\\S'   Sr\\	   \S'   Sr
\\\      \S'   \S\4S j5       rS\4S	 jrS\4S
 jr\S\4S j5       r\\" S5      SS S\S\S   4S j5       5       rS\S\S   4S jr\S1S j5       r\  S2S\S    S\\	   S\\	   S\S    4S jj5       r\ S3S\S    S\S\S    4S jj5       r\S\S    S\\S       4S j5       r\   S4S\S    S\S\\	   S\S\S\\S       4S jj5       r \  S5S\S    S\S\\	   S\S\S    4
S jj5       r!\S\S    S\4S j5       r"\S \\S       S\\\4   4S! j5       r#\   S6S \\S       S"\S#\\   S\\	   S$\S\\S       4S% jj5       r$\ S3S&\%S    S \\S       S"\S#\S\	S$\S\\S       4S' jj5       r&\ S3S&\%S    S \\S       S"\S#\S\	S$\S\\S       4S( jj5       r'\ S3S&\%S    S \\S       S"\S#\S\	S$\S\\S       4S) jj5       r(\S\S    S\S    4S* j5       r)\S\S    S\S    4S+ j5       r*\S\S    S\S    4S, j5       r+\S\S    S\S    4S- j5       r,\S\S    S.\\   S\\S       4S/ j5       r-S0r.g)7Segment?   a  A piece of text with associated style. Segments are produced by the Console render process and
are ultimately converted in to strings to be written to the terminal.

Args:
    text (str): A piece of text.
    style (:class:`~rich.style.Style`, optional): An optional style to apply to the text.
    control (Tuple[ControlCode], optional): Optional sequence of control codes.

Attributes:
    cell_length (int): The cell length of this Segment.
textNstylecontrolreturnc                 4    U u  pnU(       a  S$ [        U5      $ )zbThe number of terminal cells required to display self.text.

Returns:
    int: A number of cells.
r   )r   )selfrM   _stylerO   s       rI   cell_lengthSegment.cell_lengthQ   s     !%gq/$/rH   c              #      #    U R                   v   U R                  c  U R                  b  U R                  v   g g U R                  v   U R                  v   g 7fN)rM   rO   rN   rR   s    rI   __rich_repr__Segment.__rich_repr__[   sG     ii<<zz%jj  & **,,   AAc                 ,    [        U R                  5      $ )z#Check if the segment contains text.)boolrM   rX   s    rI   __bool__Segment.__bool__d   s    DIIrH   c                     U R                   SL$ )z,Check if the segment contains control codes.N)rO   rX   s    rI   
is_controlSegment.is_controlh   s     ||4''rH   i @  segmentcut)rK   rK   c                    Uu  p4n[         nUR                  nX':  a
  X" SXE5      4$ [        n[        X'-  [	        U5      -  5      n	 USU	 n
[        U
5      nX-
  nU(       d  U" XU5      U" X9S XE5      4$ US:X  a.  U" X9   5      S:X  a   U" USU	 S-   XE5      U" SX9S-   S -   XE5      4$ US:X  a1  U" X9S-
     5      S:X  a   U" USU	S-
   S-   XE5      U" SX9S -   XE5      4$ X:  a  U	S-  n	OU	S-  n	M  )a  Split a segment in to two at a given cell position.

Note that splitting a double-width character, may result in that character turning
into two spaces.

Args:
    segment (Segment): A segment to split.
    cut (int): A cell position to cut on.

Returns:
    A tuple of two segments.
 Nr"    r   )rK   rT   r   intlenr   )clsrc   rd   rM   rN   rO   _SegmentrT   	cell_sizeposbeforecell_posout_bys                rI   _split_cellsSegment._split_cellsm   sQ     'W))HR888+	3$D	12$3ZF'H^FVG4T$Z8  |	$) 4 9T$3Z#-u>S4a	?2EC  |	$Qw- 8A =T)C!G_s2ECS4:-u>  ~qq- rH   c                     U u  p#nUS:  d   e[        U5      (       a:  U[        U5      :  a  U [        SX45      4$ [        USU X45      [        X!S X45      4$ U R                  X5      $ )a@  Split segment in to two segments at the specified column.

If the cut point falls in the middle of a 2-cell wide character then it is replaced
by two spaces, to preserve the display width of the parent segment.

Args:
    cut (int): Offset within the segment to cut.

Returns:
    Tuple[Segment, Segment]: Two segments.
r   rf   N)r   rj   rK   rr   )rR   rd   rM   rN   rO   s        rI   split_cellsSegment.split_cells   s}      $Waxx!$''c$iWR888Tc
E3T
E3 
   ++rH   c                     U " S5      $ )zMake a new line segment.
r1   )rk   s    rI   lineSegment.line   s     4yrH   segments
post_stylec                 x   ^ ^^ UnU(       a  UR                   mUU 4S jU 5       nT(       a  U U4S jU 5       nU$ )a  Apply style(s) to an iterable of segments.

Returns an iterable of segments where the style is replaced by ``style + segment.style + post_style``.

Args:
    segments (Iterable[Segment]): Segments to process.
    style (Style, optional): Base style. Defaults to None.
    post_style (Style, optional): Style to apply on top of segment style. Defaults to None.

Returns:
    Iterable[Segments]: A new iterable of segments (possibly the same iterable).
c              3   Z   >#    U  H   u  pnT" X(       a  S OT" U5      U5      v   M"     g 7frW   r1   ).0rM   rS   rO   applyrk   s       rI   	<genexpr>&Segment.apply_style.<locals>.<genexpr>   s1      -<)D' D'$uV}gFF-<s   (+c              3   h   >#    U  H'  u  pnT" UU(       a  S OU(       a  UT-   OTU5      v   M)     g 7frW   r1   )r   rM   rS   rO   rk   r|   s       rI   r   r      sG       .=)D'  # 5;fz1  .=s   /2)__add__)rk   r{   rN   r|   result_segmentsr   s   `  ` @rI   apply_styleSegment.apply_style   sC    & #MME-<O  .=O rH   ra   c                 d    U(       a  [        [        S5      U5      $ [        [        S5      U5      $ )a  Filter segments by ``is_control`` attribute.

Args:
    segments (Iterable[Segment]): An iterable of Segment instances.
    is_control (bool, optional): is_control flag to match in search.

Returns:
    Iterable[Segment]: And iterable of Segment instances.

rO   )filterr   r   )rk   r{   ra   s      rI   filter_controlSegment.filter_control   s+     *Y/::z)4h??rH   c              #   Z  #    / nUR                   nU H  nSUR                  ;   al  UR                  (       d[  Uu  pVnU(       aM  UR                  S5      u  pnU(       a  U" U " X5      5        U	(       a  Uv   / nUR                   nU(       a  MK  M}  M  U" U5        M     U(       a  Uv   gg7f)zSplit a sequence of segments in to a list of lines.

Args:
    segments (Iterable[Segment]): Segments potentially containing line feeds.

Yields:
    Iterable[List[Segment]]: Iterable of segment lists, one per line.
rx   N)appendrM   rO   	partition)
rk   r{   ry   r   rc   rM   rN   __textnew_lines
             rI   split_linesSegment.split_lines   s      !Gw||#GOO!(Q,0NN4,@)ETs501"
!!% d w   J s   B
B+B+lengthpadinclude_new_linesc              #     #    / nUR                   nU R                  nU " S5      n	U H  n
SU
R                  ;   a  U
R                  (       d|  U
u  pnU(       an  UR	                  S5      u  pnU(       a  U" U " X5      5        U(       a3  U" XbX4S9nU(       a  UR                  U	5        Uv   UR                  5         U(       a  Ml  M  M  U" U
5        M     U(       a
  U" XbX4S9v   gg7f)a  Split segments in to lines, and crop lines greater than a given length.

Args:
    segments (Iterable[Segment]): An iterable of segments, probably
        generated from console.render.
    length (int): Desired line length.
    style (Style, optional): Style to use for any padding.
    pad (bool): Enable padding of lines that are less than `length`.

Returns:
    Iterable[List[Segment]]: An iterable of lines of segments.
rx   )rN   r   N)r   adjust_line_lengthrM   rO   r   clear)rk   r{   r   rN   r   r   ry   r   r   new_line_segmentrc   rM   segment_styler   r   r   cropped_lines                    rI   split_and_crop_linesSegment.split_and_crop_lines  s     * ! 33t9Gw||#GOO)0&Q,0NN4,@)ETs589'9 ( -(//0@A**

 d w!  " $THH s   B?C%"C%ry   c                 n   [        S U 5       5      nXR:  a"  U(       a  X" SX%-
  -  U5      /-   nU$ USS n U$ XR:  aq  / nUR                  nSnU HX  nUR                  n	XY-   U:  d  UR                  (       a  U" U5        XY-  nM6  Uu  pn[	        XU-
  5      n
U" U " X5      5          U$     U$ USS nU$ )a  Adjust a line to a given width (cropping or padding as required).

Args:
    segments (Iterable[Segment]): A list of segments in a single line.
    length (int): The desired width of the line.
    style (Style, optional): The style of padding if used (space on the end). Defaults to None.
    pad (bool, optional): Pad lines with spaces if they are shorter than `length`. Defaults to True.

Returns:
    List[Segment]: A line of segments with the desired length.
c              3   8   #    U  H  oR                   v   M     g 7frW   )rT   )r   rc   s     rI   r   -Segment.adjust_line_length.<locals>.<genexpr>X  s     BT'--Ts   rh   Nr   )sumr   rT   rO   r   )rk   ry   r   rN   r   line_lengthr   r   rc   segment_lengthrM   r   r   s                rI   r   Segment.adjust_line_lengthE  s    & BTBB 3sf.B'CU#K"LL& #  7" ! !H__FK!(!4!4/&8GOO7O1K-4*D(/CDD3t34     AwHrH   c                 :   ^ [         m[        U4S jU 5       5      $ )zGet the length of list of segments.

Args:
    line (List[Segment]): A line encoded as a list of Segments (assumes no '\\n' characters),

Returns:
    int: The length of the line.
c              3   J   >#    U  H  u  po3(       a  M  T" U5      v   M     g 7frW   r1   )r   rM   rN   rO   	_cell_lens       rI   r   *Segment.get_line_length.<locals>.<genexpr>}  s      St';tG7?9T??ts   ##)r   r   )rk   ry   r   s     @rI   get_line_lengthSegment.get_line_lengthr  s     	StSSSrH   linesc                 r   ^ U R                   mU(       a  [        U4S jU 5       5      OSnU[        U5      4$ )zGet the shape (enclosing rectangle) of a list of lines.

Args:
    lines (List[List[Segment]]): A list of lines (no '\\n' characters).

Returns:
    Tuple[int, int]: Width and height in characters.
c              3   4   >#    U  H  nT" U5      v   M     g 7frW   r1   )r   ry   r   s     rI   r   $Segment.get_shape.<locals>.<genexpr>  s     @%$--%s   r   )r   maxrj   )rk   r   	max_widthr   s      @rI   	get_shapeSegment.get_shape  s3     --DIC@%@@q	3u:&&rH   widthheight	new_linesc           	      6   U=(       d    [        U5      nU(       a  U " SU-  S-   U5      /OU " SU-  U5      /nU R                  nUSU n	U V
s/ s H	  o" XUS9PM     sn
U	SS& [        U	5      U:  a!  U	R                  U/U[        U	5      -
  -  5        U	$ s  sn
f )a  Set the shape of a list of lines (enclosing rectangle).

        Args:
            lines (List[List[Segment]]): A list of lines.
            width (int): Desired width.
            height (int, optional): Desired height or None for no change.
            style (Style, optional): Style of any padding added.
            new_lines (bool, optional): Padded lines should include "
". Defaults to False.

        Returns:
            List[List[Segment]]: New list of lines.
        rh   rx   N)rN   )rj   r   extend)rk   r   r   r   rN   r   _heightblankr   shaped_linesry   s              rI   	set_shapeSegment.set_shape  s    * &CJ 1:Sut#U+,C%KQV@W?X 	 !33XgEJ
EJTt%8U
Q |w&7S5F+F GH
s   Brk   c                     U[        U5      -
  nU(       d  USS $ USU nU(       a  U " SU-  S-   U5      OU " SU-  U5      nX//U-  -   nU$ )a  Aligns lines to top (adds extra lines to bottom as required).

        Args:
            lines (List[List[Segment]]): A list of lines.
            width (int): Desired width.
            height (int, optional): Desired height or None for no change.
            style (Style): Style of any padding added.
            new_lines (bool, optional): Padded lines should include "
". Defaults to False.

        Returns:
            List[List[Segment]]: New list of lines.
        Nrh   rx   rj   rk   r   r   r   rN   r   extra_linesr   s           rI   	align_topSegment.align_top  sd    * s5z)8Ogv2;C%K$&.S5[RWAX	K//rH   c                     U[        U5      -
  nU(       d  USS $ USU nU(       a  U " SU-  S-   U5      OU " SU-  U5      nU//U-  U-   nU$ )a  Aligns render to bottom (adds extra lines above as required).

        Args:
            lines (List[List[Segment]]): A list of lines.
            width (int): Desired width.
            height (int, optional): Desired height or None for no change.
            style (Style): Style of any padding added. Defaults to None.
            new_lines (bool, optional): Padded lines should include "
". Defaults to False.

        Returns:
            List[List[Segment]]: New list of lines.
        Nrh   rx   r   r   s           rI   align_bottomSegment.align_bottom  sf    * s5z)8Ogv2;C%K$&.S5[RWAX	K'%/rH   c                     U[        U5      -
  nU(       d  USS $ USU nU(       a  U " SU-  S-   U5      OU " SU-  U5      nUS-  nXh-
  n	U//U-  U-   U//U	-  -   nU$ )a  Aligns lines to middle (adds extra lines to above and below as required).

        Args:
            lines (List[List[Segment]]): A list of lines.
            width (int): Desired width.
            height (int, optional): Desired height or None for no change.
            style (Style): Style of any padding added.
            new_lines (bool, optional): Padded lines should include "
". Defaults to False.

        Returns:
            List[List[Segment]]: New list of lines.
        Nrh   rx   r"   r   )
rk   r   r   r   rN   r   r   r   	top_linesbottom_liness
             rI   align_middleSegment.align_middle  s    * s5z)8Ogv2;C%K$&.S5[RWAX1$	".	I%-%	L0HHrH   c              #   :  #    [        U5      n [        U5      n[        nU H`  nUR                  UR                  :X  a=  UR
                  (       d,  U" UR                  UR                  -   UR                  5      nMZ  Uv   UnMb     Uv   g! [         a     gf = f7f)a  Simplify an iterable of segments by combining contiguous segments with the same style.

Args:
    segments (Iterable[Segment]): An iterable of segments.

Returns:
    Iterable[Segment]: A possibly smaller iterable of segments that will render the same way.
N)iternextStopIterationrK   rN   rO   rM   )rk   r{   iter_segmentslast_segmentrl   rc   s         rI   simplifySegment.simplify
  s      X	.L $G!!W]]27??' %%4l6H6H  #"& %   		s(   BB A1B
BBBBc              #      #    U HN  nUR                   (       d  UR                  c  Uv   M'  Uu  p4nU " X4(       a  UR                  S5      OS5      v   MP     g7f)zRemove all links from an iterable of styles.

Args:
    segments (Iterable[Segment]): An iterable segments.

Yields:
    Segment: Segments with link removed.
N)rO   rN   update_link)rk   r{   rc   rM   rN   _controls         rI   strip_linksSegment.strip_links%  sL       G'--"7(/%X$5 1 1$ 7dKK  r[   c              #   <   #    U H  u  p#nU " USU5      v   M     g7f)zRemove all styles from an iterable of segments.

Args:
    segments (Iterable[Segment]): An iterable segments.

Yields:
    Segment: Segments with styles replace with None
Nr1   )rk   r{   rM   rS   rO   s        rI   strip_stylesSegment.strip_styles6  s%      &.!D'dD'** &.s   c              #      #    0 nU HJ  u  p4nU(       a1  UR                  U5      nUc  UR                  nXbU'   U " X6U5      v   M>  U " USU5      v   ML     g7f)zRemove all color from an iterable of segments.

Args:
    segments (Iterable[Segment]): An iterable segments.

Yields:
    Segment: Segments with colorless style.
N)getwithout_color)rk   r{   cacherM   rN   rO   colorless_styles          rI   remove_colorSegment.remove_colorC  s`      %'$, D"'))E"2"*&+&9&9O#2%L$99$g.. %-s   AAcutsc              #     #    / nUR                   n[        U5      n [        US5      nUS:X  a  gUS:w  a  O/ v   M   SnUR                  nUR                  n	[
        n
U H  nUu  pnU(       d  M  U(       a  UO	Xz" U5      -   nX:  a  U" U5        UnM5  X:X  a@  U" U5        U	" 5       v   U" 5         Un[        US5      nUS:X  a  U(       a	  U	" 5       v     gMz  UR                  Xg-
  5      u  nnUu  pnU" U5        U	" 5       v   U" 5         Un[        US5      nUS:X  a  U(       a	  U	" 5       v     gU(       a  M  M     U	" 5       v   g7f)zDivides an iterable of segments in to portions.

Args:
    cuts (Iterable[int]): Cell positions where to divide.

Yields:
    [Iterable[List[Segment]]]: An iterable of Segments in List.
rg   Nr   )r   r   r   r   copyr   ru   )rk   r{   r   split_segmentsadd_segment	iter_cutsrd   rn   segments_clearsegments_copyr   rc   rM   rS   rO   end_posro   s                    rI   divideSegment.divideY  sd     +-$++J	y"%CbyaxH  '--&++#	G$+!D'$!(#cIdO.C=(!C>('/)"$!Cy"-Cby)"//1 '.&9&9#)&DOFG,3)D'''/)"$C9b)"9%+o-C $  J os   A*E	0C	E	;E	r1   )rP   rK   )NNF)NTT)NT)NNF)/r2   r3   r4   r5   r6   str__annotations__rN   r   r   rO   r   ControlCodepropertyri   rT   r   rY   r]   r^   ra   classmethodr   r   rr   ru   ry   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rG   r1   rH   rI   rK   rK   ?   s   
 I!E8E?!/3GXh{+,30S 0 0v $  (D ( ( y-9 -3 -5AU;V -  -^,s ,u-A'B ,4    "&&*	&9%& & UO	&
 
)	& &P ?D@	*@8<@	)	@ @$ 8I#6 8DO;T  8 
 "&"&,I9%,I ,I 	,I
 ,I  ,I 
$y/	",I ,I\ 
 "&*9o* * 	*
 * 
i* *X 
T4	? 
Ts 
T 
T 'd4	?3 'c3h ' ' 
 !%!%!DO$! ! 	!
 ! ! 
d9o	! !F   )_DO$  	
   
d9o	 8   )_DO$  	
   
d9o	 8   )_DO$  	
   
d9o	 <  3 8K  4 L8I#6 L8I;N L L  
+HY$7 
+HY<O 
+ 
+ /HY$7 /HY<O / /* B	*B2:3-B	$y/	"B BrH   rK   c                   N    \ rS rSrSrS
S\\   S\SS4S jjr      SS jr	S	r
g)Segmentsi  a)  A simple renderable to render an iterable of segments. This class may be useful if
you want to print segments outside of a __rich_console__ method.

Args:
    segments (Iterable[Segment]): An iterable of segments.
    new_lines (bool, optional): Add new lines between segments. Defaults to False.
r{   r   rP   Nc                 0    [        U5      U l        X l        g rW   )listr{   r   )rR   r{   r   s      rI   __init__Segments.__init__  s    X"rH   c              #      #    U R                   (       a0  [        R                  5       nU R                   H  nUv   Uv   M     g U R                   S h  vN   g  N7frW   )r   rK   ry   r{   )rR   consoleoptionsry   rc   s        rI   __rich_console__Segments.__rich_console__  s@      >><<>D==
 ) }}$$s   AAAA)r   r{   r   r   r   r   r   rP   r   )r2   r3   r4   r5   r6   r
   rK   r]   r   r   rG   r1   rH   rI   r   r     sD    #'!2 #t #PT #	% 	%+;	%		%rH   r   c                   P    \ rS rSrS	S\\\      S\SS4S jjr      S
S jr	Sr
g)SegmentLinesi  r   r   rP   Nc                 0    [        U5      U l        X l        g)a  A simple renderable containing a number of lines of segments. May be used as an intermediate
in rendering process.

Args:
    lines (Iterable[List[Segment]]): Lists of segments forming lines.
    new_lines (bool, optional): Insert new lines after each line. Defaults to False.
N)r   r   r   )rR   r   r   s      rI   r   SegmentLines.__init__  s     %[
"rH   c              #      #    U R                   (       a6  [        R                  5       nU R                   H  nU S h  vN   Uv   M     g U R                   H  nU S h  vN   M     g  N+ N7frW   )r   rK   ry   r   )rR   r   r   r   ry   s        rI   r   SegmentLines.__rich_console__  sT      >>||~H

 # 

 #    s!   :A,A(!A,A*
A,*A,)r   r   r   r   )r2   r3   r4   r5   r
   r   rK   r]   r   r   rG   r1   rH   rI   r  r    sC    	#htG}5 	#$ 	#SW 	#
  
 +;
 	
 rH   r  __main__)r   )Syntax)Textzfrom rich.console import Console
console = Console()
text = Text.from_markup("Hello, [bold magenta]World[/]!")
console.print(text)zHello, [bold magenta]World[/]!zrich.Segmentz]A Segment is the last step in the Rich render process before generating text with ANSI codes.z
Consider the following code:
pythonT)line_numberszRWhen you call [b]print()[/b], Rich [i]renders[/i] the object in to the following:
zAThe Segments are then processed to produce the following output:
zS
You will only need to know this if you are implementing your own Rich renderables.N):enumr   	functoolsr   	itertoolsr   loggingr   operatorr   typingr   r	   r
   r   r   r   r   r   r   r   cellsr   r   r   r   r   reprr   r   rN   r   r   r   r   r   logr    ri   r   r   rK   r   r  r2   pip._vendor.rich.consolepip._vendor.rich.syntaxr  pip._vendor.rich.textr  codefrom_markuprM   ruleprintr   render	fragmentsr1   rH   rI   <module>r     s     !      $ >>' * 	+	+uS#X
&'	+sC
 " \	j \	 \	~% %2   2 z0.*D
 <=DiGLL MMg MM45MM&xd;<MMOMM] W^^D)*IMM)MMOMMVWMM$MM^; rH   