
    Bh                     D    S r SSKJr  SSKJr  S rS rS rS rS	 r	S
 r
g)z&Resolve percentages into fixed values.    )inf   )boxesc                     U b  U S:X  a  U $ U R                   S:X  a  U R                  $ U R                   S:X  d   eXR                  -  S-  $ )zReturn the percentage of the reference value, or the value unchanged.

``refer_to`` is the length for 100%. If ``refer_to`` is not a number, it
just replaces percentages.

autopx%d   )unitvalue)r   refer_tos     K/var/www/html/env/lib/python3.13/site-packages/weasyprint/layout/percent.py
percentager      sN     }	t	{{zzS   ++%++    c                     U R                   U   n[        X25      n[        XU5        US;   a  US:X  a  [        XS5        ggg)zSet a used length value from a computed length value.

``refer_to`` is the length for 100%. If ``refer_to`` is not a number, it
just replaces percentages.

)	min_width
min_heightr   r   N)styler   setattr)boxproperty_namer   r   percents        r   resolve_one_percentager      sI     IIm$E)GC(3368IA& 9J3r   c                 t    Uu  p#[        U SU5        [        U SU5        [        U SU5        [        U SU5        g )Nleftrighttopbottom)r   )r   containing_blockcb_width	cb_heights       r   resolve_position_percentagesr"   (   s:    *H31323y13)4r   c                    [        U[        R                  5      (       a  UR                  nUR                  nOUu  p#[        U [        R
                  5      (       a  UnOUn[        U SU5        [        U SU5        [        U SU5        [        U SU5        [        U SU5        [        U SU5        [        U SU5        [        U SU5        [        U S	U5        [        U S
U5        [        U SU5        US:X  ao  U R                  S   nUS:X  d  UR                  S:X  a  SU l        O#UR                  S:X  d   eUR                  U l        [        U SS5        [        U S[        5        O'[        U SU5        [        U SU5        [        U SU5        U R                  S   S:H  nS H;  nSU S3nU(       a  [        X5      (       a  M"  [        XU R                  U   5        M=     [        U S	5        [        U S5        g)z0Set used values as attributes of the box object.margin_leftmargin_right
margin_topmargin_bottompadding_leftpadding_rightpadding_toppadding_bottomwidthr   	max_widthr   heightr	   r   r   r   
max_heightborder_collapsecollapse)r   r   r   r   border__widthN)
isinstancer   Boxr,   r.   PageBoxr   r   r   r   r   hasattrr   adjust_box_sizing)	r   r   r    r!   maybe_heightr.   r1   sideprops	            r   resolve_percentagesr<   0   s   "EII..#))$++	.#u}}%% 3x8393l;3>393:3|<3 0,?323X63X6 F 8$Vv{{c1CJ;;$&&&CJsL!4sL#6sHi8sL)<sL)<yy*+z9H2f% WS//Csyy/ 3 c7#c8$r   c                 X   S H  nSU S3nU R                   U   u  p4SX44;   a  [        XS5        M/  UR                  S5       H!  nXPR                  ;   d  M  [        XS5          Mc     [	        X0R                  5       5      n[	        X@R                  5       5      n[        XX445        M     g )N)top_left	top_rightbottom_rightbottom_leftr2   _radius)r   r   )r   r   _)r   r   splitremove_decoration_sidesr   border_widthborder_height)r   cornerr   rxryr:   s         r   resolve_radii_percentagesrK   h   s    J!&1=)  C/LL%D222F3 &
 B 0 0 23BB 1 1 34BC1! Kr   c                    U R                   S   S:X  an  US:X  a4  U R                  U R                  -   U R                  -   U R                  -   nOU R
                  U R                  -   U R                  -   U R                  -   nOdU R                   S   S:X  a:  US:X  a  U R                  U R                  -   nO1U R
                  U R                  -   nOU R                   S   S:X  d   eSnUS:  a  [        X5      S:w  a"  [        X[        S[        X5      U-
  5      5        [        U SU 3[        S[        U SU 35      U-
  5      5        [        U S	U 35      S:w  a+  [        U S	U 3[        S[        U S	U 35      U-
  5      5        g g g )
N
box_sizingz
border-boxr,   zpadding-boxzcontent-boxr   r   max_min_)r   r(   r)   border_left_widthborder_right_widthr*   r+   border_top_widthborder_bottom_widthgetattrr   max)r   axisdeltas      r   r8   r8   |   s   
yy,.7?  3#4#44%%&(+(>(>? 
 #"4"44$$%'*'>'>?  
<	 M	17?$$s'8'88EOOc&8&88Eyy&-777
 qy3'Cs1gc&85&@ABtD6]C73$tf+F+N$OP3$tf&&0C4vAwsd4&M/JU/R(ST 1	 r   N)__doc__mathr   formatting_structurer   r   r   r"   r<   rK   r8    r   r   <module>r\      s.    ,  (, ' 55%p2(Ur   