
    A>i[2                        S r SSKJr  SSKrSSKJr  SSKrSSKJr  SSK	J
r
  \(       a  SSKJrJrJrJr  SS jrSSS	 jjr " S
 S5      rg)zN
Utilities for interpreting CSS from Stylers for formatting non-HTML outputs.
    )annotationsN)TYPE_CHECKING)
CSSWarning)find_stack_level)Callable	GeneratorIterableIteratorc                   ^  SU 4S jjnU$ )a  
Wrapper to expand shorthand property into top, right, bottom, left properties

Parameters
----------
side : str
    The border side to expand into properties

Returns
-------
    function: Return to call when a 'border(-{side}): {value}' string is encountered
c              3  <  >#    UR                  5       n U R                  [        U5         n[        U R                  USS9 H  u  pVTR                  U5      X6   4v   M     g! [         a,    [        R
                  " SU SU S3[        [        5       S9   gf = f7f)z
Expand shorthand property into side-specific property (top, right, bottom, left)

Parameters
----------
    prop (str): CSS property name
    value (str): String token for property

Yields
------
    Tuple (str, str): Expanded property, value
zCould not expand "z: "
stacklevelNT)strict)splitSIDE_SHORTHANDSlenKeyErrorwarningswarnr   r   zipSIDESformat)selfpropvaluetokensmappingkeyidxprop_fmts          T/var/www/html/land-tabula/venv/lib/python3.13/site-packages/pandas/io/formats/css.pyexpand_side_expander.<locals>.expand%   s      	**3v;7G DJJ=HC//#&33 >  	MM$TF"UG15+-
 	s'   BA# 6B#3BBBBr   CSSResolverr   strr   r'   returnGenerator[tuple[str, str]] )r!   r#   s   ` r"   _side_expanderr+      s    44 M    c                .   ^  T S:w  a  ST  3m SU 4S jjnU$ )a
  
Wrapper to expand 'border' property into border color, style, and width properties

Parameters
----------
side : str
    The border side to expand into properties

Returns
-------
    function: Return to call when a 'border(-{side}): {value}' string is encountered
 -c              3    >^#    UR                  5       n[        U5      S:X  d  [        U5      S:  a&  [        R                  " SU S3[        [        5       S9  ST S3SST S	3S
ST S3S0nU Hd  mTR                  5       U R                  ;   a  TUST S	3'   M,  [        U4S jU R                   5       5      (       a  TUST S3'   M[  TUST S3'   Mf     U R                  UR                  5       5       Sh  vN   g N7f)z
Expand border into color, style, and width tuples

Parameters
----------
    prop : str
        CSS property name passed to styler
    value : str
        Value passed to styler for property

Yields
------
    Tuple (str, str): Expanded property, value
r      zToo many tokens provided to "z" (expected 1-3)r   borderz-colorblackz-stylenone-widthmediumc              3  H   >#    U  H  oTR                  5       ;   v   M     g 7fN)lower).0ratiotokens     r"   	<genexpr>3_border_expander.<locals>.expand.<locals>.<genexpr>r   s     R9Qekkm+9Qs   "N)r   r   r   r   r   r   r9   BORDER_STYLESanyBORDER_WIDTH_RATIOSatomizeitems)r   r   r   r   border_declarationsr<   sides        @r"   r#    _border_expander.<locals>.expandR   s     v;!s6{QMM/v5EF+- TF&!7TF&!6TF&!8

 E{{} 2 22=B#fTF&$9:R9Q9QRRR=B#fTF&$9:=B#fTF&$9:  << 3 9 9 ;<<<s   C5D9C?:Dr%   r*   )rE   r#   s   ` r"   _border_expanderrG   B   s$     rz4&z'=R Mr,   c                     \ rS rSrSrSSSSSSSS	S
SSS.r\R                  5       r\R                  SSSSSSSSSSSS.5        \R                  5       r	\	R                  SS05        \R                  5       r
\
R                  SSSSS.5        / SQr/ S Q/ S!Q/ S"Q/ S#QS$.rS%r0 S& V VVs0 s H  nU(       a  S'U 3OS([        U5      _M     snnn ES) V VVs0 s H  nS'U 3[        S*U 35      _M     snnn E\" S+5      \" S,5      S-.Er S9     S:S/ jjr      S;S0 jr      S;S1 jrS<S2 jrS=S3 jrS>S4 jrS.\4       S?S5 jjrS@S6 jrSAS7 jrS8rg.s  snnn f s  snnn f )Br&   ~   z@
A callable for parsing and resolving CSS to atomic properties.
)pt   )emrK   )rJ      )rL         ?)rJ   g      ?)rJ   H   )ingL&d2?)rP   g
BP(?)mmg      ?)rL   r   )rJ   rL   remexpxpcrP   cmrQ   q	!!default)rL   g{Gz?)rR   rN   )rR   g      ?)rR   g?)rR   rK   )rR   g      ?)rR   g      ?)rR      )rL   g?)rL   g333333?)%zxx-smallzx-smallsmallr6   largezx-largezxx-largesmallerlargerrX   r4   )rJ   r   )rT      )rT   rY   )rT   rK   )r4   thickr6   thin)r4   hiddendotteddashedsoliddoublegrooveridgeinsetoutsetmediumdashdot
dashdotdothairmediumdashdotdotdashdotslantdashdotmediumdashed)r   r   r   r   )r   rK   r   rK   )r   rK   rY   rK   )r   rK   rY   r1   )rK   rY   r1   r_   )toprightbottomleft)r.   rr   rs   rt   ru   border-r2   )colorstylewidthzborder-{:s}-zmargin-{:s}zpadding-{:s})marginpaddingNc                    [        U[        5      (       a  U R                  U5      n[        U R	                  U5      5      nUc  0 nU R                  X25      nU R                  X25      nU R                  U5      $ )a  
The given declarations to atomic properties.

Parameters
----------
declarations_str : str | Iterable[tuple[str, str]]
    A CSS string or set of CSS declaration tuples
    e.g. "font-weight: bold; background: blue" or
    {("font-weight", "bold"), ("background", "blue")}
inherited : dict, optional
    Atomic properties indicating the inherited style context in which
    declarations_str is to be resolved. ``inherited`` should already
    be resolved, i.e. valid output of this method.

Returns
-------
dict
    Atomic CSS 2.2 properties.

Examples
--------
>>> resolve = CSSResolver()
>>> inherited = {"font-family": "serif", "font-weight": "bold"}
>>> out = resolve(
...     '''
...               border-color: BLUE RED;
...               font-size: 1em;
...               font-size: 2em;
...               font-weight: normal;
...               font-weight: inherit;
...               ''',
...     inherited,
... )
>>> sorted(out.items())  # doctest: +NORMALIZE_WHITESPACE
[('border-bottom-color', 'blue'),
 ('border-left-color', 'red'),
 ('border-right-color', 'red'),
 ('border-top-color', 'blue'),
 ('font-family', 'serif'),
 ('font-size', '24pt'),
 ('font-weight', 'bold')]
)
isinstancer'   parsedictrB   _update_initial_update_font_size_update_other_units)r   declarations	inheritedpropss       r"   __call__CSSResolver.__call__   so    ^ lC((::l3LT\\,/0I$$U6&&u8''..r,   c                    UR                  5        H  u  p4X1;  d  M  XAU'   M     UR                  5       nUR                  5        H+  u  p4US:X  a  UR                  US5      nUS;   a  XS	 M'  XEU'   M-     U$ )Ninheritinitial)r   N)rC   copyget)r   r   r   r   val	new_propss         r"   r   CSSResolver._update_initial  sx     #*ID !d + JJL	IDimmD)4''O"%$ ' r,   c                    UR                  S5      (       a0  U R                  US   U R                  U5      U R                  S9US'   U$ )N	font-sizeconversions)r   
size_to_pt_get_font_sizeFONT_SIZE_RATIOS)r   r   r   s      r"   r   CSSResolver._update_font_size*  sQ     99[!!!%k"##I. 11 "1 "E+
 r,   c                \    UR                  S5      (       a  US   nU R                  U5      $ g )Nr   )r   _get_float_font_size_from_pt)r   r   font_size_strings      r"   r   CSSResolver._get_font_size8  s1    99[!!$[1445EFFr,   c                f    UR                  S5      (       d   e[        UR                  S5      5      $ )NrJ   )endswithfloatrstrip)r   r   s     r"   r   (CSSResolver._get_float_font_size_from_pt>  s0    ((....%,,T233r,   c                   U R                  U5      nU R                   Hd  nSU S3nXA;   a  U R                  X   UU R                  S9X'   SU 3SU 34 H)  nXA;   d  M
  U R                  X   UU R                  S9X'   M+     Mf     U$ )Nrv   r5   )em_ptr   zmargin-zpadding-)r   r   r   rA   MARGIN_RATIOS)r   r   	font_sizerE   r   s        r"   r   CSSResolver._update_other_unitsB  s    ''.	JJDTF&)D}"ooK# $ 8 8 .  #4&)XdV+<=="&//'$($6$6 #2 #EK > " r,   c                  ^ ^^ SUUU 4S jjn[         R                  " ST5      nUc  U" 5       $ UR                  5       u  pgUS:X  a  SnO [        U5      nUS:w  a(  US:X  a  Uc  SnOXb-  nSnM   TU   u  pxXh-  nUS:w  a  M(  [        US5      n[        U5      U:X  a  [        U5      S	 S3n	U	$ US
 S3n	U	$ ! [         a
    U" 5       s $ f = f! [
         a
    U" 5       s $ f = f)Nc                 p   > [         R                  " ST< 3[        [        5       S9  TR	                  ST S9$ )NzUnhandled size: r   z
1!!defaultr   )r   r   r   r   r   )r   in_valr   s   r"   _error&CSSResolver.size_to_pt.<locals>._error[  s7    MM"6*-+-
 ??<[?IIr,   z^(\S*?)([a-zA-Z%!].*)r.   rK   rJ   rL   rR      df)r(   r'   )rematchgroupsr   
ValueErrorr   roundint)
r   r   r   r   r   r   r   unitmulsize_fmts
   `` `      r"   r   CSSResolver.size_to_ptX  s   	J 	J 16:=8OLLN	"9C Cj dlt|= DLCD '-	 JC dl Cms8s?c(1R(H  a|H/   x    x s$   B8 1C 8CCC#"C#c              #     #    U H[  u  p#UR                  5       nUR                  5       nX R                  ;   a"  U R                  U   nU" XU5       S h  vN   MV  X#4v   M]     g  N7fr8   )r9   CSS_EXPANSIONS)r   r   r   r   r#   s        r"   rB   CSSResolver.atomize  s`     'KD::<DKKME***,,T2!$e444k! (
 5s   AA'A%A'c              #  r  #    UR                  S5       H  nUR                  5       (       d  M  UR                  S5      u  p4nUR                  5       R                  5       nUR                  5       R                  5       nU(       a  X54v   Mx  [        R
                  " SU< 3[        [        5       S9  M     g7f)z
Generates (prop, value) pairs from declarations.

In a future version may generate parsed tokens from tinycss/tinycss2

Parameters
----------
declarations_str : str
;:z-Ill-formatted attribute: expected a colon in r   N)r   strip	partitionr9   r   r   r   r   )r   declarations_strdeclr   sepr   s         r"   r~   CSSResolver.parse  s      %**3/D::<<!^^C0NDs::<%%'D))+##%CiCD8L/1 0s   B5B7r*   r8   )r   zstr | Iterable[tuple[str, str]]r   zdict[str, str] | Noner(   dict[str, str])r   r   r   r   r(   r   )r   r   r(   float | None)r   r'   r(   r   )r   r   r(   r   )r   r'   r   r   r   r   r(   r'   )r   r	   r(   r)   )r   r'   r(   zIterator[tuple[str, str]])__name__
__module____qualname____firstlineno____doc__UNIT_RATIOSr   r   updater   rA   r?   r   r   rG   r+   r   r   r   r   r   r   r   r   rB   r~   __static_attributes__)r:   r   rG   r+   s   0000r"   r&   r&   ~   s4   
 K #'')$%! ##"&!"	
   $$&M&),-%**,		
M* 	O /E ?
> "&wtf86Ft6LL>
 4
3 dVn~dV-DEE3
 !/!.1N  ,07/57/ )7/ 
	7/r " 
	, " 
	4. 26;--".-DH-	-^"E

s   )"E
E
r&   )r!   r'   r(   r   )r.   )rE   r'   r(   r   )r   
__future__r   r   typingr   r   pandas.errorsr   pandas.util._exceptionsr   collections.abcr   r   r	   r
   r+   rG   r&   r*   r,   r"   <module>r      sC    # 	    $ 4 (V9xk kr,   