
    @>ib*                       % 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
  S SKJr  \
\\\4   r\" S5      r/ SQrS\S	'   \" \ V VVs/ s H!  u  p\" \\" XS
-   5      5        H  nUPM     M#     snnn 5      r\R0                  rS\S'    " S S\5      r\" SS9SSS jj5       r\" S5      SSS jj5       rSSS jjrSS jr S     SS jjr S       SS jjr  S       SS jjr!SS S jjr"SS!S jjr#gs  snnn f )"    )annotations)	lru_cache)
itemgetter)Callable
NamedTupleSequenceTuple)load   ))    ~   )      )   i  )ip  i  )i %  i%  )i (  i(  zlist[tuple[int, int]]_SINGLE_CELL_UNICODE_RANGES   zCallable[[str], bool]_is_single_cell_widthsc                  8    \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)	CellTable&   zDContains unicode data required to measure the cell widths of glyphs.strunicode_versionzSequence[tuple[int, int, int]]widthszfrozenset[str]narrow_to_wide N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       I/var/www/html/land-tabula/venv/lib/python3.13/site-packages/rich/cells.pyr   r   &   s    N**""r#   r   i   )maxsizec                "   [        U 5      nU(       a  US:  d  SUs=::  a  S:  a   g  Og[        U5      R                  nUS   nX$S   :  a  gSn[        U5      S-
  nXV::  a-  XV-   S-	  nX7   u  pn
X(:  a  US-
  nOX):  a  US-   nOU
$ XV::  a  M-  g)a  Get the cell size of a character.

Args:
    character (str): A single character.
    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.

Returns:
    int: Number of cells (0, 1 or 2) occupied by that character.
r      r   r   r   )ordload_cell_tabler   len)	characterr   	codepointtable
last_entrylower_boundupper_boundindexstartendwidths              r$   get_character_cell_sizer6   .   s     IIY^u	'AE'A (BO,33ErJa= Ke*q.K

$*q0!LE!)K_!)KL 
$ r#   c                    [        X5      $ )a}  Get the number of cells required to display text.

This method always caches, which may use up a lot of memory. It is recommended to use
`cell_len` over this method.

Args:
    text (str): Text to display.
    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.

Returns:
    int: Get the number of cells required to display text.
)	_cell_lentextr   s     r$   cached_cell_lenr;   Q   s     T++r#   c                L    [        U 5      S:  a  [        X5      $ [        X5      $ )  Get the cell length of a string (length as it appears in the terminal).

Args:
    text: String to measure.
    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.

Returns:
    Length of string in terminal cells.
i   )r+   r;   r8   r9   s     r$   cell_lenr>   b   s%     4y3t55T++r#   c                t  ^ [        U 5      (       a  [        U 5      $ SU ;  a  SU ;  a  [        U4S jU  5       5      $ [        T5      nSnSnSS1nSn[        U 5      nXg:  aU  X   nX;   a'  US:X  a  US-  nO4U(       a  X4UR                  ;   -  nSnO[        UT5      =n	(       a  UnX9-  nUS-  nXg:  a  MU  U$ )r=      ‍   ️c              3  <   >#    U  H  n[        UT5      v   M     g 7f)N)r6   ).0r,   r   s     r$   	<genexpr>_cell_len.<locals>.<genexpr>   s       
QUI#I??QUs   r   Nr   )r   r+   sumr*   r   r6   )
r:   r   
cell_tabletotal_widthlast_measured_characterSPECIALr2   character_countr,   character_widths
    `        r$   r8   r8   q   s     d##4y t 4 
QU
 
 	
 !1JK*."GE$iO

!K	H$
(*:S:SSS*.'"9)_"UUU*3'.
 
! r#   c                   [        U5      n[        U 5      nSnSnSn/ nSS1nXC:  a  X   =o;   aa  U	S:X  a  US-  nU(       a  US   u  pnXU4US'   O=U(       a6  US-  nU(       a*  US   u  pnXRR                  ;   a  SnUS-  nUS-  nXU4US'   Mo  [        X5      =n(       a  U	nUR	                  XDS-   =oM45        Xm-  nOU(       a  US   u  pnXS-   =oL4US'   XC:  a  M  Xv4$ )zDivide text into spans that define a single grapheme.

Args:
    text: String to split.
    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.

Returns:
    List of spans.
r   Nr@   rA   r   r(   r   )r*   r+   r   r6   append)r:   r   rG   codepoint_countr2   rI   rH   spansrJ   r,   r3   _endcell_lengthrL   s                 r$   split_graphemesrS      s=    !1J$iOE*.K(*E"G

!$I0H$
/4Ry,E!&{ ;E"I(
/4Ry,E.2K2KK26/#q(#q(!&{ ;E"I5iQQ?Q&/#LL%!)!3EF*K',Ry$E 2@E"I7 
!: r#   c                   US::  a  SU 4$ [        X5      u  p4[        X-  [        U5      -  5      n[        [	        [
        USU 5      5      n Xa:X  a#  U[        U5      :  a  U S4$ X5   S   nU SU XS 4$ Xa:  a(  X5   u  pn
Xj-   U:  a  U SU S-   SX	S -   4$ US-  nXj-  nO*X5S-
     u  pn
Xj-
  U:  a  U SU S-   SX	S -   4$ US-  nXj-  nM  )P  Split text by cell position.

If the cell position falls within a double width character, it is converted to two spaces.

Args:
    text: Text to split.
    cell_position Offset in cells.
    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.

Returns:
    Tuple to two split strings.
r    N r   )rS   intr+   rF   map_span_get_cell_len)r:   cell_positionr   rP   rR   offset	left_sizesplit_indexr3   r4   	cell_sizes              r$   _split_textr`      s1    4x(?E --U;<FC*E'6N;<I
%U#Rx-*K%tL'999$$)M!E	$}4FU|c)3d+;;;aKF"I$)1*$5!E	$}4FU|c)3d+;;;aKF"I# r#   c                L    [        U 5      (       a	  U SU XS 4$ [        XU5      $ )rU   N)r   r`   )r:   r[   r   s      r$   
split_textrb     s3     d##N]#T.%999tO<<r#   c                    [        U 5      (       a  [        U 5      nX1:  a
  U SX-
  -  -   $ U SU $ US::  a  g[        U 5      nXA:X  a  U $ XA:  a
  U SX-
  -  -   $ [        XU5      u  pU $ )a  Adjust a string by cropping or padding with spaces such that it fits within the given number of cells.

Args:
    text: String to adjust.
    total: Desired size in cells.
    unicode_version: Unicode version.

Returns:
    A string with cell size equal to total.
rW   Nr   rV   )r   r+   r>   r`   )r:   totalr   sizer_   _s         r$   set_cell_sizerg     s     d##4y<#...FU|zIcU.///$7GDKr#   c                >   [        U 5      (       a+  [        S[        U 5      U5       Vs/ s H	  o0X3U-    PM     sn$ [        X5      u  pESn/ nSnU H)  u  pnXk-   U:  a  UR	                  XU	 5        U	nSnXk-  nM+     U(       a  UR	                  XS 5        U$ s  snf )aL  Split text into lines such that each line fits within the available (cell) width.

Args:
    text: The text to fold such that it fits in the given width.
    width: The width available (number of cells).

Returns:
    A list of strings such that each string in the list has cell width
    less than or equal to the available width.
r   N)r   ranger+   rS   rN   )r:   r5   r   r2   rP   rf   	line_sizelinesline_offsetr3   r4   r_   s               r$   
chop_cellsrm   1  s     d##9>q#d)U9ST9SUU]+9STTt5HEIEK!&I 5(LL%01KI	 "' T,'(L Us   BN)auto)r,   r   r   r   returnrX   )r:   r   r   r   ro   rX   )r:   r   r   r   ro   z'tuple[list[CellSpan], int]')r:   r   r[   rX   r   r   ro   ztuple[str, str])r:   r   rd   rX   r   r   ro   r   )r:   r   r5   rX   r   r   ro   z	list[str])$
__future__r   	functoolsr   operatorr   typingr   r   r   r	   rich._unicode_datar
   r*   rX   CellSpanrZ   r   r!   	frozensetrY   chrri   _SINGLE_CELLS
issupersetr   r   r6   r;   r>   r8   rS   r`   rb   rg   rm   )_startrQ   r,   s   000r$   <module>r{      sp   "   8 8 6c3] 6 2   87LFS%q"9:I 	: 	7 1>0H0H - H#
 # 4 D 4, , ,-b '-2 
2  #2 !2 l ;A)#
)#!)#47)#)#Z ;A=
=!=47==(6os   (C<