export declare const SUPPORTED_MODES: readonly ["hex", "hsl", "rgb", "oklch"]; export type ModeType = (typeof SUPPORTED_MODES)[number]; export type ColorObject = { l: number; c: number; h: number; alpha?: number; }; export declare const CHROMA_MAX = 0.4; export declare const clamp01: (n: number) => number; /** * Parses any CSS color string into the picker's OKLCH `{l, c, h, alpha}` shape. * Returns white when the input fails to parse so the picker never throws on * bad consumer input. Hue is pinned to 0 for achromatic colors because culori * may report it as NaN per CSS Color 4. */ export declare const parseColor: (value: string) => ColorObject; /** * Convert any CSS color string to the requested format. * * Wide-gamut OKLCH inputs are gamut-mapped into sRGB for `hex`/`rgb`/`hsl` * outputs (chroma reduced, lightness and hue preserved), so the result is * the closest sRGB representation of the requested color rather than a * per-channel-clipped one that would distort hue. `oklch` output preserves * the full color, since OKLCH can express the wide gamut natively. * * Hex is uppercase; uses 8-digit form when alpha < 1. RGB/HSL produce * `rgb()`/`rgba()` and `hsl()`/`hsla()`. OKLCH matches the design system's * token format (4-decimal L/C, 2-decimal H, hue pinned to 0 when achromatic). * * Returns `null` for unparseable input. * * @example * formatColor('oklch(0.5438 0.191 267.01)', 'hex') // '#3E63DD' * formatColor('oklch(0.7 0.32 30)', 'hex') // '#FF5843' * formatColor('red', 'rgb') // 'rgb(255, 0, 0)' * formatColor('rgba(255, 0, 0, 0.5)', 'hsl') // 'hsla(0, 100%, 50%, 0.5)' * formatColor('#FF0000', 'oklch') // 'oklch(0.6279 0.2577 29.23)' * formatColor('not a color', 'hex') // null */ export declare const formatColor: (value: string, format: 'hex' | 'rgb' | 'hsl' | 'oklch') => string | null; /** * Serializes the OKLCH color to a CSS string in the requested mode. Non-oklch * modes clip out-of-gamut channels to sRGB so the output is always a valid * representable value in that format. */ export declare const getColorString: (color: ColorObject, mode: ModeType) => string; /** * Converts an OKLCH triple to a culori RGB object. The returned r/g/b channels * may fall outside [0, 1] when the input is outside the sRGB gamut — callers * use that signal to detect and mark the gamut boundary. */ export declare const oklchToRgb: (l: number, c: number, h: number) => import("culori").Rgb; type HslView = { h: number; s: number; l: number; }; /** * Derives an HSL view (h: 0-360, s/l: 0-100) from the picker's OKLCH state. * Falls back to the input hue when the color is achromatic so the user's last * hue choice isn't lost at the s=0 axis. Used by the area + hue slider in * non-oklch modes to drive the classic gradient square. */ export declare const oklchToHsl: (color: ColorObject) => HslView; /** * Converts an HSL triple (h: 0-360, s/l: 0-100) back to the picker's OKLCH * shape. Preserves the input hue when culori reports NaN (e.g. on grays) so * the user's hue choice survives a round-trip through s=0. */ export declare const hslToOklch: (h: number, s: number, l: number, alpha?: number) => ColorObject; /** * Reduces chroma until the OKLCH color is displayable in sRGB, preserving L * and H. Used in non-oklch modes so the picker can only emit colors that the * output format can actually represent. */ export declare const clampToSrgb: (color: ColorObject) => ColorObject; export {}; //# sourceMappingURL=utils.d.ts.map