HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/rich/__pycache__/palette.cpython-310.pyc
o

@%NeD
�@s�ddlmZddlmZddlmZmZmZddlm	Z	er$ddl
mZGdd�d�Ze
d	kredd
lZddlmZddlmZdd
lmZmZddlmZddlmZGdd�d�Ze�Ze�e��d
Sd
S)�)�sqrt)�	lru_cache)�Sequence�Tuple�
TYPE_CHECKING�)�ColorTriplet��Tablec@sneZdZdZdeeeeeffdd�Zdedefdd�Z	dd
d�Z
edd
�deeeefdefdd��ZdS)�PalettezA palette of available colors.�colorscCs
||_dS�N)�_colors)�selfr�r�:/usr/lib/python3/dist-packages/pip/_vendor/rich/palette.py�__init__s
zPalette.__init__�number�returncCst|j|�Sr
)rr)rrrrr�__getitem__szPalette.__getitem__r
c
Cs�ddlm}ddlm}ddlm}ddlm}|dddd	t|j	��d
�ddd
�}t
|j	�D]\}}|�t|�t
|�|d||j|�d�d��q.|S)Nr��Color��Style)�Textr	�index�RGBrrz colorsT�right)�title�caption�	highlight�caption_justifyz                )�bgcolor)�style)�pip._vendor.rich.colorr�pip._vendor.rich.styler�pip._vendor.rich.textr�pip._vendor.rich.tabler
�lenr�	enumerate�add_row�str�repr�from_rgb)rrrrr
�tabler�colorrrr�__rich__s(�	�zPalette.__rich__i)�maxsizer/csN|\���t�|jj�dtdtf�����fdd�}ttt|j��|d�}|S)z�Find a color from a palette that most closely matches a given color.

        Args:
            color (Tuple[int, int, int]): RGB components in range 0 > 255.

        Returns:
            int: Index of closes matching color.
        rrcsj�|�\}}}�|d}�|}�|}�|}�d|||d?d||d|||d?�S)zGet the distance to a color.�i��i�r)r�red2�green2�blue2�red_mean�red�green�blue��_sqrt�blue1�	get_color�green1�red1rr�get_color_distance:s
���z)Palette.match.<locals>.get_color_distance)�key)rrr�int�float�min�ranger()rr/rB�	min_indexrr<r�match,s


z
Palette.matchN)rr
)
�__name__�
__module__�__qualname__�__doc__rrrDrrrr0rrIrrrrrs
"r�__main__N)�Iterabler)�Console�ConsoleOptions)�Segmentrc@s&eZdZdededeefdd�ZdS)�ColorBox�console�optionsrccs��|jjd}td|�D]X}t|j�D]K}||j}||d}t�||d�\}}	}
t�||d|dd�\}}}
t�|d|	d|
d�}t�|d|d|
d�}tdt	||d��Vqt�
�VqdS)	N�rrg�?r2�u▄)r/r")�size�heightrG�	max_width�colorsys�
hls_to_rgbrr-rRr�line)rrTrUrY�y�x�h�l�r1�g1�b1�r2�g2�b2r"r/rrr�__rich_console__Ts�
 �zColorBox.__rich_console__N)rJrKrLrPrQrOrRrhrrrrrSSs���rS)�mathr�	functoolsr�typingrrr�
color_tripletrr'r
rrJr[rOr$r�pip._vendor.rich.consolerPrQ�pip._vendor.rich.segmentrRr%rrSrT�printrrrr�<module>s$@�