/** * Enough colour maths to keep a resolved token legible: WCAG relative luminance, * a contrast ratio, and the largest share of a hue that still clears a threshold * against the surface it is painted on. * * Colour parsing is injected rather than implemented here. Provider slots resolve * to `oklch()` under DaisyUI 5, so an oklch-to-sRGB implementation in this file * would be a second opinion about colours the browser has already decided; * `createCanvasColorMeasure` asks the browser instead. */ export interface Srgb { r: number; g: number; b: number; /** 0..1 */ a: number; } /** Resolves any CSS colour syntax to 8-bit sRGB, or `null` if not a colour. */ export type ColorMeasure = (value: string) => Srgb | null; /** WCAG 2.2 1.4.3 for text. */ export declare const LEGIBLE_TEXT_MINIMUM = 4.5; /** WCAG 2.2 1.4.11 for component boundaries, states and graphical objects. */ export declare const LEGIBLE_NON_TEXT_MINIMUM = 3; /** * The hue share used when contrast cannot be measured. 30% is the largest 5% * step that clears 4.5:1 for every success, error and warning slot across * DaisyUI's 28 shipped themes — measured across all 84 combinations rather than * picked. It is deliberately pessimistic: a theme whose slot needed no * correction at all still gets pulled most of the way to the text colour. */ export declare const UNMEASURED_HUE_WEIGHT = 30; /** * The same pessimistic fallback for a 3:1 target: 35% is the largest 5% step * that clears 3:1 for `--color-base-300` and `--color-neutral` in all 28 themes. */ export declare const UNMEASURED_NON_TEXT_HUE_WEIGHT = 35; /** WCAG relative luminance. Alpha is ignored; composite before calling. */ export declare function relativeLuminance(color: Srgb): number; export declare function contrastRatio(foreground: Srgb, background: Srgb): number; export declare function mixTowards(hue: string, target: string, hueWeight: number): string; /** * Resolves any CSS colour the browser understands to 8-bit sRGB by painting one * pixel and reading it back, so `oklch()` and `color-mix()` need no parser here. * * Returns `null` where there is no canvas to paint on — a server render, or a * DOM shim in tests — which callers treat as "contrast is unmeasurable" rather * than as an error. */ export declare function createCanvasColorMeasure(): ColorMeasure | null; /** * The given hue if it already clears `minimum` against `background`, otherwise * the largest share of it that does, mixed toward `text`. * * Mixing toward the theme's own text colour rather than toward black or white * uses the theme's own guarantee: `text` is what that theme chose to be readable * on that surface, in a light theme and a dark one alike. Stepping down from the * top keeps as much hue as the threshold allows, so a slot that was already fine * comes back untouched and a slot that was invisible loses only what it must. */ export declare function legibleColorAgainst(args: { hue?: string; text?: string; background?: string; measure?: ColorMeasure | null; minimum?: number; unmeasuredHueWeight?: number; }): string | undefined; /** * A state fill behind text that keeps its ink: the given fill if it already * clears `minimum` against `background`, otherwise the largest share of it, * mixed toward `text`, that does -- but never past the share where `text` on * the fill drops under `textMinimum`. * * The two pairs trade off. Moving the fill toward the ink separates it from the * page and brings it closer to the ink, so where text on the page is under * `minimum x textMinimum` no fill clears both, and the text wins: an unreadable * hover is worse than a faint one. It steps by 1% rather than 5% because the * window between the two floors is narrow; 5% steps overshoot it in `dark`, * `black` and `dracula`. * * Unmeasured, the fill comes back verbatim. No fixed share holds the text floor * across DaisyUI's shipped themes -- 90% already leaves `valentine` at 4.16:1 -- * so the pessimistic answer here is no correction at all. */ export declare function legibleStateFillAgainst(args: { fill?: string; text?: string; background?: string; measure?: ColorMeasure | null; minimum?: number; textMinimum?: number; }): string | undefined;