HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/rich/__pycache__/palette.cpython-310.pyc
o

;j��@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�@/opt/saltstack/salt/lib/python3.10/site-packages/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	�indexZRGBrrz colorsT�right)�titleZcaptionZ	highlightZcaption_justifyz                )�bgcolor)�style)�
rich.colorr�
rich.stylerZ	rich.textr�
rich.tabler
�lenr�	enumerateZadd_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)rZred2Zgreen2Zblue2Zred_meanZredZgreenZblue��_sqrtZblue1Z	get_colorZgreen1Zred1rr�get_color_distance:s
���z)Palette.match.<locals>.get_color_distance)�key)rrr�int�float�min�ranger#)rr)r1Z	min_indexrr/r�match,s


z
Palette.matchN)rr
)
�__name__�
__module__�__qualname__�__doc__rrr3rrrr*rr7rrrrrs
"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�?r,�u▄)r)r)�size�heightr6Z	max_width�colorsysZ
hls_to_rgbrr'r@r�line)rrBrCrG�y�x�h�lZr1Zg1�b1Zr2Zg2�b2rr)rrr�__rich_console__Ts�
 �zColorBox.__rich_console__N)r8r9r:r>r?r=r@rPrrrrrASs���rA)�mathr�	functoolsr�typingrrrZ
color_tripletrr"r
rr8rHr=r rZrich.consoler>r?Zrich.segmentr@r!rrArB�printrrrr�<module>s$@�