import { type CSSProperties, type RefObject } from "react"; /** Marks an embed root that resolves the host theme for its subtree. */ export declare const HOST_THEME_ROOT_ATTRIBUTE = "data-og-host-theme"; export type HostThemePreference = "auto" | "light" | "dark"; export type HostSurfacePreference = "host" | "theme"; export type ResolvedHostTheme = "light" | "dark"; /** * Stock literal color tokens as `[dark, light]`, mirroring `styles/tokens.css` * (a test keeps them in sync). A different value inherited from the host means * the host customized that token. */ export declare const STOCK_COLOR_TOKENS: Readonly>; type Rgba = { r: number; g: number; b: number; a: number; }; /** Parse the `rgb()/rgba()` strings that `getComputedStyle` returns. */ export declare function parseComputedColor(value: string | null | undefined): Rgba | null; /** WCAG relative luminance, 0 (black) to 1 (white). */ export declare function relativeLuminance({ r, g, b }: Pick): number; /** Parse a `#rgb`/`#rrggbb` or `rgb()` token value; null for anything else. */ export declare function parseTokenColor(value: string): Rgba | null; /** * The theme whose text reads better on this background: dark when the stock * light text has the higher contrast ratio. Mid-tone and saturated brand * backgrounds land on whichever text actually stays legible. */ export declare function themeForBackground(color: Pick): ResolvedHostTheme; /** * The first opaque background the element sits on (its ancestors only), or * null when the page paints none of its own and the browser canvas shows. */ export declare function hostBackground(element: Element): Rgba | null; /** * Resolve light or dark for an embedded root from its host page. Pure DOM * reads; never consults `prefers-color-scheme` on its own. */ export declare function resolveHostTheme(element: Element): ResolvedHostTheme; /** * Canonical text for comparing a token value with the stock one. The * published `compiled.css` is minified (`#333`, `oklch(.52 .16 22)`), so the * same color must compare equal in short and long form; otherwise every stock * token reads as a host customization and dark values leak into light themes. */ export declare function normalizeToken(value: string): string; /** * Tokens the host customized on an ancestor, by value. Setting our own * `data-og-theme` would otherwise reset them to the theme's stock values. */ export declare function hostTokenOverrides(element: Element): Record<`--${string}`, string>; /** Inline token overrides that blend the stock surfaces into the host background. */ export declare function hostSurfaceStyle(theme: ResolvedHostTheme, background: Pick | null): Record<`--${string}`, string>; export type HostTheme = { /** `data-og-theme` to set on the root, or undefined to inherit. */ attribute: ResolvedHostTheme | undefined; theme: ResolvedHostTheme | undefined; style: CSSProperties | undefined; }; /** Inline style and theme for one embed root. Pure; exported for tests. */ export declare function resolveHostThemeState(element: Element, preference: HostThemePreference, surface: HostSurfacePreference): { theme: ResolvedHostTheme; inherited: boolean; style: Record | null; }; /** * Resolve and track the host theme for an embedded root. Re-resolves when the * host flips `class`/`data-*`/`style` on , or an ancestor, and * when the OS scheme changes (which only matters for hosts that follow it). * A root nested inside another embed root inherits its resolution. */ export declare function useHostTheme(ref: RefObject, options: { theme?: HostThemePreference | undefined; surface?: HostSurfacePreference | undefined; }): HostTheme; export {};