@cascivo/design 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) cascivo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,146 @@
1
- # Temporary Holding Version
1
+ <!-- generated by scripts/readme/generate.ts — edit readme.body.md, not this file -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <div align="center">
4
+ <a href="https://cascivo.com"><img src="https://cascivo.com/logo-mark-img-accent.svg" width="72" height="72" alt="cascivo logo"></a>
5
+ <h1>@cascivo/design</h1>
6
+ <p><strong>Deterministic UI planning and auditing for AI agents — plan a page from a brief, audit the rendered result. Docs offline: npx @cascivo/docs</strong></p>
7
+
8
+ [![npm](https://img.shields.io/npm/v/%40cascivo%2Fdesign?style=flat-square&color=0079bf)](https://www.npmjs.com/package/@cascivo/design)
9
+ [![downloads](https://img.shields.io/npm/dm/%40cascivo%2Fdesign?style=flat-square&color=0079bf)](https://www.npmjs.com/package/@cascivo/design)
10
+ [![license](https://img.shields.io/npm/l/%40cascivo%2Fdesign?style=flat-square&color=0079bf)](https://github.com/cascivo/cascivo/blob/main/LICENSE)
11
+ ![types](https://img.shields.io/badge/types-included-0079bf?style=flat-square&logo=typescript&logoColor=white)
12
+
13
+ [npm](https://www.npmjs.com/package/@cascivo/design) · [cascivo.com](https://cascivo.com) · [Docs](https://cascivo.com/docs) · [Storybook](https://storybook.cascivo.com) · [GitHub](https://github.com/cascivo/cascivo)
14
+ </div>
15
+
16
+ ---
17
+
18
+ Deterministic UI planning and auditing for AI agents: turn a brief into a page plan, then audit what was
19
+ actually rendered. Same input, same output; no model in the loop.
20
+
21
+ > **Docs offline?** The full cascivo reference ships as an npm package — `npx -y @cascivo/docs`, no website needed.
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ pnpm add @cascivo/design
27
+ ```
28
+
29
+ `check` and `see` drive a browser through [Playwright](https://playwright.dev), an optional peer. Install it
30
+ only if you use them:
31
+
32
+ ```sh
33
+ pnpm add -D playwright
34
+ ```
35
+
36
+ ## Modules
37
+
38
+ | Export | Does | CLI |
39
+ | ------------- | ---------------------------------------------- | ------------------------------- |
40
+ | `check()` | Audit a rendered page (URL or file) | `cascivo design check <target>` |
41
+ | `see()` | Small screenshot of a page plus a text digest | `cascivo design see <target>` |
42
+ | `plan()` | Turn a brief into a page plan (`cv` or `view`) | `cascivo design plan "<brief>"` |
43
+ | `catalogue()` | List the page archetypes `plan()` chooses from | (none) |
44
+ | `init()` | Write a `DESIGN.md` for the project | `cascivo design init` |
45
+ | `theme()` | Derive a theme from one seed colour | `cascivo design theme` |
46
+
47
+ ```ts
48
+ import { plan } from '@cascivo/design'
49
+
50
+ const page = plan('a pricing page with three tiers', { format: 'cv' })
51
+ ```
52
+
53
+ ## `check`: audit what was rendered
54
+
55
+ ```sh
56
+ cascivo design check http://localhost:5173/pricing # or ./out/page.html
57
+ ```
58
+
59
+ ```text
60
+ score 67/100 — mobile 50 · a11y 75 · contrast 75 · tokens 92 · hierarchy 43 — 5 errors, 5 warnings
61
+ error overflow div.wide — scrolls sideways at 320/360/390/414px (280px too wide at 320px) → let it shrink or wrap: min-inline-size: 0, max-inline-size: 100%, flex-wrap: wrap
62
+ error contrast div.wide > p.faint — 2.11:1, needs 4.5:1 (#aaaaaa on #f4f4f4) → color: #6f6f6f or stronger
63
+ warn token/spacing main > div.card ×4 — padding 13px is off the spacing scale → var(--cascivo-space-3) (12px)
64
+ ```
65
+
66
+ One line per finding: `level rule selector ×N — message → fix`. Findings with the same rule and fix are
67
+ merged. `--max N` caps the list (default 20), `--json` prints everything, and the exit code is 1 when any
68
+ finding is an `error`.
69
+
70
+ | Rule | Category | Checks |
71
+ | ---------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------ |
72
+ | `overflow` | mobile | No sideways scroll at 320, 360, 390 and 414px |
73
+ | `touch-target` | mobile | Interactive elements are 44×44px on a touch device (error under 24) |
74
+ | `axe/<id>` | a11y | axe-core, WCAG 2.2 AA |
75
+ | `contrast` | contrast | Computed text colour against its background, 4.5:1 (3:1 large) |
76
+ | `token/spacing`, `/font-size`, `/radius`, `/color` | tokens | Computed values sit on the page's cascivo scales; `auto` margins and fluid `clamp()` sizes are skipped |
77
+ | `scale/spacing`, `scale/colors` | tokens | A page without cascivo: 4px grid, at most 12 colours |
78
+ | `hierarchy/h1`, `/heading-order` | hierarchy | One `<h1>`, levels descend one step at a time |
79
+ | `hierarchy/body-text`, `/line-length`, `/font-sizes` | hierarchy | Running text ≥16px, lines ≤80ch, at most 6 font sizes |
80
+
81
+ A token rule is scored by the share of the values it measured that are off-scale. Each rule is one
82
+ finding listing every distinct off-scale value with its count (text shows the first eight; `--json`
83
+ has them all).
84
+
85
+ The run is deterministic: fixed viewports, reduced motion, animations off. Each category scores 0-100 and
86
+ the total is their weighted mean (weights in `src/check/score.ts`).
87
+
88
+ ### The project's own tokens
89
+
90
+ A value is on-scale when it matches a cascivo token, a custom property the page defines on
91
+ `:root`, or a token in the front matter of the project's `DESIGN.md` (`colors`, `spacing`,
92
+ `rounded`, `typography.*.fontSize`):
93
+
94
+ ```sh
95
+ cascivo design check ./out/page.html --design ./DESIGN.md # ./DESIGN.md is the default
96
+ ```
97
+
98
+ ```ts
99
+ await check('./out/page.html', { design: './DESIGN.md' })
100
+ ```
101
+
102
+ `init({ direction })` writes such tokens for a chosen look (colours, a display and a body font
103
+ stack, one signature element, one composition move) and returns the `:root` block that applies them:
104
+
105
+ ```sh
106
+ cascivo design init --accent "#b4532a" --font-display "Georgia, serif" \
107
+ --signature "a ruled double line under the title"
108
+ ```
109
+
110
+ ### Pages behind a login
111
+
112
+ `--storage-state auth.json` (library: `{ storageState: 'auth.json' }`, also on `see`) loads a
113
+ Playwright storage state into every browser context. Create it once with
114
+ `npx playwright codegen --save-storage=auth.json <url>`. Gitignore it: it holds live session
115
+ cookies. Screenshots and findings of a logged-in page go to the model, so prefer a mock or demo
116
+ mode for the improvement loop and use the live app for a final check.
117
+
118
+ ## `see`: look at the page cheaply
119
+
120
+ ```sh
121
+ cascivo design see http://localhost:5173/pricing --width 390
122
+ ```
123
+
124
+ Saves a PNG whose long edge is at most 1280px (about 1.3k vision tokens) and prints its path, then a digest
125
+ of at most 40 lines: landmarks with their boxes, the heading outline, and the most common off-scale values.
126
+
127
+ ## `theme`: one seed colour, a whole theme
128
+
129
+ ```sh
130
+ cascivo design theme --seed "#0079bf" --mode dark --name brand > brand.css
131
+ ```
132
+
133
+ Prints a stylesheet in `@layer cascivo.theme` that defines every semantic token the shipped themes define.
134
+ Lightness is adjusted until every text/surface pair passes WCAG AA, whatever the seed.
135
+
136
+ ## Install
137
+
138
+ ```sh
139
+ pnpm add @cascivo/design
140
+ ```
141
+
142
+ ---
143
+
144
+ [cascivo.com](https://cascivo.com) · [Docs](https://cascivo.com/docs) · [Storybook](https://storybook.cascivo.com) · [GitHub](https://github.com/cascivo/cascivo) · AI agents: read [`llms.txt`](https://cascivo.com/llms.txt) (install steps + component index, plain text) or use [`@cascivo/mcp`](https://github.com/cascivo/cascivo/tree/main/packages/mcp) and [`registry.json`](https://github.com/cascivo/cascivo/blob/main/registry.json) · MIT
145
+
146
+ <div align="center"><a href="https://cascivo.com"><img src="https://cascivo.com/logo-mark-img.svg" width="28" height="28" alt="cascivo"></a></div>
@@ -0,0 +1,361 @@
1
+ /** One region of a page, top to bottom. `plan()` fills it from the components in `allow`. */
2
+ interface ArchetypeSlot {
3
+ /** Stable id, e.g. `kpis`. Shared across archetypes: the same slot plans the same way. */
4
+ id: string;
5
+ /** Registry names (components, layouts, charts) that may fill the slot. */
6
+ allow: readonly string[];
7
+ /** `true` when the slot appears only if the brief asks for it. */
8
+ optional?: boolean;
9
+ }
10
+ /** What the page shows in each state it must handle. */
11
+ interface ArchetypeStates {
12
+ empty: string;
13
+ loading: string;
14
+ error: string;
15
+ }
16
+ /** A kind of page `plan()` can produce, e.g. a pricing page or a dashboard. */
17
+ interface PageArchetype {
18
+ /** Stable id, e.g. `pricing`. */
19
+ id: string;
20
+ /** Human-readable name. */
21
+ title: string;
22
+ /** When to choose this archetype. */
23
+ description: string;
24
+ /** Words in a brief that point at this archetype. */
25
+ keywords: readonly string[];
26
+ /** The page frame: a registry layout name plus how content sits in it. */
27
+ layout: string;
28
+ /** Regions of the page, in reading order. */
29
+ slots: readonly ArchetypeSlot[];
30
+ /** States the page must design for, beyond the happy path. */
31
+ states: ArchetypeStates;
32
+ /** Rules for narrow screens. */
33
+ mobile: readonly string[];
34
+ /** Accessibility notes specific to this kind of page. */
35
+ a11y: readonly string[];
36
+ /** Mistakes to avoid: hand-written, plus the registry's own for the slot components. */
37
+ antiPatterns: readonly string[];
38
+ /** Registry page blocks that implement part of this page (`npx cascivo add <name>`). */
39
+ blocks: readonly string[];
40
+ /** A whole-page template for this archetype, when one ships. */
41
+ template?: string;
42
+ }
43
+ /** Where one page block lives. The three block sources, reconciled under one id. */
44
+ interface BlockSource {
45
+ /** Name to pass to `cascivo add`. */
46
+ registry: string;
47
+ /** Source directory, relative to the repository root. */
48
+ source: string;
49
+ /** Scaffold recipe under `packages/cli/recipes`, when the block has one. */
50
+ recipe?: string;
51
+ /** Archetypes the block belongs to. */
52
+ archetypes: readonly string[];
53
+ }
54
+ /**
55
+ * List every page archetype, in a stable order. Each is at most 1 KB of JSON, so the whole
56
+ * catalogue fits in a prompt.
57
+ */
58
+ export declare function catalogue(): readonly PageArchetype[];
59
+ /** How serious a finding is. Any `error` makes `cascivo design check` exit 1. */
60
+ type Level = 'error' | 'warn';
61
+ /** What a finding is about; each category is scored separately. */
62
+ type Category = 'mobile' | 'a11y' | 'contrast' | 'tokens' | 'hierarchy';
63
+ /** One off-scale value of a token rule, with how many elements carry it. */
64
+ interface FindingValue {
65
+ value: string;
66
+ fix: string;
67
+ count: number;
68
+ }
69
+ /** One problem found on a rendered page, with every element it was found on. */
70
+ interface Finding {
71
+ /** Stable rule id, e.g. `contrast` or `token/spacing`. */
72
+ rule: string;
73
+ /** The scored category the rule belongs to. */
74
+ category: Category;
75
+ /** How serious the finding is. */
76
+ level: Level;
77
+ /** What is wrong, in one sentence. */
78
+ message: string;
79
+ /** What to change. Findings with the same rule and fix are merged into one. */
80
+ fix: string;
81
+ /** CSS selector of the first offending element, when there is one. */
82
+ selector?: string;
83
+ /** How many elements share this rule and fix. */
84
+ count: number;
85
+ /** Every offending element's selector. */
86
+ selectors: string[];
87
+ /** Token rules: every distinct off-scale value, most frequent first. */
88
+ values?: FindingValue[];
89
+ /** Token rules: share (0-1) of measured values that are off-scale; scores the rule. */
90
+ share?: number;
91
+ }
92
+ /** A page's score: 100 is nothing to fix. */
93
+ interface Score {
94
+ /** Weighted mean of the categories, 0-100. */
95
+ total: number;
96
+ /** 0-100 per category. */
97
+ categories: Record<Category, number>;
98
+ }
99
+ /**
100
+ * Tokens a project declares for itself in the YAML front matter of its `DESIGN.md`.
101
+ *
102
+ * `check` holds a page to the cascivo scales; a project that chose its own accent or type
103
+ * step and wrote it down has not gone off the scale, it has extended it. This reads those
104
+ * values as text only: the browser resolves them (any colour syntax, `rem`), not this file.
105
+ */
106
+ /** One declared value, still as the CSS text the file held. */
107
+ interface DeclaredValue {
108
+ /** Path in the front matter, e.g. `colors.accent`. */
109
+ name: string;
110
+ value: string;
111
+ }
112
+ /** Declared values per scale, unresolved. */
113
+ interface Declared {
114
+ color: DeclaredValue[];
115
+ space: DeclaredValue[];
116
+ text: DeclaredValue[];
117
+ radius: DeclaredValue[];
118
+ }
119
+ /**
120
+ * The tokens in a DESIGN.md's front matter: `colors`, `spacing`, `rounded` and each
121
+ * `typography.<step>.fontSize`.
122
+ *
123
+ * Reads the subset of YAML that DESIGN.md uses (nested maps of scalars, two-space indent).
124
+ * A file without front matter, or a line that does not fit, declares nothing: never throws.
125
+ */
126
+ export declare function parseDesignMd(source: string): Declared;
127
+ /** The fields {@link formatCheck} reads; `check()`'s result satisfies it. */
128
+ interface Formattable {
129
+ target: string;
130
+ score: Score;
131
+ findings: readonly Finding[];
132
+ }
133
+ /**
134
+ * Render a check as compact text: a score line, then one line per finding.
135
+ *
136
+ * Built for an agent's context window: no headers, no blank lines, nothing repeated.
137
+ *
138
+ * @param result - What `check()` returned.
139
+ * @param max - Report at most this many findings (default 20).
140
+ */
141
+ export declare function formatCheck(result: Formattable, max?: number): string;
142
+ /** Options for {@link check}. */
143
+ export interface CheckOptions {
144
+ /** Desktop viewport width for the accessibility, token and hierarchy rules (default 1280). */
145
+ width?: number;
146
+ /**
147
+ * Path to the project's `DESIGN.md`. The tokens in its front matter (`colors`, `spacing`,
148
+ * `rounded`, `typography.*.fontSize`) count as on-scale. A missing file is an error.
149
+ * Custom properties the page defines on `:root` count either way.
150
+ */
151
+ design?: string;
152
+ /**
153
+ * Path to a Playwright `storageState` JSON (cookies + localStorage), loaded into every
154
+ * browser context so a page behind a login can be audited. Create it once with
155
+ * `npx playwright codegen --save-storage=auth.json <url>`. Keep it out of git.
156
+ */
157
+ storageState?: string;
158
+ }
159
+ /** What {@link check} found on one page. */
160
+ export interface CheckResult {
161
+ /** The URL or file path that was audited. */
162
+ target: string;
163
+ /** True when the page resolves cascivo tokens, so values are matched against them. */
164
+ cascivo: boolean;
165
+ /** 0-100 per category and overall. */
166
+ score: Score;
167
+ /** Findings, most serious first; like findings are merged with a count. */
168
+ findings: Finding[];
169
+ }
170
+ /**
171
+ * Audit a rendered page: mobile overflow and touch targets, WCAG 2.2 AA (axe-core),
172
+ * text contrast, token adherence and visual hierarchy.
173
+ *
174
+ * Tokens the project declares for itself are part of the scale: custom properties the page
175
+ * defines on `:root`, and the front matter of the `DESIGN.md` named by `options.design`.
176
+ *
177
+ * Deterministic: fixed viewports, reduced motion, animations off, no model involved.
178
+ * Needs the optional `playwright` peer.
179
+ *
180
+ * @param target - An http(s) or `file:` URL, or a path to an `.html` file.
181
+ * @param options - Viewport settings.
182
+ */
183
+ export declare function check(target: string, options?: CheckOptions): Promise<CheckResult>;
184
+ /**
185
+ * An aesthetic direction chosen for the project, written into `DESIGN.md` as tokens so the
186
+ * build and `check` both read the same decision.
187
+ */
188
+ interface Direction {
189
+ /** Semantic colour name (`accent`, `primary`, `background`, …) to a CSS colour. */
190
+ colors?: Readonly<Record<string, string>>;
191
+ /** Font stack for `display` and `heading`, e.g. `Georgia, "Times New Roman", serif`. */
192
+ fontDisplay?: string;
193
+ /** Font stack for body, labels and captions. */
194
+ fontBody?: string;
195
+ /** The one signature element of the design, in a sentence. */
196
+ signature?: string;
197
+ /**
198
+ * The one composition move of the design, in a sentence: the default of the page's genre
199
+ * that it breaks on purpose (asymmetry, scale contrast, a broken grid, overlap, full bleed).
200
+ */
201
+ composition?: string;
202
+ }
203
+ /**
204
+ * The `:root` block that applies a direction to a cascivo page: the same values as the front
205
+ * matter, as overrides of the `--cascivo-*` tokens. Empty when there is nothing to override.
206
+ */
207
+ export declare function directionCss(direction: Direction | undefined): string;
208
+ /** Options for {@link init}. */
209
+ export interface InitOptions {
210
+ /** Project directory to write into. Defaults to the current working directory. */
211
+ cwd?: string;
212
+ /** Theme whose token values go into the front matter. Defaults to `light`. */
213
+ theme?: string;
214
+ /** Replace an existing `DESIGN.md`. Without it an existing file is never touched. */
215
+ force?: boolean;
216
+ /**
217
+ * A chosen aesthetic direction (colours, font stacks, signature element) to write over the
218
+ * theme's tokens, so the look is decided once and recorded before anything is built.
219
+ */
220
+ direction?: Direction;
221
+ }
222
+ /** What {@link init} did. */
223
+ export interface InitResult {
224
+ /** Absolute path of the `DESIGN.md` file. */
225
+ path: string;
226
+ /** `false` when a file was already there and was left alone. */
227
+ written: boolean;
228
+ /** The theme the tokens came from. */
229
+ theme: string;
230
+ /** With a direction: the `:root` block that applies it to a page. Absent without one. */
231
+ css?: string;
232
+ }
233
+ /**
234
+ * Write a `DESIGN.md` for the project, in Google's DESIGN.md format: the theme's tokens as
235
+ * YAML front matter, then the rules for building pages with them.
236
+ *
237
+ * @param options - Where to write, which theme, and whether to replace an existing file.
238
+ * @throws When `theme` is not a cascivo theme or a direction value is not safe to write.
239
+ * Nothing is written.
240
+ */
241
+ export declare function init(options?: InitOptions): Promise<InitResult>;
242
+ /** Output formats {@link plan} can emit: `.cv` text or a ViewConfig JSON document. */
243
+ export type PlanFormat = 'cv' | 'view';
244
+ /** Options for {@link plan}. */
245
+ export interface PlanOptions {
246
+ /** Output format. Defaults to `cv`. */
247
+ format?: PlanFormat;
248
+ }
249
+ /** A registry component the plan uses or suggests. */
250
+ export interface PlanComponent {
251
+ /** Registry name, as `npx cascivo add <name>` takes it. */
252
+ name: string;
253
+ /** The slot it fills. Absent for a suggestion matched from the brief alone. */
254
+ slot?: string;
255
+ /** The props that matter, as `name: type` (`name?` when optional). */
256
+ props: readonly string[];
257
+ }
258
+ /** The archetype's rules for the page, for the agent to honour while filling the plan in. */
259
+ export interface PlanRules {
260
+ layout: string;
261
+ states: ArchetypeStates;
262
+ mobile: readonly string[];
263
+ a11y: readonly string[];
264
+ antiPatterns: readonly string[];
265
+ }
266
+ /** A page plan derived from a brief. */
267
+ export interface PlanResult {
268
+ /** Id of the page archetype the brief was matched to. */
269
+ archetype: string;
270
+ /** How strongly the brief matched it. `0` means no keyword matched and this is the default. */
271
+ score: number;
272
+ /** Format of `output`. */
273
+ format: PlanFormat;
274
+ /** The plan itself, in `format`. */
275
+ output: string;
276
+ /** Slots in the plan, in page order. */
277
+ slots: readonly string[];
278
+ /** At most eight components: the ones filling slots first, then matches from the brief. */
279
+ components: readonly PlanComponent[];
280
+ /** Ready-made page blocks for this archetype (`npx cascivo add <name>`). */
281
+ blocks: readonly string[];
282
+ /** Brief words nothing here accounts for. The caller decides what they mean. */
283
+ unmatched: readonly string[];
284
+ /** The archetype's rules. */
285
+ rules: PlanRules;
286
+ }
287
+ /**
288
+ * Turn a brief into a page plan. Deterministic: the same brief gives byte-identical output.
289
+ * No model is involved: the brief is scored against the archetype catalogue and the registry's
290
+ * intent metadata by keyword (BM25), and what it cannot place comes back in `unmatched`.
291
+ *
292
+ * @param brief - What the page is for, in plain words.
293
+ * @param options - Output settings.
294
+ */
295
+ export declare function plan(brief: string, options?: PlanOptions): PlanResult;
296
+ /** Options for {@link see}. */
297
+ export interface SeeOptions {
298
+ /** Viewport width in CSS pixels (default 1280). */
299
+ width?: number;
300
+ /** Where to write the PNG (default: a stable path in the OS temp directory). */
301
+ out?: string;
302
+ /** Playwright `storageState` JSON (cookies + localStorage) for a page behind a login. */
303
+ storageState?: string;
304
+ }
305
+ /** A screenshot of a page, plus the text an agent needs beside it. */
306
+ export interface SeeResult {
307
+ /** The URL that was captured. */
308
+ url: string;
309
+ /** Viewport width the capture used, in CSS pixels. */
310
+ width: number;
311
+ /** Absolute path of the PNG screenshot. */
312
+ path: string;
313
+ /** Pixel size of the PNG: its long edge is at most 1280. */
314
+ image: {
315
+ width: number;
316
+ height: number;
317
+ };
318
+ /** Landmarks, heading outline and off-scale values: at most 40 lines. */
319
+ digest: string;
320
+ }
321
+ /**
322
+ * Capture a page as a small PNG and a short text digest.
323
+ *
324
+ * Needs the optional `playwright` peer.
325
+ *
326
+ * @param url - An http(s) or `file:` URL, or a path to an `.html` file.
327
+ * @param options - Viewport width and output path.
328
+ */
329
+ export declare function see(url: string, options?: SeeOptions): Promise<SeeResult>;
330
+ /** Options for {@link theme}. */
331
+ export interface ThemeOptions {
332
+ /** The brand colour as hex, e.g. `#0079bf`. */
333
+ seed: string;
334
+ /** Light or dark surfaces (default `light`). */
335
+ mode?: 'light' | 'dark';
336
+ /** The `data-theme` value the tokens attach to (default `custom`). */
337
+ name?: string;
338
+ }
339
+ /** A theme derived from one seed colour. */
340
+ export interface ThemeResult {
341
+ /** The seed colour, normalized to `#rrggbb`. */
342
+ seed: string;
343
+ /** The mode the theme was generated for. */
344
+ mode: 'light' | 'dark';
345
+ /** The `data-theme` value the stylesheet targets. */
346
+ name: string;
347
+ /** The theme as a CSS stylesheet, in `@layer cascivo.theme`. */
348
+ css: string;
349
+ }
350
+ /**
351
+ * Derive a full theme from one seed colour.
352
+ *
353
+ * Deterministic: the seed's hue and chroma drive the accent ramp and tint the neutrals,
354
+ * then lightness is adjusted until every text/surface pair clears WCAG AA. The result
355
+ * defines every semantic token the shipped themes define, in `@layer cascivo.theme`.
356
+ *
357
+ * @param input - A hex colour (`#0079bf`), or options with `seed`, `mode` and `name`.
358
+ */
359
+ export declare function theme(input: string | ThemeOptions): ThemeResult;
360
+ export type { ArchetypeSlot, ArchetypeStates, BlockSource, Category, Finding as CheckFinding, Declared, DeclaredValue, Direction, FindingValue, Level, PageArchetype, Score };
361
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import{existsSync as e,mkdirSync as t,readFileSync as r,writeFileSync as i}from"node:fs";import{createRequire as a}from"node:module";import{dirname as o,join as s,resolve as c}from"node:path";import{pathToFileURL as l}from"node:url";import{writeFile as u}from"node:fs/promises";import{createHash as d}from"node:crypto";import{tmpdir as f}from"node:os";var m=[{id:`landing`,title:`Landing page`,description:`Marketing page that drives one action.`,keywords:[`landing`,`marketing`,`homepage`,`hero`,`product`,`launch`,`waitlist`],layout:`layout/section: stacked sections, centred content`,slots:[{id:`nav`,allow:[`header`]},{id:`hero`,allow:[`heading`,`text`,`button`]},{id:`features`,allow:[`card`]},{id:`proof`,allow:[`blockquote`],optional:!0},{id:`faq`,allow:[`accordion`],optional:!0},{id:`cta`,allow:[`button`]},{id:`footer`,allow:[`link`]}],states:{empty:`n/a`,loading:`none; text renders first`,error:`form errors inline`},mobile:[`one column; CTA above the fold`,`nav moves to a drawer`],a11y:[`one h1, in the hero`,`CTA names the action`],antiPatterns:[`generic three-card feature grid`,`eyebrow label on every heading`,`two primary buttons`,`Building complex multi-menu console chrome on top of Header`],blocks:[`faq`,`marketing-features`,`marketing-hero`,`site-footer`],template:`landing`},{id:`pricing`,title:`Pricing page`,description:`Compare plans and pick one.`,keywords:[`pricing`,`price`,`plan`,`tier`,`subscription`,`billing`,`upgrade`,`monthly`,`yearly`],layout:`layout/section: heading, then plan cards in one row from 64rem`,slots:[{id:`hero`,allow:[`heading`,`text`,`button`]},{id:`plans`,allow:[`card`,`badge`,`button`]},{id:`compare`,allow:[`data-table`],optional:!0},{id:`faq`,allow:[`accordion`],optional:!0}],states:{empty:`n/a: plans are static`,loading:`skeleton per plan card`,error:`alert above the plans; keep them readable`},mobile:[`plans stack, recommended first`,`comparison table scrolls in its region`],a11y:[`price and period read as one phrase`,`recommended plan marked in text`],antiPatterns:[`more than four plans`,`a primary button on every plan`,`feature lists of unequal length`,`Nesting Cards several levels deep for layout`],blocks:[`faq`,`pricing`]},{id:`dashboard`,title:`Dashboard`,description:`Key metrics, trends and recent records.`,keywords:[`dashboard`,`analytics`,`metrics`,`kpi`,`overview`,`stats`,`admin`,`monitoring`,`revenue`],layout:`layout/dashboard-layout: header, KPI strip, main`,slots:[{id:`page-header`,allow:[`layout/page-header`]},{id:`kpis`,allow:[`stat`]},{id:`chart`,allow:[`chart/line-chart`,`card`],optional:!0},{id:`table`,allow:[`data-table`]}],states:{empty:`empty-state with first action, not zeroed charts`,loading:`skeleton per card`,error:`alert per failed card`},mobile:[`KPIs go 2-up then 1-up`,`table scrolls in its card`],a11y:[`each chart has a text summary`,`trend not by colour alone`],antiPatterns:[`wall of equal cards`,`more than four KPIs`,`a chart where one number would do`,`A grid of Stats used to fake a data table`],blocks:[`block/console-app`,`block/dashboard-charts`,`dashboard-overview`,`dashboard-table`],template:`dashboard`},{id:`list`,title:`List / table page`,description:`Browse, search, sort and act on a collection of records.`,keywords:[`list`,`table`,`records`,`users`,`customers`,`inventory`,`search`,`filter`,`sort`,`crud`,`manage`],layout:`layout/page-header over one full-width table`,slots:[{id:`page-header`,allow:[`layout/page-header`]},{id:`toolbar`,allow:[`search`,`button`]},{id:`table`,allow:[`data-table`]}],states:{empty:`empty-state with create action; separate "no results"`,loading:`skeleton rows`,error:`alert with retry`},mobile:[`table scrolls sideways`,`filters move to a sheet`],a11y:[`sortable headers use aria-sort`,`row action names include the row`],antiPatterns:[`cards for tabular data`,`one empty state for "none yet" and "no match"`,`hover-only actions`,`Using DataTable for two columns of label/value pairs`],blocks:[`dashboard-table`,`block/users-table-page`]},{id:`detail`,title:`Detail page`,description:`One record: facts, sections and history.`,keywords:[`detail`,`details`,`profile`,`record`,`item`,`single`,`order`,`ticket`,`invoice`],layout:`layout/page-header over a main column; facts beside it from 64rem`,slots:[{id:`crumbs`,allow:[`breadcrumb`]},{id:`page-header`,allow:[`layout/page-header`]},{id:`facts`,allow:[`data-list`]},{id:`sections`,allow:[`tabs`],optional:!0},{id:`activity`,allow:[`timeline`],optional:!0}],states:{empty:`empty-state per empty section`,loading:`skeleton header and facts`,error:`full-page message if record missing`},mobile:[`side column drops below`,`actions collapse to an overflow menu`],a11y:[`h1 names the record`,`label/value pairs use a description list`],antiPatterns:[`more than one primary action`,`tabs hiding what must be compared`,`Using Breadcrumb to step through pages 1, 2, 3 of a dataset`],blocks:[`block/page-with-breadcrumb`]},{id:`settings`,title:`Settings page`,description:`Edit preferences or account configuration in grouped forms.`,keywords:[`settings`,`preferences`,`configuration`,`config`,`options`,`account`,`notifications`,`security`],layout:`layout/settings-layout: section nav beside one form column`,slots:[{id:`page-header`,allow:[`layout/page-header`]},{id:`fields`,allow:[`input`,`select`,`toggle`]},{id:`actions`,allow:[`button`]}],states:{empty:`n/a`,loading:`skeleton fields; no layout jump`,error:`error on the field, summary alert on submit`},mobile:[`section nav becomes a select or tabs above the form`,`save bar sticks to the bottom`],a11y:[`every control has a visible label`,`saved/failed announced in a live region`],antiPatterns:[`placeholder as label`,`a save button per field`,`destructive action next to save`],blocks:[`block/settings-form-page`,`settings-profile`]},{id:`auth`,title:`Auth screen`,description:`Sign in, sign up or reset a password.`,keywords:[`auth`,`login`,`signin`,`sign`,`signup`,`register`,`password`,`reset`,`forgot`,`authentication`,`otp`],layout:`layout/auth-layout: one centred card, no app chrome`,slots:[{id:`auth-form`,allow:[`card`,`input`,`password-input`,`button`,`link`]}],states:{empty:`n/a`,loading:`button shows loading; fields stay filled`,error:`one alert above the form; never say which field was wrong`},mobile:[`card goes edge to edge; inputs at least 44px tall`,`no horizontal scroll at 320px`],a11y:[`autocomplete set on every field`,`error moves focus to the alert`],antiPatterns:[`a marketing panel that pushes the form below the fold`,`clearing the form on error`,`social buttons above the primary method`,`Nesting Cards several levels deep for layout`],blocks:[`auth-login`,`auth-signup`,`block/login-page`],template:`auth`},{id:`onboarding`,title:`Onboarding / wizard`,description:`Lead a user through a few ordered steps to finish setup.`,keywords:[`onboarding`,`wizard`,`setup`,`step`,`stepper`,`welcome`,`getting`,`started`,`tour`,`multistep`,`flow`],layout:`layout/center: steps above one card, one question group per step`,slots:[{id:`progress`,allow:[`steps`]},{id:`fields`,allow:[`input`,`select`,`radio-card`]},{id:`actions`,allow:[`button`]}],states:{empty:`n/a`,loading:`next button shows loading; step stays put`,error:`error on the field; the step does not advance`},mobile:[`steps collapse to "Step 2 of 4"`,`back and next pinned to the bottom`],a11y:[`current step has aria-current="step"`,`focus moves to the step heading on advance`],antiPatterns:[`more than five steps`,`no way back`,`asking for what can be defaulted`,`Using Steps as a replacement for Tabs for non-sequential navigation`],blocks:[`auth-signup`]},{id:`empty`,title:`Empty / error / 404`,description:`A full-page message: nothing here yet, something failed, or not found.`,keywords:[`empty`,`error`,`404`,`500`,`notfound`,`missing`,`offline`,`maintenance`,`nothing`,`blank`,`fallback`,`found`],layout:`layout/center: one message block in the middle of the page`,slots:[{id:`message`,allow:[`empty-state`,`button`,`link`]}],states:{empty:`this page is the empty state: say what goes here and how to add it`,loading:`not shown while loading`,error:`say what failed and offer retry or a way home`},mobile:[`message fits one screen at 320px`,`action is full width`],a11y:[`title is the h1`,`error pages keep the site navigation reachable`],antiPatterns:[`a joke with no next step`,`raw error codes or stack traces`,`showing empty while data still loads`,`Showing an EmptyState while data is still fetching`],blocks:[`block/empty-dashboard`]},{id:`article`,title:`Docs / article`,description:`Long-form reading: documentation, a guide, a blog post or a changelog.`,keywords:[`docs`,`documentation`,`article`,`blog`,`post`,`guide`,`tutorial`,`changelog`,`reading`,`content`,`markdown`,`help`],layout:`layout/center: one text column at a readable measure; contents beside it from 64rem`,slots:[{id:`crumbs`,allow:[`breadcrumb`]},{id:`toc`,allow:[`toc`],optional:!0},{id:`article`,allow:[`prose`,`heading`,`text`,`code-snippet`]}],states:{empty:`n/a`,loading:`skeleton text lines`,error:`not-found message with search`},mobile:[`contents collapses above the text`,`code blocks scroll inside themselves`],a11y:[`headings descend without skipping levels`,`links make sense out of context`],antiPatterns:[`lines longer than 75 characters`,`cards around paragraphs`,`centred body text`,`Using Breadcrumb to step through pages 1, 2, 3 of a dataset`],blocks:[]},{id:`checkout`,title:`Checkout / form`,description:`One focused form: checkout, contact, booking.`,keywords:[`checkout`,`form`,`payment`,`pay`,`cart`,`contact`,`booking`,`purchase`,`shipping`,`submit`],layout:`layout/columns: form, summary beside it from 64rem`,slots:[{id:`progress`,allow:[`steps`],optional:!0},{id:`error`,allow:[`alert`],optional:!0},{id:`fields`,allow:[`input`,`select`,`checkbox`]},{id:`summary`,allow:[`data-list`],optional:!0},{id:`actions`,allow:[`button`]}],states:{empty:`empty cart: say so, link back`,loading:`submit shows loading; no double submit`,error:`summary alert, message on each field`},mobile:[`summary collapses above the form`,`right keyboard via type and inputmode`],a11y:[`errors tied to fields by aria-describedby`,`required marked in the label`],antiPatterns:[`asking for what is not needed`,`validating before blur`,`a reset button`,`Using Steps as a replacement for Tabs for non-sequential navigation`],blocks:[]}];function catalogue(){return m}var isRecord$3=e=>typeof e==`object`&&!!e,g=`@cascivo/design: check and see need Playwright. Run: pnpm add -D playwright && pnpm exec playwright install chromium`;async function loadChromium(){let e;try{e=await import(`playwright`)}catch{throw Error(g)}let t=isRecord$3(e)&&isRecord$3(e.default)&&!e.chromium?e.default:e,r=isRecord$3(t)?t.chromium:void 0;if(!isRecord$3(r)||typeof r.launch!=`function`)throw Error(g);return r}function resolveTarget(t,r=process.cwd()){if(/^(https?|file):\/\//i.test(t))return t;let i=c(r,t);if(!/\.html?$/i.test(i))throw Error(`@cascivo/design: "${t}" is not a URL or an .html file`);if(!e(i))throw Error(`@cascivo/design: no such file: ${i}`);return l(i).href}var _=`*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important;caret-color:transparent!important}`;async function settle(e){await e.evaluate(async()=>{await document.fonts.ready,await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})})}async function openSession(e){let t=await loadChromium(),r=process.env.CASCIVO_CHROMIUM,i=await t.launch(r?{executablePath:r}:{}),a=[],context=async t=>{let r=await i.newContext({viewport:{width:t.width,height:t.height},deviceScaleFactor:1,reducedMotion:`reduce`,colorScheme:`light`,locale:`en-US`,timezoneId:`UTC`,hasTouch:t.touch===!0,isMobile:t.touch===!0,bypassCSP:!0,...e?{storageState:e}:{}});return a.push(r),r};return{async open(e,t){let r=await(await context(t)).newPage();return await r.goto(e,{waitUntil:`load`}),await r.waitForLoadState(`networkidle`,{timeout:3e3}).catch(()=>void 0),await r.addStyleTag({content:_}),await settle(r),r},async blank(){return(await context({width:16,height:16})).newPage()},async close(){for(let e of a)await e.close().catch(()=>void 0);await i.close()}}}function inPage(e){let t=document,r=t.documentElement,i=t.body,a=window.innerWidth,clean=(e,t)=>(e??``).replace(/\s+/g,` `).trim().slice(0,t),selectorOf=e=>{let t=[],a=e;for(;a&&a!==i&&a!==r&&t.length<3;){if(a.id){t.unshift(`#${CSS.escape(a.id)}`);break}let e=a.tagName.toLowerCase(),r=a.classList[0],i=a.parentElement;if(r)e+=`.${CSS.escape(r)}`;else if(i){let t=Array.from(i.children).filter(e=>e.tagName===a.tagName);t.length>1&&(e+=`:nth-of-type(${t.indexOf(a)+1})`)}t.unshift(e),a=i}return t.length>0?t.join(` > `):e.tagName.toLowerCase()},visibleRect=e=>{let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let r=getComputedStyle(e);return r.visibility===`visible`&&r.display!==`none`?t:null},boxOf=e=>({x:Math.round(e.x+window.scrollX),y:Math.round(e.y+window.scrollY),w:Math.round(e.width),h:Math.round(e.height)}),o=t.createElement(`canvas`);o.width=1,o.height=1;let s=o.getContext(`2d`,{willReadFrequently:!0}),c=/* @__PURE__ */ new Map,rgba=e=>{let t=c.get(e);if(t)return t;let r=[0,0,0,0];if(s){s.clearRect(0,0,1,1),s.fillStyle=`rgba(0,0,0,0)`,s.fillStyle=e,s.fillRect(0,0,1,1);let t=s.getImageData(0,0,1,1).data;r=[t[0]??0,t[1]??0,t[2]??0,(t[3]??0)/255]}return c.set(e,r),r},over=(e,t)=>[Math.round(e[0]*e[3]+t[0]*(1-e[3])),Math.round(e[1]*e[3]+t[1]*(1-e[3])),Math.round(e[2]*e[3]+t[2]*(1-e[3]))],backgroundOf=e=>{let t=[];for(let r=e;r;r=r.parentElement){let e=getComputedStyle(r);if(e.backgroundImage!==`none`)return null;let i=rgba(e.backgroundColor);if(i[3]>0&&(t.push(i),i[3]>=1))break}let r=[255,255,255];for(let e=t.length-1;e>=0;e--)r=over(t[e],r);return r},l={title:clean(t.title,80),viewport:{width:a,height:window.innerHeight},page:{width:r.scrollWidth,height:r.scrollHeight},overflow:null,targets:[],elements:[],truncated:!1,headings:[],landmarks:[],scales:{space:[],text:[],radius:[],color:[]},declared:{space:[],text:[],radius:[],color:[]}};if(e.overflow!==null){let t=e.overflow,a=r.scrollWidth,o=[];if(a>t){let e=Array.from(i.querySelectorAll(`*`)).filter(e=>{let r=e.getBoundingClientRect();return r.width>0&&r.right+window.scrollX>t+.5});for(let t of e)if(!(t.parentElement&&e.includes(t.parentElement))&&(o.push(selectorOf(t)),o.length>=3))break}l.overflow={innerWidth:t,scrollWidth:a,offenders:o}}if(e.targets)for(let r of Array.from(t.querySelectorAll(e.targets))){let e=visibleRect(r);if(!e||`disabled`in r&&r.disabled===!0)continue;let t=getComputedStyle(r),i=clean(r.parentElement?.textContent,1e4).length,a=clean(r.textContent,1e4).length,o=e.width,s=e.height,c=`labels`in r?r.labels:null;for(let e of Array.from(c??[])){let t=e.getBoundingClientRect();o=Math.max(o,t.width),s=Math.max(s,t.height)}l.targets.push({selector:selectorOf(r),text:clean(r.textContent||r.getAttribute(`aria-label`),30),width:Math.round(o*10)/10,height:Math.round(s*10)/10,inline:t.display===`inline`&&i>a})}if(e.names){let r=t.createElement(`div`);r.style.cssText=`position:absolute;visibility:hidden;pointer-events:none;height:0`,i.append(r);let a=getComputedStyle(r),lengths=e=>{let t=[];for(let i of e){if(a.getPropertyValue(i).trim()===``)continue;r.style.width=`var(${i})`;let e=Number.parseFloat(getComputedStyle(r).width);Number.isFinite(e)&&t.push({name:i,px:Math.round(e*100)/100})}return r.style.width=``,t};l.scales.space=lengths(e.names.space),l.scales.text=lengths(e.names.text),l.scales.radius=lengths(e.names.radius);for(let t of e.names.color){if(a.getPropertyValue(t).trim()===``)continue;r.style.color=`var(${t})`;let e=rgba(getComputedStyle(r).color);e[3]>=1&&l.scales.color.push({name:t,rgb:[e[0],e[1],e[2]]})}r.remove()}if(e.declared){let a=t.createElement(`div`);a.style.cssText=`position:absolute;visibility:hidden;pointer-events:none;height:0`,i.append(a);let o=l.declared,color=(e,t)=>{if(!CSS.supports(`color`,t))return!1;a.style.color=``,a.style.color=t;let r=rgba(getComputedStyle(a).color);return r[3]>=1&&o.color.push({name:e,rgb:[r[0],r[1],r[2]]}),!0},length=e=>{if(e.includes(`%`)||!CSS.supports(`width`,e))return null;a.style.width=``,a.style.width=e;let t=Number.parseFloat(getComputedStyle(a).width);return Number.isFinite(t)?Math.round(t*100)/100:null};for(let t of e.declared.color)color(t.name,t.value);for(let t of[`space`,`text`,`radius`])for(let r of e.declared[t]){let e=length(r.value);e!==null&&o[t].push({name:r.name,px:e})}let s=/* @__PURE__ */ new Set,collect=e=>{for(let t=0;t<e.length;t++){let r=e.item(t);r.startsWith(`--`)&&!r.startsWith(`--cascivo-`)&&s.add(r)}},walk=e=>{for(let t of Array.from(e))t instanceof CSSStyleRule&&t.selectorText.split(`,`).some(e=>/^(:root|html)(?![\w-])/.test(e.trim()))&&collect(t.style),`cssRules`in t&&t.cssRules instanceof CSSRuleList&&walk(t.cssRules)};for(let e of Array.from(t.styleSheets))try{walk(e.cssRules)}catch{}collect(r.style);let c=getComputedStyle(r),u=0;for(let e of s){if(++u>400)break;let t=c.getPropertyValue(e).trim();if(t===``||color(e,t))continue;let r=length(t);if(r===null)continue;let i={name:e,px:r};o.space.push(i),o.text.push(i),o.radius.push(i)}a.remove()}if(e.elements){let r=/* @__PURE__ */ new Set([`script`,`style`,`noscript`,`template`,`br`,`wbr`,`head`]),a=/* @__PURE__ */ new Set([`p`,`li`,`dd`,`blockquote`]),o=/\b(?:clamp|min|max|calc)\(/,c=/\d(?:s|l|d)?(?:vw|vh|vi|vb|vmin|vmax|cqw|cqh|cqi|cqb|cqmin|cqmax)\b/,u=getComputedStyle(t.documentElement),isFluid=e=>{let t=e;for(let e=0;e<3;e++)t=t.replace(/var\(\s*(--[\w-]+)[^)]*\)/g,(e,t)=>u.getPropertyValue(t));return o.test(t)&&c.test(t)},kindOf=e=>e===`font-size`?`font`:e.startsWith(`padding`)?`padding`:e.startsWith(`margin`)?`margin`:e.endsWith(`gap`)?`gap`:``,d=[],fluidOf=e=>{let t=/* @__PURE__ */ new Set;for(let r=0;r<e.length;r++){let i=e[r]??``,a=kindOf(i);a&&isFluid(e.getPropertyValue(i))&&t.add(a)}return t},walk=(e,t)=>{for(let r of Array.from(e)){let e=t;if(r instanceof CSSStyleRule){let i=r.selectorText;e=t?i.split(`,`).map(e=>e.includes(`&`)?e.replaceAll(`&`,`:is(${t})`):`:is(${t}) ${e.trim()}`).join(`,`):i;let a=fluidOf(r.style);a.size>0&&d.push({sel:e,kinds:a})}`cssRules`in r&&walk(r.cssRules,e)}};for(let e of Array.from(t.styleSheets))try{walk(e.cssRules,``)}catch{}let fluidKinds=e=>{let t=/* @__PURE__ */ new Set;for(let r of d){let i=!1;try{i=e.matches(r.sel)}catch{}if(i)for(let e of r.kinds)t.add(e)}if(e instanceof HTMLElement)for(let r of fluidOf(e.style))t.add(r);return t},autoMargin=(e,t)=>{try{return String(e.computedStyleMap().get(t))===`auto`}catch{return!1}},px=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};for(let t of Array.from(i.querySelectorAll(`*`))){let i=t.tagName.toLowerCase();if(r.has(i)||t instanceof SVGElement&&i!==`svg`)continue;let o=visibleRect(t);if(!o)continue;if(l.elements.length>=e.maxElements){l.truncated=!0;break}let c=getComputedStyle(t),u=clean(Array.from(t.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(` `),1e4).length,d=px(c.fontSize),f=fluidKinds(t),m=[],add=(e,t,r=!1)=>{if(r||f.has(e))return;let i=Math.round(px(t)*100)/100;i>0&&!m.some(t=>t.kind===e&&t.px===i)&&m.push({kind:e,px:i})};add(`padding`,c.paddingTop),add(`padding`,c.paddingRight),add(`padding`,c.paddingBottom),add(`padding`,c.paddingLeft),add(`margin`,c.marginTop,autoMargin(t,`margin-top`)),add(`margin`,c.marginBottom,autoMargin(t,`margin-bottom`)),add(`margin`,c.marginLeft,autoMargin(t,`margin-left`)),add(`margin`,c.marginRight,autoMargin(t,`margin-right`)),(c.display.includes(`flex`)||c.display.includes(`grid`))&&(add(`gap`,c.rowGap),add(`gap`,c.columnGap));let g=[c.borderTopLeftRadius,c.borderTopRightRadius,c.borderBottomRightRadius,c.borderBottomLeftRadius],_=g.some(e=>e.includes(`%`))?0:Math.max(...g.map(px));_>=Math.min(o.width,o.height)/2-.5&&(_=0);let v=rgba(c.backgroundColor),y=null,b=!1,x=null;if(u>0){x=backgroundOf(t);let e=rgba(c.color);b=e[3]>=1,y=over(e,x??[255,255,255])}let S=0,C=0;if(s&&u>0&&a.has(i)){s.font=c.font||`${c.fontStyle} ${c.fontWeight} ${c.fontSize} ${c.fontFamily}`;let e=s.measureText(`0`).width,t=o.width-px(c.paddingLeft)-px(c.paddingRight),r=px(c.lineHeight)||d*1.2;e>0&&(S=Math.round(t/e)),C=Math.round((o.height-px(c.paddingTop)-px(c.paddingBottom))/r)}l.elements.push({selector:selectorOf(t),tag:i,box:boxOf(o),text:u,fontSize:Math.round(d*100)/100,fluidFont:f.has(`font`),bold:Number.parseInt(c.fontWeight,10)>=700,color:y,solidColor:b,bg:x,ownBg:v[3]>=1?[v[0],v[1],v[2]]:null,spacing:m,radius:Math.round(_*100)/100,lineCh:S,lines:C,uppercase:c.textTransform===`uppercase`})}}if(e.outline){for(let e of Array.from(t.querySelectorAll(`h1,h2,h3,h4,h5,h6,[role="heading"]`))){if(!visibleRect(e))continue;let t=Number.parseInt(e.getAttribute(`aria-level`)??``,10),r=/^h[1-6]$/i.test(e.tagName)?Number(e.tagName.slice(1)):2;l.headings.push({level:Number.isFinite(t)?t:r,text:clean(e.textContent,60),selector:selectorOf(e)})}let e={header:`banner`,nav:`navigation`,main:`main`,aside:`complementary`,footer:`contentinfo`,form:`form`,section:`region`,search:`search`};for(let r of Array.from(t.querySelectorAll(`header,nav,main,aside,footer,search,section[aria-label],section[aria-labelledby],form[aria-label],form[aria-labelledby],[role="banner"],[role="navigation"],[role="main"],[role="complementary"],[role="contentinfo"],[role="search"],[role="region"]`))){let i=visibleRect(r);if(!i)continue;let a=r.getAttribute(`aria-labelledby`),o=r.getAttribute(`aria-label`)??(a?t.getElementById(a)?.textContent:``)??``;l.landmarks.push({role:r.getAttribute(`role`)??e[r.tagName.toLowerCase()]??`region`,label:clean(o,30),selector:selectorOf(r),box:boxOf(i)})}}return l}var v=[320,360,390,414],y=`a[href],button,input:not([type="hidden"]),select,textarea,summary,[role="button"],[role="link"],[role="checkbox"],[role="radio"],[role="switch"],[role="tab"],[role="menuitem"]`,b={names:null,declared:null,overflow:null,targets:null,elements:!1,outline:!1,maxElements:0};async function measureOverflow(e,t=v){let r=[];for(let i of t){await e.setViewportSize({width:i,height:812}),await settle(e);let{overflow:t}=await e.evaluate(inPage,{...b,overflow:i});t&&r.push({width:i,...t})}return r}async function measureTapTargets(e,t=y){let{targets:r}=await e.evaluate(inPage,{...b,targets:t});return r}var isRecord$2=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fail=(e,t)=>{throw Error(`@cascivo/design: invalid storage state: ${e} ${t}`)};function str(e,t,r){let i=e[t];return typeof i==`string`?i:fail(`${r}.${t}`,`must be a string`)}function cookie(e,t){if(!isRecord$2(e))return fail(t,`must be an object`);let r={name:str(e,`name`,t),value:str(e,`value`,t)};e.url===void 0?(r.domain=str(e,`domain`,t),r.path=e.path===void 0?`/`:str(e,`path`,t)):r.url=str(e,`url`,t),e.expires!==void 0&&(typeof e.expires!=`number`&&fail(`${t}.expires`,`must be a number`),r.expires=e.expires);for(let i of[`httpOnly`,`secure`])e[i]!==void 0&&(typeof e[i]!=`boolean`&&fail(`${t}.${i}`,`must be a boolean`),r[i]=e[i]);let i=e.sameSite;return i!==void 0&&(i!==`Strict`&&i!==`Lax`&&i!==`None`&&fail(`${t}.sameSite`,`must be Strict, Lax or None`),r.sameSite=i),r}function origin(e,t){if(!isRecord$2(e))return fail(t,`must be an object`);let r=e.localStorage??[];return Array.isArray(r)?{origin:str(e,`origin`,t),localStorage:r.map((e,r)=>{let i=`${t}.localStorage[${r}]`;return isRecord$2(e)?{name:str(e,`name`,i),value:str(e,`value`,i)}:fail(i,`must be an object`)})}:fail(`${t}.localStorage`,`must be an array`)}function readStorageState(e){let t;try{t=r(e,`utf8`)}catch{throw Error(`@cascivo/design: cannot read ${e} (--storage-state)`)}let i;try{i=JSON.parse(t)}catch{throw Error(`@cascivo/design: ${e} is not valid JSON (--storage-state)`)}if(!isRecord$2(i))return fail(`storage state`,`must be a JSON object with cookies/origins`);let a=i.cookies??[],o=i.origins??[];return Array.isArray(a)?Array.isArray(o)?{cookies:a.map((e,t)=>cookie(e,`cookies[${t}]`)),origins:o.map((e,t)=>origin(e,`origins[${t}]`))}:fail(`origins`,`must be an array`):fail(`cookies`,`must be an array`)}var x=4.5;function oklabToLinearSrgb(e,t,r){let i=e+.3963377774*t+.2158037573*r,a=e-.1055613458*t-.0638541728*r,o=e-.0894841775*t-1.291485548*r,s=i*i*i,c=a*a*a,l=o*o*o;return[4.0767416621*s-3.3077115913*c+.2309699292*l,-1.2684380046*s+2.6097574011*c-.3413193965*l,-.0041960863*s-.7034186147*c+1.707614701*l]}function linearSrgbToOklab(e){let[t,r,i]=e,a=Math.cbrt(.4122214708*t+.5363325363*r+.0514459929*i),o=Math.cbrt(.2119034982*t+.6806995451*r+.1073969566*i),s=Math.cbrt(.0883024619*t+.2817188376*r+.6299787005*i);return[.2104542553*a+.793617785*o-.0040720468*s,1.9779984951*a-2.428592205*o+.4505937099*s,.0259040371*a+.7827717662*o-.808675766*s]}function oklchToSrgb(e,t,r){let i=r*Math.PI/180;return oklabToLinearSrgb(e,t*Math.cos(i),t*Math.sin(i))}function srgbToOklch(e){let[t,r,i]=linearSrgbToOklab(e),a=Math.hypot(r,i);if(a<1e-4)return{l:t,c:0,h:0};let o=Math.atan2(i,r)*180/Math.PI;return{l:t,c:a,h:o<0?o+360:o}}function oklabDistance(e,t){let[r,i,a]=linearSrgbToOklab(e),[o,s,c]=linearSrgbToOklab(t);return Math.hypot(r-o,i-s,a-c)}var toLinear=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,toGamma=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055,clamp01=e=>Math.min(1,Math.max(0,e));function srgb8ToLinear(e,t,r){return[toLinear(e/255),toLinear(t/255),toLinear(r/255)]}function rgbToHex(e){return`#${e.map(e=>Math.round(toGamma(clamp01(e))*255).toString(16).padStart(2,`0`)).join(``)}`}function hexToRgb(e){let t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)throw Error(`hexToRgb: cannot parse "${e}"`);let r=t[1],i=r.length===3?[...r].map(e=>e+e).join(``):r,a=Number.parseInt(i,16);return srgb8ToLinear(a>>16&255,a>>8&255,a&255)}function relativeLuminance(e){let[t,r,i]=e;return .2126*t+.7152*r+.0722*i}function contrastRatio(e,t){let r=relativeLuminance(e),i=relativeLuminance(t),a=Math.max(r,i),o=Math.min(r,i);return(a+.05)/(o+.05)}function parseOklchValue(e){let t=e.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)\s*(?:\/[^)]+)?\)/i);if(!t)throw Error(`parseOklch: cannot parse "${e}"`);return{l:t[1].endsWith(`%`)?parseFloat(t[1])/100:parseFloat(t[1]),c:t[2].endsWith(`%`)?parseFloat(t[2])/100:parseFloat(t[2]),h:parseFloat(t[3])}}function parseOklch(e){let{l:t,c:r,h:i}=parseOklchValue(e);return oklchToSrgb(t,r,i)}var trim=(e,t)=>String(Number(e.toFixed(t)));function formatOklch(e){return`oklch(${trim(e.l,3)} ${trim(e.c,3)} ${trim(e.h,1)})`}var inGamut=e=>e.every(e=>e>=-1e-4&&e<=1.0001);function fitGamut(e){let t=clamp01(e.l),r=Math.max(0,e.c);for(;r>0&&!inGamut(oklchToSrgb(t,r,e.h));)r=Math.max(0,r-.005);return{l:t,c:r,h:e.h}}function oklchToDisplayRgb(e){let{l:t,c:r,h:i}=fitGamut(e),[a,o,s]=oklchToSrgb(t,r,i);return[clamp01(a),clamp01(o),clamp01(s)]}function ensureContrast(e,t,r=x){let ratio=e=>contrastRatio(oklchToDisplayRgb(e),t),i=fitGamut(e);if(ratio(i)>=r)return i;let a=contrastRatio([0,0,0],t)>=contrastRatio([1,1,1],t)?-.005:.005;for(let t=i.l+a;t>=0&&t<=1;t+=a){let a=fitGamut({l:t,c:e.c,h:e.h});if(ratio(a)>ratio(i)&&(i=a),ratio(i)>=r)return i}let o=fitGamut({l:a<0?0:1,c:0,h:e.h});return ratio(o)>ratio(i)?o:i}var isRecord$1=e=>typeof e==`object`&&!!e;function parseTokens(e){if(!Array.isArray(e))throw Error(`@cascivo/tokens: tokens.json is not an array`);let t=[];for(let r of e){if(!isRecord$1(r))continue;let{name:e,category:i,role:a,value:o}=r;typeof e==`string`&&/^--cascivo-[a-z0-9-]+$/.test(e)&&typeof i==`string`&&typeof a==`string`&&typeof o==`string`&&t.push({name:e,category:i,role:a,value:o})}return t}var S=16;function literalPx(e){let t=/^(-?[\d.]+)(px|rem)$/.exec(e.trim());if(!t)return;let r=Number(t[1]);return t[2]===`rem`?r*S:r}function scaleOf(e){if(e.category===`space`)return`space`;if(e.category===`radius`)return`radius`;if(e.category===`color`)return`color`;if(e.category===`typography`&&e.role.startsWith(`text-`))return`text`}function scaleNames(e){let t={space:[],text:[],radius:[],color:[]};for(let r of e){let e=scaleOf(r);e&&t[e].push(r.name)}return t}function staticScales(e){let t={space:[],text:[],radius:[],color:[]};for(let r of e){let e=scaleOf(r);if(!e)continue;if(e===`color`){try{t.color.push({name:r.name,rgb:parseOklch(r.value)})}catch{}continue}let i=literalPx(r.value);i!==void 0&&t[e].push({name:r.name,px:i})}return t}var C;function loadTokens(){return C??=parseTokens(a(import.meta.url)(`@cascivo/tokens/tokens.json`)),C}var ee=.5;function nearestLength(e,t){let r;for(let i of t){let t=Math.abs(i.px-e),a=r?Math.abs(r.px-e):1/0;(t<a||t===a&&r!==void 0&&i.px<r.px)&&(r=i)}return r}function onLengthScale(e,t){let r=nearestLength(e,t);return r!==void 0&&Math.abs(r.px-e)<=.5}function nearestColor(e,t){let r;for(let i of t){let t=oklabDistance(e,i.rgb);(!r||t<r.distance)&&(r={token:i,distance:t})}return r}function onFourPxGrid(e){let t=Math.abs(e)%4;return Math.min(t,4-t)<=ee}var w=400,te=200,T={colors:`color`,spacing:`space`,rounded:`radius`};function unquote(e){let t=e.trim();if(t!==``){if(t.startsWith(`"`))try{let e=JSON.parse(t);return typeof e==`string`?e:void 0}catch{return}return t.startsWith(`'`)&&t.endsWith(`'`)&&t.length>=2?t.slice(1,-1):t.replace(/\s+#.*$/,``)}}function parseDesignMd(e){let t={color:[],space:[],text:[],radius:[]},r=e.replace(/^/,``).split(/\r?\n/);if(r[0]?.trim()!==`---`)return t;let i=r.indexOf(`---`,1);if(i===-1)return t;let a=0,add=(e,r,i)=>{let o=unquote(i);o===void 0||o.length>te||a>=w||(a++,t[e].push({name:r,value:o}))},o=``,s=``;for(let e of r.slice(1,i)){let t=/^( *)("[^"]*"|'[^']*'|[\w.-]+):(.*)$/.exec(e);if(!t)continue;let r=(t[1]??``).length,i=(t[2]??``).replace(/^["']|["']$/g,``),a=t[3]??``;if(r===0)o=i,s=``;else if(r===2){s=i;let e=T[o];e&&add(e,`${o}.${i}`,a)}else r===4&&o===`typography`&&i===`fontSize`&&add(`text`,`typography.${s}.fontSize`,a)}return t}var E={mobile:25,a11y:25,contrast:20,tokens:15,hierarchy:15},D={error:25,warn:8},O=Object.keys(E);function score(e){let t=/* @__PURE__ */ new Map;for(let r of e){let e=`${r.category}\n${r.rule}`;r.share===void 0?t.set(e,Math.min(60,(t.get(e)??0)+D[r.level]*r.count)):t.set(e,60*Math.min(1,Math.max(0,r.share)))}let r={};for(let e of O)r[e]=100;for(let[e,i]of t){let t=e.slice(0,e.indexOf(`
2
+ `));r[t]=Math.max(0,Math.round(r[t]-i))}let i=0,a=0;for(let e of O)i+=r[e]*E[e],a+=E[e];return{total:Math.round(i/a),categories:r}}var k={bodyTextPx:16,bodyTextChars:40,lineCh:80,fontSizes:6,colors:12,hairlinePx:2},linear=e=>srgb8ToLinear(e[0],e[1],e[2]),hex=e=>rgbToHex(linear(e)),fmt=e=>String(Math.round(e*100)/100);function overflowRule(e){let t=e.filter(e=>e.scrollWidth>e.innerWidth);if(t.length===0)return[];let r=t.map(e=>e.width).join(`/`),i=t.reduce((e,t)=>t.scrollWidth-t.innerWidth>e.scrollWidth-e.innerWidth?t:e),a=i.scrollWidth-i.innerWidth,o=[...new Set(t.flatMap(e=>e.offenders))],s={rule:`overflow`,category:`mobile`,level:`error`,message:`scrolls sideways at ${r}px (${a}px too wide at ${i.width}px)`,fix:`let it shrink or wrap: min-inline-size: 0, max-inline-size: 100%, flex-wrap: wrap`};return o.length===0?[s]:o.map(e=>({...s,selector:e}))}function targetRule(e){let t=[];for(let r of e){if(r.inline)continue;let e=Math.min(r.width,r.height);e>=43.5||t.push({rule:`touch-target`,category:`mobile`,level:e<24?`error`:`warn`,message:`${fmt(r.width)}×${fmt(r.height)}px touch target, needs 44×44`,fix:`min-block-size + min-inline-size: var(--cascivo-target-min-coarse, 2.75rem) in @media (pointer: coarse)`,selector:r.selector})}return t}var isRecord=e=>typeof e==`object`&&!!e;function parseAxe(e){if(!isRecord(e)||!Array.isArray(e.violations))return[];let t=[];for(let r of e.violations){if(!isRecord(r)||typeof r.id!=`string`||!Array.isArray(r.nodes))continue;let e=[];for(let t of r.nodes){if(!isRecord(t))continue;let r=Array.isArray(t.target)?t.target.map(String).join(` `):``,i=typeof t.failureSummary==`string`?t.failureSummary:``;e.push({target:r,summary:i})}t.push({id:r.id,impact:typeof r.impact==`string`?r.impact:`serious`,help:typeof r.help==`string`?r.help:r.id,nodes:e})}return t}function axeFix(e,t){return e.split(`
3
+ `).map(e=>e.trim()).filter(e=>e!==``&&!/^Fix (any|all) of the following:?$/i.test(e))[0]??t}function axeRule(e){let t=[];for(let r of e){let e=r.impact===`critical`||r.impact===`serious`?`error`:`warn`,i=r.nodes.length>0?r.nodes:[{target:``,summary:``}];for(let a of i)t.push({rule:`axe/${r.id}`,category:`a11y`,level:e,message:r.help,fix:axeFix(a.summary,r.help),...a.target?{selector:a.target}:{}})}return t}var isLargeText=e=>e.fontSize>=24||e.bold&&e.fontSize>=18.66,semanticFirst=e=>[...e].sort((e,t)=>Number(t.name.startsWith(`--cascivo-color-`))-Number(e.name.startsWith(`--cascivo-color-`)));function contrastRule(e,t){let r=[],i=semanticFirst(t);for(let t of e){if(t.text===0||!t.color||!t.bg)continue;let e=linear(t.color),a=linear(t.bg),o=isLargeText(t)?3:x,s=contrastRatio(e,a);if(s>=o)continue;let c=nearestColor(e,i.filter(e=>contrastRatio(e.rgb,a)>=o))?.token,l=c?`color: var(${c.name})`:`color: ${rgbToHex(oklchToDisplayRgb(ensureContrast(srgbToOklch(e),a,o)))} or stronger`;r.push({rule:`contrast`,category:`contrast`,level:`error`,message:`${s.toFixed(2)}:1, needs ${o}:1 (${hex(t.color)} on ${hex(t.bg)})`,fix:l,selector:t.selector})}return r}var usesCascivo=e=>e.space.length>=3;function pageScales(e){return{space:e.space,text:e.text,radius:e.radius,color:e.color.map(e=>({name:e.name,rgb:linear(e.rgb)}))}}var ne={space:[],text:[],radius:[],color:[]};function tokenRule(e,t,r,i=ne){let a=[],o=/* @__PURE__ */ new Map,seen=e=>void o.set(e,(o.get(e)??0)+1),s=semanticFirst(t.color),c=/* @__PURE__ */ new Set,ownColor=e=>{let t=nearestColor(linear(e),i.color);return t!==void 0&&t.distance<=.02};for(let o of e){for(let e of o.spacing)if(!(e.px<=k.hairlinePx)&&(seen(r?`token/spacing`:`scale/spacing`),!onLengthScale(e.px,i.space))){if(r){if(onLengthScale(e.px,t.space))continue;let r=nearestLength(e.px,t.space);a.push({rule:`token/spacing`,category:`tokens`,level:`warn`,message:`${e.kind} ${fmt(e.px)}px is off the spacing scale`,value:`${e.kind} ${fmt(e.px)}px`,fix:r?`var(${r.name}) (${fmt(r.px)}px)`:`use a --cascivo-space-* step`,selector:o.selector})}else if(!onFourPxGrid(e.px)){let t=Math.floor(e.px/4)*4;a.push({rule:`scale/spacing`,category:`tokens`,level:`warn`,message:`${e.kind} ${fmt(e.px)}px is off the 4px grid`,value:`${e.kind} ${fmt(e.px)}px`,fix:`use ${t}px or ${t+4}px`,selector:o.selector})}}if(r&&o.text>0&&t.text.length>0&&!o.fluidFont&&seen(`token/font-size`),r&&o.text>0&&t.text.length>0&&!o.fluidFont&&!onLengthScale(o.fontSize,t.text)&&!onLengthScale(o.fontSize,i.text)){let e=nearestLength(o.fontSize,t.text);a.push({rule:`token/font-size`,category:`tokens`,level:`warn`,message:`font-size ${fmt(o.fontSize)}px is off the type scale`,value:`font-size ${fmt(o.fontSize)}px`,fix:e?`var(${e.name}) (${fmt(e.px)}px)`:`use a --cascivo-text-* step`,selector:o.selector})}if(r&&o.radius>0&&t.radius.length>0&&seen(`token/radius`),r&&o.radius>0&&t.radius.length>0&&!onLengthScale(o.radius,t.radius)&&!onLengthScale(o.radius,i.radius)){let e=nearestLength(o.radius,t.radius);a.push({rule:`token/radius`,category:`tokens`,level:`warn`,message:`border-radius ${fmt(o.radius)}px is off the radius scale`,value:`border-radius ${fmt(o.radius)}px`,fix:e?`var(${e.name}) (${fmt(e.px)}px)`:`use a --cascivo-radius-* token`,selector:o.selector})}let e=[];o.color&&o.solidColor&&e.push(o.color),o.ownBg&&e.push(o.ownBg);for(let t of e){if(r&&s.length>0&&seen(`token/color`),ownColor(t)||(c.add(hex(t)),!r||s.length===0))continue;let e=nearestColor(linear(t),s);!e||e.distance<=.02||a.push({rule:`token/color`,category:`tokens`,level:`warn`,message:`${hex(t)} is not a theme colour`,value:hex(t),fix:`var(${e.token.name})`,selector:o.selector})}}!r&&c.size>k.colors&&a.push({rule:`scale/colors`,category:`tokens`,level:`warn`,message:`${c.size} distinct colours`,fix:`keep to ${k.colors}: one neutral ramp, one accent, status colours`,share:(c.size-k.colors)/c.size});let l=/* @__PURE__ */ new Map;for(let e of a)e.value!==void 0&&l.set(e.rule,(l.get(e.rule)??0)+1);return a.map(e=>{let t=o.get(e.rule);return e.value!==void 0&&t?{...e,share:(l.get(e.rule)??0)/t}:e})}var A=/* @__PURE__ */ new Set([`p`,`li`,`dd`,`blockquote`]);function hierarchyRule(e,t){let r=[],i=e.filter(e=>e.level===1);i.length===0&&r.push({rule:`hierarchy/h1`,category:`hierarchy`,level:`error`,message:`no <h1>`,fix:`give the page exactly one <h1> naming it`});for(let e of i.slice(1))r.push({rule:`hierarchy/h1`,category:`hierarchy`,level:`warn`,message:`${i.length} <h1> elements`,fix:`keep one <h1>; demote the others to <h2>`,selector:e.selector});let a=0;for(let t of e)a>0&&t.level>a+1&&r.push({rule:`hierarchy/heading-order`,category:`hierarchy`,level:`warn`,message:`h${t.level} follows h${a}`,fix:`use <h${a+1}>: heading levels go down one step at a time`,selector:t.selector}),a=t.level;let o=/* @__PURE__ */ new Set;for(let e of t)e.text!==0&&(o.add(Math.round(e.fontSize*2)/2),A.has(e.tag)&&(!e.uppercase&&e.text>=k.bodyTextChars&&e.fontSize<k.bodyTextPx-.01&&r.push({rule:`hierarchy/body-text`,category:`hierarchy`,level:`warn`,message:`${fmt(e.fontSize)}px running text, needs ${k.bodyTextPx}px`,fix:`font-size: var(--cascivo-text-base, 1rem)`,selector:e.selector}),e.lines>=2&&e.lineCh>k.lineCh&&r.push({rule:`hierarchy/line-length`,category:`hierarchy`,level:`warn`,message:`lines run ${e.lineCh}ch, comfortable is ${k.lineCh}ch`,fix:`max-inline-size: 65ch`,selector:e.selector})));if(o.size>k.fontSizes){let e=[...o].sort((e,t)=>e-t).join(`, `);r.push({rule:`hierarchy/font-sizes`,category:`hierarchy`,level:`warn`,message:`${o.size} font sizes (${e}px)`,fix:`keep to ${k.fontSizes}: use the --cascivo-text-* scale`})}return r}function group(e){let t=/* @__PURE__ */ new Map;for(let r of e){let e=r.value===void 0?`${r.rule}\n${r.fix}`:r.rule,i=t.get(e);if(r.value!==void 0){let a=!i,o=i??{rule:r.rule,category:r.category,level:r.level,message:``,fix:``,count:0,selectors:[],values:[],...r.share===void 0?{}:{share:r.share}};o.count+=1,r.selector!==void 0&&!o.selectors.includes(r.selector)&&o.selectors.push(r.selector);let s=o.values??[],c=s.find(e=>e.value===r.value&&e.fix===r.fix);c?c.count+=1:s.push({value:r.value,fix:r.fix,count:1}),o.values=s,a&&t.set(e,o)}else i?(i.count+=1,r.level===`error`&&(i.level=`error`),r.selector!==void 0&&!i.selectors.includes(r.selector)&&i.selectors.push(r.selector)):t.set(e,{rule:r.rule,category:r.category,level:r.level,message:r.message,fix:r.fix,...r.selector===void 0?{}:{selector:r.selector},count:1,selectors:r.selector===void 0?[]:[r.selector]})}for(let e of t.values()){if(!e.values)continue;e.values.sort((e,t)=>t.count-e.count||e.value.localeCompare(t.value));let t=Math.round((e.share??0)*100);e.message=`${e.values.length} off-scale value${e.values.length===1?``:`s`} on ${e.count} element${e.count===1?``:`s`}, ${t}% of those measured`,e.fix=e.values.length===1?e.values[0].fix:`snap each value to its nearest step`,e.selectors[0]!==void 0&&(e.selector=e.selectors[0])}return[...t.values()].sort((e,t)=>Number(t.level===`error`)-Number(e.level===`error`)||O.indexOf(e.category)-O.indexOf(t.category)||t.count-e.count||e.rule.localeCompare(t.rule))}function evaluate(e){let t=usesCascivo(e.desktop.scales),r=t?pageScales(e.desktop.scales):staticScales(loadTokens()),i=pageScales(e.desktop.declared),a=group([...overflowRule(e.overflow),...targetRule(e.targets),...axeRule(parseAxe(e.axe)),...contrastRule(e.desktop.elements,t?r.color:[]),...tokenRule(e.desktop.elements,r,t,i),...hierarchyRule(e.desktop.headings,e.desktop.elements)]);return{cascivo:t,score:score(a),findings:a}}var j=48,clip=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e;function formatFinding(e){let t=e.selector?` ${clip(e.selector,j)}`:``,r=e.count>1?` ×${e.count}`:``;if(e.values&&e.values.length>0){let t=e.values.slice(0,8).map(e=>`${e.value} → ${e.fix}${e.count>1?` ×${e.count}`:``}`),r=e.values.length-8;return r>0&&t.push(`+${r} more (--json)`),`${e.level} ${e.rule} ×${e.count} — ${e.message}: ${t.join(`; `)}`}return`${e.level} ${e.rule}${t}${r} — ${e.message} → ${e.fix}`}function formatCheck(e,t=20){let r=e.findings.filter(e=>e.level===`error`).length,i=e.findings.length-r,a=O.map(t=>`${t} ${e.score.categories[t]}`).join(` · `),o=[`score ${e.score.total}/100 — ${a} — ${r} error${r===1?``:`s`}, ${i} warning${i===1?``:`s`}`];for(let r of e.findings.slice(0,t))o.push(formatFinding(r));let s=e.findings.length-t;return s>0&&o.push(`… ${s} more (raise --max, or --json for all)`),o.join(`
4
+ `)}var M={width:1280,height:800},re=2e3,ie={color:[],space:[],text:[],radius:[]};function readDeclared(e){if(e===void 0)return ie;let t;try{t=r(e,`utf8`)}catch{throw Error(`@cascivo/design: cannot read ${e} (--design)`)}return parseDesignMd(t)}var ae=[`wcag2a`,`wcag2aa`,`wcag21a`,`wcag21aa`,`wcag22aa`];function axeSource(){let e=a(import.meta.url)(`axe-core`);if(typeof e==`object`&&e&&`source`in e&&typeof e.source==`string`)return e.source;throw Error(`@cascivo/design: axe-core did not export its source`)}async function runAxe(e){return await e.evaluate(axeSource()),e.evaluate(async e=>{let t=globalThis.axe;return t?t.run(document,{runOnly:{type:`tag`,values:e},rules:{"color-contrast":{enabled:!1}},resultTypes:[`violations`]}):null},ae)}async function check(e,t={}){let r=resolveTarget(e),i=readDeclared(t.design),a=await openSession(t.storageState===void 0?void 0:readStorageState(t.storageState));try{let o=await a.open(r,{width:v[0],height:812,touch:!0}),s=await measureOverflow(o,v);await o.setViewportSize({width:390,height:812});let c=await measureTapTargets(o,y),l=await a.open(r,{width:t.width??M.width,height:M.height});return{target:e,...evaluate({desktop:await l.evaluate(inPage,{names:scaleNames(loadTokens()),declared:i,overflow:null,targets:null,elements:!0,outline:!0,maxElements:re}),overflow:s,targets:c,axe:await runAxe(l)})}}finally{await a.close()}}var N={arcade:{colors:{primary:`oklch(0.55 0.22 27)`,"on-primary":`oklch(0.98 0 0)`,accent:`oklch(0.55 0.22 27)`,background:`oklch(0.96 0.008 250)`,surface:`oklch(1 0 0)`,text:`oklch(0.16 0.02 265)`,"text-muted":`oklch(0.51 0.02 265)`,border:`oklch(0.15 0.02 265)`,destructive:`oklch(0.52 0.24 25)`,success:`oklch(0.54 0.18 145)`,warning:`oklch(0.68 0.17 75)`,info:`oklch(0.5 0.2 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`0px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},brutalist:{colors:{primary:`oklch(0.88 0.19 105)`,"on-primary":`oklch(0.1 0 0)`,accent:`oklch(0.88 0.19 105)`,background:`oklch(0.97 0.02 95)`,surface:`oklch(1 0 0)`,text:`oklch(0.1 0 0)`,"text-muted":`oklch(0.5 0 0)`,border:`oklch(0.1 0 0)`,destructive:`oklch(0.52 0.22 22)`,success:`oklch(0.52 0.18 145)`,warning:`oklch(0.65 0.17 75)`,info:`oklch(0.48 0.2 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`0px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},corporate:{colors:{primary:`oklch(0.2 0.01 250)`,"on-primary":`oklch(0.99 0.003 250)`,accent:`oklch(0.5 0.16 255)`,background:`oklch(0.99 0.003 250)`,surface:`oklch(0.97 0.004 250)`,text:`oklch(0.2 0.01 250)`,"text-muted":`oklch(0.525 0.012 255)`,border:`oklch(0.88 0.006 250)`,destructive:`oklch(0.54 0.19 22)`,success:`oklch(0.52 0.15 145)`,warning:`oklch(0.65 0.14 75)`,info:`oklch(0.5 0.16 255)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},cyberpunk:{colors:{primary:`oklch(0.7 0.25 330)`,"on-primary":`oklch(0.16 0.03 285)`,accent:`oklch(0.7 0.25 330)`,background:`oklch(0.16 0.03 285)`,surface:`oklch(0.2 0.035 285)`,text:`oklch(0.95 0.03 320)`,"text-muted":`oklch(0.64 0.05 300)`,border:`oklch(0.6 0.2 320 / 60%)`,destructive:`oklch(0.665 0.25 18)`,success:`oklch(0.82 0.2 150)`,warning:`oklch(0.82 0.17 75)`,info:`oklch(0.78 0.16 200)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`0px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},dark:{colors:{primary:`oklch(0.922 0 0)`,"on-primary":`oklch(0.205 0 0)`,accent:`oklch(0.65 0.2 250)`,background:`oklch(0.145 0.005 250)`,surface:`oklch(0.185 0.007 250)`,text:`oklch(0.985 0.002 264)`,"text-muted":`oklch(0.614 0.018 264)`,border:`oklch(1 0 0 / 10%)`,destructive:`oklch(0.72 0.16 22)`,success:`oklch(0.72 0.13 145)`,warning:`oklch(0.82 0.13 75)`,info:`oklch(0.65 0.2 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},flat:{colors:{primary:`oklch(0.5 0.2 145)`,"on-primary":`oklch(1 0 0)`,accent:`oklch(0.5 0.2 145)`,background:`oklch(1 0 0)`,surface:`oklch(0.97 0 0)`,text:`oklch(0.1 0 0)`,"text-muted":`oklch(0.52 0 0)`,border:`oklch(0.7 0 0)`,destructive:`oklch(0.52 0.2 22)`,success:`oklch(0.52 0.18 145)`,warning:`oklch(0.6 0.16 75)`,info:`oklch(0.5 0.18 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`0px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},light:{colors:{primary:`oklch(0.205 0 0)`,"on-primary":`oklch(0.985 0 0)`,accent:`oklch(0.52 0.2 250)`,background:`oklch(1 0 0)`,surface:`oklch(0.985 0.002 264)`,text:`oklch(0.145 0.005 264)`,"text-muted":`oklch(0.5 0.016 264)`,border:`oklch(0.928 0.006 264)`,destructive:`oklch(0.54 0.188 22)`,success:`oklch(0.648 0.15 145)`,warning:`oklch(0.768 0.145 75)`,info:`oklch(0.546 0.224 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},midnight:{colors:{primary:`oklch(0.88 0 0)`,"on-primary":`oklch(0.16 0.02 280)`,accent:`oklch(0.7 0.22 290)`,background:`oklch(0.16 0.02 280)`,surface:`oklch(0.2 0.025 280)`,text:`oklch(0.96 0.01 280)`,"text-muted":`oklch(0.625 0.02 280)`,border:`oklch(1 0 0 / 8%)`,destructive:`oklch(0.72 0.16 22)`,success:`oklch(0.72 0.13 145)`,warning:`oklch(0.82 0.13 75)`,info:`oklch(0.7 0.22 290)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},minimal:{colors:{primary:`oklch(0.25 0.01 80)`,"on-primary":`oklch(0.985 0 0)`,accent:`oklch(0.25 0.01 80)`,background:`oklch(0.98 0.005 80)`,surface:`oklch(0.965 0.006 80)`,text:`oklch(0.2 0.01 80)`,"text-muted":`oklch(0.525 0.012 80)`,border:`oklch(0.92 0.005 80)`,destructive:`oklch(0.55 0.14 22)`,success:`oklch(0.55 0.13 145)`,warning:`oklch(0.65 0.12 75)`,info:`oklch(0.55 0.1 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},pastel:{colors:{primary:`oklch(0.68 0.18 350)`,"on-primary":`oklch(0.145 0.005 250)`,accent:`oklch(0.68 0.18 350)`,background:`oklch(0.99 0.01 330)`,surface:`oklch(0.975 0.013 330)`,text:`oklch(0.32 0.03 320)`,"text-muted":`oklch(0.535 0.02 325)`,border:`oklch(0.92 0.02 330)`,destructive:`oklch(0.55 0.18 22)`,success:`oklch(0.62 0.14 165)`,warning:`oklch(0.72 0.14 75)`,info:`oklch(0.68 0.18 350)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},terminal:{colors:{primary:`oklch(0.82 0.2 145)`,"on-primary":`oklch(0.17 0.01 150)`,accent:`oklch(0.82 0.2 145)`,background:`oklch(0.17 0.01 150)`,surface:`oklch(0.21 0.012 150)`,text:`oklch(0.9 0.06 150)`,"text-muted":`oklch(0.635 0.04 148)`,border:`oklch(0.4 0.08 150 / 60%)`,destructive:`oklch(0.72 0.16 22)`,success:`oklch(0.82 0.2 145)`,warning:`oklch(0.82 0.16 75)`,info:`oklch(0.82 0.2 145)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`0px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}},warm:{colors:{primary:`oklch(0.768 0.145 75)`,"on-primary":`oklch(0.18 0.015 50)`,accent:`oklch(0.768 0.145 75)`,background:`oklch(0.995 0.006 80)`,surface:`oklch(0.975 0.01 80)`,text:`oklch(0.18 0.015 50)`,"text-muted":`oklch(0.525 0.025 65)`,border:`oklch(0.92 0.018 80)`,destructive:`oklch(0.54 0.188 22)`,success:`oklch(0.648 0.15 145)`,warning:`oklch(0.768 0.145 75)`,info:`oklch(0.546 0.224 250)`},font:`ui-sans-serif`,typography:{display:{fontSize:`2.25rem`,fontWeight:600,lineHeight:1.25},heading:{fontSize:`1.5rem`,fontWeight:600,lineHeight:1.25},body:{fontSize:`1rem`,fontWeight:400,lineHeight:1.5},label:{fontSize:`0.875rem`,fontWeight:500,lineHeight:1.5},caption:{fontSize:`0.75rem`,fontWeight:400,lineHeight:1.5}},rounded:{none:`0px`,sm:`0.25rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,full:`9999px`},spacing:{1:`0.25rem`,2:`0.5rem`,3:`0.75rem`,4:`1rem`,6:`1.5rem`,8:`2rem`,12:`3rem`,16:`4rem`},motion:{fast:{duration:`100ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},base:{duration:`200ms`,timingFunction:`cubic-bezier(0, 0, 0.2, 1)`},slow:{duration:`300ms`,timingFunction:`cubic-bezier(0.4, 0, 0.2, 1)`}}}},oe=Object.keys(N).sort(),q=e=>JSON.stringify(e),se=/^(#[0-9a-f]{3,8}|(oklch|oklab|lch|lab|rgb|hsl|hwb|color|color-mix)\([^;{}<>\\]*\))$/i;function clean(e,t){let r=t.trim();if(r===``||r.length>160||/[;{}<>\\`\u0000-\u001f\u007f]/.test(r))throw Error(`${e} must be one line of 1-160 characters without ; { } < > \\ or \``);return r}function parseDirection(e){if(!e)return;let t={};for(let[r,i]of Object.entries(e.colors??{})){if(!/^[a-z][a-z0-9-]{0,39}$/.test(r))throw Error(`Colour name "${r}" must be lower-case letters, digits and hyphens`);let e=clean(`Colour "${r}"`,i);if(!se.test(e))throw Error(`Colour "${r}" must be a hex or functional CSS colour, got "${e}"`);t[r]=e}let r=e.fontDisplay===void 0?``:clean(`fontDisplay`,e.fontDisplay),i=e.fontBody===void 0?``:clean(`fontBody`,e.fontBody),a=e.signature===void 0?``:clean(`signature`,e.signature),o=e.composition===void 0?``:clean(`composition`,e.composition);if(Object.keys(t).length!==0||r||i||a||o)return{colors:t,fontDisplay:r,fontBody:i,signature:a,composition:o}}function directionCss(e){let t=parseDirection(e);if(!t)return``;let r=Object.entries(t.colors).map(([e,t])=>` --cascivo-color-${e}: ${t};`);return t.fontDisplay&&r.push(` --cascivo-font-display: ${t.fontDisplay};`),t.fontBody&&r.push(` --cascivo-font-sans: ${t.fontBody};`),r.length===0?``:[`:root {`,...r,`}`].join(`
5
+ `)}var P=/* @__PURE__ */ new Set([`display`,`heading`]);function frontMatter(e,t,r){let i=[`---`,`version: alpha`,`name: ${q(`cascivo ${e}`)}`,`description: ${q(`Design tokens of the cascivo "${e}" theme. Rules for building pages with them follow.`)}`,`colors:`];for(let[e,a]of Object.entries({...t.colors,...r?.colors}))i.push(` ${e}: ${q(a)}`);i.push(`typography:`);let a=r?.fontBody||t.font,o=r?.fontDisplay||a;for(let[e,r]of Object.entries(t.typography))i.push(` ${e}:`,` fontFamily: ${q(P.has(e)?o:a)}`,` fontSize: ${q(r.fontSize)}`,` fontWeight: ${r.fontWeight}`,` lineHeight: ${r.lineHeight}`);i.push(`rounded:`);for(let[e,r]of Object.entries(t.rounded))i.push(` ${e}: ${q(r)}`);i.push(`spacing:`);for(let[e,r]of Object.entries(t.spacing))i.push(` ${q(e)}: ${q(r)}`);i.push(`motion:`);for(let[e,r]of Object.entries(t.motion))i.push(` ${e}:`,` duration: ${q(r.duration)}`,` timingFunction: ${q(r.timingFunction)}`);return i.push(`---`),i}function renderDesignMd(e,t){let r=N[e];if(!r)throw Error(`Unknown theme "${e}". Use one of: ${oe.join(`, `)}.`);let i=parseDirection(t),a=directionCss(t),o=i?.fontBody||r.font,s=i?.fontDisplay||o,c=i?[``,`**Direction.** This project has a chosen look; the tokens above already hold it.${i.signature?` Signature element: ${i.signature}. Use it once, where it counts.`:``}${i.composition?` Composition move: ${i.composition}. The plan's slots fix what the page says and in what order; this move decides how it is laid out.`:``}`,...a?[``,`Put this in the page stylesheet, after the theme:`,``,"```css",a,"```"]:[]]:[],l=[``,`<!-- Written by \`cascivo design init --theme ${e}\`. Edit freely; re-run with --force to reset. -->`,``,`## Overview`,``,`This project uses cascivo: React components styled with layered CSS and design tokens. The values above are the \`${e}\` theme (\`data-theme="${e}"\`)${i?` with this project’s direction laid over it`:``}. Before writing a page, run \`npx cascivo design plan "<brief>"\` for its structure; after, \`npx cascivo design check <url>\`.`,...c,``,`## Colors`,``,"Semantic names, OKLCH values. `primary` is the one main action per view, `accent` the one highlight, `destructive` only what deletes. Text on `primary` uses `on-primary`. In CSS, write `var(--cascivo-color-<name>)`; other themes remap the names, so never copy a value.",``,`## Typography`,``,`${s===o?`One family (${o})`:`Two families: ${s} for display and headings, ${o} for the rest,`} on a fixed scale. One \`display\` or h1 per page; headings descend without skipping a level. Body text runs 45–75 characters per line. No sizes between steps.`,``,`## Layout`,``,"Spacing comes from the scale above (`gap={4}` is 1rem). Mobile-first from 320px; breakpoints only at 30rem, 40rem, 64rem and 80rem, container queries preferred. Coarse-pointer targets are at least 44px. Use logical properties so RTL works.",``,`## Elevation & Depth`,``,"Flat by default. Separate regions with `border` first; shadows are for things that float (menus, dialogs, popovers).",``,`## Shapes`,``,"Controls use `rounded.md`, surfaces `rounded.lg`, pills `rounded.full`. The theme owns radii: never hard-code one.",``,`## Motion`,``,"`fast` for hover and press, `base` for things that open, `slow` for whole-region changes. Animate to explain a change of state, not to decorate an entrance. Everything stops under `prefers-reduced-motion`.",``,`## Do's and Don'ts`,``,`- Do design the empty, loading and error state of every data region, not only the full one.`,`- Do keep one primary action per view and give every control an accessible name.`,"- Do take components from the registry (`npx cascivo add <name>`) and check props before use.","- Do put custom CSS in `@layer cascivo.override`.",``,`Banned, because they mark a page as machine-made:`,``,`- Don’t fill a section with a generic grid of three identical icon cards.`,`- Don’t put a small uppercase eyebrow label above every heading.`,`- Don’t fade-and-slide every block up on scroll; no default entrance motion.`,"- Don’t hard-code colours (`#fff`, `rgb()`, `oklch()`): use the tokens.","- Don’t write raw `px` for spacing, type or radii: use the scales.",`- Don’t add gradient text, glow, or a purple-to-blue gradient as decoration.`,`- Don’t wrap everything in a card, or nest cards.`,`- Don’t centre body text or long lists.`,"- Don’t use emoji as icons; use `@cascivo/icons`.",`- Don’t write filler copy ("Unlock the power of…", "Seamless", "Elevate").`,`- Don’t hide content on small screens; move it to a drawer, sheet or disclosure.`,``];return[...frontMatter(e,r,i),...l].join(`
6
+ `)}async function init(t={}){let r=t.theme??`light`,i=renderDesignMd(r,t.direction),a=directionCss(t.direction),o=a===``?{}:{css:a},s=c(t.cwd??process.cwd(),`DESIGN.md`);return e(s)&&t.force!==!0?{path:s,written:!1,theme:r,...o}:(await u(s,i),{path:s,written:!0,theme:r,...o})}var h=(e,t)=>({component:`Heading`,props:{level:e},children:t}),p=e=>({component:`Text`,children:e}),btn=(e,t=`primary`)=>({component:`Button`,props:{variant:t},children:e}),row=(e,t={})=>({component:`Flex`,props:{direction:`horizontal`,gap:3,...t},children:e}),list=e=>({component:`List`,children:e.map(e=>({component:`ListItem`,children:e}))}),F={nav:{kw:[`nav`,`navigation`,`header`,`menu`],cv:[`header Product,/ | Pricing,/pricing | Docs,/docs`],view:[{component:`Header`,props:{links:[{label:`Product`,href:`/`},{label:`Pricing`,href:`/pricing`},{label:`Docs`,href:`/docs`}]}}]},hero:{kw:[`hero`,`headline`],cv:[`center`,` h1 "The outcome, in one line"`,` p "Who it is for and why it matters, in one sentence."`,` row gap=3`,` button "Primary action" primary`,` button "Secondary action" ghost`],view:[{component:`Center`,children:[h(1,`The outcome, in one line`),p(`Who it is for and why it matters, in one sentence.`),row([btn(`Primary action`),btn(`Secondary action`,`ghost`)])]}]},features:{kw:[`feature`,`benefit`],cv:[`h2 "What it does"`,`cols 2`,` card "First benefit"`,` p "A concrete result, not an adjective."`,` card "Second benefit"`,` p "Different in kind from the first."`],view:[h(2,`What it does`),{component:`Columns`,props:{count:2},children:[{component:`Card`,children:[h(3,`First benefit`),p(`A concrete result, not an adjective.`)]},{component:`Card`,children:[h(3,`Second benefit`),p(`Different in kind from the first.`)]}]}]},proof:{kw:[`testimonial`,`quote`,`review`,`customer`,`proof`,`social`],cv:[`blockquote "A real sentence from a named customer."`],view:[{component:`Blockquote`,children:`A real sentence from a named customer.`}]},faq:{kw:[`faq`,`question`,`answer`],cv:[`h2 "Questions"`,`accordion`,` section "A question buyers ask?"`,` text "A direct answer."`,` section "Another real question?"`,` text "A direct answer."`],view:[h(2,`Questions`),h(3,`A question buyers ask?`),p(`A direct answer.`),h(3,`Another real question?`),p(`A direct answer.`)]},cta:{kw:[`cta`,`signup`,`action`],cv:[`center`,` h2 "Repeat the offer"`,` button "Primary action" primary`],view:[{component:`Center`,children:[h(2,`Repeat the offer`),btn(`Primary action`)]}]},footer:{kw:[`footer`],cv:[`separator`,`row gap=4`,` link /privacy "Privacy"`,` link /terms "Terms"`],view:[{component:`Separator`},row([{component:`Link`,props:{href:`/privacy`},children:`Privacy`},{component:`Link`,props:{href:`/terms`},children:`Terms`}],{gap:4})]},plans:{kw:[`plan`,`tier`,`price`],cv:[`cols 3`,` card "Starter"`,` h3 "$0 / month"`,` p "Who this plan is for."`,` button "Choose Starter" secondary`,` card "Pro"`,` badge "Recommended" primary`,` h3 "$0 / month"`,` p "Who this plan is for."`,` button "Choose Pro" primary`,` card "Team"`,` h3 "$0 / month"`,` p "Who this plan is for."`,` button "Choose Team" secondary`],view:[{component:`Columns`,props:{count:3},children:[`Starter`,`Pro`,`Team`].map(e=>({component:`Card`,children:[h(2,e),...e===`Pro`?[{component:`Badge`,props:{variant:`primary`},children:`Recommended`}]:[],h(3,`$0 / month`),p(`Who this plan is for.`),btn(`Choose ${e}`,e===`Pro`?`primary`:`secondary`)]}))}]},compare:{kw:[`compare`,`comparison`,`matrix`,`feature`],cv:[`table Feature,Starter,Pro,Team | Seats,1,5,Unlimited | Support,Email,Priority,Dedicated`],view:[{component:`DataTable`,props:{columns:[`feature`,`starter`,`pro`,`team`].map(e=>({key:e,header:`${e.charAt(0).toUpperCase()}${e.slice(1)}`})),rows:[{feature:`Seats`,starter:`1`,pro:`5`,team:`Unlimited`},{feature:`Support`,starter:`Email`,pro:`Priority`,team:`Dedicated`}]}}]},"page-header":{kw:[],cv:[`page-header "Page title" "One line on what this page is for."`],view:[{component:`PageHeader`,props:{title:`Page title`,description:`One line on what this page is for.`}}]},kpis:{kw:[`kpi`,`metric`,`stat`],cv:[`cols 3`,` stat "First metric" "0" "+0%"`,` stat "Second metric" "0" "+0%"`,` stat "Third metric" "0" "-0%"`],view:[{component:`Columns`,props:{count:3},children:[`First`,`Second`,`Third`].map(e=>({component:`Stat`,props:{label:`${e} metric`,value:`0`,delta:e===`Third`?`-0%`:`+0%`}}))}]},chart:{kw:[`chart`,`graph`,`trend`,`analytic`,`revenue`,`time`,`line`,`bar`],cv:[`card "Trend over time"`,` line 3 5 8 13 9 14`],view:[{component:`Card`,children:[h(2,`Trend over time`),p(`Chart region: add a LineChart from @cascivo/charts.`)]}]},table:{kw:[`table`,`list`,`record`],cv:[`card "Records"`,` table Name,Status,Updated | First,Active,Today | Second,Paused,Yesterday`],view:[{component:`DataTable`,props:{columns:[{key:`name`,header:`Name`,sortable:!0},{key:`status`,header:`Status`},{key:`updated`,header:`Updated`}],rows:[{name:`First`,status:`Active`,updated:`Today`},{name:`Second`,status:`Paused`,updated:`Yesterday`}]}}]},toolbar:{kw:[`search`,`filter`],cv:[`row gap=3`,` search`,` button "New record" primary`],view:[row([{component:`Search`,props:{label:`Search records`}},btn(`New record`)])]},crumbs:{kw:[`breadcrumb`],cv:[`breadcrumb Home,/ | Section,/section | Current`],view:[{component:`Breadcrumb`,props:{items:[{label:`Home`,href:`/`},{label:`Section`,href:`/section`},{label:`Current`}]}}]},facts:{kw:[],cv:[`card "Details"`,` data-list Status,Active | Owner,Name | Created,Date`],view:[{component:`Card`,children:[h(2,`Details`),list([`Status: Active`,`Owner: Name`,`Created: Date`])]}]},sections:{kw:[`tab`,`section`,`overview`],cv:[`tabs`,` section "Overview"`,` text "What matters most about this record."`,` section "Related"`,` text "Linked records."`],view:[{component:`Card`,children:[h(2,`Overview`),p(`What matters most about this record.`)]},{component:`Card`,children:[h(2,`Related`),p(`Linked records.`)]}]},activity:{kw:[`activity`,`history`,`timeline`,`log`,`audit`,`event`],cv:[`h2 "Activity"`,`timeline Created,Date | Updated,Date`],view:[h(2,`Activity`),{component:`Timeline`,props:{items:[{id:`created`,title:`Created`,description:`Date`},{id:`updated`,title:`Updated`,description:`Date`}]}}]},fields:{kw:[`field`,`input`,`form`],cv:[`card "Details"`,` input "Name"`,` input "Email" hint="Say why it is needed."`,` select label="Choice" First,first | Second,second`],view:[{component:`Card`,children:[h(2,`Details`),{component:`Input`,props:{label:`Name`}},{component:`Input`,props:{label:`Email`,hint:`Say why it is needed.`}},{component:`Select`,props:{label:`Choice`,options:[{value:`first`,label:`First`},{value:`second`,label:`Second`}]}}]}]},actions:{kw:[],cv:[`row gap=3 justify=end`,` button "Cancel" ghost`,` button "Save" primary`],view:[row([btn(`Cancel`,`ghost`),btn(`Save`)],{justify:`end`})]},"auth-form":{kw:[],cv:[`center`,` card "Sign in"`,` input "Email"`,` input "Password"`,` button "Sign in" primary`,` link /forgot "Forgot password?"`],view:[{component:`Center`,children:[{component:`Card`,children:[h(1,`Sign in`),{component:`Input`,props:{label:`Email`}},{component:`Input`,props:{label:`Password`}},btn(`Sign in`),{component:`Link`,props:{href:`/forgot`},children:`Forgot password?`}]}]}]},progress:{kw:[`step`,`stepper`,`wizard`,`progress`,`multistep`],cv:[`steps activeStep=0 Account | Details | Done`],view:[{component:`Steps`,props:{items:[{label:`Account`},{label:`Details`},{label:`Done`}],activeStep:0}}]},message:{kw:[],cv:[`center`,` empty-state "Say what happened" "Say what the user can do next."`,` button "Primary action" primary`],view:[{component:`Center`,children:[{component:`EmptyState`,props:{title:`Say what happened`,description:`Say what the user can do next.`}},btn(`Primary action`)]}]},toc:{kw:[`toc`,`content`,`outline`,`docs`,`documentation`,`guide`],cv:[`toc Introduction,#introduction | Usage,#usage`],view:[list([`Introduction`,`Usage`])]},article:{kw:[],cv:[`center`,` h1 "Article title"`,` p "Lead: what the reader will know by the end."`,` h2 "Introduction"`,` p "Body text at a readable measure."`,` code-snippet "npm install example"`,` h2 "Usage"`,` p "Body text."`],view:[{component:`Center`,props:{maxWidth:`65ch`},children:[h(1,`Article title`),p(`Lead: what the reader will know by the end.`),h(2,`Introduction`),p(`Body text at a readable measure.`),{component:`Code`,children:`npm install example`},h(2,`Usage`),p(`Body text.`)]}]},summary:{kw:[`summary`,`cart`,`order`,`total`,`checkout`,`payment`],cv:[`card "Summary"`,` data-list Subtotal,$0 | Total,$0`],view:[{component:`Card`,children:[h(2,`Summary`),list([`Subtotal: $0`,`Total: $0`])]}]},error:{kw:[`error`,`validation`,`invalid`],cv:[`alert "Say what failed" destructive "Say how to fix it."`],view:[{component:`Alert`,props:{variant:`destructive`,title:`Say what failed`},children:`Say how to fix it.`}]}},I=[{name:`accordion`,kind:`component`,text:`Vertically stacked, collapsible content sections navigation collapse disclosure Progressively disclosing sections of related content the user reads top to bottom`,props:[`children: ReactNode`]},{name:`action-sheet`,kind:`component`,text:`Bottom-rising sheet of discrete actions (iOS action-sheet pattern) with a Cancel button overlay action-sheet menu mobile sheet A short list of discrete actions on a touch surface, rising from the bot…`,props:[`actions: ActionSheetAction[]`,`title?: React.ReactNode`,`description?: React.ReactNode`]},{name:`ai-badge`,kind:`component`,text:`Small "AI" marker for AI-generated content; with children it opens a toggletip explaining how AI was involved ai label badge provenance explainability generated Marking a field, card, table cell or m…`,props:[]},{name:`ai-disclaimer`,kind:`component`,text:`A short, quiet note that AI-generated content may be wrong — "AI-generated content may be incorrect" ai disclaimer disclosure notice provenance generated Under an AI chat composer or answer, telling…`,props:[]},{name:`ai-status`,kind:`component`,text:`Announces what an AI is doing — thinking, generating, done, failed or stopped — with a shimmering label and an optional Stop button ai status loading thinking generating progress stop Telling the rea…`,props:[`status: 'thinking' | 'generating' | 'complete' | 'error…`,`label?: ReactNode`]},{name:`alert`,kind:`component`,text:`Highlights a short, important message inline notification message feedback Surfacing a persistent, contextual message inline within a view (warning, error, info, success)`,props:[`variant?: 'default' | 'info' | 'success' | 'warning' | 'd…`,`title?: string`]},{name:`alert-dialog`,kind:`component`,text:`Confirmation dialog requiring explicit user action; no light-dismiss overlay dialog confirm destructive Confirming a destructive or irreversible action (delete, overwrite, sign out) before it happens`,props:[`open: boolean`,`title: string`,`description: string`,`onConfirm: () => void`,`onCancel: () => void`]},{name:`app-shell`,kind:`component`,text:`Sticky-header + full-height side-nav + single-scroll-container layout with an animated, accessible nav toggle. shell layout sidebar navigation drawer responsive sticky Building an application screen…`,props:[`header: ReactNode`,`children: ReactNode`]},{name:`aspect-ratio`,kind:`component`,text:`Constrains content to a fixed width-to-height ratio layout ratio image video responsive Reserving a stable box for media that loads asynchronously, avoiding layout shift`,props:[]},{name:`avatar`,kind:`component`,text:`Displays a user image with initials fallback user profile image Representing a person or entity with a thumbnail image and initials fallback`,props:[]},{name:`avatar-group`,kind:`component`,text:`Overlapping stack of avatars with a max cap and an i18n-labelled +N overflow chip avatar group stack overflow display Showing several people compactly as an overlapping stack (collaborators, attendee…`,props:[]},{name:`badge`,kind:`component`,text:`Small status label or category indicator label status tag Labeling an item with a short, static status or category (e.g. "New", "Beta")`,props:[`variant?: 'default' | 'secondary' | 'success' | 'warning'…`]},{name:`block/console-app`,kind:`block`,text:`Carbon-parity console shell: ShellHeader + icon-rail SideNav + HeaderPanel notifications/switcher + collapsible aside + main content. block console shell navigation carbon-parity A Carbon-parity cons…`,props:[]},{name:`block/dashboard-charts`,kind:`block`,text:`Dashboard layout with KPI tiles, line chart, bar chart, and pie chart. block dashboard charts kpi A prebuilt dashboard with KPI tiles, line, bar, and pie charts`,props:[]},{name:`block/empty-dashboard`,kind:`block`,text:`Dashboard page showing an empty state with a call-to-action button. block dashboard empty-state page A first-run or zero-data dashboard with an empty state and primary CTA`,props:[]},{name:`block/login-page`,kind:`block`,text:`Authentication login page with email and password form. block login auth form page A complete login page with email and password form`,props:[]},{name:`block/notification-center`,kind:`block`,text:`A list of notification alerts with a mark-all-read action. block notifications alerts A list of notification alerts with a mark-all-read action`,props:[]},{name:`block/page-with-breadcrumb`,kind:`block`,text:`A centered content page with a breadcrumb navigation and page header. block breadcrumb page navigation A centered content page with breadcrumb navigation and a page header`,props:[]},{name:`block/settings-form-page`,kind:`block`,text:`Settings page with profile form inside a two-column settings layout. block settings form page A settings page with a profile form inside a two-column settings layout`,props:[]},{name:`block/sidebar-app`,kind:`block`,text:`Full app shell with collapsible side navigation and top header. block sidebar navigation app-shell A ready-made app shell with opinionated collapsible sidebar and top header`,props:[]},{name:`block/stats-cards`,kind:`block`,text:`Grid of KPI stat cards with trend badges. block stats kpi cards A grid of KPI stat cards with trend badges`,props:[]},{name:`block/users-table-page`,kind:`block`,text:`Full users management page with table, search, and invite action. block users table page A full user-management page with table, search, and invite action`,props:[]},{name:`blockquote`,kind:`component`,text:`Quoted passage with optional attribution footer typography quote blockquote citation Setting off a quoted passage from another source with visual emphasis`,props:[]},{name:`bottom-sheet`,kind:`component`,text:`Mobile bottom sheet with drag-to-resize detents, velocity-projected snapping, and drag-to-dismiss overlay sheet bottom-sheet mobile drag detent gesture A mobile surface that rises from the bottom and…`,props:[`title?: React.ReactNode`,`description?: React.ReactNode`]},{name:`brand/logo`,kind:`component`,text:`The cascivo mark and its sanctioned lockups, as inline SVG logo brand mark wordmark lockup identity Placing the cascivo logo in a header, footer, auth screen or splash`,props:[`variant?: 'mark' | 'mark-accent' | 'horizontal' | 'stacke…`]},{name:`breadcrumb`,kind:`component`,text:`Shows the current page location within a navigation hierarchy breadcrumb navigation hierarchy Showing the user where the current page sits in a navigation hierarchy`,props:[`items: { label: string; href?: string }[]`,`label?: string`]},{name:`button`,kind:`component`,text:`Triggers an action or event action form interactive Triggering an action or navigation the user initiates by click/press`,props:[`variant?: 'primary' | 'secondary' | 'ghost' | 'destructiv…`]},{name:`button-group`,kind:`component`,text:`Visually joins a set of related buttons into a single segmented control action segmented toolbar layout Presenting several related, independent actions that read as one control (e.g. an editor toolba…`,props:[]},{name:`calendar`,kind:`component`,text:`An accessible standalone month-grid date picker. calendar date month grid picker input Showing an always-visible month grid for picking a single date (inline, not a popover)`,props:[`label?: string`]},{name:`card`,kind:`component`,text:`Container for grouping related content container layout surface ai Grouping related content into a visually distinct surface with border/shadow`,props:[`variant?: 'default' | 'outlined' | 'elevated'`]},{name:`carousel`,kind:`component`,text:`Scroll-snap slide deck with previous/next controls and dot indicators slider gallery slideshow deck scroll-snap Presenting a sequence of media or cards the user pages through one at a time`,props:[]},{name:`chain-of-thought`,kind:`component`,text:`The steps an AI agent takes — searching, reading, calling tools — each with its status, and optional collapsible detail ai agent steps chain-of-thought reasoning progress tools Showing the discrete s…`,props:[`items: ChainOfThoughtItem[]`]},{name:`chart/area-chart`,kind:`chart`,text:`Area chart with optional stacking, multi-series support, and hover tooltip. chart area data-viz Showing cumulative volume or magnitude of a trend over continuous time`,props:[`series: AreaChartSeries<Datum>[]`,`x: (d: Datum) => number | Date`,`y: (d: Datum) => number`,`title: string`,`description?: string`]},{name:`chart/bar-chart`,kind:`chart`,text:`Bar chart with vertical/horizontal orientation, grouped or stacked modes, and multi-series support. chart bar data-viz Comparing discrete categorical values across groups`,props:[`series: BarChartSeries<Datum>[]`,`x: (d: Datum) => string`,`y: (d: Datum) => number`,`title: string`,`description?: string`]},{name:`chart/boxplot`,kind:`chart`,text:`Box-and-whisker plot with five-number summary and outlier dots per series. chart boxplot box-whisker statistics data-viz Comparing the distribution spread, median, and quartiles across groups`,props:[`series: { id: string; label: string; values: number[] }…`,`title: string`,`description?: string`]},{name:`chart/bubble-chart`,kind:`chart`,text:`Bubble chart mapping x, y, and size dimensions; radius is area-proportional via sqrt scale. chart bubble scatter three-dimensional data-viz Plotting three dimensions at once — x, y, and a size-encode…`,props:[`series: { name: string; data: { x: number; y: number; s…`,`title: string`,`description?: string`]},{name:`chart/bullet`,kind:`chart`,text:`Bullet chart with background range bands, measure bar, and target tick. chart bullet kpi progress data-viz Showing a single measure against a target with qualitative range bands`,props:[`value: number`,`target: number`,`ranges: number[]`,`label: string`]},{name:`chart/calendar`,kind:`chart`,text:`Calendar heatmap — a week-column grid of day cells colored by value (GitHub-style). chart calendar heatmap time data-viz Showing a daily value over weeks/months (activity, contributions)`,props:[`data: CalendarHeatmapDatum[]`,`title: string`,`description?: string`]},{name:`chart/candlestick`,kind:`chart`,text:`OHLC financial chart — each period a high–low wick and an open↔close body, coloured up/down. chart candlestick ohlc financial data-viz Showing open/high/low/close price movement over time`,props:[`data: CandlestickDatum[]`,`title: string`,`description?: string`]},{name:`chart/combo-chart`,kind:`chart`,text:`Combination bar + line chart on shared or dual y-axes. chart combo bar line dual-axis data-viz Overlaying two related metrics with different scales (e.g. volume bars + rate line)`,props:[`bars: { label: string; value: number }[]`,`line: { x: number; y: number }[]`,`title: string`,`description?: string`]},{name:`chart/funnel`,kind:`chart`,text:`Vertical conversion funnel — each stage is a trapezoid narrowing toward the next, with optional conversion labels. chart funnel conversion flow data-viz Showing drop-off across the ordered stages of…`,props:[`data: FunnelStage[]`,`title: string`,`description?: string`]},{name:`chart/gauge`,kind:`chart`,text:`A speedometer gauge — a value arc over a min–max sweep with threshold zones, ticks, and a needle. chart gauge speedometer kpi data-viz A single value against a range with a needle and threshold zones`,props:[`value: number`,`title: string`,`description?: string`]},{name:`chart/heatmap`,kind:`chart`,text:`Two-dimensional heatmap with band scales and color-mix cell interpolation. chart heatmap matrix data-viz Showing magnitude across two categorical dimensions as a color-coded matrix`,props:[`data: { x: string; y: string; value: number }[]`,`title: string`,`description?: string`]},{name:`chart/histogram`,kind:`chart`,text:`Frequency histogram using Freedman–Diaconis binning with hover tooltips. chart histogram distribution frequency data-viz Showing the frequency distribution of a single continuous variable`,props:[`data: number[]`,`title: string`,`label: string`,`description?: string`]},{name:`chart/kpi`,kind:`chart`,text:`KPI card showing a primary metric with optional delta indicator, icon, and sparkline. chart kpi metric dashboard data-viz Highlighting a single headline metric with an optional change delta`,props:[`value: string | number`,`label: string`]},{name:`chart/line-chart`,kind:`chart`,text:`Time-series or numeric line chart with multi-series support, hover tooltip, and legend. chart line time-series data-viz Showing trends and precise values over continuous time or a numeric range`,props:[`series: LineChartSeries<Datum>[]`,`x: (d: Datum) => number | Date`,`y: (d: Datum) => number`,`title: string`,`description?: string`]},{name:`chart/meter`,kind:`chart`,text:`Progress meter in bar or gauge variant with threshold coloring. chart meter gauge progress data-viz Showing a rated or gauged value within a known min/max range`,props:[`value: number`,`label: string`,`variant?: 'bar' | 'gauge'`]},{name:`chart/pie-chart`,kind:`chart`,text:`Pie or donut chart with hover segments and optional legend. chart pie donut data-viz Showing part-of-whole proportions with five or fewer slices`,props:[`data: PieChartDatum[]`,`title: string`,`description?: string`]},{name:`chart/polar`,kind:`chart`,text:`A polar coordinate plot — categories around the circle, value as radius. Bars (a rose), or a polar line/area. chart polar rose radial data-viz Cyclical/directional categories where the circle is mean…`,props:[`data: PolarDatum[]`,`title: string`,`description?: string`]},{name:`chart/radar`,kind:`chart`,text:`Radar / spider chart with polar grid rings, spokes, and multi-series polygon overlays. chart radar spider polar data-viz Comparing several entities across the same set of quantitative dimensions`,props:[`axes: string[]`,`series: { id: string; label: string; values: number[] }…`,`title: string`,`description?: string`]},{name:`chart/radial-bar`,kind:`chart`,text:`Concentric radial bars (a circular gauge family) — each datum is a ring whose sweep is proportional to its value. chart radial gauge progress data-viz Showing a few progress-to-goal values in a compa…`,props:[`data: RadialBarDatum[]`,`title: string`,`description?: string`]},{name:`chart/sankey`,kind:`chart`,text:`Flow diagram — ranked nodes connected by throughput-sized link ribbons. chart sankey flow network data-viz Showing flow/throughput between stages or categories`,props:[`nodes: SankeyNode[]`,`links: SankeyLink[]`,`title: string`,`description?: string`]},{name:`chart/scatter-chart`,kind:`chart`,text:`Scatter plot with variable point radius, multi-series, and hover tooltip. chart scatter plot data-viz Revealing correlation or clustering between two numeric variables`,props:[`series: ScatterChartSeries[]`,`title: string`,`description?: string`]},{name:`chart/sparkline`,kind:`chart`,text:`Compact inline sparkline for embedding trend data in dashboards or KPI cards. chart sparkline inline trend data-viz Embedding a compact micro-trend inline in text, tables, or KPI cards`,props:[`data: number[]`,`label?: string`]},{name:`chart/stream`,kind:`chart`,text:`Streamgraph — stacked areas on a centered (silhouette) flowing baseline. chart stream streamgraph area data-viz Showing how several series ebb and flow over time as proportions of a whole`,props:[`series: StreamSeries[]`,`categories: (string | number)[]`,`title: string`,`description?: string`]},{name:`chart/sunburst`,kind:`chart`,text:`Radial hierarchy — concentric rings where each node is an annular segment sized by value. chart sunburst hierarchy radial data-viz Showing a part-of-whole hierarchy across multiple levels`,props:[`data: HierNode`,`title: string`,`description?: string`]},{name:`chart/treemap`,kind:`chart`,text:`Squarified treemap for visualizing part-to-whole hierarchical data. chart treemap hierarchy part-to-whole data-viz Showing part-to-whole proportions across many segments in a compact area`,props:[`data: { id: string; label: string; value: number }[]`,`title: string`,`description?: string`]},{name:`chat-bubble`,kind:`component`,text:`Message bubble for chat and messaging UIs with avatar, name, and timestamp support chat message conversation messaging Chat UIs and messaging features showing conversation history`,props:[`children: React.ReactNode`]},{name:`checkbox`,kind:`component`,text:`Binary toggle for forms, with indeterminate support form toggle boolean Selecting zero or more options from a list where each choice is independent`,props:[`label?: string`]},{name:`checkbox-card`,kind:`component`,text:`Multi-selectable card backed by a native checkbox. Use multiple independent CheckboxCards for multi-select scenarios. checkbox card selectable form Multi-select where each option needs a title and su…`,props:[`title: ReactNode`,`description?: ReactNode`]},{name:`code`,kind:`component`,text:`Inline code span for identifiers, commands, and short snippets typography code inline mono Marking up an inline identifier, command, path, or token within prose`,props:[]},{name:`code-snippet`,kind:`component`,text:`Displays code (inline, single-line, or multi-line) with an optional copy button, lightweight built-in syntax highlighting for bash/css/js/ts, and an optional terminal-window look display code snippet…`,props:[`variant?: 'inline' | 'single' | 'multi'`,`title?: string`]},{name:`collapsible`,kind:`component`,text:`A single disclosure region toggled open and closed by its trigger disclosure collapse expand toggle show-hide Hiding a single secondary block until the user asks for it`,props:[`trigger: ReactNode`]},{name:`color-picker`,kind:`component`,text:`Interactive color selection widget with saturation/lightness area, hue and alpha sliders color input form picker hue alpha Letting a user choose an arbitrary color via a visual saturation/lightness a…`,props:[`label?: string`]},{name:`combobox`,kind:`component`,text:`Filterable single-select with an animated custom listbox, built on the dropdown open/close machine select combobox dropdown filter search Single-select from a long list where type-to-filter makes fin…`,props:[`options: ComboboxOption[]`,`label?: string`]},{name:`command-menu`,kind:`component`,text:`Cmd+K command palette with fuzzy search over grouped commands overlay command palette search cmdk keyboard scope fuzzy Giving power users a global Cmd/Ctrl+K palette to search and run actions or navi…`,props:[`open: boolean`,`onOpenChange: (open: boolean) => void`,`groups: CommandGroup[]`,`label?: string`]},{name:`comparison`,kind:`component`,text:`Reveals the difference between two layers with a draggable divider comparison before-after image slider display Showing the difference between two versions of similar content (before/after edits, ori…`,props:[`after: ReactNode`,`before: ReactNode`,`label?: string`]},{name:`contained-list`,kind:`component`,text:`Labelled list of rows inside a bordered container list container rows group Grouping a short set of related rows under a visible heading in a bordered surface`,props:[`label: ReactNode`]},{name:`context-menu`,kind:`component`,text:`Right-click context menu anchored at pointer coordinates via CSS custom properties overlay menu context right-click Offering actions contextual to an element via right-click (rename, delete, copy on…`,props:[`children: React.ReactNode`]},{name:`context-meter`,kind:`component`,text:`How much of a model’s context window a conversation has used — "12K / 200K" with a bar that warns as it fills ai context tokens usage meter quota Showing how much of the model’s context window a conv…`,props:[`value: number`,`max: number`,`label?: string`]},{name:`copy-button`,kind:`component`,text:`Icon button that copies a value to the clipboard with copied feedback clipboard copy button snippet Letting users copy a short value to the clipboard — install commands, API keys, tokens, share links`,props:[`value: string`]},{name:`data-list`,kind:`component`,text:`Key-value pairs rendered as a description list key-value description metadata details Displaying read-only key-value metadata (profile fields, record summaries)`,props:[`items?: DataListEntry[]`]},{name:`data-table`,kind:`component`,text:`Signal-driven data table with client/server sort, filter, pagination, multi-selection, expandable rows, and CSS content-visibility row containment for large datasets table data grid sort filter pagin…`,props:[`columns: Column<Row>[]`,`rows: Row[]`,`title?: string`,`description?: string`]},{name:`date-picker`,kind:`component`,text:`An accessible date-picker with a calendar popover. date calendar picker input form Picking a single calendar date in a form where a visual month grid helps (due dates, bookings)`,props:[`label?: string`]},{name:`date-range-picker`,kind:`component`,text:`A dual-calendar picker for selecting a contiguous date range. date range calendar picker input form Selecting a contiguous start–end date range (reporting windows, bookings, filters)`,props:[]},{name:`dock`,kind:`component`,text:`Fixed bottom navigation bar for mobile app shells with up to 5 items dock tab-bar bottom-nav mobile navigation app-shell Mobile app-shell navigation with 3–5 top-level destinations`,props:[`items: DockItem[]`,`label?: string`]},{name:`drawer`,kind:`component`,text:`Edge-anchored dialog panel that slides in from a screen edge with CSS-only enter/exit motion overlay drawer panel slide dialog A side or edge panel for navigation, filters, or detail views that needs…`,props:[`title?: React.ReactNode`,`description?: React.ReactNode`]},{name:`dropdown`,kind:`component`,text:`Menu of actions revealed from a trigger overlay menu actions Revealing a short menu of actions from a trigger button (row actions, "More" overflow, account menu)`,props:[`trigger: ReactElement`,`items: ({ label: string; value: string; icon?: ReactNo…`]},{name:`editable`,kind:`component`,text:`Inline click-to-edit text field form editable inline input text Editing a single piece of text in place where the value is normally read-only — titles, names, labels`,props:[`value: string`,`onValueChange: (v: string) => void`]},{name:`editor/code-editor`,kind:`editor`,text:`Lightweight code editor — a native textarea overlaid on a syntax-highlighted layer, with line numbers and Tab indent. editor code syntax-highlighting textarea inputs Editing code or config inline — J…`,props:[`label?: string`]},{name:`editor/highlight`,kind:`editor`,text:`Read-only syntax-highlighted code block — the same owned tokenizer as CodeEditor, without the textarea. editor code syntax-highlighting display read-only Displaying non-editable code or config with s…`,props:[`value: string`,`label?: string`]},{name:`empty-state`,kind:`component`,text:`Placeholder for views that have no data to display empty placeholder zero-state no-data Filling a view that has no data with guidance and a primary next step`,props:[`title: string`,`description?: string`]},{name:`fab`,kind:`component`,text:`Floating action button anchored to a screen corner, with an optional speed-dial of secondary actions inputs fab floating-action-button mobile speed-dial A single, high-emphasis primary action that fl…`,props:[`children: React.ReactNode`,`label?: string`]},{name:`field`,kind:`component`,text:`Form-field wrapper composing label, control, description, and error form layout validation accessibility Pairing a single control with its label, helper text, and validation message`,props:[`children: ReactElement`,`label?: ReactNode`,`description?: ReactNode`]},{name:`file-uploader`,kind:`component`,text:`Drag-and-drop file upload zone with file list and status indicators. upload file drop drag input form Letting users attach one or more files via click-to-browse or drag-and-drop`,props:[`label?: string`]},{name:`filter`,kind:`component`,text:`A group of toggleable pill or outline buttons for filtering content by category filter chip tag pill facet category Tag or category filtering on listing pages where the active filters must remain vis…`,props:[`options: FilterOption[]`,`label?: string`,`variant?: 'pill' | 'outline'`]},{name:`flow/flow`,kind:`flow`,text:`The declarative, AI-first flow surface — render a node/edge graph from plain serializable data. flow graph declarative diagram ai-first Rendering a graph from data — the common case and the agent-emi…`,props:[`nodes: FlowNode[]`,`edges: FlowEdge[]`]},{name:`flow/flow-background`,kind:`flow`,text:`Decorative dots / grid / cross canvas background, drawn purely in CSS gradients. flow background grid dots canvas Giving a flow canvas a sense of space and scale with a dotted or grid backdrop`,props:[`variant?: 'dots' | 'grid' | 'cross'`]},{name:`flow/flow-canvas`,kind:`flow`,text:`The pan/zoom canvas pane — a single CSS-transformed layer driven by the viewport signal. flow canvas viewport pan zoom Hosting a hand-composed flow from low-level FlowNode/FlowEdge primitives`,props:[]},{name:`flow/flow-controls`,kind:`flow`,text:`Zoom in / out / fit-view controls for a flow canvas — real, i18n-labeled buttons. flow controls zoom chrome Giving users explicit zoom/fit controls on a flow canvas`,props:[]},{name:`flow/flow-edge`,kind:`flow`,text:`An SVG edge with bezier/straight/smoothstep paths, an arrowhead, an optional label, and animation. flow edge connector animated svg Connecting two nodes with a directed path and arrowhead`,props:[`sourceX: number`,`sourceY: number`,`targetX: number`,`targetY: number`,`label?: ReactNode`]},{name:`flow/flow-handle`,kind:`flow`,text:`A connection port on a node edge — where edges attach and interactive connect starts. flow handle port connect Marking where edges connect to a node`,props:[`type: 'source' | 'target'`]},{name:`flow/flow-minimap`,kind:`flow`,text:`A scaled SVG overview of the graph with a draggable viewport rectangle. flow minimap overview chrome Orienting users in a large graph`,props:[`nodes: FlowNode[]`,`viewport: Viewport`,`label?: string | undefined`]},{name:`flow/flow-node`,kind:`flow`,text:`An HTML node box positioned in the viewport pane — draggable, selectable, with arbitrary children. flow node draggable graph Representing a unit in a graph that holds arbitrary themed content`,props:[`id: string`]},{name:`flow/flow-panel`,kind:`flow`,text:`An absolutely-positioned slot for custom flow-canvas UI (legend, toolbar). flow panel slot chrome Overlaying custom UI (a legend, a toolbar) on a flow canvas`,props:[]},{name:`flow/flow-story`,kind:`flow`,text:`A scripted, sequenced, looping flow animation — walks a graph step by step with fade-in captions. flow animation storyline walkthrough sequence Explaining how a flow works step by step, not just show…`,props:[`nodes: FlowNode[]`,`edges: FlowEdge[]`,`script: StoryStep[]`]},{name:`form`,kind:`component`,text:`Typed signal-based form store (createForm/useForm) with sync/async validation and a thin Form element wrapper form validation signals input Collecting and submitting a set of related field values tog…`,props:[`form: FormStore<T>`,`onValid: (values: T) => void | Promise<void>`,`children: ReactNode`]},{name:`header`,kind:`component`,text:`App top bar with brand, primary navigation links, and an actions slot navigation app-shell top-bar banner Providing a simple marketing or app top bar with brand, links, and actions`,props:[]},{name:`header-panel`,kind:`component`,text:`Non-modal panel anchored below the shell header at the inline-end edge — hosts notifications, app switcher, user settings navigation panel shell console overlay notifications Hosting a non-modal pane…`,props:[`open: boolean`,`onClose: () => void`,`label: string`,`children: ReactNode`]},{name:`heading`,kind:`component`,text:`Section heading with semantic level decoupled from visual size typography heading title Titling a page or section as part of the document outline`,props:[]},{name:`hover-card`,kind:`component`,text:`Hover-triggered popover with configurable open/close delay overlay hover preview floating Showing a rich preview (avatar, summary, links) when a user hovers or focuses a trigger`,props:[`children: React.ReactNode`]},{name:`icon-button`,kind:`component`,text:`Square, icon-only button with a required accessible label action icon compact toolbar A compact, recognizable action where an icon alone communicates intent (close, edit, more)`,props:[`label?: string`,`variant?: 'ghost' | 'outline' | 'filled'`]},{name:`image`,kind:`component`,text:`Image with load state, blur-up placeholder, graceful fallback, and optional zoom image media display loading Displaying a content image that should show a placeholder while loading and degrade gracef…`,props:[]},{name:`indicator`,kind:`component`,text:`Positions an overlay element (badge, dot, count) at a corner of its child badge indicator overlay notification layout Notification counts on icon buttons`,props:[`children: React.ReactNode`,`overlay: React.ReactNode`]},{name:`infinite-scroll`,kind:`component`,text:`Loads the next page when the end of a list scrolls into view feedback infinite-scroll pagination list scroll mobile lazy A long, page-fetched feed or list where the user should keep reading without a…`,props:[`onLoadMore: () => Promise<unknown> | unknown`]},{name:`inline-citation`,kind:`component`,text:`A numbered citation marker inside AI-generated text that links to its source and previews it in a hover card ai citation sources footnote references provenance Attributing a claim in an AI answer to…`,props:[`index: number`,`source: AiSource`]},{name:`inline-loading`,kind:`component`,text:`Compact inline status indicator that pairs a label with a loading, success, or error state loading status progress feedback spinner Showing the progress of a single inline action — a Save button that…`,props:[`status: 'inactive' | 'active' | 'finished' | 'error'`,`label?: ReactNode`]},{name:`input`,kind:`component`,text:`Text input field with optional label, hint, and error state form text input ai Collecting a single line of free-form text from the user`,props:[`label?: string`]},{name:`input-group`,kind:`component`,text:`Prefix/suffix addon wrapper for Input; InputGroupAddon renders inline icons/units inside the field border; InputGroupButtons collapses adjacent button borders form input addon group layout Attaching…`,props:[`children: ReactNode`]},{name:`item`,kind:`component`,text:`Generic content row primitive with media, content, and action regions row primitive list-item layout Composing a single content row with leading media, a text block, and trailing actions`,props:[`variant?: 'default' | 'muted'`]},{name:`join`,kind:`component`,text:`Groups adjacent children into a seamless joined element by removing interior borders and radii group join segmented layout Input + button search groups where the two controls should appear as one unit`,props:[`children: React.ReactNode`]},{name:`kbd`,kind:`component`,text:`Displays a keyboard key or shortcut keyboard shortcut hotkey Showing a keyboard key or shortcut the user should press`,props:[]},{name:`label`,kind:`component`,text:`Accessible caption for a form control form caption accessibility Naming a single form control (input, select, checkbox) so clicking the text focuses it`,props:[`children: ReactNode`]},{name:`large-title-header`,kind:`component`,text:`Scrolling region whose large title collapses into a compact sticky bar as it scrolls navigation header title mobile scroll sticky ios A scrolling screen that should keep its title reachable after the…`,props:[`title: string`,`children: React.ReactNode`]},{name:`layout/app-shell`,kind:`layout`,text:`Full-page application shell with persisted collapsible sidebar. Includes a signal-driven top progress bar with determinate progress, error state, and dismissible error strip. layout shell sidebar nav…`,props:[`header: ReactNode`,`children: ReactNode`]},{name:`layout/auth-layout`,kind:`layout`,text:`Centered card layout for authentication pages (login, register, forgot password). layout auth login page Centered card layout for authentication pages — login, register, reset`,props:[`children: ReactNode`]},{name:`layout/auto-grid`,kind:`layout`,text:`Media-query-free responsive grid — columns auto-fill based on available space. layout grid responsive Responsive card or tile grids that auto-fit columns to available width`,props:[]},{name:`layout/center`,kind:`layout`,text:`Horizontally centered container with a configurable max-width. layout center wrapper Horizontally centering content within a configurable max-width`,props:[]},{name:`layout/columns`,kind:`layout`,text:`Equal-width multi-column layout that collapses to single column on narrow viewports. layout grid columns Equal-width multi-column content that collapses to one column when narrow`,props:[]},{name:`layout/dashboard-layout`,kind:`layout`,text:`Dashboard page layout with stats strip, main content area, and optional aside. layout dashboard page A dashboard page with a stats strip, main content area, and optional aside`,props:[`main: ReactNode`]},{name:`layout/flex`,kind:`layout`,text:'Flex layout primitive for vertical or horizontal stacking with gap control. ⚠ Unlike CSS `flex-direction`, `direction` defaults to `vertical` — pass `direction="horizontal"` for a row. layout flex st…',props:[]},{name:`layout/grid`,kind:`layout`,text:"CSS grid layout primitive with responsive column collapsing. Establishes its own containment, so responsive `cols` adapt to the grid’s own slot width with no wrapper or container ancestor required. l…",props:[]},{name:`layout/masonry`,kind:`layout`,text:`Masonry layout — native CSS masonry where supported, multi-column fallback elsewhere (fallback orders items top-to-bottom per column). layout masonry gallery Galleries of variable-height items packed…`,props:[]},{name:`layout/page-header`,kind:`layout`,text:`Page-level header with title, description, breadcrumb, and actions slots. layout header page A page-level header with title, description, breadcrumb, and action slots`,props:[`title: ReactNode`,`description?: ReactNode`]},{name:`layout/section`,kind:`layout`,text:`Page-section shell with block padding, centered inner width, and stack gap. layout section page Wrapping a page region with block padding and a centered inner width`,props:[]},{name:`layout/settings-layout`,kind:`layout`,text:`Two-column settings page layout with a fixed-width menu and fluid content area. layout settings page A two-column settings page with a fixed-width menu and fluid content`,props:[`menu: ReactNode`,`children: ReactNode`]},{name:`layout/spacer`,kind:`layout`,text:`Fixed-height spacing block using design token steps. layout spacer spacing Inserting a fixed vertical gap between blocks using spacing token steps`,props:[]},{name:`layout/split-view`,kind:`layout`,text:`Resizable two-pane split layout with keyboard and pointer drag support. layout split resizable pane Two side-by-side panes the user can resize via pointer or keyboard`,props:[`start: ReactNode`,`end: ReactNode`,`label?: string`]},{name:`link`,kind:`component`,text:`Styled anchor for navigation, standalone or inline within prose link anchor navigation Navigating to another page, view, or resource via a real href`,props:[`variant?: 'standalone' | 'inline'`]},{name:`list`,kind:`component`,text:`Styled unordered or ordered list with ListItem typography list ul ol Presenting a set of related items as a bulleted or numbered list`,props:[]},{name:`log-viewer`,kind:`component`,text:`Virtualized monospace console for high-frequency log and stream output log stream virtual console terminal monospace Rendering continuous, high-volume log or stream output (build/deploy logs, server…`,props:[`lines: ReadonlySignal<readonly LogLine[]> | readonly L…`]},{name:`menu`,kind:`component`,text:`Dropdown menu with keyboard navigation, built on usePopover overlay menu dropdown floating Presenting a list of actions or commands triggered from a button`,props:[`children: React.ReactNode`]},{name:`menu-button`,kind:`component`,text:`A button that opens an anchored action menu of one-shot commands navigation menu actions dropdown floating Exposing a small set of one-shot actions behind a single labeled button`,props:[`label: ReactNode`,`items: MenuButtonItem[]`,`variant?: 'primary' | 'secondary' | 'ghost'`]},{name:`menubar`,kind:`component`,text:`Horizontal application menu bar with keyboard-navigable dropdown menus navigation menubar menu application A persistent application-style command bar (File / Edit / View) where each top-level entry o…`,props:[`menus: MenubarMenu[]`]},{name:`message-actions`,kind:`component`,text:`The action row under an AI reply — copy, good / bad feedback as toggle buttons, and regenerate ai chat feedback copy regenerate thumbs actions Under each assistant message: copy the reply, rate it, o…`,props:[]},{name:`modal`,kind:`component`,text:`Accessible dialog overlay using native <dialog> element overlay dialog popup ai Presenting focused content or a task that must interrupt the current flow`,props:[`title?: string`,`description?: string`]},{name:`multi-select`,kind:`component`,text:`Searchable multi-value select with a popover listbox, chips and grouping form select multi input popover combobox tags Selecting several values at once from a known list of options`,props:[`options: MultiSelectOption[]`,`label?: string`]},{name:`native-select`,kind:`component`,text:`A styled native <select> that keeps platform form/keyboard behavior with a custom chevron and focus ring inputs select native form dropdown A standard single-choice dropdown where native behavior and…`,props:[`options?: NativeSelectOption[]`]},{name:`navigation-menu`,kind:`component`,text:`Site navigation bar with links and dropdown flyout panels navigation menu flyout site-nav Primary site navigation where some destinations are plain links and others reveal a flyout of grouped links`,props:[`items: NavigationMenuItem[]`,`label?: string`]},{name:`notification`,kind:`component`,text:`Inline, actionable notification banner that surfaces a titled message with an optional recovery action notification banner message feedback actionable Surfacing a prominent, often actionable message…`,props:[`title: ReactNode`,`description?: ReactNode`,`variant?: 'info' | 'success' | 'warning' | 'error'`]},{name:`number-input`,kind:`component`,text:`Numeric input with stepper buttons, clamping, precision, and locale formatting form number input spinbutton stepper Collecting a bounded numeric value where increment/decrement by a known step is nat…`,props:[`label?: string`]},{name:`otp-input`,kind:`component`,text:`Segmented one-time code input form otp code input verification Entering a fixed-length one-time code (2FA, SMS verification, email confirmation) split across per-character slots`,props:[`value: string`,`onValueChange: (v: string) => void`]},{name:`overflow-menu`,kind:`component`,text:`Kebab icon button revealing a menu of row-level actions overlay menu actions kebab table Collapsing secondary row-level or item-level actions behind a kebab trigger in dense layouts like tables and l…`,props:[`items: { label: string; value?: string; id?: string; i…`,`label?: string`]},{name:`pagination`,kind:`component`,text:`Controls for navigating paged data sets, with page size selection pagination navigation table data pages Navigating between pages of a paged dataset`,props:[`page: number`,`pageSize: number`,`totalItems: number`,`onPageChange: (page: number) => void`]},{name:`password-input`,kind:`component`,text:`Password input with reveal toggle and optional strength meter form password input security Collecting a secret credential that should be masked by default with an opt-in reveal toggle`,props:[]},{name:`popover`,kind:`component`,text:`Anchored floating panel built on CSS Anchor Positioning + Popover API overlay floating anchor popover Showing rich, interactive content anchored to a trigger that the user must explicitly open by cli…`,props:[`children: React.ReactNode`]},{name:`progress`,kind:`component`,text:`Horizontal bar showing the completion progress of a tracked operation progress loading upload bar Tracked operations with a known total (file uploads, multi-step imports)`,props:[`label?: string`,`variant?: 'primary' | 'info' | 'success' | 'warning' | 'e…`]},{name:`progress-bar`,kind:`component`,text:`Shows determinate or indeterminate progress of a task progress loading status feedback Showing linear determinate progress of a task with a known percentage (value)`,props:[`label?: string`]},{name:`progress-circle`,kind:`component`,text:`Circular determinate progress indicator rendered as an SVG arc progress loading circle feedback Showing determinate progress compactly as a circular arc`,props:[`value: number`,`label?: string`]},{name:`progress-indicator`,kind:`component`,text:`Shows progress through the steps of a multi-step flow steps wizard stepper progress navigation Showing progress through the discrete steps of a multi-step flow (wizard, checkout)`,props:[`steps: { label: string; description?: string }[]`,`currentIndex: number`]},{name:`prompt-suggestions`,kind:`component`,text:`Starter prompts as a wrap of pill buttons — the "Try asking…" row of an empty AI chat ai chat prompts suggestions starters chips An empty conversation: offer a few concrete things to ask`,props:[`items: string[]`,`onSelect: (value: string) => void`]},{name:`prose`,kind:`component`,text:`Wrapper that styles raw descendant HTML — headings, lists, code, quotes, tables typography prose content markdown article Styling long-form authored content (articles, docs, CMS output)`,props:[]},{name:`pull-to-refresh`,kind:`component`,text:`Wraps a scrollable region and triggers a refresh when pulled down past a threshold at the top feedback pull-to-refresh mobile gesture scroll refresh A scrollable list or feed on touch devices that th…`,props:[`onRefresh: () => Promise<unknown> | unknown`,`children: React.ReactNode`]},{name:`qr-code`,kind:`component`,text:`Encodes a URL or short text into a scannable SVG QR code qr qr-code barcode encode display Letting users scan a URL, contact, or short token with a phone camera`,props:[`value: string`,`label?: string`]},{name:`radial-progress`,kind:`component`,text:`Circular progress indicator using conic-gradient, with percentage label and variant colors progress circular gauge meter kpi dashboard Dashboard KPI metrics showing completion percentage`,props:[`value: number`,`label?: string`,`variant?: 'primary' | 'info' | 'success' | 'warning' | 'e…`]},{name:`radio`,kind:`component`,text:`Single choice from a set, grouped with RadioGroup form choice group Choosing exactly one option from a small, mutually exclusive set (roughly 2–6) where all options should stay visible`,props:[`value: string`,`label?: string`]},{name:`radio-card`,kind:`component`,text:`Selectable card backed by a native radio input. Use RadioCardGroup for single-select groups. radio card selectable form Single-select from a few options where each choice needs a title plus supportin…`,props:[`value: string`,`title: ReactNode`,`description?: ReactNode`]},{name:`rating-group`,kind:`component`,text:`Star rating input with accessible radio group pattern form rating stars input feedback Capturing a discrete subjective rating on a small fixed scale (e.g. 1–5 stars)`,props:[`value: number`]},{name:`reasoning`,kind:`component`,text:`Collapsible panel for a model’s reasoning — opens and shimmers "Thinking…" while it streams, then settles to "Thought for N seconds" ai reasoning thinking chain-of-thought disclosure collapsible Show…`,props:[`children: ReactNode`,`label?: ReactNode`]},{name:`relative-time`,kind:`component`,text:`Displays a date as a localized phrase relative to now, auto-updating time date relative i18n display Showing how long ago something happened in human terms ("3 minutes ago")`,props:[`date: Date | number | string`]},{name:`reorder-list`,kind:`component`,text:`List whose rows can be reordered by pointer drag or entirely by keyboard inputs reorder sortable drag list mobile keyboard A short, user-owned ordering such as playlist tracks, form fields, or dashbo…`,props:[`value: ReorderItem[]`,`onValueChange: (value: ReorderItem[]) => void`]},{name:`resizable`,kind:`component`,text:`Two-pane splitter whose divider can be dragged or keyboard-nudged to reallocate space splitter panes layout resize divider Letting users reallocate space between two adjacent regions, e.g. an editor…`,props:[`children: ReactNode`,`label?: string`]},{name:`scroll-area`,kind:`component`,text:`A scroll container with styled, slim scrollbars and overflow shadows scroll overflow scrollbar container layout Constraining a region to a fixed height/width with overflow scrolling`,props:[]},{name:`search`,kind:`component`,text:`Search input with debounced search callback and clear button search input filter form A query field that filters or searches content, with a built-in clear button and debounced onSearch`,props:[`label?: string`]},{name:`section/cta`,kind:`section`,text:`Call-to-action band — quiet hairline-bordered section with title, description, and centered actions. Replace demo content before shipping. section cta marketing A call-to-action band with title, desc…`,props:[`title: ReactNode`,`description?: ReactNode`]},{name:`section/feature-grid`,kind:`section`,text:`Feature section — AutoGrid of items with optional title, description, and icon slots. Icons are optional; the grid works text-only. Replace demo content before shipping. section features grid A featu…`,props:[`items: FeatureItem[]`,`title?: ReactNode`,`description?: ReactNode`]},{name:`section/hero`,kind:`section`,text:`Page hero section — centered or split layout with eyebrow, title, description, actions and media slots. Replace demo content before shipping. section hero marketing The primary page intro with eyebro…`,props:[`title: ReactNode`,`variant?: "centered" | "split"`,`description?: ReactNode`]},{name:`section/media-masonry`,kind:`section`,text:`Masonry gallery section — native CSS masonry where supported, multi-column fallback elsewhere (fallback orders tiles top-to-bottom per column). Tiles style themselves; section provides only the layou…`,props:[`children: ReactNode`,`title?: ReactNode`,`description?: ReactNode`]},{name:`section/page-footer`,kind:`section`,text:`Site footer — AutoGrid of link groups with a brand/meta bottom row. Renders a <footer> element with a <nav aria-label="Footer"> wrapping the link columns. section footer navigation A site footer with…`,props:[`groups: FooterGroup[]`]},{name:`section/stats-band`,kind:`section`,text:`KPI strip — horizontal band of stats with optional delta and inline sparkline trend. Wraps via AutoGrid on narrow containers. No visible heading; provide aria-label for accessibility. section stats k…`,props:[`stats: StatItem[]`,`label?: string`]},{name:`segmented-control`,kind:`component`,text:`Mutually exclusive toggle group form toggle group segmented input A compact inline single choice among a few mutually exclusive options (2–5) such as view modes or time ranges`,props:[`options: SegmentedControlOption[]`,`value: string`,`onValueChange: (v: string) => void`,`label?: string`]},{name:`select`,kind:`component`,text:`Native select menu styled to match the design system form dropdown menu Choosing exactly one value from a known, finite list inside a form`,props:[`options: { value: string; label: string; disabled?: bool…`,`label?: string`]},{name:`separator`,kind:`component`,text:`Visual or semantic divider between content divider rule layout Dividing groups of content within a section or menu`,props:[]},{name:`share-menu`,kind:`component`,text:`A Share button opening intent links for Bluesky, Mastodon, Threads, LinkedIn and X, plus copy link and the system share sheet share social bluesky mastodon threads linkedin popover link Letting reade…`,props:[`url: string`,`items?: Array<'bluesky' | 'mastodon' | 'threads' | 'lin…`]},{name:`sheet`,kind:`component`,text:`Slide-in panel from any edge, using popover=manual and @starting-style animations overlay drawer panel slide Showing secondary content or a form in a panel that slides in from a screen edge`,props:[`open: boolean`,`onClose: () => void`,`title?: React.ReactNode`]},{name:`shell-header`,kind:`component`,text:`Console application header: brand with prefix, dropdown nav menus, global icon actions, hamburger, skip-to-content navigation header shell console menu app-shell Building console/admin app chrome wit…`,props:[]},{name:`shimmer-text`,kind:`component`,text:`Text with a bright band sweeping through it — the "Thinking…" look for a label that marks work in progress ai loading shimmer thinking text progress Styling a short label that names work in progress…`,props:[]},{name:`side-nav`,kind:`component`,text:`Collapsible sidebar navigation with optional icons and one level of grouping navigation sidebar app-shell collapsible Persistent primary navigation along the side of an app shell`,props:[`items?: SideNavItem[]`,`label?: string`]},{name:`skeleton`,kind:`component`,text:`Animated loading placeholder that mirrors the shape of pending content loading placeholder shimmer ai Indicating loading by mirroring the shape of the content that will appear`,props:[`variant?: 'text' | 'circle' | 'rect'`]},{name:`skip-nav`,kind:`component`,text:`Skip link that jumps keyboard users past the navigation to the main content accessibility skip-link keyboard navigation Letting keyboard users jump past repeated navigation to the main content`,props:[]},{name:`slider`,kind:`component`,text:`Range input for selecting a value within bounds form range input Selecting a value within a continuous or stepped numeric range where approximate adjustment is fine`,props:[`label?: string`]},{name:`sources`,kind:`component`,text:`Collapsible, numbered list of the sources an AI answer drew on — "Used 3 sources" — whose numbers match InlineCitation ai sources citations references provenance links Listing what an AI answer was b…`,props:[`items: AiSource[]`]},{name:`spinner`,kind:`component`,text:`Indeterminate loading indicator loading progress feedback Indicating indeterminate work where duration and progress are unknown`,props:[`label?: string`]},{name:`stack`,kind:`component`,text:`Overlaps children in a CSS grid stack with a configurable offset to create a card-pile effect stack pile overlap layered z-axis card-pile layout Card pile UI where depth and layering should be visible`,props:[`children: React.ReactNode`]},{name:`stat`,kind:`component`,text:`Displays a key metric with optional delta, trend direction and help text stat kpi metric number Highlighting a single key metric with a clear label`,props:[`label: string`,`value: string | number`]},{name:`status`,kind:`component`,text:`Colored dot with a label communicating the state of a system or entity status indicator dot badge Communicating the live state of a system or entity (operational, deploying, down)`,props:[]},{name:`steps`,kind:`component`,text:`Visual progress indicator for multi-step flows with horizontal and vertical orientations steps wizard stepper progress navigation onboarding checkout Checkout flows where the user moves through a fix…`,props:[`label?: string`,`items?: Step[]`]},{name:`streaming-text`,kind:`component`,text:`Reveals text character by character with a blinking cursor, catching up as a streamed reply grows ai streaming typewriter text chat Rendering an assistant reply as it streams in, smoothing bursty tok…`,props:[`text: string`]},{name:`structured-list`,kind:`component`,text:`Tabular row list for scannable data, optionally single-selectable display list table data Presenting a set of related records in aligned columns the user scans top to bottom`,props:[`items: { id: string; cells: ReactNode[]; selected?: bo…`,`label?: string`]},{name:`swap`,kind:`component`,text:`Animated toggle between two icon/content states with rotate or flip transition toggle icon animate switch flip rotate Theme toggles where an icon animates between two states (sun/moon)`,props:[`on: React.ReactNode`,`off: React.ReactNode`,`label?: string`]},{name:`swipe-item`,kind:`component`,text:`List row whose leading/trailing actions are revealed by a horizontal swipe, with keyboard parity display swipe list mobile gesture actions List rows on touch surfaces where secondary actions (archive…`,props:[`children: React.ReactNode`]},{name:`switcher`,kind:`component`,text:`Always-visible app/product switcher LIST — every entry is rendered at once, it does not collapse. Lives inside HeaderPanel; renders links with an active indicator and optional dividers. For a collaps…`,props:[`items: SwitcherEntry[]`,`label?: string`]},{name:`tabs`,kind:`component`,text:`Switch between related panels of content navigation tabs sections Switching between peer panels of related content in the same context`,props:[`children: ReactNode`]},{name:`tag`,kind:`component`,text:`Compact chip for labeling, categorizing, or filtering content chip label filter category Labeling, categorizing, or filtering content with a compact chip`,props:[`variant?: 'default' | 'info' | 'success' | 'warning' | 'e…`]},{name:`tags-input`,kind:`component`,text:`Free-form multi-value chip input form tags chips multi input Collecting an open-ended set of free-text values the user types themselves (keywords, emails, labels)`,props:[`value: string[]`,`onValueChange: (v: string[]) => void`,`label?: string`]},{name:`terminal`,kind:`component`,text:`An animated terminal that types out a script of commands and output — for demos, onboarding and agent transcripts ai terminal cli demo typewriter agent transcript Demonstrating a CLI or agent run on…`,props:[`lines: TerminalLine[]`]},{name:`text`,kind:`component`,text:`Body text with size, weight, and muted variants typography text paragraph body Rendering body copy, paragraphs, and inline text in app UI`,props:[]},{name:`textarea`,kind:`component`,text:`Multi-line text input with optional label, hint, and error state form text multiline ai Capturing multi-line free text such as messages, descriptions, or comments`,props:[`label?: string`,`rows?: number`]},{name:`tile`,kind:`component`,text:`A selectable card with radio (single) or checkbox (multi) semantics, toggled by click or keyboard inputs tile card selectable choice A visually rich, clickable choice card in a single- or multi-selec…`,props:[`value: string`]},{name:`time-picker`,kind:`component`,text:`Native time input wrapper with label, hint, error, and size variants time input form Capturing a time of day (HH:mm) in a form, such as a meeting or reminder time`,props:[`label?: string`]},{name:`timeline`,kind:`component`,text:`Ordered sequence of events with status markers and a connector line timeline steps history progress events Showing an ordered sequence of events over time (activity feeds, order tracking)`,props:[`items: { id: string; title: ReactNode; description?: R…`]},{name:`toast`,kind:`component`,text:`Transient notification surfaced via the useToast hook overlay notification feedback Confirming that a background or just-completed action succeeded or failed (e.g. "Saved")`,props:[`title: string`,`description?: string`,`variant?: 'default' | 'success' | 'warning' | 'destructiv…`]},{name:`toc`,kind:`component`,text:`Table of contents with scroll-spy highlighting of the active section toc table-of-contents navigation scroll-spy anchor Long-form pages (docs, articles) that benefit from in-page jump links`,props:[`items: { id: string; label: string; level?: number }[]`]},{name:`toggle`,kind:`component`,text:`On/off switch built as an accessible button switch form boolean Flipping a single binary setting that takes effect immediately (e.g. notifications on/off)`,props:[`label?: string`]},{name:`toggle-group`,kind:`component`,text:`A set of toggle buttons for single or multiple selection selection segmented toolbar choice Choosing one value from a small, mutually exclusive set that should stay visible (type="single")`,props:[`type: 'single' | 'multiple'`,`items: { value: string; label?: string; icon?: React.R…`]},{name:`toggletip`,kind:`component`,text:`A click-triggered info popover for supplementary, selectable content overlay toggletip info popover floating Revealing brief supplementary information on demand when the user clicks an info affordance`,props:[`trigger: ReactNode`,`children: ReactNode`]},{name:`tool-call`,kind:`component`,text:`Card for one AI tool invocation — the tool name, its lifecycle status, collapsible input/output, and approval actions ai agent tool function-call approval mcp status Showing an AI tool or function ca…`,props:[`name: string`,`status: 'pending' | 'running' | 'awaiting-approval' | '…`]},{name:`tooltip`,kind:`component`,text:`Contextual label shown on hover or focus overlay hint popover Labeling an icon-only control or clarifying a terse element on hover or focus`,props:[`content: ReactNode`,`children: ReactElement`]},{name:`tree-view`,kind:`component`,text:`Hierarchical, expandable tree of nodes with keyboard navigation and selection display tree hierarchy navigation files Showing nested, parent/child data the user expands and collapses (file trees, org…`,props:[`items: { id: string; label: ReactNode; icon?: ReactNod…`,`label?: string`]},{name:`typing-indicator`,kind:`component`,text:`Three bouncing dots that hold a chat message slot while an assistant (or a person) is composing a reply ai chat typing loading dots thinking Holding the place of an assistant reply between sending a…`,props:[`label?: string`]},{name:`user`,kind:`component`,text:`Identity composite: an avatar with a name, description, and optional action slot user avatar identity display Showing a person with their name and a secondary line (email, role) next to an avatar`,props:[`name: ReactNode`,`description?: ReactNode`]},{name:`virtual-list`,kind:`component`,text:`Renders only the rows inside the viewport, so list length costs no extra DOM display virtual virtualization list performance scroll Lists long enough that rendering every row costs noticeable time or…`,props:[`items: Item[]`,`itemHeight: number`,`height: number`,`renderItem: (item: Item, index: number) => React.ReactNode`,`label?: string`]},{name:`visually-hidden`,kind:`component`,text:`Hides content visually while keeping it available to screen readers accessibility screen-reader sr-only hidden Giving an icon-only control an accessible name without showing text`,props:[`children: ReactNode`]},{name:`wheel-picker`,kind:`component`,text:`iOS-style drum picker — a column of options that scrolls and snaps to a selection inputs picker wheel drum scroll-snap mobile ios Touch surfaces picking one value from a short, ordered, homogeneous r…`,props:[`options: WheelPickerOption[]`,`value: string`,`onValueChange: (value: string) => void`,`label?: string`]}],L=new Set(`a an and are as at be build by can create design for from has have i in into is it its make me my need of on or our page screen should show so some that the their this to ui use want we with you your one two three four five six`.split(` `));function tokenize(e){let t=[];for(let r of e.toLowerCase().split(/[^a-z0-9]+/))r.length<2||L.has(r)||t.push(r.length>3&&r.endsWith(`s`)&&!r.endsWith(`ss`)?r.slice(0,-1):r);return t}var R=1.2,z=.75;function bm25(e){let t=e.map(e=>{let t=/* @__PURE__ */ new Map;for(let r of e)t.set(r,(t.get(r)??0)+1);return t}),r=/* @__PURE__ */ new Map;for(let e of t)for(let t of e.keys())r.set(t,(r.get(t)??0)+1);let i=e.length,a=e.reduce((e,t)=>e+t.length,0)/Math.max(i,1)||1;return{has:(e,r)=>t[e]?.has(r)===!0,score(o,s){let c=t[o],l=e[o]?.length??0;if(!c)return 0;let u=0;for(let e of s){let t=c.get(e);if(t===void 0)continue;let o=r.get(e)??0,s=Math.log(1+(i-o+.5)/(o+.5));u+=s*t*2.2/(t+R*(.25+z*l/a))}return u}}}var B=8,V=12,H=bm25(m.map(e=>{let t=tokenize(e.keywords.join(` `));return[...t,...t,...t,...tokenize(`${e.title} ${e.description}`)]})),U=bm25(I.map(e=>tokenize(`${e.name} ${e.text}`))),W=new Map(I.map((e,t)=>[e.name,t])),ce=new Map(I.map(e=>[e.name,new Set(tokenize(e.name))])),G=new Map(Object.entries(F).map(([e,t])=>[e,new Set(tokenize(`${e} ${t.kw.join(` `)}`))]));function round(e){return Math.round(e*1e3)/1e3}function pickArchetype(e){let t=0,r=0;m.forEach((i,a)=>{let o=round(H.score(a,e));o>r&&(t=a,r=o)});let i=m[t];if(!i)throw Error(`@cascivo/design: the archetype catalogue is empty`);return{archetype:i,score:r}}function fragment(e){let t=F[e];if(!t)throw Error(`@cascivo/design: slot "${e}" has no fragment`);return t}function oneLine(e,t){let r=e.replace(/["\\]/g,``).replace(/\s+/g,` `).trim();return r.length<=t?r:`${r.slice(0,t-1).trimEnd()}…`}function renderCv(e,t){let{states:r}=t.rules,i=[`# plan: ${t.archetype} (score ${t.score}) — placeholder copy`,`# slots: content order only, not visual layout. Composition comes from DESIGN.md.`,`# layout: ${t.rules.layout}`,`# states: empty = ${r.empty} | loading = ${r.loading} | error = ${r.error}`,`# mobile: ${t.rules.mobile.join(`; `)}`,`# a11y: ${t.rules.a11y.join(`; `)}`,`# avoid: ${t.rules.antiPatterns.join(`; `)}`],a=t.components.filter(e=>e.slot===void 0).map(e=>e.name);a.length>0&&i.push(`# also consider: ${a.join(`, `)}`),t.blocks.length>0&&i.push(`# blocks: ${t.blocks.join(`, `)}`),t.unmatched.length>0&&i.push(`# unmatched: ${t.unmatched.join(`, `)}`),i.push(`@title "${oneLine(e,60)}"`);for(let e of t.slots)i.push(`# ${e}`,...fragment(e).cv);return`${i.join(`
7
+ `)}\n`}function renderView(e){let t=e.flatMap(e=>fragment(e).view);return`${JSON.stringify({version:1,view:{regions:{main:t}}})}\n`}function plan(e,t={}){let r=t.format??`cv`,i=[...new Set(tokenize(e))],{archetype:a,score:o}=pickArchetype(i),s=m.indexOf(a),c=a.slots.filter(e=>!e.optional||i.some(t=>G.get(e.id)?.has(t))).map(e=>e.id),l=[],u=/* @__PURE__ */ new Set,add=(e,t)=>{let r=W.get(e);if(r===void 0||u.has(e)||l.length>=B)return;u.add(e);let i=I[r]?.props??[];l.push(t===void 0?{name:e,props:i}:{name:e,slot:t,props:i})},d=a.slots.filter(e=>c.includes(e.id)),f=Math.max(0,...d.map(e=>e.allow.length));for(let e=0;e<f;e++)for(let t of d){let r=t.allow[e];r!==void 0&&add(r,t.id)}let explained=e=>H.has(s,e)||c.some(t=>G.get(t)?.has(e)),g=i.filter(e=>!explained(e)),named=(e,t)=>ce.get(e)?.has(t)===!0,_=I.map((e,t)=>({name:e.name,score:round(U.score(t,g))})).filter(e=>!u.has(e.name)&&g.some(t=>named(e.name,t))).sort((e,t)=>t.score-e.score||(e.name<t.name?-1:+(e.name>t.name))).slice(0,3);for(let e of _)add(e.name);let v=g.filter(e=>!l.some(t=>named(t.name,e))).slice(0,V),y={archetype:a.id,score:o,slots:c,components:l,blocks:a.blocks,unmatched:v,rules:{layout:a.layout,states:a.states,mobile:a.mobile,a11y:a.a11y,antiPatterns:a.antiPatterns}},b=r===`view`?renderView(c):renderCv(e,y);return{...y,format:r,output:b}}var le=1280;function fit(e,t){let r=Math.min(1,le/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function defaultPath(e,t){let r=d(`sha256`).update(`${e}\n${t}`).digest(`hex`).slice(0,12);return s(f(),`cascivo-design`,`see-${r}.png`)}var K=10,J=16,Y=8,more=e=>e>0?[` … ${e} more`]:[];function digest(e,t){let r=[`${e.title||`(untitled)`} — viewport ${e.viewport.width}×${e.viewport.height}, page ${e.page.width}×${e.page.height}`];r.push(`landmarks (x,y w×h):${e.landmarks.length===0?` none`:``}`);for(let t of e.landmarks.slice(0,K)){let e=t.label?` "${t.label}"`:``;r.push(` ${t.role}${e} ${t.box.x},${t.box.y} ${t.box.w}×${t.box.h}`)}r.push(...more(e.landmarks.length-K)),r.push(`headings:${e.headings.length===0?` none`:``}`);for(let t of e.headings.slice(0,J))r.push(` ${` `.repeat(Math.max(0,t.level-1))}h${t.level} ${t.text}`);r.push(...more(e.headings.length-J));let i=usesCascivo(e.scales),a=group(tokenRule(e.elements,i?pageScales(e.scales):t,i).map(({value:e,share:t,...r})=>r)).slice().sort((e,t)=>t.count-e.count);r.push(`off-scale (${i?`cascivo tokens`:`4px grid`}):${a.length===0?` none`:``}`);for(let e of a.slice(0,Y))r.push(` ${e.message}${e.count>1?` ×${e.count}`:``} → ${e.fix}`);return r.push(...more(a.length-Y)),r.slice(0,40).join(`
8
+ `)}async function see(e,r={}){let a=resolveTarget(e),s=r.width??1280,l=c(r.out??defaultPath(a,s)),u=await openSession(r.storageState===void 0?void 0:readStorageState(r.storageState));try{let r=await u.open(a,{width:s,height:800}),c=await r.evaluate(inPage,{names:scaleNames(loadTokens()),declared:null,overflow:null,targets:null,elements:!0,outline:!0,maxElements:2e3}),d=Math.min(c.page.height,1600),f=await r.screenshot({type:`png`,fullPage:!0,clip:{x:0,y:0,width:s,height:d}}),m=fit(s,d),g=Buffer.from(f);if(m.width!==s){let e=await(await u.blank()).evaluate(async e=>{let t=new Image;t.src=e.src,await t.decode();let r=document.createElement(`canvas`);r.width=e.width,r.height=e.height;let i=r.getContext(`2d`);return i?(i.imageSmoothingQuality=`high`,i.drawImage(t,0,0,e.width,e.height),r.toDataURL(`image/png`)):``},{src:`data:image/png;base64,${g.toString(`base64`)}`,...m}),t=e.slice(e.indexOf(`,`)+1);if(t===``)throw Error(`@cascivo/design: could not downscale the screenshot`);g=Buffer.from(t,`base64`)}return t(o(l),{recursive:!0}),i(l,g),{url:e,width:s,path:l,image:m,digest:digest(c,staticScales(loadTokens()))}}finally{await u.close()}}function accentScale(e){let t=e.baseMode===`light`,r=e.accentHue,i=e.accentChroma;return{accent:{l:t?.52:.65,c:i,h:r},hover:{l:t?.45:.707,c:i,h:r},active:{l:t?.373:.808,c:Math.min(i,.155),h:r},subtle:{l:t?.97:.623,c:.025,h:r},muted:{l:t?.932:.623,c:t?.055:i*.2,h:r}}}var X=[`--cascivo-color-background`,`--cascivo-color-surface`,`--cascivo-color-surface-2`],Z=[`--cascivo-color-foreground`,`--cascivo-color-foreground-muted`,`--cascivo-color-text-subtle`,`--cascivo-color-text-muted`,`--cascivo-color-accent-text`,`--cascivo-color-accent-text-hover`,`--cascivo-color-success-foreground`,`--cascivo-color-warning-foreground`,`--cascivo-color-destructive-foreground`,`--cascivo-color-info-foreground`],Q=[[`--cascivo-color-text-on-accent`,`--cascivo-color-accent`,`--cascivo-color-accent-hover`,`--cascivo-color-accent-active`],[`--cascivo-color-primary-fg`,`--cascivo-color-primary`,`--cascivo-color-primary-hover`,`--cascivo-color-primary-active`],[`--cascivo-color-text-on-destructive`,`--cascivo-color-destructive`,`--cascivo-color-destructive-hover`],[`--cascivo-color-info-content`,`--cascivo-color-info`],[`--cascivo-color-success-content`,`--cascivo-color-success`],[`--cascivo-color-warning-content`,`--cascivo-color-warning`],[`--cascivo-color-error-content`,`--cascivo-color-error`],[`--cascivo-color-secondary-content`,`--cascivo-color-secondary`,`--cascivo-color-secondary-hover`]],$=[[`--cascivo-color-success-foreground`,`--cascivo-color-success-subtle`],[`--cascivo-color-warning-foreground`,`--cascivo-color-warning-subtle`],[`--cascivo-color-destructive-foreground`,`--cascivo-color-destructive-subtle`],[`--cascivo-color-info-foreground`,`--cascivo-color-info-subtle`],[`--cascivo-color-accent-text`,`--cascivo-color-accent-subtle`]];[...Z.flatMap(e=>X.map(t=>[e,t])),...Q.flatMap(([e,...t])=>t.map(t=>[e,t])),...$];var isColor=e=>typeof e==`object`,ue=.25;function tokens(e,t,r){let i=e===`light`,n=(e,r)=>({l:e,c:r,h:t}),lch=(e,t,r)=>({l:e,c:t,h:r}),pick=(e,t)=>i?e:t,a=accentScale({baseMode:e,accentHue:t,accentChroma:r}),o=lch(1,0,0),s=n(.145,.005);return{"--cascivo-disabled-opacity":`0.5`,"--cascivo-hover-opacity":`0.8`,"--cascivo-font-display":`var(--cascivo-font-sans)`,"--cascivo-color-background":pick(o,n(.145,.005)),"--cascivo-color-surface":pick(n(.985,.002),n(.185,.007)),"--cascivo-color-surface-2":pick(n(.967,.003),n(.22,.008)),"--cascivo-color-bg":`var(--cascivo-color-background)`,"--cascivo-color-bg-subtle":`var(--cascivo-color-surface)`,"--cascivo-color-surface-raised":pick(`var(--cascivo-color-surface)`,`var(--cascivo-color-surface-2)`),"--cascivo-color-surface-overlay":pick(`var(--cascivo-color-background)`,`var(--cascivo-color-surface)`),"--cascivo-color-border":pick(n(.928,.006),n(.27,.008)),"--cascivo-color-border-strong":pick(n(.872,.008),n(.32,.01)),"--cascivo-border-subtle":pick(n(.928,.006),n(.24,.008)),"--cascivo-border-default":pick(n(.872,.008),n(.27,.008)),"--cascivo-border-strong":pick(n(.707,.015),n(.36,.012)),"--cascivo-color-foreground":pick(s,n(.985,.002)),"--cascivo-color-foreground-muted":pick(n(.5,.018),n(.707,.015)),"--cascivo-color-text":`var(--cascivo-color-foreground)`,"--cascivo-color-text-subtle":pick(n(.446,.018),n(.707,.015)),"--cascivo-color-text-muted":pick(n(.5,.016),n(.65,.016)),"--cascivo-color-text-on-accent":pick(o,s),"--cascivo-color-text-on-destructive":o,"--cascivo-color-accent":a.accent,"--cascivo-color-accent-foreground":`var(--cascivo-color-text-on-accent)`,"--cascivo-color-accent-hover":a.hover,"--cascivo-color-accent-active":a.active,"--cascivo-color-accent-subtle":pick(a.subtle,n(.25,Math.min(r,.04))),"--cascivo-color-accent-muted":pick(a.muted,n(.32,Math.min(r,.06))),"--cascivo-color-accent-text":a.accent,"--cascivo-color-accent-text-hover":a.hover,"--cascivo-color-primary":pick(lch(.205,0,0),lch(.922,0,0)),"--cascivo-color-primary-fg":pick(lch(.985,0,0),lch(.205,0,0)),"--cascivo-color-primary-hover":pick(lch(.27,0,0),lch(.86,0,0)),"--cascivo-color-primary-active":pick(lch(.32,0,0),lch(.8,0,0)),"--cascivo-color-active-bg":pick(`oklch(0.145 0.005 264 / 6%)`,`oklch(1 0 0 / 8%)`),"--cascivo-color-destructive":pick(lch(.54,.188,22),lch(.72,.16,22)),"--cascivo-color-destructive-hover":pick(lch(.448,.17,22),lch(.628,.188,22)),"--cascivo-color-destructive-subtle":pick(lch(.971,.013,22),lch(.25,.05,22)),"--cascivo-color-error":pick(lch(.628,.188,22),lch(.72,.16,22)),"--cascivo-color-warning":pick(lch(.768,.145,75),lch(.82,.13,75)),"--cascivo-color-success":pick(lch(.648,.15,145),lch(.72,.13,145)),"--cascivo-color-success-subtle":pick(lch(.982,.018,145),lch(.25,.04,145)),"--cascivo-color-warning-subtle":pick(lch(.98,.02,75),lch(.25,.04,75)),"--cascivo-color-info":pick(lch(.546,.224,250),lch(.65,.2,250)),"--cascivo-color-info-subtle":pick(lch(.97,.025,250),lch(.25,.05,250)),"--cascivo-color-success-foreground":pick(lch(.45,.14,145),lch(.72,.13,145)),"--cascivo-color-warning-foreground":pick(lch(.5,.14,75),lch(.82,.13,75)),"--cascivo-color-destructive-foreground":pick(lch(.448,.17,22),lch(.85,.12,22)),"--cascivo-color-info-foreground":pick(lch(.45,.19,250),lch(.75,.16,250)),"--cascivo-radius-base":`0.375rem`,"--cascivo-radius-control":`var(--cascivo-radius-base)`,"--cascivo-radius-field":`var(--cascivo-radius-base)`,"--cascivo-radius-item":`calc(var(--cascivo-radius-base) * 0.66)`,"--cascivo-radius-overlay":`calc(var(--cascivo-radius-base) * 2)`,"--cascivo-radius-surface":`calc(var(--cascivo-radius-base) * 1.66)`,"--cascivo-radius-indicator":`calc(var(--cascivo-radius-base) / 2)`,"--cascivo-radius-full":`9999px`,"--cascivo-radius-component":`var(--cascivo-radius-base)`,"--cascivo-radius-button":`var(--cascivo-radius-base)`,"--cascivo-radius-input":`var(--cascivo-radius-base)`,"--cascivo-radius-card":`calc(var(--cascivo-radius-base) * 1.66)`,"--cascivo-radius-badge":`var(--cascivo-radius-full)`,"--cascivo-radius-modal":`calc(var(--cascivo-radius-base) * 2)`,"--cascivo-shadow-xs":pick(`0 1px 2px oklch(0 0 0 / 0.05)`,`none`),"--cascivo-shadow-sm":pick(`0 1px 3px oklch(0 0 0 / 0.07), 0 1px 2px oklch(0 0 0 / 0.04)`,`0 1px 3px oklch(0 0 0 / 0.4)`),"--cascivo-shadow-md":pick(`0 2px 8px oklch(0 0 0 / 0.07), 0 1px 2px oklch(0 0 0 / 0.04)`,`0 2px 8px oklch(0 0 0 / 0.45)`),"--cascivo-shadow-overlay":pick(`0 4px 32px oklch(0 0 0 / 0.16), 0 0 0 1px oklch(0 0 0 / 0.04)`,`0 4px 32px oklch(0 0 0 / 0.6), 0 0 0 1px oklch(1 0 0 / 0.06)`),"--cascivo-shadow-lg":`var(--cascivo-shadow-overlay)`,"--cascivo-ring-width":`2px`,"--cascivo-ring-offset":`0px`,"--cascivo-ring-color":`color-mix(in oklch, var(--cascivo-color-accent) ${pick(55,65)}%, transparent)`,"--cascivo-color-focus-ring":n(pick(.623,.65),r),"--cascivo-focus-ring":`0 0 0 var(--cascivo-ring-width) var(--cascivo-ring-color)`,"--cascivo-chart-1":pick(lch(.62,.13,70),lch(.8,.13,70)),"--cascivo-chart-2":pick(lch(.62,.11,240),lch(.8,.11,240)),"--cascivo-chart-3":pick(lch(.6,.13,135),lch(.73,.13,165)),"--cascivo-chart-4":pick(lch(.6,.18,55),lch(.95,.15,100)),"--cascivo-chart-5":pick(lch(.5,.13,270),lch(.63,.12,250)),"--cascivo-chart-6":pick(lch(.58,.16,30),lch(.68,.15,40)),"--cascivo-chart-7":pick(lch(.62,.12,350),lch(.73,.11,350)),"--cascivo-chart-8":pick(lch(.5,.12,200),lch(.72,.08,200)),"--cascivo-chart-grid":`var(--cascivo-color-border)`,"--cascivo-chart-axis":`var(--cascivo-color-text-muted)`,"--cascivo-chart-fill-opacity":pick(`0.25`,`0.4`),"--cascivo-chart-fill-opacity-overlap":pick(`0.125`,`0.2`),"--cascivo-chart-bar-radius":`2px`,"--cascivo-color-primary-content":`var(--cascivo-color-primary-fg)`,"--cascivo-color-accent-content":`var(--cascivo-color-text-on-accent)`,"--cascivo-color-destructive-content":`var(--cascivo-color-text-on-destructive)`,"--cascivo-color-info-content":o,"--cascivo-color-success-content":o,"--cascivo-color-warning-content":s,"--cascivo-color-error-content":o,"--cascivo-color-secondary":pick(n(.92,.004),n(.27,.008)),"--cascivo-color-secondary-content":pick(n(.27,.01),n(.9,.004)),"--cascivo-color-secondary-hover":pick(n(.86,.006),n(.32,.01)),"--cascivo-color-secondary-subtle":pick(n(.967,.002),n(.22,.005))}}function tune(e,t){let color=t=>{let r=e[t];if(!isColor(r))throw Error(`@cascivo/design: ${t} is not a tunable colour`);return r},rgb=e=>oklchToDisplayRgb(color(e)),r={l:1,c:0,h:0},i={l:.145,c:.005,h:t};for(let[t,a,...o]of Q){let s=rgb(a),c=contrastRatio(oklchToDisplayRgb(r),s)>=contrastRatio(oklchToDisplayRgb(i),s)?r:i;e[t]=c;for(let t of[a,...o])e[t]=ensureContrast(color(t),oklchToDisplayRgb(c))}e[`--cascivo-color-accent-text`]=color(`--cascivo-color-accent`),e[`--cascivo-color-accent-text-hover`]=color(`--cascivo-color-accent-hover`);for(let[t,r]of[...Z.flatMap(e=>X.map(t=>[e,t])),...$])e[t]=ensureContrast(color(t),rgb(r));for(let t of Object.keys(e)){let r=e[t];isColor(r)&&(e[t]=fitGamut(r))}}function theme(e){let t=typeof e==`string`?{seed:e}:e,r=t.mode??`light`,i=t.name??`custom`;if(!/^[a-z][a-z0-9-]*$/.test(i))throw Error(`@cascivo/design: theme name must be kebab-case, got "${i}"`);let a;try{a=hexToRgb(t.seed)}catch{throw Error(`@cascivo/design: seed must be a hex colour like #0079bf, got "${t.seed}"`)}let o=srgbToOklch(a),s=Math.round(o.h*10)/10,c=tokens(r,s,Math.round(Math.min(o.c,ue)*1e3)/1e3);tune(c,s);let l=rgbToHex(a),u=Object.entries(c).map(([e,t])=>` ${e}: ${isColor(t)?formatOklch(t):t};`).join(`
9
+ `);return{seed:l,mode:r,name:i,css:[`/* cascivo theme "${i}" (${r}) from seed ${l}. Text pairs meet WCAG AA ${x}:1. */`,`/* Use: import after @cascivo/tokens, then set data-theme="${i}" on <html>. */`,`@layer cascivo.theme {`,` [data-theme='${i}'] {`,` color-scheme: ${r};`,u,` }`,`}`,``].join(`
10
+ `)}}export{catalogue,check,directionCss,formatCheck,init,parseDesignMd,plan,see,theme};
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
2
  "name": "@cascivo/design",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Deterministic UI planning and auditing for AI agents — plan a page from a brief, audit the rendered result. Docs offline: npx @cascivo/docs",
6
+ "keywords": [
7
+ "agent",
8
+ "ai",
9
+ "audit",
10
+ "cascivo",
11
+ "design",
12
+ "design-system",
13
+ "ui-planning"
14
+ ],
15
+ "homepage": "https://github.com/cascivo/cascivo/tree/main/packages/design#readme",
16
+ "bugs": "https://github.com/cascivo/cascivo/issues",
17
+ "license": "MIT",
18
+ "author": "urbanisierung",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/cascivo/cascivo.git",
22
+ "directory": "packages/design"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "type": "module",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ "./package.json": "./package.json",
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "default": "./dist/index.js"
35
+ }
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "provenance": true
40
+ },
41
+ "dependencies": {
42
+ "@cascivo/tokens": "^1.3.1",
43
+ "axe-core": "^4.11.4"
44
+ },
45
+ "devDependencies": {
46
+ "@cascivo/theme-kit": "0.0.0",
47
+ "@types/node": "^25",
48
+ "playwright": "^1.61.0",
49
+ "typescript": "^5",
50
+ "vite-plus": "^1.0.0"
51
+ },
52
+ "peerDependencies": {
53
+ "playwright": ">=1.40.0"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "playwright": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "scripts": {
61
+ "build": "vp build && node scripts/flatten-types.mjs && node scripts/check-types-flat.mjs",
62
+ "check": "tsc --noEmit",
63
+ "test": "vp test",
64
+ "dev": "vp pack --watch"
65
+ }
6
66
  }
package/readme.body.md ADDED
@@ -0,0 +1,117 @@
1
+ Deterministic UI planning and auditing for AI agents: turn a brief into a page plan, then audit what was
2
+ actually rendered. Same input, same output; no model in the loop.
3
+
4
+ > **Docs offline?** The full cascivo reference ships as an npm package — `npx -y @cascivo/docs`, no website needed.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ pnpm add @cascivo/design
10
+ ```
11
+
12
+ `check` and `see` drive a browser through [Playwright](https://playwright.dev), an optional peer. Install it
13
+ only if you use them:
14
+
15
+ ```sh
16
+ pnpm add -D playwright
17
+ ```
18
+
19
+ ## Modules
20
+
21
+ | Export | Does | CLI |
22
+ | ------------- | ---------------------------------------------- | ------------------------------- |
23
+ | `check()` | Audit a rendered page (URL or file) | `cascivo design check <target>` |
24
+ | `see()` | Small screenshot of a page plus a text digest | `cascivo design see <target>` |
25
+ | `plan()` | Turn a brief into a page plan (`cv` or `view`) | `cascivo design plan "<brief>"` |
26
+ | `catalogue()` | List the page archetypes `plan()` chooses from | (none) |
27
+ | `init()` | Write a `DESIGN.md` for the project | `cascivo design init` |
28
+ | `theme()` | Derive a theme from one seed colour | `cascivo design theme` |
29
+
30
+ ```ts
31
+ import { plan } from '@cascivo/design'
32
+
33
+ const page = plan('a pricing page with three tiers', { format: 'cv' })
34
+ ```
35
+
36
+ ## `check`: audit what was rendered
37
+
38
+ ```sh
39
+ cascivo design check http://localhost:5173/pricing # or ./out/page.html
40
+ ```
41
+
42
+ ```text
43
+ score 67/100 — mobile 50 · a11y 75 · contrast 75 · tokens 92 · hierarchy 43 — 5 errors, 5 warnings
44
+ error overflow div.wide — scrolls sideways at 320/360/390/414px (280px too wide at 320px) → let it shrink or wrap: min-inline-size: 0, max-inline-size: 100%, flex-wrap: wrap
45
+ error contrast div.wide > p.faint — 2.11:1, needs 4.5:1 (#aaaaaa on #f4f4f4) → color: #6f6f6f or stronger
46
+ warn token/spacing main > div.card ×4 — padding 13px is off the spacing scale → var(--cascivo-space-3) (12px)
47
+ ```
48
+
49
+ One line per finding: `level rule selector ×N — message → fix`. Findings with the same rule and fix are
50
+ merged. `--max N` caps the list (default 20), `--json` prints everything, and the exit code is 1 when any
51
+ finding is an `error`.
52
+
53
+ | Rule | Category | Checks |
54
+ | ---------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------ |
55
+ | `overflow` | mobile | No sideways scroll at 320, 360, 390 and 414px |
56
+ | `touch-target` | mobile | Interactive elements are 44×44px on a touch device (error under 24) |
57
+ | `axe/<id>` | a11y | axe-core, WCAG 2.2 AA |
58
+ | `contrast` | contrast | Computed text colour against its background, 4.5:1 (3:1 large) |
59
+ | `token/spacing`, `/font-size`, `/radius`, `/color` | tokens | Computed values sit on the page's cascivo scales; `auto` margins and fluid `clamp()` sizes are skipped |
60
+ | `scale/spacing`, `scale/colors` | tokens | A page without cascivo: 4px grid, at most 12 colours |
61
+ | `hierarchy/h1`, `/heading-order` | hierarchy | One `<h1>`, levels descend one step at a time |
62
+ | `hierarchy/body-text`, `/line-length`, `/font-sizes` | hierarchy | Running text ≥16px, lines ≤80ch, at most 6 font sizes |
63
+
64
+ A token rule is scored by the share of the values it measured that are off-scale. Each rule is one
65
+ finding listing every distinct off-scale value with its count (text shows the first eight; `--json`
66
+ has them all).
67
+
68
+ The run is deterministic: fixed viewports, reduced motion, animations off. Each category scores 0-100 and
69
+ the total is their weighted mean (weights in `src/check/score.ts`).
70
+
71
+ ### The project's own tokens
72
+
73
+ A value is on-scale when it matches a cascivo token, a custom property the page defines on
74
+ `:root`, or a token in the front matter of the project's `DESIGN.md` (`colors`, `spacing`,
75
+ `rounded`, `typography.*.fontSize`):
76
+
77
+ ```sh
78
+ cascivo design check ./out/page.html --design ./DESIGN.md # ./DESIGN.md is the default
79
+ ```
80
+
81
+ ```ts
82
+ await check('./out/page.html', { design: './DESIGN.md' })
83
+ ```
84
+
85
+ `init({ direction })` writes such tokens for a chosen look (colours, a display and a body font
86
+ stack, one signature element, one composition move) and returns the `:root` block that applies them:
87
+
88
+ ```sh
89
+ cascivo design init --accent "#b4532a" --font-display "Georgia, serif" \
90
+ --signature "a ruled double line under the title"
91
+ ```
92
+
93
+ ### Pages behind a login
94
+
95
+ `--storage-state auth.json` (library: `{ storageState: 'auth.json' }`, also on `see`) loads a
96
+ Playwright storage state into every browser context. Create it once with
97
+ `npx playwright codegen --save-storage=auth.json <url>`. Gitignore it: it holds live session
98
+ cookies. Screenshots and findings of a logged-in page go to the model, so prefer a mock or demo
99
+ mode for the improvement loop and use the live app for a final check.
100
+
101
+ ## `see`: look at the page cheaply
102
+
103
+ ```sh
104
+ cascivo design see http://localhost:5173/pricing --width 390
105
+ ```
106
+
107
+ Saves a PNG whose long edge is at most 1280px (about 1.3k vision tokens) and prints its path, then a digest
108
+ of at most 40 lines: landmarks with their boxes, the heading outline, and the most common off-scale values.
109
+
110
+ ## `theme`: one seed colour, a whole theme
111
+
112
+ ```sh
113
+ cascivo design theme --seed "#0079bf" --mode dark --name brand > brand.css
114
+ ```
115
+
116
+ Prints a stylesheet in `@layer cascivo.theme` that defines every semantic token the shipped themes define.
117
+ Lightness is adjusted until every text/surface pair passes WCAG AA, whatever the seed.