@steamfield/decks 0.0.0-stage → 1.0.0-rc.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.
Files changed (117) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +28 -2
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +5 -0
  5. package/dist/index-B2n69xrC.d.ts +75 -0
  6. package/dist/index-BURtH7IB.d.ts +182 -0
  7. package/dist/index-BV_-6L5L.d.ts +136 -0
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.js +6 -0
  10. package/dist/kit/chrome/od-byline.css +7 -0
  11. package/dist/kit/chrome/od-cover-head.css +10 -0
  12. package/dist/kit/chrome/od-eyebrow.css +13 -0
  13. package/dist/kit/chrome/od-logo.css +167 -0
  14. package/dist/kit/chrome/od-qr-card.css +30 -0
  15. package/dist/kit/ink/code-ink.css +83 -0
  16. package/dist/kit/ink/graph-3d.css +29 -0
  17. package/dist/kit/ink/ink-bars.css +7 -0
  18. package/dist/kit/ink/ink-card-rect.css +6 -0
  19. package/dist/kit/ink/ink-chip.css +62 -0
  20. package/dist/kit/ink/ink-line.css +7 -0
  21. package/dist/kit/ink/ink-number.css +22 -0
  22. package/dist/kit/ink/ink-ping.css +4 -0
  23. package/dist/kit/ink/ink-rule.css +4 -0
  24. package/dist/kit/ink/ink-timeline-cursor.css +3 -0
  25. package/dist/kit/ink/ink-timeline.css +9 -0
  26. package/dist/kit/ink/underline.css +12 -0
  27. package/dist/kit/ink/unit-grid.css +3 -0
  28. package/dist/kit/story/story-card.css +19 -0
  29. package/dist/kit/story/story-link.css +13 -0
  30. package/dist/kit/story/story-stage.css +59 -0
  31. package/dist/kit/styles/base.css +82 -0
  32. package/dist/kit/styles/compat.css +78 -0
  33. package/dist/kit/styles/components.css +224 -0
  34. package/dist/kit/styles/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  35. package/dist/kit/styles/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
  36. package/dist/kit/styles/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
  37. package/dist/kit/styles/fonts/inter-greek-wght-normal.woff2 +0 -0
  38. package/dist/kit/styles/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  39. package/dist/kit/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
  40. package/dist/kit/styles/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
  41. package/dist/kit/styles/fonts.css +73 -0
  42. package/dist/kit/styles/index.css +36 -0
  43. package/dist/kit/styles/layout.css +181 -0
  44. package/dist/kit/styles/stats.css +92 -0
  45. package/dist/kit/styles/story-frame.css +179 -0
  46. package/dist/kit/styles/story-marks.css +115 -0
  47. package/dist/kit/styles/story-transition.css +182 -0
  48. package/dist/kit/styles.css +1 -0
  49. package/dist/kit.d.ts +880 -0
  50. package/dist/kit.js +3475 -0
  51. package/dist/layers.css +60 -0
  52. package/dist/layouts.css +58 -0
  53. package/dist/lint/ai-rhetoric-patterns.tsv +110 -0
  54. package/dist/lint/deck-writing-reminder.md +9 -0
  55. package/dist/motion.css +215 -0
  56. package/dist/motion.d.ts +2 -0
  57. package/dist/motion.js +1 -0
  58. package/dist/node.d.ts +63 -0
  59. package/dist/node.js +1 -0
  60. package/dist/overview-view.css +58 -0
  61. package/dist/play-view.css +29 -0
  62. package/dist/plugin/skills/building-a-deck/SKILL.md +22 -0
  63. package/dist/plugin/skills/building-a-deck/references/workflow.md +86 -0
  64. package/dist/plugin/skills/deck-data/SKILL.md +27 -0
  65. package/dist/plugin/skills/deck-data/references/fact-check.md +59 -0
  66. package/dist/plugin/skills/deck-data/references/provenance.md +61 -0
  67. package/dist/plugin/skills/deck-design/SKILL.md +31 -0
  68. package/dist/plugin/skills/deck-design/references/layout.md +55 -0
  69. package/dist/plugin/skills/deck-motion/SKILL.md +34 -0
  70. package/dist/plugin/skills/deck-motion/references/motion.md +66 -0
  71. package/dist/plugin/skills/visualization/SKILL.md +34 -0
  72. package/dist/plugin/skills/visualization/references/VENDORED.md +25 -0
  73. package/dist/plugin/skills/visualization/references/annotations.md +27 -0
  74. package/dist/plugin/skills/visualization/references/chart-selection.md +29 -0
  75. package/dist/plugin/skills/visualization/references/color-strategy.md +22 -0
  76. package/dist/plugin/skills/visualization/references/encoding-channels.md +44 -0
  77. package/dist/plugin/skills/visualization/references/ink.md +38 -0
  78. package/dist/plugin/skills/visualization/references/marks.md +33 -0
  79. package/dist/plugin/skills/visualization/references/presentation.md +43 -0
  80. package/dist/plugin/skills/working-with-decks/SKILL.md +34 -0
  81. package/dist/plugin/skills/working-with-decks/references/project.md +59 -0
  82. package/dist/plugin/skills/writing-slides/SKILL.md +45 -0
  83. package/dist/plugin/skills/writing-slides/references/lint.md +11 -0
  84. package/dist/plugin/skills/writing-slides/references/prose-patterns.md +48 -0
  85. package/dist/presenter-view.css +113 -0
  86. package/dist/print-view.module.css +32 -0
  87. package/dist/prose-patterns-DPqjGBFu.js +76 -0
  88. package/dist/prose-scan-BrWZ7gxZ.js +233 -0
  89. package/dist/src-C-OfT72W.js +396 -0
  90. package/dist/src-CmQgaG1b.js +2469 -0
  91. package/dist/src-DizFoqYt.js +1508 -0
  92. package/dist/templates/conventional/deck.config.ts +7 -0
  93. package/dist/templates/conventional/setup.ts +3 -0
  94. package/dist/templates/conventional/slides/01-cover.mdx +9 -0
  95. package/dist/templates/conventional/slides/02-first-point.mdx +12 -0
  96. package/dist/templates/conventional/styles/index.css +1 -0
  97. package/dist/templates/story/components/FirstStage.tsx +34 -0
  98. package/dist/templates/story/data/01-first.ts +8 -0
  99. package/dist/templates/story/data-sources.md +7 -0
  100. package/dist/templates/story/deck.config.ts +8 -0
  101. package/dist/templates/story/setup.ts +3 -0
  102. package/dist/templates/story/slides/01-cover.mdx +9 -0
  103. package/dist/templates/story/slides/02-first-point.mdx +6 -0
  104. package/dist/templates/story/styles/index.css +1 -0
  105. package/dist/transition.css +87 -0
  106. package/docs/README.md +28 -0
  107. package/docs/canvas.md +134 -0
  108. package/docs/cli.md +49 -0
  109. package/docs/code-blocks.md +132 -0
  110. package/docs/config.md +183 -0
  111. package/docs/getting-started.md +204 -0
  112. package/docs/kit.md +371 -0
  113. package/docs/migrating-from-slidev.md +45 -0
  114. package/docs/motion.md +396 -0
  115. package/docs/presenting.md +99 -0
  116. package/docs/slides.md +246 -0
  117. package/package.json +108 -4
package/dist/kit.js ADDED
@@ -0,0 +1,3475 @@
1
+ import { c as motionMode, i as useTween, o as ease, s as gsap, t as useTimeline } from "./src-C-OfT72W.js";
2
+ import { b as useSlideScale, g as registerSettleProbe, u as registerCaptionProvider, y as useSlide } from "./src-DizFoqYt.js";
3
+ import { useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { CustomEase } from "gsap/CustomEase";
6
+ import { encode } from "uqr";
7
+ import { scaleLinear } from "d3-scale";
8
+ import { Chart, Graph, compileGraph } from "@opendata-ai/openchart-react";
9
+ import "@opendata-ai/openchart-react/styles.css";
10
+ import { FLUID_SPRING, springDuration } from "@opendata-ai/openchart-core";
11
+ // \0rolldown/runtime.js
12
+ var __defProp = Object.defineProperty;
13
+ var __exportAll = (all, flags) => {
14
+ let target = Object.setPrototypeOf({}, null);
15
+ for (var name in all) __defProp(target, name, {
16
+ get: all[name],
17
+ enumerable: true
18
+ });
19
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
20
+ return flags & 2 ? target : Object.preventExtensions(target);
21
+ };
22
+ // ../kit/src/chrome/od-byline.tsx
23
+ function OdByline({ children, className = "" }) {
24
+ return /* @__PURE__ */ jsx("div", {
25
+ className: `od-mono od-byline ${className}`,
26
+ children
27
+ });
28
+ }
29
+ // ../kit/src/theme/theme-default.json
30
+ var theme_default_default = {
31
+ surfaces: {
32
+ "canvas": "#09090b",
33
+ "canvas-cover": "#08090a",
34
+ "surface": "#111113",
35
+ "surface-raised": "#18181b",
36
+ "muted": "#27272a"
37
+ },
38
+ text: {
39
+ "primary": "#f7f8f8",
40
+ "secondary": "#d0d6e0",
41
+ "muted": "#a1a1aa",
42
+ "faint": "#71717a",
43
+ "dim": "#52525b",
44
+ "highlight": "#ffffff"
45
+ },
46
+ borders: {
47
+ "default": "rgba(255, 255, 255, 0.08)",
48
+ "subtle": "rgba(255, 255, 255, 0.05)",
49
+ "rule": "rgba(255, 255, 255, 0.06)",
50
+ "axis": "rgba(255, 255, 255, 0.12)"
51
+ },
52
+ ramps: {
53
+ "cyan": [
54
+ "#0e7490",
55
+ "#06b6d4",
56
+ "#22d3ee",
57
+ "#67e8f9"
58
+ ],
59
+ "amber": [
60
+ "#d97706",
61
+ "#f59e0b",
62
+ "#fbbf24",
63
+ "#fcd34d"
64
+ ],
65
+ "rose": [
66
+ "#e11d48",
67
+ "#f43f5e",
68
+ "#fb7185",
69
+ "#fda4af"
70
+ ],
71
+ "emerald": [
72
+ "#059669",
73
+ "#10b981",
74
+ "#34d399",
75
+ "#6ee7b7"
76
+ ],
77
+ "violet": [
78
+ "#7c3aed",
79
+ "#8b5cf6",
80
+ "#a78bfa",
81
+ "#c4b5fd"
82
+ ],
83
+ "slate": [
84
+ "#64748b",
85
+ "#94a3b8",
86
+ "#cbd5e1",
87
+ "#e2e8f0"
88
+ ]
89
+ },
90
+ accents: {
91
+ "cyan": "{ramps.cyan.2}",
92
+ "cyan-bright": "{ramps.cyan.3}",
93
+ "cyan-soft": "{ramps.cyan.4}",
94
+ "blue": "#3b82f6",
95
+ "blue-soft": "#60a5fa",
96
+ "violet": "{ramps.violet.3}",
97
+ "violet-dim": "{ramps.violet.2}",
98
+ "emerald": "{ramps.emerald.3}",
99
+ "amber": "{ramps.amber.2}",
100
+ "amber-soft": "{ramps.amber.3}",
101
+ "rose": "{ramps.rose.3}",
102
+ "pink": "#f472b6",
103
+ "slate": "{ramps.slate.2}"
104
+ },
105
+ glows: {
106
+ "primary": "{accents.cyan}",
107
+ "secondary": "{accents.blue}",
108
+ "amber": "{accents.amber}",
109
+ "violet": "{accents.violet-dim}",
110
+ "emerald": "{accents.emerald}",
111
+ "rose": "{ramps.rose.1}"
112
+ },
113
+ categorical: [
114
+ "#58a6ff",
115
+ "#3fb950",
116
+ "#d29922",
117
+ "#bc8cff",
118
+ "#f47067",
119
+ "#39d2c0",
120
+ "#f0883e",
121
+ "#a5d6ff",
122
+ "#8b949e",
123
+ "#f778ba",
124
+ "#7ee787",
125
+ "#d2a8ff"
126
+ ],
127
+ fonts: {
128
+ "sans": "Inter, sans-serif",
129
+ "serif": "{fonts.sans}",
130
+ "mono": "{fonts.sans}"
131
+ },
132
+ shape: {
133
+ "radius": "12px",
134
+ "hairline": "1px",
135
+ "card-width": "36",
136
+ "dim": "0.4"
137
+ },
138
+ chart: {
139
+ "text": "{text.muted}",
140
+ "gridline": "{borders.subtle}",
141
+ "axis": "{borders.axis}",
142
+ "eyebrow": "{accents.cyan}",
143
+ "title": "{text.primary}",
144
+ "subtitle": "{text.muted}",
145
+ "source": "{text.faint}",
146
+ "graph-label": "#e0e0e0"
147
+ },
148
+ "qr-white": "#fff",
149
+ brand: {
150
+ "name": "Decks",
151
+ "url": null,
152
+ "wordmark-gradient": "linear-gradient(95deg, #7dd3fc 0%, #38bdf8 45%, #3b82f6 100%)",
153
+ "logo": null
154
+ }
155
+ };
156
+ // ../kit/src/theme/theme-resolve.ts
157
+ /**
158
+ * Theme resolution: merge a deck's `theme.json` over `default.json`, resolve
159
+ * `{path.to.token}` aliases, validate, and render the CSS custom properties.
160
+ *
161
+ * Pure functions with no Node or Vite imports, so the Vite plugin in
162
+ * `vite.config.mts`, `default.ts` and the tests all share one code path.
163
+ */
164
+ const HUE_NAMES = [
165
+ "cyan",
166
+ "amber",
167
+ "rose",
168
+ "emerald",
169
+ "violet",
170
+ "slate"
171
+ ];
172
+ function isObject(v) {
173
+ return typeof v === "object" && v !== null && !Array.isArray(v);
174
+ }
175
+ /** Objects merge key by key; arrays and scalars in `over` replace `base`. */
176
+ function deepMerge(base, over) {
177
+ if (!isObject(base) || !isObject(over)) return over === void 0 ? base : over;
178
+ const out = { ...base };
179
+ for (const [k, v] of Object.entries(over)) out[k] = k in base ? deepMerge(base[k], v) : v;
180
+ return out;
181
+ }
182
+ const ALIAS = /\{([\w.-]+)\}/g;
183
+ /**
184
+ * Resolve `{group.token}` aliases (the W3C design-token alias form) anywhere
185
+ * in a string value. A numeric segment into a ramp is the 1-based ink step,
186
+ * so `{ramps.cyan.2}` is the same color as `ink('cyan', 2)`.
187
+ */
188
+ function resolveAliases(raw) {
189
+ const lookup = (path, seen) => {
190
+ if (seen.includes(path)) throw new Error(`theme: alias cycle ${[...seen, path].join(" -> ")}`);
191
+ let node = raw;
192
+ for (const seg of path.split(".")) {
193
+ if (Array.isArray(node)) node = node[Number(seg) - 1];
194
+ else if (isObject(node)) node = node[seg];
195
+ else node = void 0;
196
+ if (node === void 0) throw new Error(`theme: unknown alias {${path}}`);
197
+ }
198
+ if (typeof node !== "string") throw new Error(`theme: alias {${path}} is not a string`);
199
+ return expand(node, [...seen, path]);
200
+ };
201
+ const expand = (s, seen) => s.replace(ALIAS, (_, path) => lookup(path, seen));
202
+ const walk = (v) => {
203
+ if (typeof v === "string") return expand(v, []);
204
+ if (Array.isArray(v)) return v.map(walk);
205
+ if (isObject(v)) return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, walk(x)]));
206
+ return v;
207
+ };
208
+ return walk(raw);
209
+ }
210
+ const HEX = /^#[0-9a-f]{6}$/i;
211
+ /** Shape keys are emitted as root `--od-<key>` vars, so an unknown one could shadow a color token. */
212
+ const SHAPE_KEYS = [
213
+ "radius",
214
+ "hairline",
215
+ "card-width",
216
+ "dim"
217
+ ];
218
+ const CSS_LENGTH = /^(?:0|\d*\.?\d+(?:px|r?em|%|vw|vh|vmin|vmax|pt|ch|ex))$/;
219
+ /** Throws on a theme the components cannot render: missing hues, bad ramps, non-hex glows, unknown or malformed shape keys. */
220
+ function validateTheme(t) {
221
+ for (const hue of HUE_NAMES) {
222
+ const ramp = t.ramps?.[hue];
223
+ if (!Array.isArray(ramp) || ramp.length !== 4 || !ramp.every((c) => HEX.test(c))) throw new Error(`theme: ramps.${hue} must be four #rrggbb colors`);
224
+ }
225
+ if (!HEX.test(t.surfaces.canvas)) throw new Error("theme: surfaces.canvas must be #rrggbb");
226
+ for (const [k, v] of Object.entries(t.glows)) if (!HEX.test(v)) throw new Error(`theme: glows.${k} must be #rrggbb (it is used as an rgb triplet)`);
227
+ if (!Array.isArray(t.categorical) || t.categorical.length === 0) throw new Error("theme: categorical must be a non-empty array");
228
+ for (const k of Object.keys(t.shape ?? {})) if (!SHAPE_KEYS.includes(k)) throw new Error(`theme: shape.${k} is not a shape key (expected one of ${SHAPE_KEYS.join(", ")})`);
229
+ for (const k of ["radius", "hairline"]) if (!CSS_LENGTH.test(String(t.shape?.[k]))) throw new Error(`theme: shape.${k} must be a CSS length, e.g. "12px"`);
230
+ for (const k of ["card-width", "dim"]) if (!/^\d*\.?\d+$/.test(String(t.shape?.[k]))) throw new Error(`theme: shape.${k} must be a unitless number as a string, e.g. "0.4"`);
231
+ return t;
232
+ }
233
+ /** `default` merged with an optional override, aliases resolved, validated. */
234
+ function resolveTheme$1(defaults, override) {
235
+ return validateTheme(resolveAliases(override === void 0 ? defaults : deepMerge(defaults, override)));
236
+ }
237
+ function rgbTriplet(hex) {
238
+ const h = hex.slice(1);
239
+ return [
240
+ 0,
241
+ 2,
242
+ 4
243
+ ].map((i) => parseInt(h.slice(i, i + 2), 16)).join(", ");
244
+ }
245
+ /**
246
+ * The `:root` custom properties for a resolved theme. Ramps, the categorical
247
+ * palette, chart colors and brand text are read from JS (`#decks/theme`), not
248
+ * from CSS, so they are not emitted here.
249
+ */
250
+ function themeCss(t) {
251
+ const vars = [];
252
+ for (const [k, v] of Object.entries(t.surfaces)) vars.push([k, v]);
253
+ for (const [k, v] of Object.entries(t.text)) vars.push([k === "primary" ? "text" : `text-${k}`, v]);
254
+ for (const [k, v] of Object.entries(t.accents)) vars.push([k, v]);
255
+ for (const [k, v] of Object.entries(t.borders)) vars.push([k === "default" ? "border" : `border-${k}`, v]);
256
+ for (const [k, v] of Object.entries(t.glows)) vars.push([`glow-${k}-rgb`, rgbTriplet(v)]);
257
+ for (const [k, v] of Object.entries(t.fonts)) vars.push([`font-${k}`, v]);
258
+ for (const [k, v] of Object.entries(t.shape)) vars.push([k, v]);
259
+ vars.push(["qr-white", t["qr-white"]]);
260
+ vars.push(["wordmark-gradient", t.brand["wordmark-gradient"]]);
261
+ const lines = vars.map(([k, v]) => ` --od-${k}: ${v};`);
262
+ lines.push(" --slidev-theme-background: var(--od-canvas);", " --slidev-theme-color: var(--od-text);", " --slidev-theme-primary: var(--od-cyan);", " --slidev-theme-code-background: var(--od-surface);");
263
+ return `/* Generated from theme/default.json and the deck's theme.json. */\n:root {\n${lines.join("\n")}\n}\n`;
264
+ }
265
+ // ../kit/src/theme/theme.ts
266
+ let active;
267
+ let sheet$1;
268
+ const initial = resolveTheme();
269
+ let CATEGORICAL_COLORS = initial.categorical;
270
+ let CANVAS = initial.surfaces.canvas;
271
+ function resolveTheme(deckTheme) {
272
+ return resolveTheme$1(theme_default_default, deckTheme);
273
+ }
274
+ function installTheme(value) {
275
+ const next = document.createElement("style");
276
+ next.textContent = themeCss(value);
277
+ if (sheet$1?.isConnected) sheet$1.replaceWith(next);
278
+ else document.head.append(next);
279
+ sheet$1 = next;
280
+ active = value;
281
+ CATEGORICAL_COLORS = value.categorical;
282
+ CANVAS = value.surfaces.canvas;
283
+ }
284
+ function theme() {
285
+ if (!active) throw new Error("No kit theme installed; call installTheme in setup.ts");
286
+ return active;
287
+ }
288
+ function ink(hue, step) {
289
+ const [one, two, three, four] = theme().ramps[hue];
290
+ return step === 1 ? one : step === 2 ? two : step === 3 ? three : four;
291
+ }
292
+ // ../kit/src/chrome/od-logo.tsx
293
+ function onAnimationEnd(event) {
294
+ if (!event.animationName.includes("move")) return;
295
+ const layer = event.target;
296
+ if (!(layer instanceof Element)) return;
297
+ if (layer.classList.contains("od-settle-teal")) layer.classList.replace("od-settle-teal", "od-float-teal");
298
+ else if (layer.classList.contains("od-settle-cyan")) layer.classList.replace("od-settle-cyan", "od-float-cyan");
299
+ }
300
+ /**
301
+ * The theme's brand mark (`brand.logo`; `null` renders nothing). On the live slide its layers
302
+ * play the two-cycle intro and then float; everywhere else, and under instant motion, the mark
303
+ * is drawn settled.
304
+ */
305
+ function OdLogo({ size = 32 }) {
306
+ const { renderContext } = useSlide();
307
+ const { logo } = theme().brand;
308
+ if (!logo) return null;
309
+ const settled = renderContext !== "slide" || motionMode() === "instant";
310
+ return /* @__PURE__ */ jsx("svg", {
311
+ className: settled ? "od-logo is-settled" : "od-logo",
312
+ width: size,
313
+ height: size,
314
+ viewBox: logo["view-box"],
315
+ "aria-hidden": "true",
316
+ onAnimationEnd,
317
+ dangerouslySetInnerHTML: { __html: logo.svg }
318
+ });
319
+ }
320
+ // ../kit/src/chrome/od-cover-head.tsx
321
+ function OdCoverHead({ url, className = "" }) {
322
+ const { brand } = theme();
323
+ const address = url ?? brand.url;
324
+ return /* @__PURE__ */ jsxs("div", {
325
+ className: `od-cover-head ${className}`,
326
+ children: [/* @__PURE__ */ jsxs("div", {
327
+ className: "od-brand",
328
+ children: [/* @__PURE__ */ jsx(OdLogo, { size: 46 }), /* @__PURE__ */ jsx("span", {
329
+ className: "od-brand-name",
330
+ children: brand.name
331
+ })]
332
+ }), address && /* @__PURE__ */ jsx("span", {
333
+ className: "od-mono od-cover-url",
334
+ children: address
335
+ })]
336
+ });
337
+ }
338
+ // ../kit/src/chrome/od-eyebrow.tsx
339
+ function OdEyebrow({ accent, children }) {
340
+ return /* @__PURE__ */ jsxs("div", {
341
+ className: "od-eyebrow-row",
342
+ children: [/* @__PURE__ */ jsx("span", { className: "od-eyebrow-rule" }), /* @__PURE__ */ jsx("span", {
343
+ className: `od-eyebrow${accent ? ` ${accent}` : ""}`,
344
+ children
345
+ })]
346
+ });
347
+ }
348
+ // ../kit/src/chrome/od-qr-card.tsx
349
+ function OdQrCard({ url, image, label, sublabel, ariaLabel }) {
350
+ const qr = url ? encode(url, {
351
+ ecc: "M",
352
+ border: 0
353
+ }) : null;
354
+ const path = qr?.data.flatMap((row, y) => row.flatMap((dark, x) => dark ? [`M${x * 10},${y * 10}h10v10h-10z`] : [])).join("");
355
+ return /* @__PURE__ */ jsxs("div", {
356
+ className: "od-qr-card",
357
+ children: [
358
+ /* @__PURE__ */ jsx("div", {
359
+ className: "od-qr-frame",
360
+ role: "img",
361
+ "aria-label": ariaLabel ?? `QR code${label ? ` to ${label}` : ""}`,
362
+ children: qr ? /* @__PURE__ */ jsx("div", {
363
+ className: "od-qr-img",
364
+ children: /* @__PURE__ */ jsxs("svg", {
365
+ "aria-hidden": "true",
366
+ xmlns: "http://www.w3.org/2000/svg",
367
+ viewBox: `0 0 ${qr.size * 10} ${qr.size * 10}`,
368
+ children: [/* @__PURE__ */ jsx("rect", {
369
+ fill: "white",
370
+ width: qr.size * 10,
371
+ height: qr.size * 10
372
+ }), /* @__PURE__ */ jsx("path", {
373
+ fill: "black",
374
+ d: path
375
+ })]
376
+ })
377
+ }) : /* @__PURE__ */ jsx("div", {
378
+ className: "od-qr-img",
379
+ style: { background: image ? `url('${image}') center/contain no-repeat` : "" }
380
+ })
381
+ }),
382
+ label && /* @__PURE__ */ jsx("span", {
383
+ className: "od-eyebrow od-qr-label",
384
+ children: label
385
+ }),
386
+ sublabel && /* @__PURE__ */ jsx("span", {
387
+ className: "od-mono od-qr-sublabel",
388
+ children: sublabel
389
+ })
390
+ ]
391
+ });
392
+ }
393
+ // ../kit/src/geometry/hash.ts
394
+ /**
395
+ * Deterministic hashing for the ink layer.
396
+ *
397
+ * Every random looking value on a story slide comes from here, keyed on data
398
+ * identity (series id plus index) rather than on geometry or time. That is why
399
+ * a resize, an HMR reload or a repaint never makes a stroke shimmer.
400
+ */
401
+ const TABLE_SIZE = 1024;
402
+ /** mulberry32: small, fast, and identical on every platform. */
403
+ function mulberry32(state) {
404
+ let a = state >>> 0;
405
+ return () => {
406
+ a = a + 1831565813 >>> 0;
407
+ let t = a;
408
+ t = Math.imul(t ^ t >>> 15, t | 1);
409
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
410
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
411
+ };
412
+ }
413
+ function buildTable() {
414
+ const next = mulberry32(1592597118);
415
+ const out = new Array(TABLE_SIZE);
416
+ for (let i = 0; i < TABLE_SIZE; i++) out[i] = next();
417
+ return out;
418
+ }
419
+ /** 1024 precomputed values in [0,1). Built once at module load. */
420
+ const HASH_TABLE = buildTable();
421
+ /** FNV-1a over UTF-16 code units. Returns an unsigned 32 bit integer. */
422
+ function fnv1a(input) {
423
+ let h = 2166136261;
424
+ for (let i = 0; i < input.length; i++) {
425
+ h ^= input.charCodeAt(i);
426
+ h = Math.imul(h, 16777619);
427
+ }
428
+ return h >>> 0;
429
+ }
430
+ /** Final avalanche mixer so nearby indices land far apart in the table. */
431
+ function mix32(n) {
432
+ let h = n >>> 0;
433
+ h ^= h >>> 16;
434
+ h = Math.imul(h, 2146121005);
435
+ h ^= h >>> 15;
436
+ h = Math.imul(h, 2221713035);
437
+ h ^= h >>> 16;
438
+ return h >>> 0;
439
+ }
440
+ function seedToInt(seed) {
441
+ if (typeof seed === "number") return mix32(Math.trunc(seed) >>> 0);
442
+ return fnv1a(seed);
443
+ }
444
+ /**
445
+ * Deterministic value in [0,1) for a seed and an optional index.
446
+ * Same arguments always give the same number.
447
+ */
448
+ function hash(seed, i = 0) {
449
+ const idx = mix32(seedToInt(seed) ^ Math.imul(i >>> 0, 2654435761)) & 1023;
450
+ const value = HASH_TABLE[idx];
451
+ if (value === void 0) throw new Error(`Missing hash table entry ${idx}`);
452
+ return value;
453
+ }
454
+ /** Deterministic value in [lo,hi) for a seed and an index. */
455
+ function hashRange(seed, i, lo, hi) {
456
+ return lo + hash(seed, i) * (hi - lo);
457
+ }
458
+ /** Deterministic value in [-amp,+amp] for a seed and an index. */
459
+ function hashSigned(seed, i, amp) {
460
+ return (hash(seed, i) - .5) * 2 * amp;
461
+ }
462
+ // ../kit/src/geometry/brush.ts
463
+ /**
464
+ * brushRibbon: turn a polyline into a chain of short closed filled polygons.
465
+ *
466
+ * This is how every mark on a story slide is drawn. A stroke is not one path
467
+ * with a stroke width, it is a run of ~12 unit dabs, each a closed 16 point
468
+ * polygon whose top and bottom edges wobble independently. Overlap darkening
469
+ * comes from stacked fill opacity plus an overpaint pass on a hashed subset,
470
+ * not from blend modes.
471
+ *
472
+ * All numbers are viewBox units on the 1920x1080 stage.
473
+ */
474
+ /** Vertices per dab: 8 along the top edge, 8 back along the bottom edge. */
475
+ const EDGE_VERTS = 8;
476
+ /** Fraction of dabs that get a darker second pass. */
477
+ const OVERPAINT_SHARE = .3;
478
+ /** Fill opacity of that second pass. */
479
+ const OVERPAINT_OPACITY = .3;
480
+ const OPACITY_MIN = .42;
481
+ const OPACITY_MAX = .78;
482
+ /**
483
+ * Mutable so the visual gate can tune the ink without touching call sites.
484
+ * Sized for a 1920x1080 stage read from the back of a room, which is why
485
+ * wobble and edge are several times the amplitude a web page would use.
486
+ */
487
+ const BRUSH_DEFAULTS = {
488
+ width: 14,
489
+ seed: 0,
490
+ taperIn: .12,
491
+ taperOut: .18,
492
+ startWidth: .35,
493
+ endWidth: .25,
494
+ belly: 1,
495
+ wobble: 2.2,
496
+ edge: .9,
497
+ chisel: 0,
498
+ samples: 12
499
+ };
500
+ function smoothstep(t) {
501
+ const c = Math.min(1, Math.max(0, t));
502
+ return c * c * (3 - 2 * c);
503
+ }
504
+ /** Width multiplier along the stroke: narrow tips, full belly in the middle. */
505
+ function widthProfile(t, o) {
506
+ if (o.taperIn > 0 && t < o.taperIn) return o.startWidth + (o.belly - o.startWidth) * smoothstep(t / o.taperIn);
507
+ if (o.taperOut > 0 && t > 1 - o.taperOut) return o.belly + (o.endWidth - o.belly) * smoothstep((t - (1 - o.taperOut)) / o.taperOut);
508
+ return o.belly;
509
+ }
510
+ /** Resample a polyline at a fixed arc spacing. Always returns >= 2 points. */
511
+ function resample(points, spacing) {
512
+ const src = points.filter((p, i) => i === 0 || p.x !== points[i - 1]?.x || p.y !== points[i - 1]?.y);
513
+ const first = src[0];
514
+ if (!first) return [];
515
+ if (src.length < 2) return [first, first];
516
+ const step = Math.max(.5, spacing);
517
+ const out = [{
518
+ x: first.x,
519
+ y: first.y
520
+ }];
521
+ let carry = 0;
522
+ for (let i = 1; i < src.length; i++) {
523
+ const a = src[i - 1];
524
+ const b = src[i];
525
+ if (!a || !b) throw new Error(`Missing polyline segment ${i}`);
526
+ const dx = b.x - a.x;
527
+ const dy = b.y - a.y;
528
+ const len = Math.hypot(dx, dy);
529
+ if (len === 0) continue;
530
+ let travelled = step - carry;
531
+ while (travelled <= len) {
532
+ const u = travelled / len;
533
+ out.push({
534
+ x: a.x + dx * u,
535
+ y: a.y + dy * u
536
+ });
537
+ travelled += step;
538
+ }
539
+ carry = len - (travelled - step);
540
+ }
541
+ const last = src[src.length - 1];
542
+ const tail = out[out.length - 1];
543
+ if (!last || !tail) throw new Error("Resampled polyline has no endpoint");
544
+ if (Math.hypot(last.x - tail.x, last.y - tail.y) > 1e-6) out.push({
545
+ x: last.x,
546
+ y: last.y
547
+ });
548
+ if (out.length < 2) out.push({
549
+ x: last.x,
550
+ y: last.y
551
+ });
552
+ return out;
553
+ }
554
+ function round(n) {
555
+ return Math.round(n * 100) / 100;
556
+ }
557
+ /** Each dab spans this many sample spacings, so neighbours overlap heavily. */
558
+ const DAB_SPAN = 2.6;
559
+ /** Arc length between wobble control points; the edge drifts, never jumps. */
560
+ const WOBBLE_PERIOD = 90;
561
+ /** Floor of the per dab lens envelope, so a dab's own ends never pinch to zero. */
562
+ const LENS_FLOOR = .55;
563
+ /** Smooth, deterministic noise in [-1, 1] along arc length. */
564
+ function drift(seed, lane, arc) {
565
+ const cell = Math.floor(arc / WOBBLE_PERIOD);
566
+ const u = smoothstep(arc / WOBBLE_PERIOD - cell);
567
+ const a = hash(seed, lane * 4096 + cell) * 2 - 1;
568
+ return a + (hash(seed, lane * 4096 + cell + 1) * 2 - 1 - a) * u;
569
+ }
570
+ /** Position and unit tangent at arc length `arc` along a resampled polyline. */
571
+ function along(line, cum, arc) {
572
+ const total = cum[cum.length - 1];
573
+ if (total === void 0) throw new Error("Polyline has no arc lengths");
574
+ const s = Math.min(Math.max(arc, 0), total);
575
+ let i = 1;
576
+ while (i < cum.length - 1 && (cum[i] ?? total) < s) i++;
577
+ const a = line[i - 1];
578
+ const b = line[i];
579
+ const end = cum[i];
580
+ const start = cum[i - 1];
581
+ if (!a || !b || start === void 0 || end === void 0) throw new Error(`Missing arc segment ${i}`);
582
+ const len = end - start;
583
+ const u = len === 0 ? 0 : (s - start) / len;
584
+ let dx = b.x - a.x;
585
+ let dy = b.y - a.y;
586
+ const n = Math.hypot(dx, dy) || 1;
587
+ dx /= n;
588
+ dy /= n;
589
+ return {
590
+ x: a.x + (b.x - a.x) * u,
591
+ y: a.y + (b.y - a.y) * u,
592
+ dx,
593
+ dy
594
+ };
595
+ }
596
+ /**
597
+ * Build the dab chain for a polyline.
598
+ *
599
+ * The centreline is resampled at `samples` units of arc length. Each sample
600
+ * becomes one closed polygon centred on it and spanning DAB_SPAN samples, so
601
+ * consecutive dabs overlap by most of their length and fuse into one ribbon.
602
+ * The top and bottom edges follow independent low frequency drifts along the
603
+ * arc plus fine hashed jitter per vertex, and each dab is a shallow lens so
604
+ * its own ends feather into its neighbours instead of cutting a hard tile.
605
+ */
606
+ function brushRibbon(points, opts = {}) {
607
+ const o = {
608
+ ...BRUSH_DEFAULTS,
609
+ ...opts
610
+ };
611
+ const line = resample(points, o.samples);
612
+ if (line.length < 2) return [];
613
+ const cum = [0];
614
+ for (let i = 1; i < line.length; i++) {
615
+ const a = line[i - 1];
616
+ const b = line[i];
617
+ const previous = cum[i - 1];
618
+ if (!a || !b || previous === void 0) throw new Error(`Missing ribbon segment ${i}`);
619
+ cum.push(previous + Math.hypot(b.x - a.x, b.y - a.y));
620
+ }
621
+ const total = cum[cum.length - 1];
622
+ if (total === void 0 || total === 0) return [];
623
+ const seed = o.seed;
624
+ const shear = Math.tan(o.chisel);
625
+ const dabs = [];
626
+ const segments = line.length - 1;
627
+ const half_span = o.samples * DAB_SPAN / 2;
628
+ for (let s = 0; s < segments; s++) {
629
+ const start = cum[s];
630
+ const end = cum[s + 1];
631
+ if (start === void 0 || end === void 0) throw new Error(`Missing dab segment ${s}`);
632
+ const centre = (start + end) / 2;
633
+ const k = s * 64;
634
+ const top = [];
635
+ const bottom = [];
636
+ for (let v = 0; v < EDGE_VERTS; v++) {
637
+ const u = v / 7;
638
+ const arc = centre + (u - .5) * 2 * half_span;
639
+ const p = along(line, cum, arc);
640
+ const t = Math.min(1, Math.max(0, arc / total));
641
+ const lens = LENS_FLOOR + .44999999999999996 * Math.sin(Math.PI * u);
642
+ const half = o.width * widthProfile(t, o) * lens / 2;
643
+ const nx = -p.dy;
644
+ const ny = p.dx;
645
+ const topWobble = drift(seed, 1, arc) * o.wobble;
646
+ const botWobble = drift(seed, 2, arc) * o.wobble;
647
+ const topJit = (hash(seed, k + 8 + v) - .5) * 2 * o.edge;
648
+ const botJit = (hash(seed, k + 24 + v) - .5) * 2 * o.edge;
649
+ const topOff = half + topWobble + topJit;
650
+ const botOff = -(half - botWobble + botJit);
651
+ top.push({
652
+ x: p.x + nx * topOff + p.dx * topOff * shear,
653
+ y: p.y + ny * topOff + p.dy * topOff * shear
654
+ });
655
+ bottom.push({
656
+ x: p.x + nx * botOff + p.dx * botOff * shear,
657
+ y: p.y + ny * botOff + p.dy * botOff * shear
658
+ });
659
+ }
660
+ let d = [...top, ...bottom.reverse()].map((p, i) => `${i === 0 ? "M" : "L"}${round(p.x)} ${round(p.y)}`).join("");
661
+ d += "Z";
662
+ const dab = {
663
+ d,
664
+ fillOpacity: round(hashRange(seed, k + 3, OPACITY_MIN, OPACITY_MAX) * 1e3) / 1e3
665
+ };
666
+ if (hash(seed, k + 4) < OVERPAINT_SHARE) dab.overpaint = OVERPAINT_OPACITY;
667
+ dabs.push(dab);
668
+ }
669
+ return dabs;
670
+ }
671
+ // ../kit/src/geometry/grid.ts
672
+ /** Geometry defaults, shared by `UnitGrid`'s props and the math below. */
673
+ const UNIT_GRID_DEFAULTS = {
674
+ glyph: "square",
675
+ cols: 20,
676
+ cellWidth: 16,
677
+ gapX: 8,
678
+ gapY: 8,
679
+ origin: {
680
+ x: 0,
681
+ y: 0
682
+ }
683
+ };
684
+ /** Cell height after the glyph default, in stage units. */
685
+ function unitCellHeight(geom) {
686
+ const w = geom.cellWidth ?? UNIT_GRID_DEFAULTS.cellWidth;
687
+ return geom.cellHeight ?? (geom.glyph === "sheet" ? w * 1.32 : w);
688
+ }
689
+ /** Centre of cell `index`, in stage viewBox units, before any scatter or collapse. */
690
+ function unitCellCenter(index, geom) {
691
+ const w = geom.cellWidth ?? UNIT_GRID_DEFAULTS.cellWidth;
692
+ const h = unitCellHeight(geom);
693
+ const cols = Math.max(1, geom.cols ?? UNIT_GRID_DEFAULTS.cols);
694
+ const origin = geom.origin ?? UNIT_GRID_DEFAULTS.origin;
695
+ return {
696
+ x: origin.x + index % cols * (w + (geom.gapX ?? UNIT_GRID_DEFAULTS.gapX)) + w / 2,
697
+ y: origin.y + Math.floor(index / cols) * (h + (geom.gapY ?? UNIT_GRID_DEFAULTS.gapY)) + h / 2
698
+ };
699
+ }
700
+ // ../kit/src/geometry/parliament.ts
701
+ var parliament_exports = /* @__PURE__ */ __exportAll({
702
+ layout: () => layout,
703
+ thresholdAngle: () => thresholdAngle
704
+ });
705
+ /** Seat diameter as a share of the closest centre-to-centre spacing. */
706
+ const SEAT_SHARE = .7;
707
+ /**
708
+ * Rows for `total` seats. With rows `r0 + i * g` matching spacing `pi * r / n`
709
+ * to `g`, and `r0 = INNER_SHARE * outer`, the seat count works out to
710
+ * `pi * R * (R - 1) * (k + 1/2)` for `k = INNER_SHARE / (1 - INNER_SHARE)`;
711
+ * solve for R and round. A row count that would leave the inner row with
712
+ * under two seats steps down.
713
+ */
714
+ function defaultRows(total) {
715
+ const x = total / (Math.PI * 1.5);
716
+ let rows = Math.max(1, Math.round((1 + Math.sqrt(1 + 4 * x)) / 2));
717
+ while (rows > 1 && innerQuota(total, rows) < 2) rows--;
718
+ return rows;
719
+ }
720
+ /** The spacing-matched gap for `rows` rows: solves `pi * sum(r) / total = g`. */
721
+ function matchedGap(total, rows, radius) {
722
+ return Math.PI * rows * radius / (total + Math.PI * rows * (rows - 1) / 2);
723
+ }
724
+ function innerQuota(total, rows) {
725
+ const gap = matchedGap(total, rows, 1);
726
+ const radii = Array.from({ length: rows }, (_, i) => 1 - (rows - 1 - i) * gap);
727
+ return total * (1 - (rows - 1) * gap) / radii.reduce((sum, r) => sum + r, 0);
728
+ }
729
+ /** Seat positions for `total` seats over concentric rows ending at `radius`. */
730
+ function layout(total, options) {
731
+ if (!Number.isInteger(total) || total < 1) throw new RangeError(`parliament: total must be a positive integer, got ${total}`);
732
+ const { radius } = options;
733
+ if (!Number.isFinite(radius) || radius <= 0) throw new RangeError(`parliament: radius must be a finite number above 0, got ${radius}`);
734
+ if (options.rowGap !== void 0 && (!Number.isFinite(options.rowGap) || options.rowGap <= 0)) throw new RangeError(`parliament: rowGap must be a finite number above 0, got ${options.rowGap}`);
735
+ const rows = options.rows ?? defaultRows(total);
736
+ if (!Number.isInteger(rows) || rows < 1) throw new RangeError(`parliament: rows must be a positive integer, got ${rows}`);
737
+ const rowGap = rows === 1 ? 0 : options.rowGap ?? matchedGap(total, rows, radius);
738
+ const rowRadii = Array.from({ length: rows }, (_, i) => radius - (rows - 1 - i) * rowGap);
739
+ if (radius - (rows - 1) * rowGap <= 0) throw new RangeError(`parliament: ${rows} rows ${rowGap} apart do not fit inside radius ${radius}`);
740
+ const radiusSum = rowRadii.reduce((sum, r) => sum + r, 0);
741
+ const allocation = rowRadii.map((r) => {
742
+ const quota = total * r / radiusSum;
743
+ return {
744
+ seats: Math.floor(quota),
745
+ remainder: quota % 1
746
+ };
747
+ });
748
+ const remaining = total - allocation.reduce((sum, row) => sum + row.seats, 0);
749
+ const ranked = [...allocation].sort((a, b) => b.remainder - a.remainder);
750
+ for (const row of ranked.slice(0, remaining)) row.seats++;
751
+ const rowSeats = allocation.map((row) => row.seats);
752
+ if (rowSeats.some((n) => n < 1)) throw new RangeError(`parliament: ${total} seats leave a row of ${rows} empty`);
753
+ const seats = rowRadii.flatMap((r, row) => {
754
+ const count = rowSeats[row];
755
+ if (count === void 0) throw new Error(`parliament: missing row ${row}`);
756
+ return Array.from({ length: count }, (_, i) => {
757
+ const angle = Math.PI * (1 - (i + 1 / 2) / count);
758
+ return {
759
+ x: Math.cos(angle) * r,
760
+ y: -Math.sin(angle) * r,
761
+ angle,
762
+ row
763
+ };
764
+ });
765
+ }).sort((a, b) => b.angle - a.angle || a.row - b.row);
766
+ const chords = rowRadii.map((r, row) => {
767
+ const count = rowSeats[row];
768
+ if (count === void 0) throw new Error(`parliament: missing row ${row}`);
769
+ return count > 1 ? 2 * r * Math.sin(Math.PI / (2 * count)) : 2 * r;
770
+ });
771
+ const closest = Math.min(...chords, ...rows > 1 ? [rowGap] : []);
772
+ return {
773
+ seats,
774
+ rowRadii,
775
+ rowSeats,
776
+ rowGap: rows === 1 ? Math.min(...chords) : rowGap,
777
+ seatRadius: SEAT_SHARE * closest / 2
778
+ };
779
+ }
780
+ /**
781
+ * The angle of a threshold after the first `at` seats in reading order: the
782
+ * mean angle of the seats either side, so a radial tick there passes through
783
+ * neither. `at` 0 is the left baseline (pi) and `at` equal to the seat count the
784
+ * right one (0). Two seats at the same angle cannot be split by a radial line,
785
+ * so a threshold that falls between them throws rather than drawing through
786
+ * both; move the threshold or change the row count.
787
+ */
788
+ function thresholdAngle(seats, at) {
789
+ if (!Number.isInteger(at) || at < 0 || at > seats.length) throw new RangeError(`parliament: threshold ${at} is outside 0..${seats.length}`);
790
+ if (at === 0) return Math.PI;
791
+ if (at === seats.length) return 0;
792
+ const before = seats[at - 1];
793
+ const after = seats[at];
794
+ if (!before || !after) throw new Error(`parliament: missing seats at threshold ${at}`);
795
+ if (before.angle === after.angle) throw new RangeError(`parliament: threshold ${at} falls between two seats at the same angle (rows ${before.row} and ${after.row})`);
796
+ return (before.angle + after.angle) / 2;
797
+ }
798
+ // ../kit/src/geometry/scales.ts
799
+ /**
800
+ * d3-scale wrappers and clean axis helpers for the 1920x1080 stage.
801
+ *
802
+ * Axes on a story slide are horizontal hairline rules plus two x labels. There
803
+ * are no axis lines, no ticks and no legend: series carry direct end labels in
804
+ * their own ink, which is what stackEndLabels resolves.
805
+ */
806
+ /** Linear interpolation, including extrapolation beyond the endpoints. */
807
+ function lerp(a, b, t) {
808
+ return a + (b - a) * t;
809
+ }
810
+ /** Clamp to the 0..1 range every beat field and progress helper works in. */
811
+ function clamp01(n) {
812
+ return Math.min(1, Math.max(0, n));
813
+ }
814
+ /** Left to right scale across the stage. */
815
+ function xScale(domain, range) {
816
+ return scaleLinear().domain(domain).range(range);
817
+ }
818
+ /** Top down scale: pass the range already inverted (bottom first). */
819
+ function yScale(domain, range) {
820
+ return scaleLinear().domain(domain).range(range);
821
+ }
822
+ /**
823
+ * Progress of item `i` of `n` when one 0..1 beat field is staggered by `step` per item: each
824
+ * item starts `step` after the one before it, and the last one still lands at 1.
825
+ */
826
+ function stagger(progress, i, n, step) {
827
+ return clamp01((progress - i * step) / (1 - (n - 1) * step));
828
+ }
829
+ /**
830
+ * Nudge overlapping end labels apart, keeping their vertical order.
831
+ *
832
+ * Returns resolved centres in the input order. Pure: no clamping to the stage,
833
+ * because a caller that cares about the frame edge will shift the whole block.
834
+ */
835
+ function stackEndLabels(labels, gap = 0) {
836
+ const order = labels.map((label, index) => ({
837
+ label,
838
+ index
839
+ })).sort((a, b) => a.label.y - b.label.y || a.index - b.index);
840
+ const out = new Array(labels.length);
841
+ let prevY = -1e400;
842
+ let prevH = 0;
843
+ for (const [i, { label, index }] of order.entries()) {
844
+ const min = i === 0 ? label.y : prevY + prevH / 2 + label.h / 2 + gap;
845
+ const y = Math.max(label.y, min);
846
+ out[index] = y;
847
+ prevY = y;
848
+ prevH = label.h;
849
+ }
850
+ return out;
851
+ }
852
+ // ../kit/src/geometry/ripple.ts
853
+ /** The stage diagonal: the farthest two points in the 1920x1080 viewBox can be. */
854
+ const STAGE_DIAGONAL = Math.hypot(1920, 1080);
855
+ /** Default hashed jitter, as a share of the stagger window. */
856
+ const JITTER = .08;
857
+ /**
858
+ * A mark's local progress when the beat field `t` ripples outward from
859
+ * `from`. `stagger` is the share of the field spent on the spread (0..1):
860
+ * 0 returns `t` (clamped to 0..1), so every mark moves together.
861
+ */
862
+ function rippleProgress(t, at, from, stagger, opts = {}) {
863
+ const spread = Math.min(.999, clamp01(stagger));
864
+ if (spread <= 0) return clamp01(t);
865
+ const reach = Math.max(1, opts.reach ?? STAGE_DIAGONAL);
866
+ const jitter = opts.seed === void 0 ? 0 : hashSigned(opts.seed, opts.index ?? 0, opts.jitter ?? JITTER);
867
+ return clamp01((t - clamp01(Math.hypot(at.x - from.x, at.y - from.y) / reach + jitter) * spread) / (1 - spread));
868
+ }
869
+ // ../kit/src/theme/easings.ts
870
+ /**
871
+ * Three easings and one duration table, for the whole deck.
872
+ *
873
+ * SETTLE is for anything that appears, disappears, recolors or repositions.
874
+ * DRAW is for anything that draws or travels in a beat, and is eased on both
875
+ * ends: a line that leaves at full speed reads as a wipe rather than as a
876
+ * stroke, which is what SETTLE is for. TRACE is for the one
877
+ * long hero moves: the cover trace and a staggered gather, where a slow start,
878
+ * a run, and a long settle read as a hand moving rather than as a wipe. There
879
+ * is no fourth easing, and there are no numeric duration literals outside this
880
+ * file (a unit test scans for them).
881
+ */
882
+ const SETTLE = "odSettle";
883
+ const DRAW = "odDraw";
884
+ const TRACE = "odTrace";
885
+ /** The same curves as CSS strings, for transitions that stay in CSS. */
886
+ const SETTLE_CSS = "cubic-bezier(.32,.72,0,1)";
887
+ const DRAW_CSS = "cubic-bezier(.65,0,.35,1)";
888
+ const TRACE_CSS = "cubic-bezier(.62,.02,.18,1)";
889
+ const TRACE_PATH = "M0,0 C0.62,0.02 0.18,1 1,1";
890
+ gsap.registerPlugin(CustomEase);
891
+ gsap.registerEase(SETTLE, gsap.parseEase(ease.settle));
892
+ gsap.registerEase(DRAW, gsap.parseEase(ease.draw));
893
+ CustomEase.create(TRACE, TRACE_PATH);
894
+ gsap.defaults({ ease: SETTLE });
895
+ /** Durations in seconds. Every tween on a story slide reads one of these. */
896
+ const DUR = {
897
+ /** One step of a progressive append, such as a fan chart sample path. */
898
+ tick: .03,
899
+ opacity: .14,
900
+ draw: .24,
901
+ card: .3,
902
+ color: .34,
903
+ eraseDelay: .35,
904
+ eraseHold: .49,
905
+ grow: .56,
906
+ morph: .6,
907
+ scale: .9,
908
+ /** A field gathering into one card, sheet by sheet. */
909
+ gather: 1.6,
910
+ /** The cover's hero line, traced end to end. */
911
+ trace: 1.8,
912
+ bloom: 2.4
913
+ };
914
+ /**
915
+ * The start offset, in seconds, of item `i` of `n` when a group of tweens is
916
+ * spread across `spread` seconds. The offsets follow an ease-in-out curve: the
917
+ * first few leave close together, the middle flows and the last few settle, so
918
+ * a cascade reads as one gesture rather than a metronome of even steps.
919
+ */
920
+ function easedStagger(i, n, spread) {
921
+ if (n <= 1 || spread <= 0) return 0;
922
+ const t = i / (n - 1);
923
+ return spread * (.5 - Math.cos(Math.PI * t) / 2);
924
+ }
925
+ // ../kit/src/theme/filters.tsx
926
+ const FILTER_IDS = {
927
+ marker: "mk-marker",
928
+ markerLite: "mk-marker-lite",
929
+ dry: "mk-dry",
930
+ dryLite: "mk-dry-lite",
931
+ rule: "mk-rule",
932
+ ruleLite: "mk-rule-lite",
933
+ /** Soft same hue glow for clean strokes. Not a marker filter. */
934
+ glow: "mk-glow"
935
+ };
936
+ /** `url(#id)` for the filter attribute. */
937
+ function filterUrl(id) {
938
+ const token = Object.entries(FILTER_IDS).find(([, value]) => value === id);
939
+ if (token) return `var(--od-filter-${token[0]})`;
940
+ return `url(#${id})`;
941
+ }
942
+ const SPECS = [
943
+ {
944
+ id: FILTER_IDS.rule,
945
+ dryness: -.12,
946
+ displace: .6,
947
+ seed: 3
948
+ },
949
+ {
950
+ id: FILTER_IDS.ruleLite,
951
+ dryness: -.12,
952
+ displace: 0,
953
+ seed: 3
954
+ },
955
+ {
956
+ id: FILTER_IDS.marker,
957
+ dryness: -.3,
958
+ displace: 2.6,
959
+ seed: 7
960
+ },
961
+ {
962
+ id: FILTER_IDS.markerLite,
963
+ dryness: -.3,
964
+ displace: 0,
965
+ seed: 7
966
+ },
967
+ {
968
+ id: FILTER_IDS.dry,
969
+ dryness: -.55,
970
+ displace: 1.8,
971
+ seed: 11
972
+ },
973
+ {
974
+ id: FILTER_IDS.dryLite,
975
+ dryness: -.55,
976
+ displace: 0,
977
+ seed: 11
978
+ }
979
+ ];
980
+ function StoryDefs({ prefix }) {
981
+ return /* @__PURE__ */ jsxs("defs", { children: [SPECS.map((spec) => /* @__PURE__ */ jsxs("filter", {
982
+ id: `${prefix}-${spec.id}`,
983
+ x: "-20%",
984
+ y: "-20%",
985
+ width: "140%",
986
+ height: "140%",
987
+ colorInterpolationFilters: "sRGB",
988
+ filterUnits: "objectBoundingBox",
989
+ children: [
990
+ /* @__PURE__ */ jsx("feTurbulence", {
991
+ type: "fractalNoise",
992
+ baseFrequency: "0.9",
993
+ numOctaves: 2,
994
+ seed: spec.seed,
995
+ result: "grain"
996
+ }),
997
+ /* @__PURE__ */ jsx("feColorMatrix", {
998
+ in: "grain",
999
+ type: "luminanceToAlpha",
1000
+ result: "grainAlpha"
1001
+ }),
1002
+ /* @__PURE__ */ jsx("feComposite", {
1003
+ in: "SourceGraphic",
1004
+ in2: "grainAlpha",
1005
+ operator: "arithmetic",
1006
+ k1: 0,
1007
+ k2: 1,
1008
+ k3: spec.dryness,
1009
+ k4: 0,
1010
+ result: "dried"
1011
+ }),
1012
+ spec.displace !== 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("feTurbulence", {
1013
+ type: "fractalNoise",
1014
+ baseFrequency: "0.012",
1015
+ numOctaves: 2,
1016
+ seed: spec.seed + 1,
1017
+ result: "warp"
1018
+ }), /* @__PURE__ */ jsx("feDisplacementMap", {
1019
+ in: "dried",
1020
+ in2: "warp",
1021
+ scale: spec.displace,
1022
+ xChannelSelector: "R",
1023
+ yChannelSelector: "G"
1024
+ })] })
1025
+ ]
1026
+ }, spec.id)), /* @__PURE__ */ jsxs("filter", {
1027
+ id: `${prefix}-${FILTER_IDS.glow}`,
1028
+ x: "-10%",
1029
+ y: "-10%",
1030
+ width: "120%",
1031
+ height: "120%",
1032
+ colorInterpolationFilters: "sRGB",
1033
+ filterUnits: "userSpaceOnUse",
1034
+ children: [
1035
+ /* @__PURE__ */ jsx("feGaussianBlur", {
1036
+ in: "SourceGraphic",
1037
+ stdDeviation: 7,
1038
+ result: "blur"
1039
+ }),
1040
+ /* @__PURE__ */ jsx("feComponentTransfer", {
1041
+ in: "blur",
1042
+ result: "halo",
1043
+ children: /* @__PURE__ */ jsx("feFuncA", {
1044
+ type: "linear",
1045
+ slope: .55
1046
+ })
1047
+ }),
1048
+ /* @__PURE__ */ jsxs("feMerge", { children: [/* @__PURE__ */ jsx("feMergeNode", { in: "halo" }), /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })] })
1049
+ ]
1050
+ })] });
1051
+ }
1052
+ // ../kit/src/story/after-transition.ts
1053
+ /** The runtime removes this documented attribute after its ViewTransition finishes. */
1054
+ function afterTransition(run) {
1055
+ const html = document.documentElement;
1056
+ if (!html.hasAttribute("data-deck-transition")) {
1057
+ run();
1058
+ return () => {};
1059
+ }
1060
+ const observer = new MutationObserver(() => {
1061
+ if (html.hasAttribute("data-deck-transition")) return;
1062
+ observer.disconnect();
1063
+ run();
1064
+ });
1065
+ observer.observe(html, {
1066
+ attributes: true,
1067
+ attributeFilter: ["data-deck-transition"]
1068
+ });
1069
+ return () => observer.disconnect();
1070
+ }
1071
+ // ../kit/src/story/story-stage.tsx
1072
+ const STAGE = {
1073
+ width: 1920,
1074
+ height: 1080
1075
+ };
1076
+ function StoryStage({ beats = 1, click = 0, stage, overlay, card, background, fluid = false, enterAfterTransition = false, className = "" }) {
1077
+ const { isActive, renderContext } = useSlide();
1078
+ const root = useRef(null);
1079
+ const prefix = useId();
1080
+ const currentClick = useRef(click);
1081
+ const entry = useRef(null);
1082
+ const styles = Object.fromEntries(Object.entries(FILTER_IDS).map(([name, id]) => [`--od-filter-${name}`, filterUrl(`${prefix}-${id}`)]));
1083
+ useLayoutEffect(() => {
1084
+ currentClick.current = click;
1085
+ }, [click]);
1086
+ useLayoutEffect(() => {
1087
+ const el = root.current;
1088
+ if (!el) return;
1089
+ const groups = [
1090
+ ".od-story-head, .od-enter-a",
1091
+ ".od-enter-b",
1092
+ ".od-story-card, .od-enter-c",
1093
+ ".od-story-foot"
1094
+ ].map((selector) => Array.from(el.querySelectorAll(selector)));
1095
+ const all = groups.flat();
1096
+ const rest = () => gsap.set(all, { clearProps: "opacity,transform" });
1097
+ entry.current?.kill();
1098
+ rest();
1099
+ if (!isActive || renderContext !== "slide" || currentClick.current > 0 || motionMode() === "instant") return;
1100
+ const transitioning = document.documentElement.hasAttribute("data-deck-transition");
1101
+ if (transitioning && !enterAfterTransition) return;
1102
+ const named = (element) => {
1103
+ const name = getComputedStyle(element).getPropertyValue("view-transition-name").trim();
1104
+ return name !== "" && name !== "none";
1105
+ };
1106
+ const held = transitioning ? groups.map((group) => group.filter((element) => !named(element) && !Array.from(element.querySelectorAll("[class*=\"vt-\"], .od-story-head, .od-story-card")).some(named))) : groups;
1107
+ if (transitioning) gsap.set(held.flat(), { opacity: 0 });
1108
+ const cancel = afterTransition(() => {
1109
+ if (currentClick.current > 0) {
1110
+ rest();
1111
+ return;
1112
+ }
1113
+ const tl = gsap.timeline();
1114
+ entry.current = tl;
1115
+ let at = 0;
1116
+ for (const group of held) {
1117
+ if (!group.length) continue;
1118
+ tl.fromTo(group, {
1119
+ opacity: 0,
1120
+ y: 14
1121
+ }, {
1122
+ opacity: 1,
1123
+ y: 0,
1124
+ duration: DUR.morph,
1125
+ ease: SETTLE,
1126
+ clearProps: "transform"
1127
+ }, at);
1128
+ at += DUR.opacity;
1129
+ }
1130
+ });
1131
+ return () => {
1132
+ cancel();
1133
+ entry.current?.kill();
1134
+ rest();
1135
+ };
1136
+ }, [
1137
+ isActive,
1138
+ renderContext,
1139
+ enterAfterTransition
1140
+ ]);
1141
+ useLayoutEffect(() => {
1142
+ if (click <= 0 || !root.current) return;
1143
+ entry.current?.progress(1).pause();
1144
+ }, [click]);
1145
+ return /* @__PURE__ */ jsxs("div", {
1146
+ ref: root,
1147
+ className: `od-slide is-story${renderContext === "slide" ? " vt-on" : ""}${fluid ? " is-fluid" : ""} ${className}`,
1148
+ style: styles,
1149
+ children: [background && /* @__PURE__ */ jsx("div", {
1150
+ className: "od-stage-background",
1151
+ "aria-hidden": "true",
1152
+ children: background
1153
+ }), /* @__PURE__ */ jsxs("div", {
1154
+ className: "od-story-frame",
1155
+ children: [
1156
+ /* @__PURE__ */ jsxs("svg", {
1157
+ className: "od-stage",
1158
+ viewBox: "0 0 1920 1080",
1159
+ preserveAspectRatio: "xMidYMid slice",
1160
+ "aria-hidden": "true",
1161
+ children: [/* @__PURE__ */ jsx(StoryDefs, { prefix }), stage]
1162
+ }),
1163
+ /* @__PURE__ */ jsxs("div", {
1164
+ className: "od-stage-overlay",
1165
+ children: [overlay, card]
1166
+ }),
1167
+ beats > 1 && /* @__PURE__ */ jsx("footer", {
1168
+ className: "od-story-foot",
1169
+ children: Array.from({ length: beats }, (_, i) => ({
1170
+ id: `beat${i}`,
1171
+ i
1172
+ })).map(({ id, i }) => /* @__PURE__ */ jsx("span", { className: `od-beat${i <= click ? " is-done" : ""}${i === click ? " is-current" : ""}` }, id))
1173
+ })
1174
+ ]
1175
+ })]
1176
+ });
1177
+ }
1178
+ // ../kit/src/ink/code-tokens.ts
1179
+ /**
1180
+ * Only the keywords the decks actually use. An unknown word renders plain,
1181
+ * which is the right failure: a missed keyword reads as ordinary text rather
1182
+ * than as the wrong colour.
1183
+ */
1184
+ const KEYWORDS = /* @__PURE__ */ new Set([
1185
+ "ALL",
1186
+ "AND",
1187
+ "AS",
1188
+ "ASC",
1189
+ "AVG",
1190
+ "BY",
1191
+ "CASE",
1192
+ "COUNT",
1193
+ "CROSS",
1194
+ "DESC",
1195
+ "DISTINCT",
1196
+ "ELSE",
1197
+ "END",
1198
+ "FROM",
1199
+ "FULL",
1200
+ "GROUP",
1201
+ "HAVING",
1202
+ "IN",
1203
+ "INNER",
1204
+ "IS",
1205
+ "JOIN",
1206
+ "LEFT",
1207
+ "LIKE",
1208
+ "LIMIT",
1209
+ "MAX",
1210
+ "MIN",
1211
+ "NOT",
1212
+ "NULL",
1213
+ "OFFSET",
1214
+ "ON",
1215
+ "OR",
1216
+ "ORDER",
1217
+ "OUTER",
1218
+ "RIGHT",
1219
+ "SELECT",
1220
+ "SUM",
1221
+ "THEN",
1222
+ "UNION",
1223
+ "USING",
1224
+ "WHEN",
1225
+ "WHERE",
1226
+ "WITH"
1227
+ ]);
1228
+ /**
1229
+ * Single quoted strings and double quoted identifiers both read as literal:
1230
+ * they are the values and the dataset references, and colouring them apart
1231
+ * would put a third accent on a stage that allows one.
1232
+ */
1233
+ const TOKEN = /('[^']*'|"[^"]*"|[A-Za-z_][A-Za-z0-9_]*|\s+|[^\sA-Za-z_'"]+)/g;
1234
+ function tokenizeSql(line) {
1235
+ const tokens = [];
1236
+ for (const [text] of line.matchAll(TOKEN)) if (text.startsWith("'") || text.startsWith("\"")) tokens.push({
1237
+ text,
1238
+ kind: "literal"
1239
+ });
1240
+ else if (KEYWORDS.has(text.toUpperCase())) tokens.push({
1241
+ text,
1242
+ kind: "keyword"
1243
+ });
1244
+ else tokens.push({
1245
+ text,
1246
+ kind: "plain"
1247
+ });
1248
+ return tokens;
1249
+ }
1250
+ // ../kit/src/ink/ink-style.ts
1251
+ const STORY_STYLE = { ink: "clean" };
1252
+ function inkStyle() {
1253
+ return STORY_STYLE.ink;
1254
+ }
1255
+ /** Stroke widths in viewBox units of the 1920x1080 stage. */
1256
+ const STROKE = {
1257
+ /** A data series. */
1258
+ line: 3.5,
1259
+ /** A hairline axis or baseline. */
1260
+ rule: 1.5,
1261
+ /** An annotation tick. */
1262
+ tick: 4,
1263
+ /** A faint background stroke. */
1264
+ faint: 2
1265
+ };
1266
+ /** `M x y L x y ...` for a polyline, rounded to centipixels. */
1267
+ function polylinePath(points) {
1268
+ if (points.length === 0) return "";
1269
+ const r = (n) => Math.round(n * 100) / 100;
1270
+ return points.map((p, i) => `${i === 0 ? "M" : "L"}${r(p.x)} ${r(p.y)}`).join("");
1271
+ }
1272
+ // ../kit/src/ink/code-ink.tsx
1273
+ /** Parent timelines drive reveal: first the frame, then the crisp, unfiltered code. */
1274
+ function CodeInk({ lines, x, y, width, height, label = "", hue = "slate", step = 2, labelColor = "", overflow = false, scroll = false, surface = false, reveal = 1, fontSize = 1, lang, href, seed = "code-ink" }) {
1275
+ const clean = inkStyle() === "clean";
1276
+ const [active, setActive] = useState(false);
1277
+ const frameProgress = clamp01(reveal / .6);
1278
+ const textProgress = clamp01((reveal - .5) / .5);
1279
+ const color = ink(hue, step);
1280
+ const interactive = (Boolean(href) || scroll) && textProgress > .5;
1281
+ const lit = active && interactive;
1282
+ const dabs = useMemo(() => clean ? [] : brushRibbon([
1283
+ {
1284
+ x,
1285
+ y
1286
+ },
1287
+ {
1288
+ x: x + width,
1289
+ y
1290
+ },
1291
+ {
1292
+ x: x + width,
1293
+ y: y + height
1294
+ },
1295
+ {
1296
+ x,
1297
+ y: y + height
1298
+ },
1299
+ {
1300
+ x,
1301
+ y
1302
+ }
1303
+ ], {
1304
+ seed: `${seed}:frame`,
1305
+ width: 3.4,
1306
+ taperIn: .02,
1307
+ taperOut: .04,
1308
+ startWidth: .8,
1309
+ endWidth: .6,
1310
+ wobble: 1.1,
1311
+ edge: .6,
1312
+ samples: 14
1313
+ }), [
1314
+ clean,
1315
+ x,
1316
+ y,
1317
+ width,
1318
+ height,
1319
+ seed
1320
+ ]);
1321
+ const boxStyle = {
1322
+ left: `${x / STAGE.width * 100}%`,
1323
+ top: `${y / STAGE.height * 100}%`,
1324
+ width: `${width / STAGE.width * 100}%`,
1325
+ height: `${height / STAGE.height * 100}%`,
1326
+ fontSize: `calc(${fontSize} * var(--sw))`,
1327
+ opacity: textProgress,
1328
+ transform: `translateY(calc(${(1 - textProgress) * 10 / 19.2} * var(--sw)))`
1329
+ };
1330
+ const Box = href ? "a" : "div";
1331
+ const rows = lines.map((line, i) => ({
1332
+ id: `line${i}`,
1333
+ line,
1334
+ tokens: tokenizeSql(line).map((token, j) => ({
1335
+ ...token,
1336
+ id: `token${j}`
1337
+ }))
1338
+ }));
1339
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
1340
+ className: "od-stage-layer",
1341
+ "aria-hidden": "true",
1342
+ children: /* @__PURE__ */ jsx("svg", {
1343
+ viewBox: "0 0 1920 1080",
1344
+ preserveAspectRatio: "xMidYMid slice",
1345
+ "aria-hidden": "true",
1346
+ children: /* @__PURE__ */ jsx("g", {
1347
+ style: {
1348
+ clipPath: `inset(0 ${(1 - frameProgress) * 100}% 0 0)`,
1349
+ color
1350
+ },
1351
+ children: clean ? /* @__PURE__ */ jsx("rect", {
1352
+ x,
1353
+ y,
1354
+ width,
1355
+ height,
1356
+ rx: 10,
1357
+ fill: "none",
1358
+ stroke: "currentColor",
1359
+ strokeWidth: STROKE.rule,
1360
+ strokeOpacity: lit ? 1 : .7
1361
+ }) : /* @__PURE__ */ jsx("g", {
1362
+ filter: filterUrl(FILTER_IDS.rule),
1363
+ children: dabs.map((dab) => /* @__PURE__ */ jsx("path", {
1364
+ d: dab.d,
1365
+ fill: "currentColor",
1366
+ style: { fillOpacity: dab.fillOpacity }
1367
+ }, dab.d))
1368
+ })
1369
+ })
1370
+ })
1371
+ }), /* @__PURE__ */ jsxs(Box, {
1372
+ className: `od-codeink${overflow ? " is-overflow" : ""}${scroll ? " is-scroll" : ""}${surface ? " is-surface" : ""}${href ? " is-link" : ""}${interactive ? " is-interactive" : ""}${lit ? " is-lit" : ""}`,
1373
+ style: boxStyle,
1374
+ href,
1375
+ target: href ? "_blank" : void 0,
1376
+ rel: href ? "noopener" : void 0,
1377
+ onMouseEnter: () => setActive(true),
1378
+ onMouseLeave: () => setActive(false),
1379
+ onFocus: () => setActive(true),
1380
+ onBlur: () => setActive(false),
1381
+ children: [label && /* @__PURE__ */ jsx("div", {
1382
+ className: "od-codeink-label",
1383
+ style: { color: labelColor || color },
1384
+ children: label
1385
+ }), /* @__PURE__ */ jsx("pre", {
1386
+ className: "od-codeink-body",
1387
+ children: rows.map((row) => /* @__PURE__ */ jsx("span", {
1388
+ className: "od-codeink-line",
1389
+ children: lang === "sql" ? row.tokens.map((token) => /* @__PURE__ */ jsx("span", {
1390
+ style: { color: token.kind === "keyword" ? color : token.kind === "literal" ? ink("amber", 3) : void 0 },
1391
+ children: token.text
1392
+ }, token.id)) : row.line
1393
+ }, row.id))
1394
+ })]
1395
+ })] });
1396
+ }
1397
+ // ../kit/src/ink/graph-3d.tsx
1398
+ const MAX_NODES = 2e3;
1399
+ const ORBIT_SECONDS = 90;
1400
+ const SETTLE_DRIFT = .01;
1401
+ const SETTLE_QUIET_MS = 600;
1402
+ const MIN_SETTLE_MS = 1600;
1403
+ const RESUME_IDLE_MS = 4e3;
1404
+ const MAX_HANDLE_WAIT_MS = 12e3;
1405
+ function subscribeMotion(notify) {
1406
+ const observer = new MutationObserver(notify);
1407
+ observer.observe(document.documentElement, {
1408
+ attributes: true,
1409
+ attributeFilter: ["data-deck-motion"]
1410
+ });
1411
+ return () => observer.disconnect();
1412
+ }
1413
+ function Graph3D({ nodes, edges, orbit = true, dim = 1, zoom = 1, spec, legend = false }) {
1414
+ const { isActive, renderContext } = useSlide();
1415
+ const scale = useSlideScale();
1416
+ const mode = useSyncExternalStore(subscribeMotion, motionMode, () => "instant");
1417
+ const live = isActive && renderContext === "slide" && mode === "live";
1418
+ const [ready, setReady] = useState(false);
1419
+ const [failure, setFailure] = useState(null);
1420
+ useLayoutEffect(() => {
1421
+ if (!live || ready) return;
1422
+ let cancelled = false;
1423
+ import("@opendata-ai/openchart-react/graph-3d").then(() => {
1424
+ if (!cancelled) setReady(true);
1425
+ }, (cause) => {
1426
+ if (!cancelled) setFailure(new Error("Graph3D WebGL renderer failed to load", { cause }));
1427
+ });
1428
+ return () => {
1429
+ cancelled = true;
1430
+ };
1431
+ }, [live, ready]);
1432
+ const graphSpec = useMemo(() => {
1433
+ const value = {
1434
+ type: "graph",
1435
+ nodes,
1436
+ edges,
1437
+ animation: { enter: false },
1438
+ encoding: {
1439
+ ...nodes.some((node) => node.category !== void 0) ? { nodeColor: {
1440
+ field: "category",
1441
+ type: "nominal"
1442
+ } } : {},
1443
+ ...edges.some((edge) => edge.confidence !== void 0) ? { edgeWidth: {
1444
+ field: "confidence",
1445
+ type: "quantitative"
1446
+ } } : {},
1447
+ ...nodes.some((node) => node.label !== void 0) ? { nodeLabel: { field: "label" } } : {}
1448
+ },
1449
+ layout: {
1450
+ type: "force",
1451
+ ...nodes.some((node) => node.category !== void 0) ? { clustering: { field: "category" } } : {},
1452
+ chargeStrength: -500,
1453
+ linkDistance: 100,
1454
+ linkStrength: .3,
1455
+ collisionPadding: 4,
1456
+ warmup: 30,
1457
+ seed: 42
1458
+ },
1459
+ theme: {
1460
+ colors: {
1461
+ categorical: CATEGORICAL_COLORS,
1462
+ background: "transparent",
1463
+ text: theme().chart["graph-label"]
1464
+ },
1465
+ spacing: { padding: 4 }
1466
+ },
1467
+ ...spec,
1468
+ dimensions: 3
1469
+ };
1470
+ if (value.nodes.length > MAX_NODES) {
1471
+ console.warn(`[Graph3D] ${value.nodes.length} nodes exceeds the ${MAX_NODES} WebGL ceiling; truncating.`);
1472
+ value.nodes = value.nodes.slice(0, MAX_NODES);
1473
+ const kept = new Set(value.nodes.map((node) => node.id));
1474
+ value.edges = value.edges.filter((edge) => kept.has(edge.source) && kept.has(edge.target));
1475
+ }
1476
+ return value;
1477
+ }, [
1478
+ nodes,
1479
+ edges,
1480
+ spec
1481
+ ]);
1482
+ if (failure) throw failure;
1483
+ return /* @__PURE__ */ jsx("div", {
1484
+ className: "od-graph3d-host",
1485
+ style: { opacity: dim },
1486
+ children: live && ready && isActive && renderContext === "slide" ? /* @__PURE__ */ jsx(LiveGraph, {
1487
+ spec: graphSpec,
1488
+ orbit,
1489
+ zoom,
1490
+ legend,
1491
+ scale
1492
+ }) : /* @__PURE__ */ jsx(GraphStill, {
1493
+ spec: graphSpec,
1494
+ zoom,
1495
+ legend
1496
+ })
1497
+ });
1498
+ }
1499
+ /** A deterministic perspective projection, usable even before any live graph has mounted. */
1500
+ function GraphStill({ spec, zoom, legend }) {
1501
+ const graph = useMemo(() => compileGraph(spec, {
1502
+ width: 1920,
1503
+ height: 1080,
1504
+ darkMode: true
1505
+ }), [spec]);
1506
+ const projected = graph.nodes.map((node) => {
1507
+ const seed = `${graph.simulationConfig.seed ?? 0}:${node.community ?? ""}`;
1508
+ const x = hashSigned(seed, 0, 400) + hashSigned(node.id, 0, 180);
1509
+ const y = hashSigned(seed, 1, 240) + hashSigned(node.id, 1, 140);
1510
+ const k = 1e3 / (1e3 - hashSigned(node.id, 2, 180)) * Math.max(zoom, 1);
1511
+ return {
1512
+ ...node,
1513
+ x: 960 + x * k,
1514
+ y: 540 - y * k,
1515
+ r: node.radius * k
1516
+ };
1517
+ });
1518
+ const positions = new Map(projected.map((node) => [node.id, node]));
1519
+ const drawnEdges = graph.edges.map((edge, i) => ({
1520
+ ...edge,
1521
+ id: `edge${i}`
1522
+ }));
1523
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
1524
+ className: "od-graph3d-still",
1525
+ viewBox: "0 0 1920 1080",
1526
+ role: "img",
1527
+ "aria-label": "Similarity graph",
1528
+ children: [drawnEdges.map((edge) => {
1529
+ const source = positions.get(edge.source);
1530
+ const target = positions.get(edge.target);
1531
+ if (!source || !target) return null;
1532
+ return /* @__PURE__ */ jsx("path", {
1533
+ d: `M${source.x} ${source.y}L${target.x} ${target.y}`,
1534
+ fill: "none",
1535
+ stroke: edge.stroke,
1536
+ strokeWidth: edge.strokeWidth,
1537
+ strokeOpacity: .3
1538
+ }, edge.id);
1539
+ }), projected.map((node, i) => /* @__PURE__ */ jsxs("g", {
1540
+ "aria-label": node.label ?? node.id,
1541
+ children: [/* @__PURE__ */ jsx("circle", {
1542
+ cx: node.x,
1543
+ cy: node.y,
1544
+ r: node.r,
1545
+ fill: node.fill,
1546
+ opacity: node.opacity
1547
+ }), i < 40 && node.label && /* @__PURE__ */ jsx("text", {
1548
+ x: node.x + node.r + 5,
1549
+ y: node.y,
1550
+ fill: graph.theme.colors.text,
1551
+ children: node.label
1552
+ })]
1553
+ }, node.id))]
1554
+ }), legend && "entries" in graph.legend && /* @__PURE__ */ jsx("ul", {
1555
+ className: "od-graph3d-legend",
1556
+ "aria-label": "Graph categories",
1557
+ children: graph.legend.entries.map((entry) => /* @__PURE__ */ jsxs("li", {
1558
+ style: { color: entry.color },
1559
+ children: [entry.label, (legend === true || legend.counts !== false) && ` (${entry.count ?? 0})`]
1560
+ }, entry.label))
1561
+ })] });
1562
+ }
1563
+ function LiveGraph({ spec, orbit, zoom, legend, scale }) {
1564
+ const host = useRef(null);
1565
+ const graph = useRef(null);
1566
+ const settings = useRef({
1567
+ orbit,
1568
+ zoom
1569
+ });
1570
+ useLayoutEffect(() => {
1571
+ settings.current = {
1572
+ orbit,
1573
+ zoom
1574
+ };
1575
+ }, [orbit, zoom]);
1576
+ useLayoutEffect(() => {
1577
+ const element = host.current;
1578
+ if (!element) return;
1579
+ const mountedAt = performance.now();
1580
+ let lastFrame = mountedAt;
1581
+ let rafId = 0;
1582
+ let resumeTimer;
1583
+ let paused = false;
1584
+ let settled = false;
1585
+ let radius = 0;
1586
+ let height = 0;
1587
+ let angle = 0;
1588
+ let fitRadius = 0;
1589
+ let fitHeight = 0;
1590
+ let center = {
1591
+ x: 0,
1592
+ y: 0,
1593
+ z: 0
1594
+ };
1595
+ let driftAnchor = null;
1596
+ function readPose() {
1597
+ const camera = graph.current?.getCamera();
1598
+ const position = camera?.position;
1599
+ const target = camera?.target;
1600
+ if (!position || !target) return false;
1601
+ radius = Math.hypot(position.x - target.x, position.z - target.z);
1602
+ if (radius === 0) return false;
1603
+ height = position.y - target.y;
1604
+ angle = Math.atan2(position.z - target.z, position.x - target.x);
1605
+ center = { ...target };
1606
+ return true;
1607
+ }
1608
+ function tick(now) {
1609
+ const handle = graph.current;
1610
+ if (!handle && now - mountedAt > MAX_HANDLE_WAIT_MS) {
1611
+ console.warn(`Graph3D: no camera handle after ${MAX_HANDLE_WAIT_MS}ms; stopping orbit.`);
1612
+ return;
1613
+ }
1614
+ rafId = requestAnimationFrame(tick);
1615
+ const dt = (now - lastFrame) / 1e3;
1616
+ lastFrame = now;
1617
+ if (!handle || paused) return;
1618
+ if (!settled) {
1619
+ const first = fitRadius === 0;
1620
+ const keepAngle = angle;
1621
+ handle.zoomToFit({ duration: 0 });
1622
+ if (!readPose()) return;
1623
+ if (!first) angle = keepAngle;
1624
+ fitRadius = radius;
1625
+ fitHeight = height;
1626
+ const distance = Math.hypot(radius, height);
1627
+ if (!driftAnchor || Math.abs(distance - driftAnchor.distance) > SETTLE_DRIFT * driftAnchor.distance) driftAnchor = {
1628
+ distance,
1629
+ at: now
1630
+ };
1631
+ else if (now - driftAnchor.at > SETTLE_QUIET_MS && now - mountedAt > MIN_SETTLE_MS) settled = true;
1632
+ }
1633
+ if (fitRadius === 0) return;
1634
+ if (settings.current.orbit) angle += Math.PI * 2 / ORBIT_SECONDS * dt;
1635
+ radius = fitRadius / Math.max(settings.current.zoom, 1);
1636
+ height = fitHeight / Math.max(settings.current.zoom, 1);
1637
+ handle.flyTo({
1638
+ x: center.x,
1639
+ y: center.y,
1640
+ position: {
1641
+ x: center.x + radius * Math.cos(angle),
1642
+ y: center.y + height,
1643
+ z: center.z + radius * Math.sin(angle)
1644
+ },
1645
+ target: center
1646
+ }, { duration: 0 });
1647
+ }
1648
+ function onCameraInput() {
1649
+ paused = true;
1650
+ clearTimeout(resumeTimer);
1651
+ resumeTimer = setTimeout(() => {
1652
+ if (!readPose()) return;
1653
+ fitRadius = radius * Math.max(settings.current.zoom, 1);
1654
+ fitHeight = height * Math.max(settings.current.zoom, 1);
1655
+ settled = true;
1656
+ paused = false;
1657
+ }, RESUME_IDLE_MS);
1658
+ }
1659
+ element.addEventListener("pointerdown", onCameraInput, true);
1660
+ element.addEventListener("wheel", onCameraInput, {
1661
+ capture: true,
1662
+ passive: true
1663
+ });
1664
+ rafId = requestAnimationFrame(tick);
1665
+ return () => {
1666
+ cancelAnimationFrame(rafId);
1667
+ clearTimeout(resumeTimer);
1668
+ element.removeEventListener("pointerdown", onCameraInput, true);
1669
+ element.removeEventListener("wheel", onCameraInput, true);
1670
+ };
1671
+ }, []);
1672
+ return /* @__PURE__ */ jsx("div", {
1673
+ ref: host,
1674
+ className: "od-graph3d",
1675
+ style: {
1676
+ width: `${scale * 100}%`,
1677
+ height: `${scale * 100}%`,
1678
+ transform: `scale(${1 / scale})`,
1679
+ transformOrigin: "top left"
1680
+ },
1681
+ children: /* @__PURE__ */ jsx(Graph, {
1682
+ ref: graph,
1683
+ spec,
1684
+ darkMode: "force",
1685
+ legend,
1686
+ tooltip: false,
1687
+ fitOnLoad: false
1688
+ })
1689
+ });
1690
+ }
1691
+ // ../kit/src/story/timeline-position.ts
1692
+ /** Resolve once before inserting a group so relative positions do not stagger it. */
1693
+ function resolvePosition(tl, position) {
1694
+ if (typeof position === "number") return position;
1695
+ if (typeof position === "string") {
1696
+ if (position === "<") {
1697
+ const recent = tl.recent();
1698
+ return recent && "startTime" in recent ? recent.startTime() : tl.duration();
1699
+ }
1700
+ if (position === ">") return tl.duration();
1701
+ const relative = /^([+-])=([\d.]+)$/.exec(position);
1702
+ if (relative) {
1703
+ const delta = (relative[1] === "-" ? -1 : 1) * Number(relative[2]);
1704
+ return Math.max(0, tl.duration() + delta);
1705
+ }
1706
+ const label = tl.labels[position];
1707
+ if (label !== void 0) return label;
1708
+ }
1709
+ return tl.duration();
1710
+ }
1711
+ /** Includes the deck's explicit instant mode as well as the system preference. */
1712
+ function prefersReducedMotion() {
1713
+ return motionMode() === "instant";
1714
+ }
1715
+ // ../kit/src/ink/ink-bars.tsx
1716
+ function InkBars({ rows, domain, xRange, yBand, thickness = 24, sort = "none", labelWidth = 460, labelGap = 40, format = String, hue = "emerald", step = 3, seed = "ink-bars", ref }) {
1717
+ const { isActive, renderContext } = useSlide();
1718
+ const settled = !isActive || renderContext !== "slide" || motionMode() === "instant";
1719
+ const driven = useRef(false);
1720
+ const revision = useTween({ value: 0 });
1721
+ const animations = useRef(/* @__PURE__ */ new Set());
1722
+ useLayoutEffect(() => {
1723
+ const owned = animations.current;
1724
+ return () => {
1725
+ for (const animation of owned) animation.kill();
1726
+ owned.clear();
1727
+ };
1728
+ }, []);
1729
+ const labelFor = (row) => row.text ?? format(row.value);
1730
+ function layoutFor(next, nextDomain) {
1731
+ const sorted = [...next];
1732
+ if (sort === "asc") sorted.sort((a, b) => a.value - b.value);
1733
+ if (sort === "desc") sorted.sort((a, b) => b.value - a.value);
1734
+ const pitch = sorted.length ? (yBand[1] - yBand[0]) / sorted.length : 0;
1735
+ return Object.fromEntries(sorted.map((row, i) => [row.id, {
1736
+ y: yBand[0] + pitch * (i + .5),
1737
+ len: (Math.max(nextDomain[0], Math.min(nextDomain[1], row.value)) - nextDomain[0]) / (nextDomain[1] - nextDomain[0] || 1) * (xRange[1] - xRange[0])
1738
+ }]));
1739
+ }
1740
+ const [state] = useState(() => {
1741
+ const layout = layoutFor(rows, domain);
1742
+ return Object.fromEntries(rows.flatMap((row) => {
1743
+ const slot = layout[row.id];
1744
+ if (!slot) return [];
1745
+ const base = ink(row.hue ?? hue, row.step ?? step);
1746
+ return [[row.id, new Proxy({
1747
+ ...slot,
1748
+ reveal: 0,
1749
+ opacity: 1,
1750
+ accent: 0,
1751
+ label: row.label,
1752
+ text: labelFor(row),
1753
+ accentColor: base,
1754
+ base
1755
+ }, { set(target, key, value) {
1756
+ const previous = Reflect.get(target, key);
1757
+ const written = Reflect.set(target, key, value);
1758
+ if (key !== "_gsap" && previous !== value) {
1759
+ driven.current = true;
1760
+ revision.value++;
1761
+ }
1762
+ return written;
1763
+ } })]];
1764
+ }));
1765
+ });
1766
+ const [order] = useState(() => rows.map((row) => row.id));
1767
+ function track(tl) {
1768
+ const recent = tl.recent();
1769
+ if (typeof recent !== "function") animations.current.add(recent);
1770
+ return tl;
1771
+ }
1772
+ useImperativeHandle(ref, () => ({
1773
+ labelLeft: xRange[0] - labelGap - labelWidth,
1774
+ get state() {
1775
+ driven.current = true;
1776
+ revision.value++;
1777
+ return state;
1778
+ },
1779
+ addGrow(tl, position, { spread = 0 } = {}) {
1780
+ driven.current = true;
1781
+ revision.value++;
1782
+ const at = resolvePosition(tl, position ?? ">");
1783
+ order.forEach((id, i) => {
1784
+ const row = state[id];
1785
+ if (!row) return;
1786
+ track(tl.to(row, {
1787
+ reveal: 1,
1788
+ opacity: 1,
1789
+ duration: DUR.grow,
1790
+ lazy: false
1791
+ }, at + easedStagger(i, order.length, spread)));
1792
+ });
1793
+ return tl;
1794
+ },
1795
+ addReorder(tl, next, nextDomain = domain, position, { spread = 0 } = {}) {
1796
+ const target = layoutFor(next, nextDomain);
1797
+ const at = resolvePosition(tl, position ?? ">");
1798
+ const surviving = next.filter((row) => target[row.id] && state[row.id]);
1799
+ surviving.forEach((row, i) => {
1800
+ const slot = target[row.id];
1801
+ const current = state[row.id];
1802
+ if (!slot || !current) return;
1803
+ const start = at + easedStagger(i, surviving.length, spread);
1804
+ track(tl.set(current, {
1805
+ text: labelFor(row),
1806
+ label: row.label
1807
+ }, start));
1808
+ track(tl.to(current, {
1809
+ y: slot.y,
1810
+ len: slot.len,
1811
+ duration: DUR.scale
1812
+ }, start));
1813
+ });
1814
+ return tl;
1815
+ },
1816
+ addExit(tl, ids, position) {
1817
+ const at = resolvePosition(tl, position ?? `+=${DUR.eraseDelay}`);
1818
+ for (const id of ids) {
1819
+ const row = state[id];
1820
+ if (row) track(tl.to(row, {
1821
+ opacity: 0,
1822
+ duration: DUR.opacity
1823
+ }, at));
1824
+ }
1825
+ return tl;
1826
+ },
1827
+ addRecolor(tl, id, color, position) {
1828
+ const row = state[id];
1829
+ if (!row) return tl;
1830
+ const at = resolvePosition(tl, position ?? ">");
1831
+ track(tl.set(row, { accentColor: color }, at));
1832
+ return track(tl.to(row, {
1833
+ accent: 1,
1834
+ duration: DUR.color
1835
+ }, at));
1836
+ }
1837
+ }));
1838
+ const live = order.flatMap((id) => {
1839
+ const row = state[id];
1840
+ if (!row) return [];
1841
+ const visible = settled && !driven.current ? {
1842
+ ...row,
1843
+ reveal: 1
1844
+ } : row;
1845
+ return visible.opacity > 0 && visible.reveal > 0 ? [{
1846
+ id,
1847
+ row: visible
1848
+ }] : [];
1849
+ });
1850
+ const stacked = stackEndLabels(live.map(({ row }) => ({
1851
+ y: row.y,
1852
+ h: thickness
1853
+ })), thickness * .5);
1854
+ return /* @__PURE__ */ jsx("g", {
1855
+ className: "od-ink-bars",
1856
+ children: live.map(({ id, row }, i) => {
1857
+ const drawn = row.len * clamp01(row.reveal);
1858
+ const color = row.accent > 0 ? `color-mix(in oklab, ${row.accentColor} ${row.accent * 100}%, ${row.base})` : row.base;
1859
+ const dabs = inkStyle() === "marker" ? brushRibbon([{
1860
+ x: xRange[0],
1861
+ y: row.y
1862
+ }, {
1863
+ x: xRange[0] + Math.max(drawn, 1),
1864
+ y: row.y
1865
+ }], {
1866
+ seed: `${seed}:${id}`,
1867
+ width: thickness,
1868
+ taperIn: .04,
1869
+ taperOut: .07,
1870
+ startWidth: .82,
1871
+ endWidth: .66,
1872
+ wobble: 1.6,
1873
+ edge: .9,
1874
+ samples: 16
1875
+ }) : [];
1876
+ return /* @__PURE__ */ jsxs("g", {
1877
+ style: {
1878
+ color,
1879
+ opacity: row.opacity
1880
+ },
1881
+ children: [
1882
+ /* @__PURE__ */ jsx("text", {
1883
+ className: "od-stage-label",
1884
+ x: xRange[0] - labelGap,
1885
+ y: row.y + thickness * .36,
1886
+ textAnchor: "end",
1887
+ children: row.label
1888
+ }),
1889
+ inkStyle() === "clean" ? /* @__PURE__ */ jsx("rect", {
1890
+ x: xRange[0],
1891
+ y: row.y - thickness / 2,
1892
+ width: Math.max(drawn, 1),
1893
+ height: thickness,
1894
+ rx: 3,
1895
+ fill: "currentColor",
1896
+ filter: filterUrl(FILTER_IDS.glow)
1897
+ }) : /* @__PURE__ */ jsxs("g", {
1898
+ filter: filterUrl(FILTER_IDS.marker),
1899
+ children: [dabs.map((dab) => /* @__PURE__ */ jsx("path", {
1900
+ d: dab.d,
1901
+ fill: "currentColor",
1902
+ style: { fillOpacity: dab.fillOpacity }
1903
+ }, dab.d)), dabs.filter((dab) => dab.overpaint !== void 0).map((dab) => /* @__PURE__ */ jsx("path", {
1904
+ d: dab.d,
1905
+ fill: "currentColor",
1906
+ style: { fillOpacity: dab.overpaint }
1907
+ }, `over:${dab.d}`))]
1908
+ }),
1909
+ /* @__PURE__ */ jsx("text", {
1910
+ className: "od-bars-value",
1911
+ x: xRange[0] + drawn + thickness * .7,
1912
+ y: (stacked[i] ?? row.y) + thickness * .36,
1913
+ textAnchor: "start",
1914
+ children: row.text
1915
+ })
1916
+ ]
1917
+ }, id);
1918
+ })
1919
+ });
1920
+ }
1921
+ // ../kit/src/ink/ink-card-rect.tsx
1922
+ function InkCardRect({ x, y, width, height, radius = 12, surface = "var(--od-surface)", hue, glowCx = 0, glowCy = 0, glowR = 1, glowEdge = 1, glowOpacity = .12, lit, stroke = "currentColor", strokeWidth = STROKE.rule, strokeOpacity = 1, dash, glowFilter = false, children }) {
1923
+ const gradientId = `od-card-glow-${useId()}`;
1924
+ const { isActive, renderContext } = useSlide();
1925
+ const live = isActive && renderContext === "slide" && motionMode() === "live";
1926
+ const box = {
1927
+ x,
1928
+ y,
1929
+ width,
1930
+ height,
1931
+ rx: radius
1932
+ };
1933
+ const glowInk = hue ? ink(hue, 3) : "currentColor";
1934
+ return /* @__PURE__ */ jsxs("g", {
1935
+ className: `od-ink-card-rect${lit === true ? " is-lit" : lit === false ? " is-unlit" : ""}`,
1936
+ children: [
1937
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("radialGradient", {
1938
+ id: gradientId,
1939
+ cx: glowCx,
1940
+ cy: glowCy,
1941
+ r: glowR,
1942
+ gradientUnits: "objectBoundingBox",
1943
+ children: [/* @__PURE__ */ jsx("stop", {
1944
+ offset: "0",
1945
+ stopColor: glowInk,
1946
+ style: { stopOpacity: glowOpacity }
1947
+ }), /* @__PURE__ */ jsx("stop", {
1948
+ offset: glowEdge,
1949
+ stopColor: glowInk,
1950
+ style: { stopOpacity: 0 }
1951
+ })]
1952
+ }) }),
1953
+ /* @__PURE__ */ jsx("rect", {
1954
+ ...box,
1955
+ fill: surface
1956
+ }),
1957
+ /* @__PURE__ */ jsx("rect", {
1958
+ ...box,
1959
+ fill: `url(#${gradientId})`,
1960
+ className: "od-card-glow",
1961
+ style: {
1962
+ opacity: lit === false ? 0 : 1,
1963
+ transition: live ? void 0 : "none"
1964
+ }
1965
+ }),
1966
+ /* @__PURE__ */ jsx("rect", {
1967
+ ...box,
1968
+ fill: "none",
1969
+ stroke,
1970
+ strokeWidth,
1971
+ style: {
1972
+ strokeOpacity,
1973
+ transition: live ? void 0 : "none"
1974
+ },
1975
+ strokeDasharray: dash,
1976
+ filter: glowFilter ? filterUrl(FILTER_IDS.glow) : void 0,
1977
+ className: "od-card-stroke"
1978
+ }),
1979
+ children
1980
+ ]
1981
+ });
1982
+ }
1983
+ // ../kit/src/story/story-motion.ts
1984
+ /**
1985
+ * Shared motion for the story chrome: card swaps and the slide entrance.
1986
+ *
1987
+ * Everything here is small on purpose. The card rises six pixels while it
1988
+ * fades, the headline and card settle into place on slide entry, and that is
1989
+ * the whole vocabulary. The pace comes from DUR, the curve from SETTLE, and
1990
+ * both are the same ones the stage timelines use, so chrome and ink read as
1991
+ * one motion system rather than two.
1992
+ */
1993
+ /** How far a piece of chrome travels while it fades in, in px. */
1994
+ const RISE = {
1995
+ card: 6,
1996
+ enter: 14
1997
+ };
1998
+ /**
1999
+ * Enter callback: fade in with a short rise. Under instant motion it settles
2000
+ * immediately.
2001
+ */
2002
+ function riseIn(el, done) {
2003
+ if (prefersReducedMotion()) {
2004
+ gsap.set(el, {
2005
+ opacity: 1,
2006
+ y: 0
2007
+ });
2008
+ done();
2009
+ return;
2010
+ }
2011
+ gsap.fromTo(el, {
2012
+ opacity: 0,
2013
+ y: RISE.card
2014
+ }, {
2015
+ opacity: 1,
2016
+ y: 0,
2017
+ duration: DUR.card,
2018
+ ease: SETTLE,
2019
+ onComplete: done
2020
+ });
2021
+ }
2022
+ /**
2023
+ * Enter callback: fade in place over the card beat, no travel. Pairs with
2024
+ * `fadeOutInPlace` for a label that swaps on a beat (a timeline date, a map
2025
+ * legend), which should cross fade on the card's clock without the card's
2026
+ * rise.
2027
+ */
2028
+ function fadeIn(el, done) {
2029
+ if (prefersReducedMotion()) {
2030
+ gsap.set(el, { opacity: 1 });
2031
+ done();
2032
+ return;
2033
+ }
2034
+ gsap.fromTo(el, { opacity: 0 }, {
2035
+ opacity: 1,
2036
+ duration: DUR.card,
2037
+ ease: SETTLE,
2038
+ onComplete: done
2039
+ });
2040
+ }
2041
+ /**
2042
+ * Ease a box from a measured height to its natural height over the card beat.
2043
+ *
2044
+ * For a container whose content is swapped by `riseIn`/`fadeOutInPlace`: the
2045
+ * outgoing copy leaves the flow, so without this the box would resize to the
2046
+ * incoming copy in one frame. Call it from the enter callback with the height
2047
+ * recorded in before leaving. Any height tween still running on the box is
2048
+ * killed first, so fast clicking never stacks two. Under reduced motion the
2049
+ * box takes its new height at once.
2050
+ */
2051
+ function easeHeight(el, from) {
2052
+ gsap.killTweensOf(el, "height");
2053
+ gsap.set(el, { clearProps: "height,overflow" });
2054
+ const to = el.offsetHeight;
2055
+ if (prefersReducedMotion() || !(from > 0) || Math.abs(to - from) < 1) return;
2056
+ gsap.fromTo(el, {
2057
+ height: from,
2058
+ overflow: "hidden"
2059
+ }, {
2060
+ height: to,
2061
+ duration: DUR.card,
2062
+ ease: SETTLE,
2063
+ clearProps: "height,overflow"
2064
+ });
2065
+ }
2066
+ /**
2067
+ * Leave callback for a swapped card body: take the outgoing copy out of
2068
+ * flow so the two states overlap rather than collapsing the card height mid
2069
+ * swap, then fade it without moving it. Only the incoming copy travels.
2070
+ */
2071
+ function fadeOutInPlace(el, done) {
2072
+ gsap.set(el, {
2073
+ position: "absolute",
2074
+ top: 0,
2075
+ left: 0,
2076
+ right: 0
2077
+ });
2078
+ if (prefersReducedMotion()) {
2079
+ gsap.set(el, { opacity: 0 });
2080
+ done();
2081
+ return;
2082
+ }
2083
+ gsap.to(el, {
2084
+ opacity: 0,
2085
+ duration: DUR.opacity,
2086
+ onComplete: done
2087
+ });
2088
+ }
2089
+ /**
2090
+ * Slide entrance: each group fades in and settles up over the morph
2091
+ * duration, starting one `opacity` beat after the previous group. Returns
2092
+ * the timeline so the caller can kill it on re-entry or unmount.
2093
+ */
2094
+ function entrance(opts) {
2095
+ const tl = gsap.timeline();
2096
+ let at = 0;
2097
+ for (const group of opts.groups) {
2098
+ if (!group.length) continue;
2099
+ tl.fromTo(group, {
2100
+ opacity: 0,
2101
+ y: RISE.enter
2102
+ }, {
2103
+ opacity: 1,
2104
+ y: 0,
2105
+ duration: DUR.morph,
2106
+ ease: SETTLE,
2107
+ clearProps: "transform"
2108
+ }, at);
2109
+ at += DUR.opacity;
2110
+ }
2111
+ if (prefersReducedMotion()) tl.progress(1).pause();
2112
+ return tl;
2113
+ }
2114
+ // ../kit/src/ink/ink-chip.tsx
2115
+ function InkChip({ x, y, text, hue = "cyan", anchor = "left", progress = 1, href, wide = false }) {
2116
+ const { isActive, renderContext } = useSlide();
2117
+ const live = isActive && renderContext === "slide" && motionMode() === "live";
2118
+ const style = {
2119
+ ...anchor === "right" ? { right: `${(STAGE.width - x) / STAGE.width * 100}%` } : { left: `calc(${x / STAGE.width * 100}% + 0.520833 * var(--sw))` },
2120
+ top: `${y / STAGE.height * 100}%`,
2121
+ opacity: progress,
2122
+ transform: `translateY(-50%) translateY(calc(${live ? (1 - progress) * RISE.card / 19.2 : 0} * var(--sw)))`,
2123
+ pointerEvents: href && progress > .5 ? "auto" : "none",
2124
+ transition: live ? void 0 : "none",
2125
+ "--od-chip-ink": ink(hue, 3)
2126
+ };
2127
+ const className = `od-inkchip${href ? " is-link" : ""}${wide ? " is-wide" : ""}`;
2128
+ return href ? /* @__PURE__ */ jsx("a", {
2129
+ className,
2130
+ style,
2131
+ href,
2132
+ target: "_blank",
2133
+ rel: "noopener",
2134
+ children: text
2135
+ }) : /* @__PURE__ */ jsx("div", {
2136
+ className,
2137
+ style,
2138
+ children: text
2139
+ });
2140
+ }
2141
+ // ../kit/src/ink/ink-line.tsx
2142
+ function truncate(points, fraction) {
2143
+ if (fraction >= 1) return points;
2144
+ if (fraction <= 0 || points.length < 2) return [];
2145
+ let total = 0;
2146
+ for (let i = 1; i < points.length; i++) {
2147
+ const a = points[i - 1];
2148
+ const b = points[i];
2149
+ if (a && b) total += Math.hypot(b.x - a.x, b.y - a.y);
2150
+ }
2151
+ const first = points[0];
2152
+ if (!first) return [];
2153
+ const out = [first];
2154
+ let walked = 0;
2155
+ for (let i = 1; i < points.length; i++) {
2156
+ const a = points[i - 1];
2157
+ const b = points[i];
2158
+ if (!a || !b) continue;
2159
+ const len = Math.hypot(b.x - a.x, b.y - a.y);
2160
+ if (walked + len >= total * fraction) {
2161
+ const u = len === 0 ? 0 : (total * fraction - walked) / len;
2162
+ out.push({
2163
+ x: a.x + (b.x - a.x) * u,
2164
+ y: a.y + (b.y - a.y) * u
2165
+ });
2166
+ break;
2167
+ }
2168
+ out.push(b);
2169
+ walked += len;
2170
+ }
2171
+ return out.length < 2 ? [] : out;
2172
+ }
2173
+ function InkLine({ series, xDomain, yDomain, xRange, yRange, interp = "linear", hue = "cyan", step = 3, reveal = 1, ghost = false, color = "", seed = "ink-line", width = BRUSH_DEFAULTS.width, dots = false, head = false, ref }) {
2174
+ const { isActive, renderContext } = useSlide();
2175
+ const root = useRef(null);
2176
+ const draw = useTween({
2177
+ t: 1,
2178
+ opacity: 1
2179
+ });
2180
+ const animations = useRef(/* @__PURE__ */ new Set());
2181
+ useLayoutEffect(() => {
2182
+ const owned = animations.current;
2183
+ return () => {
2184
+ for (const animation of owned) animation.kill();
2185
+ owned.clear();
2186
+ };
2187
+ }, []);
2188
+ function track(tl) {
2189
+ const recent = tl.recent();
2190
+ if (typeof recent !== "function") animations.current.add(recent);
2191
+ }
2192
+ useImperativeHandle(ref, () => ({
2193
+ get root() {
2194
+ return root.current;
2195
+ },
2196
+ addDraw(tl, position, opts = {}) {
2197
+ tl.fromTo(draw, { t: 0 }, {
2198
+ t: 1,
2199
+ duration: opts.duration ?? DUR.grow,
2200
+ ease: opts.ease ?? "odDraw",
2201
+ lazy: false
2202
+ }, position);
2203
+ track(tl);
2204
+ return tl;
2205
+ },
2206
+ addErase(tl, position) {
2207
+ tl.to(draw, {
2208
+ opacity: 0,
2209
+ duration: DUR.opacity
2210
+ }, position ?? `+=${DUR.eraseDelay}`);
2211
+ track(tl);
2212
+ tl.set(draw, { t: 0 }, `+=${DUR.eraseHold}`);
2213
+ track(tl);
2214
+ tl.set(draw, { opacity: 1 }, "<");
2215
+ track(tl);
2216
+ return tl;
2217
+ },
2218
+ settle() {
2219
+ draw.t = 1;
2220
+ }
2221
+ }));
2222
+ const sx = xScale(xDomain, xRange);
2223
+ const sy = yScale(yDomain, yRange);
2224
+ const raw = series.map((p) => ({
2225
+ x: sx(p.x),
2226
+ y: sy(p.y)
2227
+ }));
2228
+ const projected = raw.flatMap((p, i) => {
2229
+ const previous = raw[i - 1];
2230
+ return interp === "step" && previous ? [{
2231
+ x: p.x,
2232
+ y: previous.y
2233
+ }, p] : [p];
2234
+ });
2235
+ const revealed = truncate(projected, clamp01(reveal));
2236
+ const clean = inkStyle() === "clean";
2237
+ const dabs = clean ? [] : brushRibbon(revealed, {
2238
+ seed: `${seed}:${interp}`,
2239
+ width
2240
+ });
2241
+ const ghostT = typeof ghost === "number" ? clamp01(ghost) : ghost ? 1 : 0;
2242
+ const isGhost = ghostT >= .5;
2243
+ const ghostColor = ghostT <= 0 ? ink(hue, step) : ghostT >= 1 ? ink("slate", 1) : `color-mix(in oklab, ${ink("slate", 1)} ${(ghostT * 100).toFixed(1)}%, ${ink(hue, step)})`;
2244
+ const first = projected[0];
2245
+ const last = projected.at(-1);
2246
+ const front = first && last ? first.x + (last.x - first.x) * draw.t : 0;
2247
+ let headY = last?.y ?? 0;
2248
+ for (let i = 1; i < projected.length; i++) {
2249
+ const a = projected[i - 1];
2250
+ const b = projected[i];
2251
+ if (a && b && (front - a.x) * (front - b.x) <= 0) {
2252
+ headY = b.x === a.x ? b.y : a.y + (b.y - a.y) * (front - a.x) / (b.x - a.x);
2253
+ break;
2254
+ }
2255
+ }
2256
+ const animateGhost = isActive && renderContext === "slide" && motionMode() === "live" && typeof ghost !== "number";
2257
+ const markStyle = {
2258
+ opacity: 1 - (1 - Number(theme().shape.dim)) * ghostT,
2259
+ transition: animateGhost ? void 0 : "none"
2260
+ };
2261
+ const glow = isGhost ? void 0 : filterUrl(FILTER_IDS.glow);
2262
+ return /* @__PURE__ */ jsxs("g", {
2263
+ ref: root,
2264
+ className: "od-ink-line-root",
2265
+ style: {
2266
+ color: color || ghostColor,
2267
+ opacity: draw.opacity,
2268
+ "--od-clip": `${(1 - draw.t) * 100}%`
2269
+ },
2270
+ children: [
2271
+ /* @__PURE__ */ jsx("g", {
2272
+ className: "od-ink-line",
2273
+ children: /* @__PURE__ */ jsxs("g", {
2274
+ className: "od-ink-body",
2275
+ style: markStyle,
2276
+ filter: clean ? glow : filterUrl(FILTER_IDS.marker),
2277
+ children: [clean ? /* @__PURE__ */ jsx("path", {
2278
+ d: polylinePath(revealed),
2279
+ fill: "none",
2280
+ stroke: "currentColor",
2281
+ strokeWidth: STROKE.line,
2282
+ strokeLinecap: "round",
2283
+ strokeLinejoin: "round"
2284
+ }) : dabs.map((dab) => /* @__PURE__ */ jsx("path", {
2285
+ d: dab.d,
2286
+ fill: "currentColor",
2287
+ style: { fillOpacity: dab.fillOpacity }
2288
+ }, dab.d)), dabs.filter((dab) => dab.overpaint !== void 0).map((dab) => /* @__PURE__ */ jsx("path", {
2289
+ d: dab.d,
2290
+ fill: "currentColor",
2291
+ style: { fillOpacity: dab.overpaint }
2292
+ }, `over:${dab.d}`))]
2293
+ })
2294
+ }),
2295
+ clean && dots && draw.t > 0 && /* @__PURE__ */ jsx("g", {
2296
+ className: "od-ink-dots",
2297
+ style: markStyle,
2298
+ filter: glow,
2299
+ children: raw.map((p) => {
2300
+ const u = clamp01((front - p.x + 48) / 48);
2301
+ const r = Math.round(7 * (u + .45 * Math.sin(Math.PI * u)) * 100) / 100;
2302
+ return /* @__PURE__ */ jsx("circle", {
2303
+ cx: p.x,
2304
+ cy: p.y,
2305
+ r,
2306
+ fill: "currentColor"
2307
+ }, `${p.x}:${p.y}`);
2308
+ })
2309
+ }),
2310
+ head && !isGhost && reveal >= 1 && draw.t > 0 && draw.t < 1 && projected.length >= 2 && /* @__PURE__ */ jsx("g", {
2311
+ className: "od-ink-head",
2312
+ transform: `translate(${Math.round(front * 100) / 100} ${Math.round(headY * 100) / 100})`,
2313
+ style: { opacity: Math.round(clamp01((1 - draw.t) / .08) * 100) / 100 },
2314
+ children: /* @__PURE__ */ jsx("g", {
2315
+ filter: filterUrl(FILTER_IDS.glow),
2316
+ children: /* @__PURE__ */ jsx("circle", {
2317
+ r: 6,
2318
+ fill: "currentColor"
2319
+ })
2320
+ })
2321
+ })
2322
+ ]
2323
+ });
2324
+ }
2325
+ // ../kit/src/ink/ink-number.tsx
2326
+ function InkNumber({ value, label = "", hue = "emerald", step = 3, size = 6.4, count = true, prefix = "", suffix = "", ref }) {
2327
+ const { isActive, renderContext } = useSlide();
2328
+ const bare = value.replace(/,/g, "");
2329
+ const numeric = Number(bare);
2330
+ const countable = count && bare.trim() !== "" && Number.isFinite(numeric);
2331
+ const places = value.includes(".") ? value.length - value.indexOf(".") - 1 : 0;
2332
+ const state = useTween({
2333
+ n: 0,
2334
+ grow: 0
2335
+ });
2336
+ const registered = useRef(false);
2337
+ useLayoutEffect(() => {
2338
+ if (!isActive || renderContext !== "slide" || motionMode() === "instant") {
2339
+ state.n = countable ? numeric : 0;
2340
+ state.grow = 1;
2341
+ }
2342
+ }, [
2343
+ isActive,
2344
+ renderContext,
2345
+ state,
2346
+ countable,
2347
+ numeric
2348
+ ]);
2349
+ useLayoutEffect(() => () => {
2350
+ gsap.killTweensOf(state);
2351
+ registered.current = false;
2352
+ }, [state]);
2353
+ useImperativeHandle(ref, () => ({ addGrow(tl, position) {
2354
+ const at = resolvePosition(tl, position ?? ">");
2355
+ if (!registered.current) {
2356
+ state.grow = 0;
2357
+ state.n = 0;
2358
+ registered.current = true;
2359
+ }
2360
+ tl.to(state, {
2361
+ grow: 1,
2362
+ ...countable ? { n: numeric } : {},
2363
+ duration: DUR.grow
2364
+ }, at);
2365
+ return tl;
2366
+ } }), [
2367
+ state,
2368
+ countable,
2369
+ numeric
2370
+ ]);
2371
+ const shown = !countable ? value : value.includes(",") ? state.n.toLocaleString("en-US", {
2372
+ minimumFractionDigits: places,
2373
+ maximumFractionDigits: places
2374
+ }) : state.n.toFixed(places);
2375
+ return /* @__PURE__ */ jsxs("div", {
2376
+ className: "od-bignum",
2377
+ children: [/* @__PURE__ */ jsxs("div", {
2378
+ className: "od-bignum-figure",
2379
+ style: {
2380
+ color: ink(hue, step),
2381
+ fontSize: `calc(${size} * var(--sw))`,
2382
+ opacity: state.grow,
2383
+ transform: countable ? "none" : `scaleY(${.3 + .7 * state.grow})`
2384
+ },
2385
+ children: [
2386
+ prefix && /* @__PURE__ */ jsx("span", { children: prefix }),
2387
+ shown,
2388
+ suffix && /* @__PURE__ */ jsx("span", { children: suffix })
2389
+ ]
2390
+ }), label && /* @__PURE__ */ jsx("div", {
2391
+ className: "od-bignum-label",
2392
+ style: { opacity: state.grow },
2393
+ children: label
2394
+ })]
2395
+ });
2396
+ }
2397
+ // ../kit/src/ink/ink-ping.tsx
2398
+ const settle$1 = gsap.parseEase(SETTLE);
2399
+ const q$1 = (n) => Math.round(n * 1e3) / 1e3;
2400
+ const smooth = (t) => t * t * (3 - 2 * t);
2401
+ const BEACON = {
2402
+ grow: 1.4,
2403
+ peak: .75,
2404
+ rise: .3,
2405
+ echoLag: .24,
2406
+ echoPeak: .55
2407
+ };
2408
+ /** A one-shot focus ring driven by its parent's progress. Both endpoints are invisible. */
2409
+ function InkPing({ x, y, r = 10, width, height, rx = 0, hue = "cyan", step = 3, color = "", progress = 0, beacon = false }) {
2410
+ if (progress <= 0 || progress >= 1) return null;
2411
+ const isRect = width !== void 0;
2412
+ const w = width ?? 0;
2413
+ const h = height ?? width ?? 0;
2414
+ const center = isRect ? {
2415
+ x: x + w / 2,
2416
+ y: y + h / 2
2417
+ } : {
2418
+ x,
2419
+ y
2420
+ };
2421
+ const ringAt = (p, peak) => ({
2422
+ transform: `translate(${q$1(center.x)} ${q$1(center.y)}) scale(${q$1(1 + (beacon ? BEACON.grow : .8) * settle$1(p))})`,
2423
+ opacity: q$1(beacon ? peak * smooth(Math.min(1, p / BEACON.rise)) * (1 - p) ** 1.4 : peak * Math.min(1, p / .15) * (1 - p))
2424
+ });
2425
+ const echoProgress = (progress - BEACON.echoLag) / (1 - BEACON.echoLag);
2426
+ const rings = [ringAt(progress, beacon ? BEACON.peak : .9)];
2427
+ if (beacon && echoProgress > 0 && echoProgress < 1) rings.push(ringAt(echoProgress, BEACON.echoPeak));
2428
+ const stroke = color || ink(hue, step);
2429
+ const strokeWidth = beacon ? STROKE.rule : STROKE.line;
2430
+ return rings.map((ring, i) => /* @__PURE__ */ jsx("g", {
2431
+ className: "od-ink-ping",
2432
+ style: { opacity: ring.opacity },
2433
+ transform: ring.transform,
2434
+ "aria-hidden": "true",
2435
+ tabIndex: -1,
2436
+ children: /* @__PURE__ */ jsx("g", {
2437
+ filter: inkStyle() === "clean" ? filterUrl(FILTER_IDS.glow) : void 0,
2438
+ children: isRect ? /* @__PURE__ */ jsx("rect", {
2439
+ x: -w / 2,
2440
+ y: -h / 2,
2441
+ width: w,
2442
+ height: h,
2443
+ rx,
2444
+ stroke,
2445
+ strokeWidth
2446
+ }) : /* @__PURE__ */ jsx("circle", {
2447
+ r,
2448
+ stroke,
2449
+ strokeWidth
2450
+ })
2451
+ })
2452
+ }, i === 0 ? "focus" : "echo"));
2453
+ }
2454
+ // ../kit/src/ink/ink-rule.tsx
2455
+ function InkRule({ x1, x2, y, hue = "slate", step = 1, width = 2.6, seed = "ink-rule", opacity = .55, ref }) {
2456
+ const root = useRef(null);
2457
+ const { isActive, renderContext } = useSlide();
2458
+ useLayoutEffect(() => {
2459
+ const el = root.current;
2460
+ if (!el) return;
2461
+ if (!isActive || renderContext !== "slide" || motionMode() === "instant") gsap.set(el, { clipPath: "inset(0 0% 0 0)" });
2462
+ }, [isActive, renderContext]);
2463
+ useLayoutEffect(() => {
2464
+ const el = root.current;
2465
+ return () => {
2466
+ if (el) gsap.killTweensOf(el);
2467
+ };
2468
+ }, []);
2469
+ useImperativeHandle(ref, () => ({
2470
+ get root() {
2471
+ return root.current;
2472
+ },
2473
+ addDraw(tl, position) {
2474
+ return tl.fromTo(root.current, { clipPath: "inset(0 100% 0 0)" }, {
2475
+ clipPath: "inset(0 0% 0 0)",
2476
+ duration: DUR.draw,
2477
+ ease: DRAW
2478
+ }, position);
2479
+ }
2480
+ }), []);
2481
+ const clean = inkStyle() === "clean";
2482
+ const dabs = clean ? [] : brushRibbon([{
2483
+ x: x1,
2484
+ y
2485
+ }, {
2486
+ x: x2,
2487
+ y
2488
+ }], {
2489
+ seed: `${seed}:${y}`,
2490
+ width,
2491
+ taperIn: .02,
2492
+ taperOut: .02,
2493
+ startWidth: .7,
2494
+ endWidth: .7,
2495
+ wobble: .7,
2496
+ edge: .4
2497
+ });
2498
+ return /* @__PURE__ */ jsx("g", {
2499
+ ref: root,
2500
+ className: "od-ink-rule",
2501
+ style: {
2502
+ color: ink(hue, step),
2503
+ opacity
2504
+ },
2505
+ children: clean ? /* @__PURE__ */ jsx("line", {
2506
+ x1,
2507
+ x2,
2508
+ y1: y,
2509
+ y2: y,
2510
+ stroke: "currentColor",
2511
+ strokeWidth: STROKE.rule,
2512
+ strokeLinecap: "round"
2513
+ }) : /* @__PURE__ */ jsx("g", {
2514
+ filter: filterUrl(FILTER_IDS.rule),
2515
+ children: dabs.map((dab) => /* @__PURE__ */ jsx("path", {
2516
+ d: dab.d,
2517
+ fill: "currentColor",
2518
+ style: { fillOpacity: dab.fillOpacity }
2519
+ }, dab.d))
2520
+ })
2521
+ });
2522
+ }
2523
+ // ../kit/src/ink/ink-timeline.tsx
2524
+ function InkTimeline({ ticks, domain, range, y, hue = "cyan", step = 2, brightStep = 4, tickHeight = 74, tickWidth = STROKE.tick, labelGap = 14, labelOffset = 46, rowHeight = 38, labelSize = 26, labelRows = 4, state, ref }) {
2525
+ const [, refresh] = useReducer((n) => n + 1, 0);
2526
+ const { isActive, renderContext } = useSlide();
2527
+ const settled = !isActive || renderContext !== "slide" || motionMode() === "instant";
2528
+ const driven = useRef(false);
2529
+ const revision = useTween({ value: 0 });
2530
+ const [own] = useState(() => ticks.map(() => new Proxy({
2531
+ ink: 0,
2532
+ lift: 0
2533
+ }, { set(target, key, value) {
2534
+ const previous = Reflect.get(target, key);
2535
+ const written = Reflect.set(target, key, value);
2536
+ if ((key === "ink" || key === "lift") && previous !== value) {
2537
+ driven.current = true;
2538
+ revision.value++;
2539
+ }
2540
+ return written;
2541
+ } })));
2542
+ const beats = state ?? own;
2543
+ const animations = useRef(/* @__PURE__ */ new Set());
2544
+ useLayoutEffect(() => {
2545
+ const owned = animations.current;
2546
+ return () => {
2547
+ for (const animation of owned) animation.kill();
2548
+ owned.clear();
2549
+ };
2550
+ }, []);
2551
+ const sx = xScale(domain, range);
2552
+ useImperativeHandle(ref, () => ({
2553
+ get state() {
2554
+ driven.current = true;
2555
+ revision.value++;
2556
+ return own;
2557
+ },
2558
+ addInk(tl, position) {
2559
+ driven.current = true;
2560
+ revision.value++;
2561
+ tl.to(beats, {
2562
+ ink: 1,
2563
+ duration: DUR.draw,
2564
+ ease: DRAW,
2565
+ stagger: DUR.tick,
2566
+ lazy: false,
2567
+ onUpdate: refresh
2568
+ }, position);
2569
+ const recent = tl.recent();
2570
+ if (typeof recent !== "function") animations.current.add(recent);
2571
+ return tl;
2572
+ },
2573
+ addLift(tl, id, position) {
2574
+ const index = ticks.findIndex((tick) => tick.id === id);
2575
+ const target = beats[index];
2576
+ if (!target) return tl;
2577
+ tl.to(target, {
2578
+ lift: 1,
2579
+ duration: DUR.morph,
2580
+ onUpdate: refresh
2581
+ }, position);
2582
+ const recent = tl.recent();
2583
+ if (typeof recent !== "function") animations.current.add(recent);
2584
+ return tl;
2585
+ },
2586
+ tickX(id) {
2587
+ return sx(ticks.find((tick) => tick.id === id)?.at ?? domain[0]);
2588
+ }
2589
+ }));
2590
+ const rowRight = new Array(Math.max(1, labelRows)).fill(-1e400);
2591
+ const rowOf = /* @__PURE__ */ new Map();
2592
+ const ordered = ticks.map((tick, index) => ({
2593
+ tick,
2594
+ index,
2595
+ x: sx(tick.at)
2596
+ })).sort((a, b) => a.x - b.x || a.index - b.index);
2597
+ for (const { tick, index, x } of ordered) {
2598
+ const half = tick.label.length * labelSize * .6 / 2;
2599
+ let row = rowRight.findIndex((right) => x - half >= right + labelGap);
2600
+ if (row < 0) row = rowRight.indexOf(Math.min(...rowRight));
2601
+ rowRight[row] = x + half;
2602
+ rowOf.set(index, row);
2603
+ }
2604
+ return /* @__PURE__ */ jsxs("g", {
2605
+ className: "od-ink-timeline",
2606
+ children: [/* @__PURE__ */ jsx("line", {
2607
+ className: "od-tl-rule",
2608
+ x1: range[0] - 40,
2609
+ x2: range[1] + 40,
2610
+ y1: y,
2611
+ y2: y,
2612
+ stroke: ink("slate", 1),
2613
+ strokeWidth: STROKE.rule,
2614
+ strokeOpacity: .55
2615
+ }), ticks.map((tick, index) => {
2616
+ const x = sx(tick.at);
2617
+ const row = rowOf.get(index) ?? 0;
2618
+ const top = y - tickHeight * (tick.bright ? 1 : .66);
2619
+ const foot = y + tickWidth * 2;
2620
+ const labelY = y + labelOffset + row * rowHeight;
2621
+ const beat = !state && settled && !driven.current ? {
2622
+ ink: 1,
2623
+ lift: own[index]?.lift ?? 0
2624
+ } : beats[index] ?? {
2625
+ ink: 0,
2626
+ lift: 0
2627
+ };
2628
+ const dabs = inkStyle() === "clean" ? [] : brushRibbon([{
2629
+ x,
2630
+ y: foot
2631
+ }, {
2632
+ x,
2633
+ y: top
2634
+ }], {
2635
+ seed: `ink-timeline:${tick.id}`,
2636
+ width: tickWidth * 3,
2637
+ taperIn: .08,
2638
+ taperOut: .3,
2639
+ startWidth: .8,
2640
+ endWidth: .3,
2641
+ wobble: 1.8,
2642
+ edge: 1.1,
2643
+ samples: 11
2644
+ });
2645
+ return /* @__PURE__ */ jsxs("g", {
2646
+ style: {
2647
+ color: ink(hue, tick.bright ? brightStep : step),
2648
+ opacity: beat.ink
2649
+ },
2650
+ children: [
2651
+ /* @__PURE__ */ jsx("g", {
2652
+ style: {
2653
+ opacity: 1 - beat.lift,
2654
+ transformOrigin: `${x}px ${y}px`,
2655
+ transform: `scale(${1 - .75 * beat.lift})`
2656
+ },
2657
+ children: inkStyle() === "clean" ? /* @__PURE__ */ jsx("line", {
2658
+ x1: x,
2659
+ x2: x,
2660
+ y1: foot,
2661
+ y2: top,
2662
+ stroke: "currentColor",
2663
+ strokeWidth: tickWidth,
2664
+ strokeLinecap: "round",
2665
+ strokeDasharray: tick.projected ? `0 ${tickWidth * 2.5}` : void 0,
2666
+ filter: tick.bright ? filterUrl(FILTER_IDS.glow) : void 0
2667
+ }) : /* @__PURE__ */ jsx("g", {
2668
+ filter: filterUrl(FILTER_IDS.dry),
2669
+ children: dabs.map((dab) => /* @__PURE__ */ jsx("path", {
2670
+ d: dab.d,
2671
+ fill: "currentColor",
2672
+ style: { fillOpacity: dab.fillOpacity }
2673
+ }, dab.d))
2674
+ })
2675
+ }),
2676
+ row > 0 && /* @__PURE__ */ jsx("line", {
2677
+ x1: x,
2678
+ x2: x,
2679
+ y1: foot,
2680
+ y2: labelY - labelSize,
2681
+ stroke: "currentColor",
2682
+ strokeWidth: 1,
2683
+ strokeOpacity: .45
2684
+ }),
2685
+ /* @__PURE__ */ jsx("text", {
2686
+ className: `od-stage-label${tick.bright ? " is-end" : ""}`,
2687
+ x,
2688
+ y: labelY,
2689
+ textAnchor: "middle",
2690
+ style: { fontSize: `${labelSize}px` },
2691
+ children: tick.label
2692
+ })
2693
+ ]
2694
+ }, tick.id);
2695
+ })]
2696
+ });
2697
+ }
2698
+ // ../kit/src/ink/ink-timeline-cursor.tsx
2699
+ function InkTimelineCursor({ position, domain, range, y, hue }) {
2700
+ const x = xScale(domain, range)(position);
2701
+ return /* @__PURE__ */ jsxs("g", {
2702
+ className: "timeline-cursor",
2703
+ style: { color: ink(hue, 3) },
2704
+ children: [/* @__PURE__ */ jsx("line", {
2705
+ x1: range[0],
2706
+ x2: x,
2707
+ y1: y,
2708
+ y2: y,
2709
+ stroke: "currentColor",
2710
+ strokeWidth: STROKE.faint
2711
+ }), /* @__PURE__ */ jsx("circle", {
2712
+ cx: x,
2713
+ cy: y,
2714
+ r: 9,
2715
+ className: "cursor-dot",
2716
+ stroke: "currentColor",
2717
+ strokeWidth: STROKE.tick
2718
+ })]
2719
+ });
2720
+ }
2721
+ // ../kit/src/story/scripted-demo.ts
2722
+ function useScriptedDemo() {
2723
+ const { clicks, isActive } = useSlide();
2724
+ const [visit, setVisit] = useState({
2725
+ active: isActive,
2726
+ count: isActive ? 1 : 0
2727
+ });
2728
+ if (visit.active !== isActive) setVisit({
2729
+ active: isActive,
2730
+ count: visit.count + (isActive ? 1 : 0)
2731
+ });
2732
+ return {
2733
+ clicks,
2734
+ isActive,
2735
+ playCount: visit.count,
2736
+ shown: (at) => clicks >= at
2737
+ };
2738
+ }
2739
+ // ../kit/src/ink/chart-entrance.ts
2740
+ function useChartEntrance(animation, enabled, visit) {
2741
+ const busy = useRef(false);
2742
+ const config = typeof animation === "object" ? animation : {};
2743
+ const enter = typeof config.enter === "object" ? config.enter : {};
2744
+ const spring = enter.spring ?? (animation === "fluid" || config.preset === "fluid" ? FLUID_SPRING : void 0);
2745
+ const milliseconds = animation === false || config.enter === false ? 0 : (enter.duration ?? (spring ? springDuration(spring) : 500)) + (config.annotationDelay ?? 0);
2746
+ useEffect(() => registerSettleProbe(() => busy.current), []);
2747
+ useEffect(() => {
2748
+ if (!enabled || visit < 1 || milliseconds === 0) return;
2749
+ busy.current = true;
2750
+ const timer = setTimeout(() => {
2751
+ busy.current = false;
2752
+ }, milliseconds);
2753
+ return () => {
2754
+ clearTimeout(timer);
2755
+ busy.current = false;
2756
+ };
2757
+ }, [
2758
+ enabled,
2759
+ milliseconds,
2760
+ visit
2761
+ ]);
2762
+ }
2763
+ // ../kit/src/ink/open-chart.tsx
2764
+ function OpenChart({ spec, onMarkHover, onMarkLeave }) {
2765
+ const scale = useSlideScale();
2766
+ const { renderContext } = useSlide();
2767
+ const { isActive, playCount, clicks } = useScriptedDemo();
2768
+ const [mode, setMode] = useState(null);
2769
+ useLayoutEffect(() => {
2770
+ setMode(motionMode());
2771
+ });
2772
+ const entryClick = useRef(clicks);
2773
+ const visit = useRef(playCount);
2774
+ useLayoutEffect(() => {
2775
+ if (visit.current !== playCount) {
2776
+ entryClick.current = clicks;
2777
+ visit.current = playCount;
2778
+ }
2779
+ }, [clicks, playCount]);
2780
+ const animated = isActive && renderContext === "slide" && mode === "live" && (visit.current !== playCount ? clicks : entryClick.current) === 0;
2781
+ const animatedSpec = {
2782
+ ...spec,
2783
+ animation: animated ? spec.animation ?? true : false
2784
+ };
2785
+ useChartEntrance(animatedSpec.animation, animated && mode !== null, playCount);
2786
+ return /* @__PURE__ */ jsx("div", {
2787
+ className: "oc-slide-chart",
2788
+ style: {
2789
+ width: `${scale * 100}%`,
2790
+ height: `${scale * 100}%`,
2791
+ transform: `scale(${1 / scale})`,
2792
+ transformOrigin: "top left"
2793
+ },
2794
+ children: mode !== null && /* @__PURE__ */ jsx(Chart, {
2795
+ spec: animatedSpec,
2796
+ darkMode: "force",
2797
+ autoResize: true,
2798
+ onMarkHover,
2799
+ onMarkLeave
2800
+ }, `${playCount}-${animated}`)
2801
+ });
2802
+ }
2803
+ // ../kit/src/ink/underline.tsx
2804
+ /** The mark follows the typeset word, including font loading and frame resizing. */
2805
+ function Underline({ children, hue = "amber", step = 3, thickness = 5 }) {
2806
+ const host = useRef(null);
2807
+ const [size, setSize] = useState({
2808
+ width: 0,
2809
+ word: ""
2810
+ });
2811
+ useLayoutEffect(() => {
2812
+ const element = host.current;
2813
+ if (!element) return;
2814
+ const measure = () => {
2815
+ const width = element.offsetWidth;
2816
+ const word = (element.textContent ?? "").trim();
2817
+ setSize((previous) => previous.width === width && previous.word === word ? previous : {
2818
+ width,
2819
+ word
2820
+ });
2821
+ };
2822
+ measure();
2823
+ if (typeof ResizeObserver === "undefined") return;
2824
+ const observer = new ResizeObserver(measure);
2825
+ observer.observe(element);
2826
+ return () => observer.disconnect();
2827
+ });
2828
+ const { width, word } = size;
2829
+ const height = Math.max(thickness * 3, 12);
2830
+ const clean = inkStyle() === "clean";
2831
+ const mid = height / 2;
2832
+ const cleanPath = width < 4 ? "" : `M1 ${mid} Q${width / 2} ${mid + thickness * .6} ${width - 1} ${mid}`;
2833
+ const seed = `underline:${word}`;
2834
+ const lift = hashSigned(seed, 1, thickness);
2835
+ const dabs = clean || width < 4 ? [] : brushRibbon([
2836
+ {
2837
+ x: 1,
2838
+ y: mid + lift
2839
+ },
2840
+ {
2841
+ x: width / 2,
2842
+ y: mid + hashSigned(seed, 2, thickness)
2843
+ },
2844
+ {
2845
+ x: width - 1,
2846
+ y: mid - lift
2847
+ }
2848
+ ], {
2849
+ seed,
2850
+ width: thickness,
2851
+ taperIn: .14,
2852
+ taperOut: .22,
2853
+ wobble: thickness * .22,
2854
+ edge: thickness * .16,
2855
+ samples: 9
2856
+ });
2857
+ return /* @__PURE__ */ jsxs("span", {
2858
+ ref: host,
2859
+ className: "od-underline",
2860
+ children: [children, (dabs.length > 0 || cleanPath) && /* @__PURE__ */ jsx("svg", {
2861
+ className: "od-underline-mark",
2862
+ width,
2863
+ height,
2864
+ viewBox: `0 0 ${width} ${height}`,
2865
+ "aria-hidden": "true",
2866
+ style: { color: ink(hue, step) },
2867
+ children: clean ? /* @__PURE__ */ jsx("path", {
2868
+ d: cleanPath,
2869
+ fill: "none",
2870
+ stroke: "currentColor",
2871
+ strokeWidth: thickness * .6,
2872
+ strokeLinecap: "round"
2873
+ }) : /* @__PURE__ */ jsx("g", {
2874
+ filter: filterUrl(FILTER_IDS.dry),
2875
+ children: dabs.map((dab) => /* @__PURE__ */ jsx("path", {
2876
+ d: dab.d,
2877
+ fill: "currentColor",
2878
+ style: { fillOpacity: dab.fillOpacity }
2879
+ }, dab.d))
2880
+ })
2881
+ })]
2882
+ });
2883
+ }
2884
+ // ../kit/src/ink/unit-grid.tsx
2885
+ const settle = gsap.parseEase(SETTLE);
2886
+ const trace = gsap.parseEase(TRACE);
2887
+ const q = (n, step = 100) => Math.round(n * step) / step;
2888
+ const p = (x, y) => `${q(x, 10)} ${q(y, 10)}`;
2889
+ function markerSquare(seed, w, h) {
2890
+ const j = Math.min(w, h) * .14;
2891
+ const jit = (i) => (hash(seed, i) - .5) * 2 * j;
2892
+ return {
2893
+ body: `M${[
2894
+ p(jit(1), jit(2)),
2895
+ p(w / 2 + jit(3), jit(4) * .6),
2896
+ p(w + jit(5), jit(6)),
2897
+ p(w + jit(7) * .6, h / 2 + jit(8)),
2898
+ p(w + jit(9), h + jit(10)),
2899
+ p(w / 2 + jit(11), h + jit(12) * .6),
2900
+ p(jit(13), h + jit(14)),
2901
+ p(jit(15) * .6, h / 2 + jit(16))
2902
+ ].join("L")}Z`,
2903
+ marks: []
2904
+ };
2905
+ }
2906
+ function pageMarks(w, h, fold) {
2907
+ const rule = (y) => {
2908
+ const x0 = w * .16;
2909
+ const x1 = w * .74;
2910
+ const t = Math.max(.6, h * .045);
2911
+ return `M${p(x0, y)}L${p(x1, y)}L${p(x1, y + t)}L${p(x0, y + t)}Z`;
2912
+ };
2913
+ return [
2914
+ {
2915
+ d: `M${p(w - fold, 0)}L${p(w - fold, fold)}L${p(w, fold)}Z`,
2916
+ opacity: .55
2917
+ },
2918
+ {
2919
+ d: rule(h * .56),
2920
+ opacity: .42
2921
+ },
2922
+ {
2923
+ d: rule(h * .73),
2924
+ opacity: .42
2925
+ }
2926
+ ];
2927
+ }
2928
+ function sheet(seed, w, h, marker) {
2929
+ const j = marker ? Math.min(w, h) * .07 : 0;
2930
+ const jit = (i) => (hash(seed, i) - .5) * 2 * j;
2931
+ const fold = Math.min(w, h) * .3;
2932
+ return {
2933
+ body: `M${p(jit(1), jit(2))}L${p(w - fold + jit(3), jit(4))}L${p(w + jit(5), fold + jit(6))}L${p(w + jit(7), h + jit(8))}L${p(jit(9), h + jit(10))}Z`,
2934
+ marks: pageMarks(w, h, fold)
2935
+ };
2936
+ }
2937
+ /** A prop-driven waffle. The stage owns the reveal, recolor and gather timelines. */
2938
+ function UnitGrid({ items, count = 0, glyph = UNIT_GRID_DEFAULTS.glyph, cols = UNIT_GRID_DEFAULTS.cols, cellWidth = UNIT_GRID_DEFAULTS.cellWidth, cellHeight, gapX = UNIT_GRID_DEFAULTS.gapX, gapY = UNIT_GRID_DEFAULTS.gapY, origin = UNIT_GRID_DEFAULTS.origin, color, colorBy, seed = "unit-grid", reveal = 1, stagger = .6, recolor = 0, scatter = 0, collapse = 0, collapseTo = {
2939
+ x: 960,
2940
+ y: 540
2941
+ }, collapseStagger = 0, collapseInto, glow = false, filterId = FILTER_IDS.markerLite, ref }) {
2942
+ const marker = inkStyle() === "marker";
2943
+ const h = unitCellHeight({
2944
+ glyph,
2945
+ cellWidth,
2946
+ cellHeight
2947
+ });
2948
+ const base = color ?? ink("slate", 2);
2949
+ const layout = useMemo(() => {
2950
+ const source = items ?? Array.from({ length: Math.max(0, count) }, (_, i) => ({ id: `${seed}:${i}` }));
2951
+ return source.map((item, i) => {
2952
+ const id = `${seed}:${item.id}`;
2953
+ const shape = glyph === "sheet" ? sheet(id, cellWidth, h, marker) : marker ? markerSquare(id, cellWidth, h) : {
2954
+ body: null,
2955
+ marks: []
2956
+ };
2957
+ const center = unitCellCenter(i, {
2958
+ origin,
2959
+ cols,
2960
+ cellWidth,
2961
+ cellHeight: h,
2962
+ gapX,
2963
+ gapY
2964
+ });
2965
+ return {
2966
+ item,
2967
+ index: i,
2968
+ ...shape,
2969
+ cx: center.x,
2970
+ cy: center.y,
2971
+ order: (i + hash(`${seed}:order`, i) * Math.max(1, cols)) / Math.max(1, source.length - 1 + Math.max(1, cols)),
2972
+ gather: hash(`${seed}:gather`, i),
2973
+ jx: hashSigned(`${seed}:jx`, i, 70),
2974
+ jy: hashSigned(`${seed}:jy`, i, 70),
2975
+ fillOpacity: marker ? q(hashRange(`${seed}:alpha`, i, .58, .96), 1e3) : void 0
2976
+ };
2977
+ });
2978
+ }, [
2979
+ items,
2980
+ count,
2981
+ seed,
2982
+ glyph,
2983
+ cellWidth,
2984
+ h,
2985
+ marker,
2986
+ origin,
2987
+ cols,
2988
+ gapX,
2989
+ gapY
2990
+ ]);
2991
+ const spread = clamp01(stagger);
2992
+ const ramp = Math.max(.001, 1 - spread);
2993
+ const c = clamp01(collapse);
2994
+ const mix = clamp01(recolor);
2995
+ const wave = clamp01(collapseStagger);
2996
+ const waveRamp = Math.max(.001, 1 - wave);
2997
+ const farMax = layout.reduce((max, cell) => Math.max(max, Math.hypot(cell.cx - collapseTo.x, cell.cy - collapseTo.y)), 1);
2998
+ const mid = layout.reduce((acc, cell) => ({
2999
+ x: acc.x + cell.cx / layout.length,
3000
+ y: acc.y + cell.cy / layout.length
3001
+ }), {
3002
+ x: 0,
3003
+ y: 0
3004
+ });
3005
+ const cells = layout.map((cell) => {
3006
+ const shown = q(settle(clamp01((clamp01(reveal) - cell.order * spread) / ramp)), 32);
3007
+ let trip = c;
3008
+ let size = 1 - c;
3009
+ let absorbed = 0;
3010
+ let bowX = 0;
3011
+ let bowY = 0;
3012
+ if (wave > 0) {
3013
+ const lead = clamp01(1 - Math.hypot(cell.cx - collapseTo.x, cell.cy - collapseTo.y) / farMax + (cell.gather - .5) * .3);
3014
+ const own = clamp01((c - lead * wave) / waveRamp);
3015
+ trip = trace(own);
3016
+ size = 1 - .6 * trip * trip;
3017
+ const dx = collapseTo.x - cell.cx;
3018
+ const dy = collapseTo.y - cell.cy;
3019
+ if (collapseInto) {
3020
+ const edge = Math.min(dx === 0 ? 1 : collapseInto.width / 2 / Math.abs(dx), dy === 0 ? 1 : collapseInto.height / 2 / Math.abs(dy), 1);
3021
+ absorbed = clamp01(1 - (1 - trip) / Math.max(.001, edge));
3022
+ } else absorbed = clamp01((own - .7) / (1 - .7));
3023
+ const arc = Math.sin(Math.PI * trip) * .22 * (cell.gather < .5 ? -1 : 1);
3024
+ bowX = -dy * arc;
3025
+ bowY = dx * arc;
3026
+ }
3027
+ const cx = cell.cx + (collapseTo.x - cell.cx) * trip + bowX + clamp01(scatter) * ((mid.x - cell.cx) * .3 + cell.jx);
3028
+ const cy = cell.cy + (collapseTo.y - cell.cy) * trip + bowY + clamp01(scatter) * ((mid.y - cell.cy) * .3 + cell.jy);
3029
+ const targetColor = () => {
3030
+ if (typeof colorBy === "function") {
3031
+ const target = colorBy(cell.item, cell.index);
3032
+ if (target) return target;
3033
+ } else if (typeof colorBy === "string") return colorBy;
3034
+ return cell.item.hue ? ink(cell.item.hue, cell.item.step ?? 2) : base;
3035
+ };
3036
+ const fill = mix <= 0 ? base : `color-mix(in oklab, ${targetColor()} ${q(mix * 100, 10)}%, ${base})`;
3037
+ return {
3038
+ ...cell,
3039
+ absorbed,
3040
+ fill,
3041
+ opacity: q(shown * (1 - absorbed), 32),
3042
+ transform: `translate(${q(cx, 10)} ${q(cy, 10)}) scale(${q((.62 + .38 * shown) * size, 1e3)}) translate(${-cellWidth / 2} ${-h / 2})`
3043
+ };
3044
+ });
3045
+ const arrived = cells.filter((cell) => cell.absorbed > 0).length;
3046
+ useImperativeHandle(ref, () => ({ arrived }), [arrived]);
3047
+ const filter = marker ? filterId === "none" ? void 0 : filterUrl(filterId) : glow ? filterUrl(FILTER_IDS.glow) : void 0;
3048
+ return /* @__PURE__ */ jsx("g", {
3049
+ className: "od-unit-grid",
3050
+ children: cells.map((cell) => /* @__PURE__ */ jsx("g", {
3051
+ style: { opacity: cell.opacity },
3052
+ transform: cell.transform,
3053
+ children: /* @__PURE__ */ jsxs("g", {
3054
+ filter,
3055
+ children: [cell.body === null ? /* @__PURE__ */ jsx("rect", {
3056
+ className: "od-unit-grid-body",
3057
+ style: { fillOpacity: cell.fillOpacity },
3058
+ width: cellWidth,
3059
+ height: h,
3060
+ rx: Math.min(cellWidth, h) * .18,
3061
+ fill: cell.fill
3062
+ }) : /* @__PURE__ */ jsx("path", {
3063
+ className: "od-unit-grid-body",
3064
+ style: { fillOpacity: cell.fillOpacity },
3065
+ d: cell.body,
3066
+ fill: cell.fill
3067
+ }), cell.marks.map((mark) => /* @__PURE__ */ jsx("path", {
3068
+ style: { fillOpacity: mark.opacity },
3069
+ d: mark.d,
3070
+ fill: CANVAS
3071
+ }, mark.d))]
3072
+ })
3073
+ }, cell.item.id))
3074
+ });
3075
+ }
3076
+ // ../kit/src/story/entrance.ts
3077
+ /** Build after child refs exist; entrance and beats share that mount order. */
3078
+ function useStageEntrance(build, opts = {}) {
3079
+ const { clicks, isActive, renderContext } = useSlide();
3080
+ const entrance = useRef(null);
3081
+ const builder = useRef(build);
3082
+ const beatBuilder = useRef(opts.beats);
3083
+ const wasActive = useRef(false);
3084
+ useLayoutEffect(() => {
3085
+ const tl = gsap.timeline({ paused: true });
3086
+ try {
3087
+ builder.current(tl);
3088
+ } catch (error) {
3089
+ tl.kill();
3090
+ throw error;
3091
+ }
3092
+ entrance.current = tl;
3093
+ return () => {
3094
+ tl.kill();
3095
+ entrance.current = null;
3096
+ wasActive.current = false;
3097
+ };
3098
+ }, []);
3099
+ useLayoutEffect(() => {
3100
+ const tl = entrance.current;
3101
+ if (!tl) return;
3102
+ const arriving = !wasActive.current;
3103
+ wasActive.current = isActive;
3104
+ if (renderContext !== "slide" || prefersReducedMotion()) tl.progress(1).pause();
3105
+ else if (!isActive) tl.pause(0);
3106
+ else if (clicks > 0) tl.progress(1).pause();
3107
+ else if (arriving) {
3108
+ tl.pause(0);
3109
+ return afterTransition(() => {
3110
+ tl.play(0);
3111
+ });
3112
+ }
3113
+ }, [
3114
+ clicks,
3115
+ isActive,
3116
+ renderContext
3117
+ ]);
3118
+ useTimeline((tl, beat) => {
3119
+ if (beatBuilder.current) beatBuilder.current(tl, beat);
3120
+ else beat(0);
3121
+ });
3122
+ }
3123
+ // ../kit/src/story/stage.ts
3124
+ function useStage({ copy, enter, beats }) {
3125
+ const demo = useScriptedDemo();
3126
+ const { clicks, isActive } = demo;
3127
+ const { renderContext } = useSlide();
3128
+ const entrance = useRef(null);
3129
+ const builder = useRef(enter);
3130
+ const wasActive = useRef(false);
3131
+ useLayoutEffect(() => {
3132
+ const tl = gsap.timeline({ paused: true });
3133
+ builder.current?.(tl);
3134
+ entrance.current = tl;
3135
+ return () => {
3136
+ tl.kill();
3137
+ };
3138
+ }, []);
3139
+ useLayoutEffect(() => {
3140
+ const tl = entrance.current;
3141
+ if (!tl) return;
3142
+ const arriving = !wasActive.current;
3143
+ wasActive.current = isActive;
3144
+ if (renderContext !== "slide" || motionMode() === "instant") tl.progress(1).pause();
3145
+ else if (!isActive) tl.pause(0);
3146
+ else if (clicks > 0) tl.progress(1).pause();
3147
+ else if (arriving) {
3148
+ tl.pause(0);
3149
+ return afterTransition(() => {
3150
+ tl.play(0);
3151
+ });
3152
+ }
3153
+ }, [
3154
+ clicks,
3155
+ isActive,
3156
+ renderContext
3157
+ ]);
3158
+ useTimeline(beats);
3159
+ const card = copy[Math.min(Math.max(clicks, 0), copy.length - 1)];
3160
+ if (!card) throw new Error("useStage needs at least one copy entry");
3161
+ return {
3162
+ ...demo,
3163
+ copy: card,
3164
+ beats: copy.length
3165
+ };
3166
+ }
3167
+ // ../kit/src/story/stage-map.ts
3168
+ /**
3169
+ * useStageMap: the mapping between stage units and the overlay.
3170
+ *
3171
+ * Both live in `.od-story-frame`, the largest 16:9 box that fits the viewport
3172
+ * (story-frame.css), and the stage svg's viewBox is 16:9 too, so the mapping is a
3173
+ * fixed ratio: x percent of the frame's width is always viewBox x * 1920/100.
3174
+ * It used to depend on the window, because the frame was the whole viewport
3175
+ * and `xMidYMid slice` cropped the ink by however far the window was from
3176
+ * 16:9; the frame removed the crop and with it the window dependency.
3177
+ *
3178
+ * The functions stay because the two spaces still use different numbers, and
3179
+ * an overlay element that has to sit on an svg mark should say so at the call
3180
+ * site rather than open-coding a division by 19.2.
3181
+ */
3182
+ function useStageMap() {
3183
+ /** A stage rect as overlay percentages. */
3184
+ function toPctBox(x, y, w, h) {
3185
+ return {
3186
+ left: x / STAGE.width * 100,
3187
+ top: y / STAGE.height * 100,
3188
+ width: w / STAGE.width * 100,
3189
+ height: h / STAGE.height * 100
3190
+ };
3191
+ }
3192
+ /** The centre of an overlay percentage box, in stage units. */
3193
+ function toStageCenter(box) {
3194
+ return {
3195
+ x: (box.left + box.width / 2) / 100 * STAGE.width,
3196
+ y: (box.top + box.height / 2) / 100 * STAGE.height
3197
+ };
3198
+ }
3199
+ /** An overlay percentage box as a stage rect size. */
3200
+ function toStageSize(box) {
3201
+ return {
3202
+ width: box.width / 100 * STAGE.width,
3203
+ height: box.height / 100 * STAGE.height
3204
+ };
3205
+ }
3206
+ return {
3207
+ toPctBox,
3208
+ toStageCenter,
3209
+ toStageSize
3210
+ };
3211
+ }
3212
+ // ../kit/src/story/story-card.tsx
3213
+ function StoryCard({ lead, leadContent, body = "", anchor = "left", hue = "cyan", className = "", style }) {
3214
+ const { isActive, renderContext } = useSlide();
3215
+ const captionRoot = useRef(null);
3216
+ useLayoutEffect(() => {
3217
+ if (isActive && renderContext === "slide") return registerCaptionProvider(() => {
3218
+ const root = captionRoot.current;
3219
+ if (!root) return;
3220
+ const { display, visibility } = getComputedStyle(root);
3221
+ if (display === "none" || visibility === "hidden" || visibility === "collapse") return;
3222
+ return {
3223
+ lead,
3224
+ body
3225
+ };
3226
+ });
3227
+ });
3228
+ const box = useRef(null);
3229
+ const incoming = useRef(null);
3230
+ const outgoing = useRef(null);
3231
+ const oldHeight = useRef(0);
3232
+ const attachIncoming = useCallback((element) => {
3233
+ incoming.current = element;
3234
+ return () => {
3235
+ oldHeight.current = box.current?.offsetHeight ?? 0;
3236
+ incoming.current = null;
3237
+ };
3238
+ }, []);
3239
+ const [content, setContent] = useState({
3240
+ lead,
3241
+ body,
3242
+ leadContent,
3243
+ old: null
3244
+ });
3245
+ if (content.lead !== lead || content.body !== body) setContent({
3246
+ lead,
3247
+ body,
3248
+ leadContent,
3249
+ old: {
3250
+ lead: content.lead,
3251
+ body: content.body,
3252
+ leadContent: content.leadContent
3253
+ }
3254
+ });
3255
+ else if (content.leadContent !== leadContent) setContent({
3256
+ ...content,
3257
+ leadContent
3258
+ });
3259
+ useLayoutEffect(() => {
3260
+ const el = box.current;
3261
+ if (!el) return;
3262
+ const from = oldHeight.current;
3263
+ gsap.set(el, { clearProps: "height,overflow" });
3264
+ const to = el.offsetHeight;
3265
+ if (!content.old || !isActive || renderContext !== "slide" || motionMode() === "instant") {
3266
+ gsap.set(incoming.current, { clearProps: "opacity,transform" });
3267
+ if (content.old) setContent((previous) => ({
3268
+ ...previous,
3269
+ old: null
3270
+ }));
3271
+ return;
3272
+ }
3273
+ const tl = gsap.timeline({ onComplete: () => setContent((previous) => ({
3274
+ ...previous,
3275
+ old: null
3276
+ })) });
3277
+ tl.fromTo(incoming.current, {
3278
+ opacity: 0,
3279
+ y: 6
3280
+ }, {
3281
+ opacity: 1,
3282
+ y: 0,
3283
+ duration: DUR.card,
3284
+ ease: SETTLE,
3285
+ clearProps: "transform"
3286
+ }, 0);
3287
+ tl.to(outgoing.current, {
3288
+ opacity: 0,
3289
+ duration: DUR.opacity
3290
+ }, 0);
3291
+ if (from > 0 && Math.abs(to - from) >= 1) tl.fromTo(el, {
3292
+ height: from,
3293
+ overflow: "hidden"
3294
+ }, {
3295
+ height: to,
3296
+ duration: DUR.card,
3297
+ ease: SETTLE,
3298
+ clearProps: "height,overflow"
3299
+ }, 0);
3300
+ return () => {
3301
+ tl.kill();
3302
+ };
3303
+ }, [
3304
+ isActive,
3305
+ renderContext,
3306
+ content.old
3307
+ ]);
3308
+ const copy = (text) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
3309
+ className: "od-story-lead",
3310
+ children: text.leadContent ?? text.lead
3311
+ }), text.body && /* @__PURE__ */ jsx("p", {
3312
+ className: "od-story-copy",
3313
+ children: text.body
3314
+ })] });
3315
+ return /* @__PURE__ */ jsx("div", {
3316
+ ref: captionRoot,
3317
+ className: `od-story-card anchor-${anchor} accent-${hue}${className ? ` ${className}` : ""}`,
3318
+ style,
3319
+ "data-lead": lead,
3320
+ "data-body": body,
3321
+ children: /* @__PURE__ */ jsxs("div", {
3322
+ ref: box,
3323
+ className: "od-story-card-body",
3324
+ children: [content.old && /* @__PURE__ */ jsx("div", {
3325
+ ref: outgoing,
3326
+ "aria-hidden": "true",
3327
+ style: {
3328
+ position: "absolute",
3329
+ top: 0,
3330
+ left: 0,
3331
+ right: 0
3332
+ },
3333
+ children: copy(content.old)
3334
+ }, `${content.old.lead}|${content.old.body}`), /* @__PURE__ */ jsx("div", {
3335
+ ref: attachIncoming,
3336
+ children: copy({
3337
+ lead,
3338
+ body,
3339
+ leadContent
3340
+ })
3341
+ }, `${lead}|${body}`)]
3342
+ })
3343
+ });
3344
+ }
3345
+ // ../kit/src/story/story-cover.tsx
3346
+ function StoryCover({ field, head, title, lede, byline, eyebrow, aside, background, center = false, url, brand = false, enterAfterTransition = false, children }) {
3347
+ return /* @__PURE__ */ jsx(StoryStage, {
3348
+ className: "is-story-cover",
3349
+ fluid: !field && !aside,
3350
+ enterAfterTransition,
3351
+ background,
3352
+ overlay: /* @__PURE__ */ jsxs(Fragment, { children: [
3353
+ field,
3354
+ /* @__PURE__ */ jsxs("div", {
3355
+ className: "od-cover-frame",
3356
+ children: [
3357
+ head ?? ((url || brand) && /* @__PURE__ */ jsx(OdCoverHead, {
3358
+ className: "od-enter-a",
3359
+ url
3360
+ })),
3361
+ /* @__PURE__ */ jsxs("div", {
3362
+ className: `od-enter-b od-cover-body${center ? " od-cover-center" : ""}`,
3363
+ children: [
3364
+ eyebrow,
3365
+ /* @__PURE__ */ jsx("h1", {
3366
+ className: "od-title",
3367
+ children: title
3368
+ }),
3369
+ lede && /* @__PURE__ */ jsx("p", {
3370
+ className: "od-lede od-cover-lede",
3371
+ children: lede
3372
+ }),
3373
+ children
3374
+ ]
3375
+ }),
3376
+ byline && /* @__PURE__ */ jsx(OdByline, {
3377
+ className: "od-enter-c",
3378
+ children: byline
3379
+ })
3380
+ ]
3381
+ }),
3382
+ aside
3383
+ ] })
3384
+ });
3385
+ }
3386
+ // ../kit/src/story/story-layer.tsx
3387
+ function StoryLayer({ children, className = "" }) {
3388
+ return /* @__PURE__ */ jsx("div", {
3389
+ className: `od-stage-layer ${className}`,
3390
+ children: /* @__PURE__ */ jsx("svg", {
3391
+ viewBox: "0 0 1920 1080",
3392
+ preserveAspectRatio: "xMidYMid slice",
3393
+ "aria-hidden": "true",
3394
+ children
3395
+ })
3396
+ });
3397
+ }
3398
+ // ../kit/src/story/story-link.tsx
3399
+ function StoryLink({ href, label, opacity = 1 }) {
3400
+ return /* @__PURE__ */ jsx("a", {
3401
+ className: "od-mono od-story-link",
3402
+ href,
3403
+ target: "_blank",
3404
+ rel: "noopener",
3405
+ style: {
3406
+ opacity,
3407
+ pointerEvents: opacity > .5 ? "auto" : "none"
3408
+ },
3409
+ children: label ?? href.replace(/^https?:\/\//, "")
3410
+ });
3411
+ }
3412
+ // ../kit/src/theme/chart-theme.ts
3413
+ const slideChartTheme = {
3414
+ get colors() {
3415
+ const { chart } = theme();
3416
+ return {
3417
+ background: "transparent",
3418
+ text: chart.text,
3419
+ gridline: chart.gridline,
3420
+ axis: chart.axis
3421
+ };
3422
+ },
3423
+ get fonts() {
3424
+ const { fonts } = theme();
3425
+ return {
3426
+ family: fonts.sans,
3427
+ mono: fonts.mono,
3428
+ sizes: {
3429
+ title: 30,
3430
+ subtitle: 22,
3431
+ body: 21,
3432
+ small: 18,
3433
+ axisTick: 20,
3434
+ metricLabel: 16,
3435
+ metricValue: 38
3436
+ }
3437
+ };
3438
+ },
3439
+ spacing: {
3440
+ xAxisHeight: 52,
3441
+ xAxisLabelPadding: 4
3442
+ },
3443
+ get chrome() {
3444
+ const { chart } = theme();
3445
+ return {
3446
+ eyebrow: { color: chart.eyebrow },
3447
+ title: { color: chart.title },
3448
+ subtitle: { color: chart.subtitle },
3449
+ source: { color: chart.source },
3450
+ byline: { color: chart.source }
3451
+ };
3452
+ }
3453
+ };
3454
+ function scaleChartTheme(value, scale) {
3455
+ return {
3456
+ ...value,
3457
+ fonts: {
3458
+ ...value.fonts,
3459
+ sizes: Object.fromEntries(Object.entries(value.fonts.sizes).map(([key, size]) => [key, size * scale]))
3460
+ },
3461
+ spacing: {
3462
+ ...value.spacing,
3463
+ xAxisHeight: value.spacing.xAxisHeight * scale,
3464
+ xAxisLabelPadding: value.spacing.xAxisLabelPadding * scale
3465
+ }
3466
+ };
3467
+ }
3468
+ const slideChartAnimation = {
3469
+ enter: {
3470
+ duration: 900,
3471
+ ease: "smooth"
3472
+ },
3473
+ annotationDelay: 350
3474
+ };
3475
+ export { BRUSH_DEFAULTS, CANVAS, CATEGORICAL_COLORS, CodeInk, DRAW, DRAW_CSS, DUR, FILTER_IDS, Graph3D, InkBars, InkCardRect, InkChip, InkLine, InkNumber, InkPing, InkRule, InkTimeline, InkTimelineCursor, OdByline, OdCoverHead, OdEyebrow, OdLogo, OdQrCard, OpenChart, RISE, SETTLE, SETTLE_CSS, STAGE, STORY_STYLE, STROKE, StoryCard, StoryCover, StoryLayer, StoryLink, StoryStage, TRACE, TRACE_CSS, UNIT_GRID_DEFAULTS, Underline, UnitGrid, brushRibbon, clamp01, easeHeight, easedStagger, entrance, fadeIn, fadeOutInPlace, filterUrl, gsap, hash, hashRange, hashSigned, ink, inkStyle, installTheme, lerp, parliament_exports as parliament, polylinePath, prefersReducedMotion, resolvePosition, resolveTheme, rippleProgress, riseIn, scaleChartTheme, slideChartAnimation, slideChartTheme, stackEndLabels, stagger, theme, tokenizeSql, unitCellCenter, unitCellHeight, useSlideScale as useFrameScale, useScriptedDemo, useStage, useStageEntrance, useStageMap, xScale, yScale };