import { type BaseThemeKey, type ThemeData, type ThemePreloadData, type CssVariableStyleContent, type ThemeRegistrationData, type ThemeCssVariableName, type ExternalThemeData, type ThemeCssColorVariableName } from './ThemeModel'; export declare const CSS_VAR_EXPRESSION_PREFIX = "var(--"; export declare const DH_VAR_PREFIX = "--dh-color-"; export declare const TMP_CSS_PROP_PREFIX = "dh-tmp"; export declare const NON_WHITESPACE_REGEX: RegExp; export declare const WHITESPACE_REGEX: RegExp; export declare const DH_CSS_VAR_NAME_REGEXP: RegExp; export type VarExpressionResolver = (varExpression: string) => string; /** * Resolves the current values of CSS variables we want to preload. Preloading * happens before themes are fully loaded so that we can style things like the * loading spinner and background color which are shown to the user early on in * the app lifecycle. * @defaultPreloadValues Default values to use if a preload variable is not set. */ export declare function calculatePreloadStyleContent(defaultPreloadValues: Record): CssVariableStyleContent; /** * Create a resolver function for calculating the value of a css variable based * on a given element's computed style. If the variable resolves to '', we check * `defaultValues` for a default value, and if one does not exist, * return ''. * @param el Element to resolve css variables against * @param defaultValues Default values to use if a variable is not set. */ export declare function createCssVariableResolver(el: Element, defaultValues: Record): (varName: ThemeCssVariableName) => string; /** * Create a style tag containing preload css variables and add to the head. * @param id The id of the style tag * @param preloadStyleContent The css variable content to add to the style tag */ export declare function createPreloadStyleElement(id: `theme-preload-${string}`, preloadStyleContent: CssVariableStyleContent): void; /** * Extracts all css variable expressions from the given record and returns * a set of unique expressions. * @param record The record to extract css variable expressions from */ export declare function extractDistinctCssVariableExpressions(record: Record): Set; /** * Returns an array of the active themes. The first item will always be one * of the base themes. Optionally, the second item will be a custom theme. */ export declare function getActiveThemes(themeKey: string, themeRegistration: ThemeRegistrationData): [ThemeData] | [ThemeData, ThemeData]; /** * Get default base theme data. */ export declare function getDefaultBaseThemes(): ThemeData[]; /** * Get the default selected theme key. Precedence is: * 1. Theme key override query parameter * 2. Theme key from preload data * 3. Default dark theme key * @returns The default selected theme key */ export declare function getDefaultSelectedThemeKey(): string; /** * Derive unique theme key from plugin root path and theme name. * @param pluginName The root path of the plugin * @param themeName The name of the theme */ export declare function getThemeKey(pluginName: string, themeName: string): string; /** * A theme key override can be set via a query parameter to force a specific * theme selection. Useful for embedded widget scenarios that don't expose the * theme selector. */ export declare function getThemeKeyOverride(): string | null; /** * Get the preload data from local storage or null if it does not exist or is * invalid */ export declare function getThemePreloadData(): ThemePreloadData | null; /** * Identifies start and end indices of any top-level expressions in the given * string. * * e.g. * getExpressionRanges('var(--aaa-aa) #fff var(--bbb-bb)') * yields: * [ * [0, 12], // 'var(--aaa-aa)' * [14, 17] // '#fff' * [19, 31], // 'var(--bbb-bb)' * ] * * In cases where there are nested expressions, only the indices of the outermost * expression will be included. * * e.g. * getExpressionRanges('var(--ccc-cc, var(--aaa-aa, green)) var(--bbb-bb)') * yields: * [ * [0, 34], // 'var(--ccc-cc, var(--aaa-aa, green))' * [36, 48], // 'var(--bbb-bb)' * ] * @param value The string to search for expressions * @returns An array of [start, end] index pairs for each expression */ export declare function getExpressionRanges(value: string): [number, number][]; /** * Check if the given theme key is one of the base themes. * @param themeKey The theme key to check * @returns True if the theme key is a base theme key, false otherwise */ export declare function isBaseThemeKey(themeKey: string): themeKey is BaseThemeKey; /** * Determine if a given object is a `ExternalThemeData` object. * @param maybeExternalThemeData An object that may or may not be a `ExternalThemeData` * @returns True if the object is a `ExternalThemeData`, false otherwise */ export declare function isExternalThemeData(maybeExternalThemeData: unknown): maybeExternalThemeData is ExternalThemeData; /** * Check if the current URL specifies an external theme key override. * @returns True if the external theme key override is set, false otherwise */ export declare function isExternalThemeEnabled(): boolean; /** * Check if PRELOAD_TRANSPARENT_THEME_QUERY_PARAM query parameter is set to true. * @returns True if the preload transparent theme query parameter is set, false * otherwise */ export declare function isPreloadTransparentTheme(): boolean; /** * Validate that a given CSS variable name / value pair is a valid Deephaven * color variable. * @param name The name of the CSS variable to validate, e.g. '--dh-color-primary' * @param value The value of the CSS color to validate * @returns True if the name is a valid Deephaven color variable and the value * is a valid CSS color, false otherwise */ export declare function isValidColorVar(name: string, value: string): name is ThemeCssColorVariableName; /** * Parse external theme data into a `ThemeData` object. Invalid CSS color variable * pairs are excluded from the resulting `ThemeData` object. * @param externalThemeData The external theme data to parse * @returns A `ThemeData` object representing the external theme */ export declare function parseExternalThemeData({ baseThemeKey, name, cssVars, }: ExternalThemeData): ThemeData; /** * Replace the `fill='...'` attribute in the given SVG content with the given * color string. * @param svgContent Inline SVG content to replace the fill color in * @param fillColor The color to replace the fill color with */ export declare function replaceSVGFillColor(svgContent: string, fillColor: string): string; /** * Request theme data from the parent window. * @returns A promise that resolves to the external theme data * @throws Error if the response is not a valid `ExternalThemeData` */ export declare function requestExternalThemeData(): Promise; /** * Make a copy of the given object replacing any css variable expressions * contained in its prop values with values resolved from the given HTML element. * Variables that resolve to color strings will also be normalized to 8 digit * hex values (or optionally 6 digit hex if `isAlphaOptional` is true). * * Note that the browser will force a reflow when calling `getComputedStyle` if * css properties have changed. In order to avoid a reflow for every property * check we use distinct setup, resolve / normalize, and cleanup passes: * 1. Setup - Create a tmp element and set all css props we want to evaluate * 2. Resolve / Normalize - Evaluate all css props via `getPropertyValue` calls * and replace the original expressions with resolved values. Also normalize * css colors to rgb/a. * 3. Cleanup - Remove the tmp element * @param record An object whose values may contain css var expressions * @param targetElement The element to resolve css variables against. Defaults * to document.body * @param isAlphaOptional If true, the alpha value will be dropped from resolved * 8 character hex colors if it is 'ff'. Defaults to false. */ export declare function resolveCssVariablesInRecord>(record: T, targetElement?: HTMLElement, isAlphaOptional?: boolean): T; /** * Resolve css variable expressions in the given string using the * given resolver and replace the original expressions with the resolved values. * * @param resolver Function that can resolve a css variable expression * @param value Value that may contain css variable expressions */ export declare function resolveCssVariablesInString(resolver: VarExpressionResolver, value: string): string; /** * Store theme preload data in local storage. * @param preloadData The preload data to set */ export declare function setThemePreloadData(preloadData: ThemePreloadData): void; /** * Preload minimal theme variables from the cache. * @defaultPreloadValues Optional default values to use if a preload variable is not set. */ export declare function preloadTheme(defaultPreloadValues?: Record): void; /** * Inline SVGs cannot depend on dynamic CSS variables, so we have to statically * update them if we want to change their color. * * This function: * 1. Clears any previous overrides * 2. Resolves CSS variables containing inline SVG urls * 3. Resolves mapped color variables and replaces the `fill='...'` attribute with the result * 4. Sets the original CSS variable to the new replaced value * * Note that it is preferable to use inline SVGs as background-mask values and * just change the background color instead of relying on this util, but this * is not always possible. e.g.