use std::collections::HashMap;
use std::sync::LazyLock;
use csscolorparser::Color;
#[cfg(feature = "tailwind_colors")]
pub use tailwindcss::{TAILWIND_COLORS, TAILWIND_NAME_COLORS};
pub const NAMED_COLORS: LazyLock<HashMap<&'static str, Color>> = LazyLock::new(|| {
HashMap::from_iter([
("aliceblue", [240, 248, 255].into()),
("antiquewhite", [250, 235, 215].into()),
("aqua", [0, 255, 255].into()),
("aquamarine", [127, 255, 212].into()),
("azure", [240, 255, 255].into()),
("beige", [245, 245, 220].into()),
("bisque", [255, 228, 196].into()),
("black", [0, 0, 0].into()),
("blanchedalmond", [255, 235, 205].into()),
("blue", [0, 0, 255].into()),
("blueviolet", [138, 43, 226].into()),
("brown", [165, 42, 42].into()),
("burlywood", [222, 184, 135].into()),
("cadetblue", [95, 158, 160].into()),
("chartreuse", [127, 255, 0].into()),
("chocolate", [210, 105, 30].into()),
("coral", [255, 127, 80].into()),
("cornflowerblue", [100, 149, 237].into()),
("cornsilk", [255, 248, 220].into()),
("crimson", [220, 20, 60].into()),
("cyan", [0, 255, 255].into()),
("darkblue", [0, 0, 139].into()),
("darkcyan", [0, 139, 139].into()),
("darkgoldenrod", [184, 134, 11].into()),
("darkgray", [169, 169, 169].into()),
("darkgreen", [0, 100, 0].into()),
("darkgrey", [169, 169, 169].into()),
("darkkhaki", [189, 183, 107].into()),
("darkmagenta", [139, 0, 139].into()),
("darkolivegreen", [85, 107, 47].into()),
("darkorange", [255, 140, 0].into()),
("darkorchid", [153, 50, 204].into()),
("darkred", [139, 0, 0].into()),
("darksalmon", [233, 150, 122].into()),
("darkseagreen", [143, 188, 143].into()),
("darkslateblue", [72, 61, 139].into()),
("darkslategray", [47, 79, 79].into()),
("darkslategrey", [47, 79, 79].into()),
("darkturquoise", [0, 206, 209].into()),
("darkviolet", [148, 0, 211].into()),
("deeppink", [255, 20, 147].into()),
("deepskyblue", [0, 191, 255].into()),
("dimgray", [105, 105, 105].into()),
("dimgrey", [105, 105, 105].into()),
("dodgerblue", [30, 144, 255].into()),
("firebrick", [178, 34, 34].into()),
("floralwhite", [255, 250, 240].into()),
("forestgreen", [34, 139, 34].into()),
("fuchsia", [255, 0, 255].into()),
("gainsboro", [220, 220, 220].into()),
("ghostwhite", [248, 248, 255].into()),
("gold", [255, 215, 0].into()),
("goldenrod", [218, 165, 32].into()),
("gray", [128, 128, 128].into()),
("green", [0, 128, 0].into()),
("greenyellow", [173, 255, 47].into()),
("grey", [128, 128, 128].into()),
("honeydew", [240, 255, 240].into()),
("hotpink", [255, 105, 180].into()),
("indianred", [205, 92, 92].into()),
("indigo", [75, 0, 130].into()),
("ivory", [255, 255, 240].into()),
("khaki", [240, 230, 140].into()),
("lavender", [230, 230, 250].into()),
("lavenderblush", [255, 240, 245].into()),
("lawngreen", [124, 252, 0].into()),
("lemonchiffon", [255, 250, 205].into()),
("lightblue", [173, 216, 230].into()),
("lightcoral", [240, 128, 128].into()),
("lightcyan", [224, 255, 255].into()),
("lightgoldenrodyellow", [250, 250, 210].into()),
("lightgray", [211, 211, 211].into()),
("lightgreen", [144, 238, 144].into()),
("lightgrey", [211, 211, 211].into()),
("lightpink", [255, 182, 193].into()),
("lightsalmon", [255, 160, 122].into()),
("lightseagreen", [32, 178, 170].into()),
("lightskyblue", [135, 206, 250].into()),
("lightslategray", [119, 136, 153].into()),
("lightslategrey", [119, 136, 153].into()),
("lightsteelblue", [176, 196, 222].into()),
("lightyellow", [255, 255, 224].into()),
("lime", [0, 255, 0].into()),
("limegreen", [50, 205, 50].into()),
("linen", [250, 240, 230].into()),
("magenta", [255, 0, 255].into()),
("maroon", [128, 0, 0].into()),
("mediumaquamarine", [102, 205, 170].into()),
("mediumblue", [0, 0, 205].into()),
("mediumorchid", [186, 85, 211].into()),
("mediumpurple", [147, 112, 219].into()),
("mediumseagreen", [60, 179, 113].into()),
("mediumslateblue", [123, 104, 238].into()),
("mediumspringgreen", [0, 250, 154].into()),
("mediumturquoise", [72, 209, 204].into()),
("mediumvioletred", [199, 21, 133].into()),
("midnightblue", [25, 25, 112].into()),
("mintcream", [245, 255, 250].into()),
("mistyrose", [255, 228, 225].into()),
("moccasin", [255, 228, 181].into()),
("navajowhite", [255, 222, 173].into()),
("navy", [0, 0, 128].into()),
("oldlace", [253, 245, 230].into()),
("olive", [128, 128, 0].into()),
("olivedrab", [107, 142, 35].into()),
("orange", [255, 165, 0].into()),
("orangered", [255, 69, 0].into()),
("orchid", [218, 112, 214].into()),
("palegoldenrod", [238, 232, 170].into()),
("palegreen", [152, 251, 152].into()),
("paleturquoise", [175, 238, 238].into()),
("palevioletred", [219, 112, 147].into()),
("papayawhip", [255, 239, 213].into()),
("peachpuff", [255, 218, 185].into()),
("peru", [205, 133, 63].into()),
("pink", [255, 192, 203].into()),
("plum", [221, 160, 221].into()),
("powderblue", [176, 224, 230].into()),
("purple", [128, 0, 128].into()),
("rebeccapurple", [102, 51, 153].into()),
("red", [255, 0, 0].into()),
("rosybrown", [188, 143, 143].into()),
("royalblue", [65, 105, 225].into()),
("saddlebrown", [139, 69, 19].into()),
("salmon", [250, 128, 114].into()),
("sandybrown", [244, 164, 96].into()),
("seagreen", [46, 139, 87].into()),
("seashell", [255, 245, 238].into()),
("sienna", [160, 82, 45].into()),
("silver", [192, 192, 192].into()),
("skyblue", [135, 206, 235].into()),
("slateblue", [106, 90, 205].into()),
("slategray", [112, 128, 144].into()),
("slategrey", [112, 128, 144].into()),
("snow", [255, 250, 250].into()),
("springgreen", [0, 255, 127].into()),
("steelblue", [70, 130, 180].into()),
("tan", [210, 180, 140].into()),
("teal", [0, 128, 128].into()),
("thistle", [216, 191, 216].into()),
("tomato", [255, 99, 71].into()),
("turquoise", [64, 224, 208].into()),
("violet", [238, 130, 238].into()),
("wheat", [245, 222, 179].into()),
("white", [255, 255, 255].into()),
("whitesmoke", [245, 245, 245].into()),
("yellow", [255, 255, 0].into()),
("yellowgreen", [154, 205, 50].into()),
])
});
#[cfg(feature = "tailwind_colors")]
mod tailwindcss {
use std::collections::HashMap;
use std::sync::LazyLock;
use csscolorparser::Color;
static SLATE: [[u8; 4]; 11] = [
0xf8fafcffu32.to_be_bytes(),
0xf1f5f9ffu32.to_be_bytes(),
0xe2e8f0ffu32.to_be_bytes(),
0xcbd5e1ffu32.to_be_bytes(),
0x94a3b8ffu32.to_be_bytes(),
0x64748bffu32.to_be_bytes(),
0x475569ffu32.to_be_bytes(),
0x334155ffu32.to_be_bytes(),
0x1e293bffu32.to_be_bytes(),
0x0f172affu32.to_be_bytes(),
0x020617ffu32.to_be_bytes(),
];
static GREY: [[u8; 4]; 11] = [
0xf9fafbffu32.to_be_bytes(),
0xf3f4f6ffu32.to_be_bytes(),
0xe5e7ebffu32.to_be_bytes(),
0xd1d5dbffu32.to_be_bytes(),
0x9ca3afffu32.to_be_bytes(),
0x6b7280ffu32.to_be_bytes(),
0x4b5563ffu32.to_be_bytes(),
0x374151ffu32.to_be_bytes(),
0x1f2937ffu32.to_be_bytes(),
0x111827ffu32.to_be_bytes(),
0x030712ffu32.to_be_bytes(),
];
static ZINC: [[u8; 4]; 11] = [
0xfafafaffu32.to_be_bytes(),
0xf4f4f5ffu32.to_be_bytes(),
0xe4e4e7ffu32.to_be_bytes(),
0xd4d4d8ffu32.to_be_bytes(),
0xa1a1aaffu32.to_be_bytes(),
0x71717affu32.to_be_bytes(),
0x52525bffu32.to_be_bytes(),
0x3f3f46ffu32.to_be_bytes(),
0x27272affu32.to_be_bytes(),
0x18181bffu32.to_be_bytes(),
0x09090bffu32.to_be_bytes(),
];
static NEUTRAL: [[u8; 4]; 11] = [
0xfafafaffu32.to_be_bytes(),
0xf5f5f5ffu32.to_be_bytes(),
0xe5e5e5ffu32.to_be_bytes(),
0xd4d4d4ffu32.to_be_bytes(),
0xa3a3a3ffu32.to_be_bytes(),
0x737373ffu32.to_be_bytes(),
0x525252ffu32.to_be_bytes(),
0x404040ffu32.to_be_bytes(),
0x262626ffu32.to_be_bytes(),
0x171717ffu32.to_be_bytes(),
0x0a0a0affu32.to_be_bytes(),
];
static STONE: [[u8; 4]; 11] = [
0xfafaf9ffu32.to_be_bytes(),
0xf5f5f4ffu32.to_be_bytes(),
0xe7e5e4ffu32.to_be_bytes(),
0xd6d3d1ffu32.to_be_bytes(),
0xa8a29effu32.to_be_bytes(),
0x78716cffu32.to_be_bytes(),
0x57534effu32.to_be_bytes(),
0x44403cffu32.to_be_bytes(),
0x292524ffu32.to_be_bytes(),
0x1c1917ffu32.to_be_bytes(),
0x0c0a09ffu32.to_be_bytes(),
];
static RED: [[u8; 4]; 11] = [
0xfef2f2ffu32.to_be_bytes(),
0xfee2e2ffu32.to_be_bytes(),
0xfecacaffu32.to_be_bytes(),
0xfca5a5ffu32.to_be_bytes(),
0xf87171ffu32.to_be_bytes(),
0xef4444ffu32.to_be_bytes(),
0xdc2626ffu32.to_be_bytes(),
0xb91c1cffu32.to_be_bytes(),
0x991b1bffu32.to_be_bytes(),
0x7f1d1dffu32.to_be_bytes(),
0x450a0affu32.to_be_bytes(),
];
static ORANGE: [[u8; 4]; 11] = [
0xfff7edffu32.to_be_bytes(),
0xffedd5ffu32.to_be_bytes(),
0xfed7aaffu32.to_be_bytes(),
0xfdba74ffu32.to_be_bytes(),
0xfb923cffu32.to_be_bytes(),
0xf97316ffu32.to_be_bytes(),
0xea580cffu32.to_be_bytes(),
0xc2410cffu32.to_be_bytes(),
0x9a3412ffu32.to_be_bytes(),
0x7c2d12ffu32.to_be_bytes(),
0x431407ffu32.to_be_bytes(),
];
static AMBER: [[u8; 4]; 11] = [
0xfffbebffu32.to_be_bytes(),
0xfef3c7ffu32.to_be_bytes(),
0xfde68affu32.to_be_bytes(),
0xfcd34dffu32.to_be_bytes(),
0xfbbf24ffu32.to_be_bytes(),
0xf59e0bffu32.to_be_bytes(),
0xd97706ffu32.to_be_bytes(),
0xb45309ffu32.to_be_bytes(),
0x92400effu32.to_be_bytes(),
0x78350fffu32.to_be_bytes(),
0x451a03ffu32.to_be_bytes(),
];
static YELLOW: [[u8; 4]; 11] = [
0xfefce8ffu32.to_be_bytes(),
0xfef9c3ffu32.to_be_bytes(),
0xfef08affu32.to_be_bytes(),
0xfde047ffu32.to_be_bytes(),
0xfacc15ffu32.to_be_bytes(),
0xeab308ffu32.to_be_bytes(),
0xca8a04ffu32.to_be_bytes(),
0xa16207ffu32.to_be_bytes(),
0x854d0effu32.to_be_bytes(),
0x713f12ffu32.to_be_bytes(),
0x422006ffu32.to_be_bytes(),
];
static LIME: [[u8; 4]; 11] = [
0xf7fee7ffu32.to_be_bytes(),
0xecfccbffu32.to_be_bytes(),
0xd9f99dffu32.to_be_bytes(),
0xbef264ffu32.to_be_bytes(),
0xa3e635ffu32.to_be_bytes(),
0x84cc16ffu32.to_be_bytes(),
0x65a30dffu32.to_be_bytes(),
0x4d7c0fffu32.to_be_bytes(),
0x3f6212ffu32.to_be_bytes(),
0x365314ffu32.to_be_bytes(),
0x1a2e05ffu32.to_be_bytes(),
];
static GREEN: [[u8; 4]; 11] = [
0xf0fdf4ffu32.to_be_bytes(),
0xdcfce7ffu32.to_be_bytes(),
0xbbf7d0ffu32.to_be_bytes(),
0x86efacffu32.to_be_bytes(),
0x4ade80ffu32.to_be_bytes(),
0x22c55effu32.to_be_bytes(),
0x16a34affu32.to_be_bytes(),
0x15803dffu32.to_be_bytes(),
0x166534ffu32.to_be_bytes(),
0x14532dffu32.to_be_bytes(),
0x052e16ffu32.to_be_bytes(),
];
static EMERALD: [[u8; 4]; 11] = [
0xecfdf5ffu32.to_be_bytes(),
0xd1fae5ffu32.to_be_bytes(),
0xa7f3d0ffu32.to_be_bytes(),
0x6ee7b7ffu32.to_be_bytes(),
0x34d399ffu32.to_be_bytes(),
0x10b981ffu32.to_be_bytes(),
0x059669ffu32.to_be_bytes(),
0x047857ffu32.to_be_bytes(),
0x065f46ffu32.to_be_bytes(),
0x064e3bffu32.to_be_bytes(),
0x022c22ffu32.to_be_bytes(),
];
static TEAL: [[u8; 4]; 11] = [
0xf0fdfaffu32.to_be_bytes(),
0xccfbf1ffu32.to_be_bytes(),
0x99f6e4ffu32.to_be_bytes(),
0x5eead4ffu32.to_be_bytes(),
0x2dd4bfffu32.to_be_bytes(),
0x14b8a6ffu32.to_be_bytes(),
0x0d9488ffu32.to_be_bytes(),
0x0f766effu32.to_be_bytes(),
0x115e59ffu32.to_be_bytes(),
0x134e4affu32.to_be_bytes(),
0x042f2effu32.to_be_bytes(),
];
static CYAN: [[u8; 4]; 11] = [
0xecfeffffu32.to_be_bytes(),
0xcffafeffu32.to_be_bytes(),
0xa5f3fcffu32.to_be_bytes(),
0x67e8f9ffu32.to_be_bytes(),
0x22d3eeffu32.to_be_bytes(),
0x06b6d4ffu32.to_be_bytes(),
0x0891b2ffu32.to_be_bytes(),
0x0e7490ffu32.to_be_bytes(),
0x155e75ffu32.to_be_bytes(),
0x164e63ffu32.to_be_bytes(),
0x083344ffu32.to_be_bytes(),
];
static SKY: [[u8; 4]; 11] = [
0xf0f9ffffu32.to_be_bytes(),
0xe0f2feffu32.to_be_bytes(),
0xbae6fdffu32.to_be_bytes(),
0x7dd3fcffu32.to_be_bytes(),
0x38bdf8ffu32.to_be_bytes(),
0x0ea5e9ffu32.to_be_bytes(),
0x0284c7ffu32.to_be_bytes(),
0x0369a1ffu32.to_be_bytes(),
0x075985ffu32.to_be_bytes(),
0x0c4a6effu32.to_be_bytes(),
0x082f49ffu32.to_be_bytes(),
];
static BLUE: [[u8; 4]; 11] = [
0xeff6ffffu32.to_be_bytes(),
0xdbeafeffu32.to_be_bytes(),
0xbfdbfeffu32.to_be_bytes(),
0x93c5fdffu32.to_be_bytes(),
0x60a5faffu32.to_be_bytes(),
0x3b82f6ffu32.to_be_bytes(),
0x2563ebffu32.to_be_bytes(),
0x1d4ed8ffu32.to_be_bytes(),
0x1e40afffu32.to_be_bytes(),
0x1e3a8affu32.to_be_bytes(),
0x172554ffu32.to_be_bytes(),
];
static INDIGO: [[u8; 4]; 11] = [
0xeef2ffffu32.to_be_bytes(),
0xe0e7ffffu32.to_be_bytes(),
0xc7d2feffu32.to_be_bytes(),
0xa5b4fcffu32.to_be_bytes(),
0x818cf8ffu32.to_be_bytes(),
0x6366f1ffu32.to_be_bytes(),
0x4f46e5ffu32.to_be_bytes(),
0x4338caffu32.to_be_bytes(),
0x3730a3ffu32.to_be_bytes(),
0x312e81ffu32.to_be_bytes(),
0x1e1b4bffu32.to_be_bytes(),
];
static VIOLET: [[u8; 4]; 11] = [
0xf5f3ffffu32.to_be_bytes(),
0xede9feffu32.to_be_bytes(),
0xddd6feffu32.to_be_bytes(),
0xc4b5fdffu32.to_be_bytes(),
0xa78bfaffu32.to_be_bytes(),
0x8b5cf6ffu32.to_be_bytes(),
0x7c3aedffu32.to_be_bytes(),
0x6d28d9ffu32.to_be_bytes(),
0x5b21b6ffu32.to_be_bytes(),
0x4c1d95ffu32.to_be_bytes(),
0x2e1065ffu32.to_be_bytes(),
];
static PURPLE: [[u8; 4]; 11] = [
0xfaf5ffffu32.to_be_bytes(),
0xf3e8ffffu32.to_be_bytes(),
0xe9d5ffffu32.to_be_bytes(),
0xd8b4feffu32.to_be_bytes(),
0xc084fcffu32.to_be_bytes(),
0xa855f7ffu32.to_be_bytes(),
0x9333eaffu32.to_be_bytes(),
0x7e22ceffu32.to_be_bytes(),
0x6b21a8ffu32.to_be_bytes(),
0x581c87ffu32.to_be_bytes(),
0x3b0764ffu32.to_be_bytes(),
];
static FUCHSIA: [[u8; 4]; 11] = [
0xfdf4ffffu32.to_be_bytes(),
0xfae8ffffu32.to_be_bytes(),
0xf5d0feffu32.to_be_bytes(),
0xf0abfcffu32.to_be_bytes(),
0xe879f9ffu32.to_be_bytes(),
0xd946efffu32.to_be_bytes(),
0xc026d3ffu32.to_be_bytes(),
0xa21cafffu32.to_be_bytes(),
0x86198fffu32.to_be_bytes(),
0x701a75ffu32.to_be_bytes(),
0x4a044effu32.to_be_bytes(),
];
static PINK: [[u8; 4]; 11] = [
0xfdf2f8ffu32.to_be_bytes(),
0xfce7f3ffu32.to_be_bytes(),
0xfbcfe8ffu32.to_be_bytes(),
0xf9a8d4ffu32.to_be_bytes(),
0xf472b6ffu32.to_be_bytes(),
0xec4899ffu32.to_be_bytes(),
0xdb2777ffu32.to_be_bytes(),
0xbe185dffu32.to_be_bytes(),
0x9d174dffu32.to_be_bytes(),
0x831843ffu32.to_be_bytes(),
0x500724ffu32.to_be_bytes(),
];
static ROSE: [[u8; 4]; 11] = [
0xfff1f2ffu32.to_be_bytes(),
0xffe4e6ffu32.to_be_bytes(),
0xfecdd3ffu32.to_be_bytes(),
0xfda4afffu32.to_be_bytes(),
0xfb7185ffu32.to_be_bytes(),
0xf43f5effu32.to_be_bytes(),
0xe11d48ffu32.to_be_bytes(),
0xbe123cffu32.to_be_bytes(),
0x9f1239ffu32.to_be_bytes(),
0x881337ffu32.to_be_bytes(),
0x4c0519ffu32.to_be_bytes(),
];
macro_rules! gen_tailwind_colors {
( $( $name:ident => $value:expr ),* $(,)? ) => {
pub const TAILWIND_COLORS: LazyLock<HashMap<&'static str, Color>> = LazyLock::new(|| {
let mut map = HashMap::new();
for (i, &tone) in [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950].iter().enumerate() {
$(
let tones = &$value;
let key = format!("{}-{}", stringify!($name), tone);
map.insert(&*Box::leak(key.into_boxed_str()), tones[i].into());
)*
}
map.insert("none", [0, 0, 0, 0].into());
map.insert("transparent", [0, 0, 0, 0].into());
map.insert("black", [0, 0, 0, 255].into());
map.insert("white", [255, 255, 255, 255].into());
map
});
};
}
pub const TAILWIND_NAME_COLORS: [&str; 22] = [
"slate", "grey", "zinc", "neutral", "stone", "red", "orange", "amber", "yellow", "lime",
"green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "purple", "violet", "fuchsia",
"pink", "rose",
];
gen_tailwind_colors! {
slate => SLATE,
grey => GREY,
zinc => ZINC,
neutral => NEUTRAL,
stone => STONE,
red => RED,
orange => ORANGE,
amber => AMBER,
yellow => YELLOW,
lime => LIME,
green => GREEN,
emerald => EMERALD,
teal => TEAL,
cyan => CYAN,
sky => SKY,
blue => BLUE,
indigo => INDIGO,
purple => PURPLE,
violet => VIOLET,
fuchsia => FUCHSIA,
pink => PINK,
rose => ROSE,
}
}