
    q"h_                        S SK r S SKJr  S SKJr  S SKJrJrJrJ	r	  \ R                  S:  a  S SKJr  OS SKJr   " S S\5      rS	\S
\	\   S\\   4S jrS	\S\\   S\\   S\\   S\\   4
S jr SS	\S\\   S\\\      S\\   4S jjr\S:X  aH  S SKJr  \ " S S5      5       r\" S\" SSS5      \" SSS5      \" SSS5      /5      r\" \" \5      5        gg)    N)Fraction)ceil)castListOptionalSequence)      )Protocolc                   J    \ rS rSr% SrSr\\   \S'   Sr	\\S'   Sr
\\S'   Srg)	Edge   z1Any object that defines an edge (such as Layout).Nsize   ratiominimum_size )__name__
__module____qualname____firstlineno____doc__r   r   int__annotations__r   r   __static_attributes__r       I/var/www/html/env/lib/python3.13/site-packages/pip/_vendor/rich/_ratio.pyr   r      s&    ;D(3-E3NL#r   r   totaledgesreturnc                    U Vs/ s H  o"R                   =(       d    SPM     nn[        nSU;   Ga  [        [        X15      5       VVVs/ s H  u  nu  pbUb  M  XR4PM     nnnnU [	        S U 5       5      -
  nUS::  a8  [        X15       VVs/ s H  u  pbUc  UR
                  =(       d    SOUPM!     snn$ U" U[	        S U 5       5      5      n	U H1  u  pRXR                  -  UR
                  ::  d  M#  UR
                  X5'     O7   U" S5      n
U H&  u  pR[        XR                  -  U
-   S5      u  pjXcU'   M(     O	SU;   a  GM  [        [        [           U5      $ s  snf s  snnnf s  snnf )a`  Divide total space to satisfy size, ratio, and minimum_size, constraints.

The returned list of integers should add up to total in most cases, unless it is
impossible to satisfy all the constraints. For instance, if there are two edges
with a minimum size of 20 each and `total` is 30 then the returned list will be
greater than total. In practice, this would mean that a Layout object would
clip the rows that would overflow the screen height.

Args:
    total (int): Total number of characters.
    edges (List[Edge]): Edges within total space.

Returns:
    List[int]: Number of characters for each edge.
Nc              3   6   #    U  H  o=(       d    S v   M     g7f)r   Nr   ).0r   s     r   	<genexpr> ratio_resolve.<locals>.<genexpr>2   s     <ed		es   r   r   c              3   P   #    U  H  u  pUR                   =(       d    S v   M     g7f)r   N)r   )r#   _edges      r   r$   r%   ;   s     KNDJJO!ONs   $&)r   r   	enumeratezipsumr   r   divmodr   r   r   )r   r   r(   sizes	_Fractionindexr   flexible_edges	remainingportion	remainders              r   ratio_resolver4      s   " .33UTii4UE3I %- (1U1B'C
'C#| UM'C 	 
 C<e<<<	> #&e"3"3JD .2\$##(qtC"3 
 sKNKK

 *KE#t'8'88#00	 * "!I-"(::)=	)I1"M#e  . E %-H S	5!!S 4
s   E
E"E"&E)ratiosmaximumsvaluesc                 b   [        X5       VVs/ s H  u  pEU(       a  UOSPM     nnn[        U5      nU(       d  USS $ U n/ nUR                  n	[        XU5       HI  u  pJnU(       a4  US:  a.  [        U
[	        XG-  U-  5      5      nU	" X-
  5        X|-  nXd-  nMA  U	" U5        MK     U$ s  snnf )aD  Divide an integer total in to parts based on ratios.

Args:
    total (int): The total to divide.
    ratios (List[int]): A list of integer ratios.
    maximums (List[int]): List of maximums values for each slot.
    values (List[int]): List of values

Returns:
    List[int]: A list of integers guaranteed to sum to total.
r   N)r*   r+   appendminround)r   r5   r6   r7   r   _maxtotal_ratiototal_remainingresultr9   maximumvaluedistributeds                r   ratio_reducerC   Q   s     7:&6KL6K{ute"6KFLf+KayOF]]F!$Vv!>[1_guU-D{-R'STK5&'*O K5M "? M Ms   B+minimumsc                 x   U(       a(  [        X5       VVs/ s H  u  p4U(       a  UOSPM     nnn[        U5      nUS:  d   S5       eU n/ nUR                  nUc  S/[        U5      -  n	OUn	[        X5       H8  u  p:US:  a  [	        U
[        X6-  U-  5      5      nOUnU" U5        XS-  nXk-  nM:     U$ s  snnf )a   Distribute an integer total in to parts based on ratios.

Args:
    total (int): The total to divide.
    ratios (List[int]): A list of integer ratios.
    minimums (List[int]): List of minimum values for each slot.

Returns:
    List[int]: A list of integers guaranteed to sum to total.
r   zSum of ratios must be > 0)r*   r+   r9   lenmaxr   )r   r5   rD   r   _minr=   r>   distributed_totalr9   	_minimumsminimumrB   s               r   ratio_distributerL   q   s     :=f:OP:O;54%Q&:OPf+K?777?O#%%%FC#f+%		f0?gtE,Ck,Q'RSK)K{& 1 ' Qs   B6__main__)	dataclassc                   F    \ rS rSr% Sr\\   \S'   Sr\\S'   Sr	\\S'   Sr
g)E   Nr   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   rP   rP      s#    "hsm"scr   rP   n   r   )N)sys	fractionsr   mathr   typingr   r   r   r   version_infor   pip._vendor.typing_extensionsr   r   r4   rC   rL   r   dataclassesrN   rP   resolvedprintr+   r   r   r   <module>r\      s5   
   1 1v68 :" :"Xd^ :"S	 :"zS	-1#Y@DS		#YB DH!!S	!-5d3i-@!	#Y!H z%  
 S1T1a=!D!Q-4A"OPH	#h- r   