
    Kxh                         d dl mZ d dlmZmZmZmZmZ ddlm	Z	 ddl
mZmZ er
ddlmZmZmZ  G d de          Zd	d
ddded         ddfdZdS )    )
itemgetter)TYPE_CHECKINGCallable
NamedTupleOptionalSequence   )errors)is_renderable	rich_cast)ConsoleConsoleOptionsRenderableTypec                       e Zd ZU dZeed<   	 eed<   	 edefd            ZddZdedd fdZ	dedd fd	Z
	 ddee         dee         dd fdZe	 	 	 	 	 	 	 	 dd            Zd
S )MeasurementzSStores the minimum and maximum widths (in characters) required to render an object.minimummaximumreturnc                      | j         | j        z
  S )z+Get difference between maximum and minimum.)r   r   )selfs    K/var/www/html/what/lib/python3.11/site-packages/pip/_vendor/rich/measure.pyspanzMeasurement.span   s     |dl**    c           
          | \  }}t          t          d|          |          }t          t          d|          t          dt          ||                              S )zGet measurement that ensures that minimum <= maximum and minimum >= 0

        Returns:
            Measurement: A normalized measurement.
        r   )minmaxr   )r   r   r   s      r   	normalizezMeasurement.normalize   sQ      c!Woow//3q'??C3w3H3H,I,IJJJr   widthc                 d    | \  }}t          t          ||          t          ||                    S )zGet a RenderableWith where the widths are <= width.

        Args:
            width (int): Maximum desired width.

        Returns:
            Measurement: New Measurement object.
        )r   r   r   r   r   r   s       r   with_maximumzMeasurement.with_maximum"   s2      3w..GU0C0CDDDr   c                     | \  }}t          d|          }t          t          ||          t          ||                    S )zGet a RenderableWith where the widths are >= width.

        Args:
            width (int): Minimum desired width.

        Returns:
            Measurement: New Measurement object.
        r   )r   r   r    s       r   with_minimumzMeasurement.with_minimum.   s?      Au3w..GU0C0CDDDr   N	min_width	max_widthc                 f    | }||                     |          }||                    |          }|S )aN  Clamp a measurement within the specified range.

        Args:
            min_width (int): Minimum desired width, or ``None`` for no minimum. Defaults to None.
            max_width (int): Maximum desired width, or ``None`` for no maximum. Defaults to None.

        Returns:
            Measurement: New Measurement object.
        )r#   r!   )r   r$   r%   measurements       r   clampzMeasurement.clamp;   sA      %229==K %229==Kr   consoler   optionsr   
renderabler   c                    |j         }|dk     rt          dd          S t          |t                    r|                    ||j        d          }t          |          }t          |          rt          |dd          }|` |||          	                                
                    |          }|j        dk     rt          dd          S |	                                S t          d|          S t          j        d|d          )	a  Get a measurement for a renderable.

        Args:
            console (~rich.console.Console): Console instance.
            options (~rich.console.ConsoleOptions): Console options.
            renderable (RenderableType): An object that may be rendered with Rich.

        Raises:
            errors.NotRenderableError: If the object is not renderable.

        Returns:
            Measurement: Measurement object containing range of character widths required to render the object.
        r	   r   F)markup	highlight__rich_measure__NzUnable to get render width for zD; a str, Segment, or object with __rich_console__ method is required)r%   r   
isinstancestr
render_strr-   r   r   getattrr   r!   r   r
   NotRenderableError)clsr)   r*   r+   
_max_widthget_console_widthrender_widths          r   getzMeasurement.getN   s4   " &
>>q!$$$j#&& 	 ++7>U ,  J z**
$$ 	 
$6==  !,%%gw77Y[[!\*-- 
  '!++&q!,,,#--///"1j111+U* U U U  r   )r   r   )NN)r)   r   r*   r   r+   r   r   r   )__name__
__module____qualname____doc__int__annotations__propertyr   r   r!   r#   r   r(   classmethodr9    r   r   r   r      sA        ]]LLL5LLL5+c + + + X+K K K K
E# 
E- 
E 
E 
E 
EE# E- E E E E KO !#:B3-	   & ++*:+HX+	+ + + [+ + +r   r   r)   r   r*   r   renderablesr   r   c           	          |st          dd          S t           j         fd|D             }t          t          |t          d                    j        t          |t          d                    j                  }|S )a  Get a measurement that would fit a number of renderables.

    Args:
        console (~rich.console.Console): Console instance.
        options (~rich.console.ConsoleOptions): Console options.
        renderables (Iterable[RenderableType]): One or more renderable objects.

    Returns:
        Measurement: Measurement object containing range of character widths required to
            contain all given renderables.
    r   c                 *    g | ]} |          S rB   rB   ).0r+   r)   get_measurementr*   s     r   
<listcomp>z'measure_renderables.<locals>.<listcomp>   s4       :D*55  r   )keyr	   )r   r9   r   r   r   r   )r)   r*   rC   measurementsmeasured_widthrG   s   ``   @r   measure_renderablesrL   }   s       !1a   !oO     HS  L !Ljmm,,,4Ljmm,,,4 N r   N)operatorr   typingr   r   r   r   r    r
   protocolr   r   r)   r   r   r   r   rL   rB   r   r   <module>rQ      s         J J J J J J J J J J J J J J       . . . . . . . . A@@@@@@@@@@o o o o o* o o od *+ 	     r   