R`iD
d dl mZ d dlmZ d dlmZmZmZ ddlm Z erd dl
mZ G d d Ze
d k( rLd d
lZd dlmZ d dlmZ d d
lmZmZ d dlmZ d dlmZ G d d Z e Zej7 e y
y
) )sqrt) lru_cache)SequenceTuple
TYPE_CHECKING )ColorTripletTablec z e Zd ZdZdeeeeef fdZdedefdZ d
dZ
ed d
eeeef defd Zy)PalettezA palette of available colors.colorsc || _ y N)_colors)selfr s /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/rich/palette.py__init__zPalette.__init__ s numberreturnc , t | j | S r )r r )r r s r __getitem__zPalette.__getitem__ s T\\&122r c
< ddl m} ddlm} ddlm} ddlm} |dddd t | j d
dd
}t | j D ]F \ }}|j t | t | |d | |j | H |S )Nr ColorStyle)Textr
indexRGBr r
z colorsTright)titlecaption highlightcaption_justifyz )bgcolor)style)pip._vendor.rich.colorr pip._vendor.rich.styler pip._vendor.rich.textr pip._vendor.rich.tabler lenr enumerateadd_rowstrreprfrom_rgb)r r r r r tabler colors r __rich__zPalette.__rich__ s 00.04<<()1#
&dll3LE5MME
UXU>5>>53I%JK
4 r i )maxsizer4 c |\ t | j j dt dt ffd}t t
t | j | }|S )zFind 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.
r r c
| \ }}}|z dz }|z
}|z
} |z
} d|z |z |z dz d|z |z z d|z
|z |z dz z S )zGet the distance to a color. i i )
r red2green2blue2red_meanredgreenblue_sqrtblue1 get_colorgreen1red1s
r get_color_distancez)Palette.match.