import { C as DEFAULT_CHROME_MAP, S as ChromeRole, a as Config, b as TokenListingByPath, c as LayeredConfig, d as Project, f as ResolveAt, g as TokenMap, h as SwatchbookToken, i as AxisVarianceResult, l as PlainConfig, m as SwatchbookIntegration, n as AxisConfig, o as Diagnostic, p as ResolverConfig, r as AxisVariancePerAxis, s as DiagnosticSeverity, t as Axis, u as Preset, w as buildChromeDefaultsCss, x as CHROME_ROLES } from "./types-Cwn0Uyq2.mjs"; import { transformCSSValue } from "@terrazzo/token-tools/css"; //#region src/config.d.ts /** * Identity helper for typed `swatchbook.config.ts`. Consumers write: * * ```ts * import { defineSwatchbookConfig } from '@unpunnyfuns/swatchbook-core'; * export default defineSwatchbookConfig({ * tokens: ['tokens/**\/*.json'], * resolver: 'tokens/resolver.json', * }); * ``` * * Or with authored layered axes (no resolver file): * * ```ts * export default defineSwatchbookConfig({ * tokens: ['tokens/base/**\/*.json'], * axes: [ * { * name: 'mode', * contexts: { Light: [], Dark: ['tokens/modes/dark.json'] }, * default: 'Light', * }, * ], * }); * ``` * * `resolver` and `axes` are mutually exclusive. Setting neither falls * back to a single synthetic theme. * * Named distinctly from Terrazzo's `defineConfig` to keep imports unambiguous. */ declare function defineSwatchbookConfig(config: Config): Config; //#endregion //#region src/load.d.ts /** * Load a swatchbook project from a config. Read tokens at any axis * tuple via `project.resolveAt(tuple)`; read the default-tuple * snapshot directly via `project.defaultTokens`. * * The `cwd` defaults to `process.cwd()`. All relative paths in * `config` (token globs, `resolver`, layered axis overlay globs) * resolve against this directory. */ declare function loadProject(config: Config, cwd?: string): Promise; //#endregion //#region src/css-axis-projected.d.ts type VarianceInfo = { kind: 'baseline-only'; } | { kind: 'single-axis'; axis: string; } | { kind: 'orthogonal-after-probe'; touching: ReadonlySet; } | { kind: 'joint-variant'; touching: ReadonlySet; jointCases: readonly JointCase[]; }; interface JointCase { tuple: Record; cartesianValueKey: string; } /** @internal Addon-internal smart-emitter options. Not part of the public API. */ interface EmitAxisProjectedCssOptions { /** Override the prefix from project config (default: `project.config.cssVarPrefix ?? ''`). */ prefix?: string; /** * Validated chrome-alias entries from `Project.chrome`. Each `source → * target` pair appends `---: var(---);` * to a trailing `:root` block. Defaults to `project.chrome`. See * `validateChrome`. */ chrome?: Record; /** * Pre-computed variance analysis. When omitted, the emitter calls * `analyzeProjectVariance(project)` itself. Callers that need the * analysis for other purposes (diagnostics, alternative emit paths) * can compute it once and pass it here to avoid duplicate work. */ variance?: Map; } /** * Emit a single concatenated stylesheet by routing each token to the * cheapest emit strategy that still produces the spec-correct value * at every tuple. Spec-faithful for any DTCG-compliant resolver * (orthogonal or not): * * - **Baseline-only tokens** — emitted once in `:root`, never in any cell * - **Single-axis tokens** — emitted in `:root` plus the touching axis's * cell blocks (standard projection: `[data--=""]`) * - **Orthogonal-after-probe tokens** (touched by 2+ axes but * cell-composition matches cartesian) — emitted in `:root` plus * every touching axis's cell blocks; CSS cascade resolves the * correct value at any tuple * - **Joint-variant tokens** (cell composition diverges from cartesian * at some joint tuple) — emitted in `:root` plus per-axis cell blocks * AS WELL AS compound `[data-A="ctx_a"][data-B="ctx_b"]` blocks * carrying the cartesian-correct value at exactly the divergent * joint tuples. Compound selector specificity `(0,2,0)` beats the * singletons' `(0,1,0)`, so the joint cell wins under cascade. * * Smart dedup: every cell re-emits a token's value when ANY axis touches * the token (not just when this cell differs from baseline). For * orthogonal-after-probe tokens this means the last touching axis's * cell wins under cascade — which matches what `analyzeProjectVariance` * already verified for the `orthogonal-after-probe` classification. * * The classification work is the value-comparison + targeted-joint-probe * pass in `analyzeProjectVariance`. The emitter consumes that analysis * and does no spec reasoning of its own — every routing decision is * already in the `VarianceInfo` for the token. * * Output size scales with `baseline + per-axis cells + joint compound * blocks`. For mostly-orthogonal fixtures, dramatically smaller than * cartesian. In the worst case (every token touched by every axis with * joint variance on every pair), output approaches cartesian but never * exceeds it. * * For single-axis projects (a synthetic `theme` axis, or a resolver * with one modifier), the cell selector uses the axis's actual name * — e.g. `[data-mode="Dark"]`. * * Public, but scoped to swatchbook's own preview build: this is how the * addon produces the stylesheet it injects into Storybook and how the MCP * server answers CSS-preview queries — both call it directly through this * entry rather than duplicating the emission logic. It is not a * general-purpose production CSS emitter; consumers building their own * transform pipeline for a shipped platform should drive * `@terrazzo/plugin-css` / the Terrazzo CLI against their DTCG sources * instead, the same way swatchbook's own preview build does internally. */ declare function emitAxisProjectedCss(project: Project, options?: EmitAxisProjectedCssOptions): string; //#endregion export { type Axis, type AxisConfig, type AxisVariancePerAxis, type AxisVarianceResult, CHROME_ROLES, type ChromeRole, type Config, DEFAULT_CHROME_MAP, type Diagnostic, type DiagnosticSeverity, type LayeredConfig, type PlainConfig, type Preset, type Project, type ResolveAt, type ResolverConfig, type SwatchbookIntegration, type SwatchbookToken, type TokenListingByPath, type TokenMap, buildChromeDefaultsCss, defineSwatchbookConfig, emitAxisProjectedCss, loadProject }; //# sourceMappingURL=index.d.mts.map