@mechane-ai/elements 0.49.0 → 0.50.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 (102) hide show
  1. package/README.md +40 -2
  2. package/dist/{article-yyNPg6VU.js → article-CRlhq9oA.js} +531 -463
  3. package/dist/article.js +1 -1
  4. package/dist/catalog.json +37 -1
  5. package/dist/{categorical-values-DCznViFp.js → categorical-values-BYP_R5gS.js} +13 -13
  6. package/dist/charts/cartesian.js +1 -1
  7. package/dist/charts/comparison.js +1 -1
  8. package/dist/charts/distribution.js +1 -1
  9. package/dist/charts/figure.js +12 -12
  10. package/dist/charts/graph.js +1 -1
  11. package/dist/charts/hierarchy.js +1 -1
  12. package/dist/charts/image.js +1 -1
  13. package/dist/charts/matrix.js +1 -1
  14. package/dist/charts/plot.js +4 -4
  15. package/dist/charts/relationship.js +1 -1
  16. package/dist/charts/text.js +1 -1
  17. package/dist/charts/timeline.js +1 -1
  18. package/dist/charts/trend.js +1 -1
  19. package/dist/charts.js +7 -7
  20. package/dist/collections.js +1 -1
  21. package/dist/{dumbbell-plot-CMv9llfd.js → dumbbell-plot-BC8d_IJy.js} +45 -45
  22. package/dist/{embedding-map-DC-lgzCq.js → embedding-map-Bj8krO-d.js} +528 -528
  23. package/dist/figure-frame-koVKcXph.js +323 -0
  24. package/dist/{image-grid-DHqtj_zs.js → image-grid-CLhol2jy.js} +47 -47
  25. package/dist/kits/evaluation.js +50 -48
  26. package/dist/kits/interpretability.js +7 -7
  27. package/dist/kits/operations.js +4 -4
  28. package/dist/kits/research.js +346 -264
  29. package/dist/kits/training.js +3 -3
  30. package/dist/layout.js +1 -1075
  31. package/dist/lesson/spec.js +11 -11
  32. package/dist/lesson.js +4 -4
  33. package/dist/mdx.js +4 -4
  34. package/dist/packages/charts/src/chart-inspection.d.ts +4 -1
  35. package/dist/packages/charts/src/figure/caption-scope.d.ts +12 -0
  36. package/dist/packages/charts/src/figure/figure-frame.d.ts +2 -1
  37. package/dist/packages/charts/src/index.d.ts +2 -0
  38. package/dist/packages/collections/src/data-table-trigger.d.ts +2 -0
  39. package/dist/packages/kits/src/evaluation/leaderboard.d.ts +2 -0
  40. package/dist/packages/kits/src/research/collection-page.d.ts +46 -0
  41. package/dist/packages/kits/src/research/index.d.ts +2 -0
  42. package/dist/packages/kits/src/research/milestone-path.d.ts +1 -2
  43. package/dist/packages/kits/src/research/work-heartbeat.d.ts +4 -3
  44. package/dist/packages/layout/src/detail-page.d.ts +3 -1
  45. package/dist/packages/teaching/src/article/article-context.d.ts +2 -0
  46. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +13 -0
  47. package/dist/packages/teaching/src/article/article.d.ts +6 -1
  48. package/dist/packages/teaching/src/article/figure.d.ts +20 -3
  49. package/dist/packages/teaching/src/article/index.d.ts +1 -1
  50. package/dist/packages/teaching/src/article/view-essay.d.ts +2 -1
  51. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +4 -0
  52. package/dist/packages/teaching/src/lesson/index.d.ts +2 -2
  53. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +19 -3
  54. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +2 -0
  55. package/dist/packages/teaching/src/lesson/playback.d.ts +9 -6
  56. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +7 -2
  57. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +4 -1
  58. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +5 -6
  59. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +1 -1
  60. package/dist/packages/teaching/src/scene/scene-node.d.ts +4 -1
  61. package/dist/packages/teaching/src/scene/scene-validate.d.ts +6 -0
  62. package/dist/packages/teaching/src/scene/scene-wire.d.ts +6 -1
  63. package/dist/packages/teaching/src/scene/scene.d.ts +1 -1
  64. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +5 -1
  65. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +1 -1
  66. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +1 -1
  67. package/dist/packages/teaching/src/time/tween.d.ts +2 -0
  68. package/dist/{param-BE3VMSkH.js → param-BdqTpZER.js} +166 -99
  69. package/dist/{plot-layout-Bqe4-0qZ.js → plot-layout-B2xRt-_k.js} +144 -130
  70. package/dist/{plot-surface-DON6WUmk.js → plot-surface-0cKFwtws.js} +1 -1
  71. package/dist/{reference-lines-hjuD1rRZ.js → reference-lines-nSxcZVF5.js} +1 -1
  72. package/dist/{scene-BP0Ue0R5.js → scene-4ePpWdmE.js} +1227 -1125
  73. package/dist/scene.js +1 -1
  74. package/dist/{slope-chart-C8eeSgL4.js → slope-chart-DWZIYDty.js} +179 -179
  75. package/dist/{src-B2rgpWap.js → src-DNclWY4V.js} +1 -1
  76. package/dist/src-DhWMspwr.js +1085 -0
  77. package/dist/styles2.css +77 -14
  78. package/dist/{time-series-BL933QyA.js → time-series-CsngFxr1.js} +952 -948
  79. package/dist/{token-heatmap-BB65awva.js → token-heatmap-BQLIxPky.js} +84 -84
  80. package/dist/{token-predictions-Pa8eUGan.js → token-predictions-C3B5L-eO.js} +126 -126
  81. package/dist/{transport-DzyxVXbL.js → transport-4V9rfYHN.js} +278 -233
  82. package/dist/{tree-diagram-DJhKBiia.js → tree-diagram-Dau9jeXS.js} +115 -115
  83. package/dist/{treemap-CxxgABUg.js → treemap-DWrMQndu.js} +27 -27
  84. package/dist/use-tween-BsaEO862.js +10 -0
  85. package/dist/{violin-plot-CoAEF_7Z.js → violin-plot-D05ODcyc.js} +123 -123
  86. package/dist/{waterfall-DdoEXEkT.js → waterfall-BkLLv2Lm.js} +39 -39
  87. package/package.json +1 -1
  88. package/recipes/counting-cards.tsx +3 -3
  89. package/skills/review-elements/SKILL.md +14 -0
  90. package/skills/review-explainer/SKILL.md +2 -1
  91. package/skills/upgrade-elements/references/releases.md +61 -0
  92. package/skills/use-elements/SKILL.md +21 -17
  93. package/skills/use-elements/references/editorial-restraint.md +40 -0
  94. package/skills/use-elements/references/styling.md +23 -0
  95. package/skills/use-elements/references/teaching.md +13 -0
  96. package/skills/use-elements/references/workspace.md +14 -8
  97. package/skills/write-explainer/references/article.md +50 -2
  98. package/skills/write-explainer/references/lesson.md +18 -9
  99. package/skills/write-explainer/references/scene-parts.md +17 -12
  100. package/skills/write-explainer/references/scene.md +25 -3
  101. package/dist/figure-frame-BjFzbl3m.js +0 -270
  102. package/dist/use-tween-5HZ55_9d.js +0 -72
@@ -6,6 +6,11 @@ export type SceneLabels = {
6
6
  readonly objects: string;
7
7
  /** The header of the exact-value table. */
8
8
  readonly objectColumn: string;
9
+ /**
10
+ * Ends the plot's accessible name when a press acts, with `onSelectedChange`. Name the action, such as "Press Enter
11
+ * to turn the card over."
12
+ */
13
+ readonly press: string;
9
14
  readonly missingLocale: string;
10
15
  readonly invalidBox: string;
11
16
  readonly invalidAspect: string;
@@ -28,6 +33,7 @@ export type SceneLabels = {
28
33
  export declare const sceneLabels: {
29
34
  readonly objects: 'diagram parts';
30
35
  readonly objectColumn: 'Part';
36
+ readonly press: 'Press Enter or Space to activate a part.';
31
37
  readonly missingLocale: 'This scene needs a locale. Pass `locale`, or place it inside a Lesson.';
32
38
  readonly invalidBox: 'The scene box needs two finite, increasing values on each axis.';
33
39
  readonly invalidAspect: 'The scene aspect must be a positive, finite ratio of width to height.';
@@ -27,6 +27,11 @@ export type SceneWireProps = {
27
27
  readonly tone?: ChartTone | undefined;
28
28
  /** How the wire runs between its ends. Defaults to `straight`. */
29
29
  readonly shape?: SceneWireShape | undefined;
30
+ /**
31
+ * Pixels the wire's middle bows off the line between its ends. Positive is above a wire that runs across and right of
32
+ * an upright one. A wire does not avoid other objects, so bow it around a node between its ends.
33
+ */
34
+ readonly bend?: number | undefined;
30
35
  /** Dashed for a modelled or proposed connection. */
31
36
  readonly isDashed?: boolean | undefined;
32
37
  /** Draws an arrowhead at the `to` end. Defaults to true. */
@@ -42,4 +47,4 @@ export type SceneWireProps = {
42
47
  * A connection between two scene objects that stays attached to their edges while they move. Its thickness can carry a
43
48
  * signed weight, eased when the weight changes. Give it a label to make it an item the reader can inspect.
44
49
  */
45
- export declare function SceneWire({ from, to, id, label, text, textSide, weight, tone, shape, isDashed, hasArrow, isShown, isActive, emphasis, }: SceneWireProps): ReactNode;
50
+ export declare function SceneWire({ from, to, id, label, text, textSide, weight, tone, shape, bend, isDashed, hasArrow, isShown, isActive, emphasis, }: SceneWireProps): ReactNode;
@@ -19,7 +19,7 @@ export type SceneProps = Omit<FigureProps, 'locale'> & FigureSelectionProps & {
19
19
  readonly pace?: Pace | undefined;
20
20
  /**
21
21
  * The narrowest plot in pixels; below it the plot scrolls inside the frame. Left out, it is the width at which no
22
- * two objects on the same row touch. Set it only to keep more room than the objects need.
22
+ * two objects on one row touch and each wire keeps room for its arrow and text. Set it only to keep more room.
23
23
  */
24
24
  readonly minWidth?: number | undefined;
25
25
  /** The wire weight magnitude drawn thickest. Weights must lie within plus or minus this. Defaults to 1. */
@@ -1,4 +1,4 @@
1
- import type { NumericDomain } from '../../../../charts/src/index.ts';
1
+ import type { ChartTone, NumericDomain } from '../../../../charts/src/index.ts';
2
2
  import type { HeatmapPalette } from '../../../../charts/src/matrix/index.ts';
3
3
  import type { SceneOffset } from '../scene-geometry.ts';
4
4
  /** The pixel boxes of the named cell sizes. */
@@ -30,6 +30,10 @@ export type SceneCellInput = {
30
30
  readonly value?: number | undefined;
31
31
  /** The readout sentence. Left out, the cell says its row, column and value. */
32
32
  readonly label?: string | undefined;
33
+ /** The hue of the cell's text and tint, such as a card's suit. A palette's fill still wins. */
34
+ readonly tone?: ChartTone | undefined;
35
+ /** True draws the cell gray and unfilled, such as a card already dealt. Its value and label stay. */
36
+ readonly isMuted?: boolean | undefined;
33
37
  };
34
38
  /** The numbers of a vector or a matrix: a flat list, or a list of rows. */
35
39
  export type SceneCellValues = ReadonlyArray<number | ReadonlyArray<number>>;
@@ -61,7 +61,7 @@ export type SceneCellsProps = {
61
61
  readonly size?: SceneCellSizeName | undefined;
62
62
  /** One caption per row, drawn left of the grid in a column as wide as the longest. */
63
63
  readonly rowLabels?: ReadonlyArray<string> | undefined;
64
- /** One caption per column, drawn above the grid. */
64
+ /** One caption per column, drawn above the grid. A long caption wraps, and a word wider than its column overhangs. */
65
65
  readonly columnLabels?: ReadonlyArray<string> | undefined;
66
66
  /** A row, a column, or one cell where both are given, drawn with a strong outline. Indices count from 0. */
67
67
  readonly highlight?: {
@@ -20,7 +20,7 @@ export type SceneSlotProps = {
20
20
  readonly text?: string | undefined;
21
21
  /** The readout sentence. With one, the arrow keys reach the slot; Left and Right step on to a card sitting on it. */
22
22
  readonly label?: string | undefined;
23
- /** True draws the slot as the place that matters now: a solid outline and a tint. */
23
+ /** True draws the slot as the place that matters now: a solid outline and a tint. Nothing else recedes. */
24
24
  readonly isActive?: boolean | undefined;
25
25
  /** The hue of the outline while active. Defaults to neutral. */
26
26
  readonly tone?: ChartTone | undefined;
@@ -12,6 +12,8 @@ export type Tween<Key extends string> = {
12
12
  /** Stops any move in flight. The tween still answers `get` and can be moved again. */
13
13
  readonly destroy: () => void;
14
14
  };
15
+ /** Fast at first and settling gently, the curve the motion tokens use for interface transitions. */
16
+ export declare function eased(progress: number): number;
15
17
  /**
16
18
  * Makes a tween that starts at `initial`. Give it a new target with `to` and read `get` on each change: authors
17
19
  * describe where things are, and the tween supplies the motion between.
@@ -1,63 +1,126 @@
1
1
  import { d as e, m as t } from "./src-Dxs3Buo_.js";
2
2
  import { r as n } from "./figure-format-B8kRZMlo.js";
3
+ import { n as r, t as i } from "./clock-DSm5lkNE.js";
3
4
  import "@stylexjs/stylex";
4
- import { createParts as r } from "@ui-sdk/react/primitive";
5
- import { createContext as i, use as a, useEffect as o, useRef as s } from "react";
6
- import { announce as c, bindDrag as l, createChange as u, definePrimitive as d, dragThreshold as f, isRTL as p } from "@ui-sdk/core";
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
- import { Check as ee, ChevronDown as te } from "lucide-react";
9
- import { SelectTrigger as g, SelectValue as ne } from "@ui-sdk/react/select";
10
- import { clamp as re, fractionOf as _, scrubTo as v, stepBy as y, stepFromKey as b, stepValue as x, valueAt as S } from "@ui-sdk/core/number";
5
+ import { createParts as a } from "@ui-sdk/react/primitive";
6
+ import { createContext as o, use as s, useEffect as c, useRef as l } from "react";
7
+ import { announce as u, bindDrag as d, createChange as f, definePrimitive as p, dragThreshold as m, isRTL as h } from "@ui-sdk/core";
8
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
9
+ import { Check as v, ChevronDown as y } from "lucide-react";
10
+ import { SelectTrigger as ee, SelectValue as te } from "@ui-sdk/react/select";
11
+ import { clamp as b, fractionOf as x, scrubTo as S, stepBy as ne, stepFromKey as re, stepValue as C, valueAt as w } from "@ui-sdk/core/number";
12
+ // packages/teaching/src/time/tween.ts
13
+ var T = {
14
+ instant: 0,
15
+ fast: 140,
16
+ regular: 320,
17
+ slow: 640
18
+ }, ie = 4;
19
+ function E() {}
20
+ function D(e) {
21
+ return 1 - (1 - e) ** ie;
22
+ }
23
+ function O(e, t) {
24
+ let n = new Map(Object.entries(t)), r = Object.entries(e);
25
+ return r.length === n.size && r.every(([e, t]) => n.get(e) === t);
26
+ }
27
+ function k(e, t, n) {
28
+ let r = new Map(Object.entries(e));
29
+ return {
30
+ ...t,
31
+ ...Object.fromEntries(Object.entries(t).map(([e, t]) => {
32
+ let i = r.get(e) ?? t;
33
+ return [e, i + (t - i) * n];
34
+ }))
35
+ };
36
+ }
37
+ function ae(e) {
38
+ let t = /* @__PURE__ */ new Set(), n = {
39
+ shown: e,
40
+ from: e,
41
+ target: e,
42
+ started: -1,
43
+ duration: 0,
44
+ stop: E
45
+ };
46
+ function a(e) {
47
+ n.shown = e;
48
+ for (let e of t) e();
49
+ }
50
+ function o() {
51
+ n.stop(), n.stop = E;
52
+ }
53
+ function s(e) {
54
+ o(), n.target = e, O(n.shown, e) || a(e);
55
+ }
56
+ function c(e) {
57
+ n.started < 0 && (n.started = e);
58
+ let t = Math.min(1, (e - n.started) / n.duration);
59
+ t >= 1 ? (o(), a(n.target)) : a(k(n.from, n.target, D(t)));
60
+ }
61
+ function l(e, t = "regular") {
62
+ O(n.target, e) || (T[t] === 0 || i() ? s(e) : (o(), n.from = n.shown, n.target = e, n.started = -1, n.duration = T[t], n.stop = r(c)));
63
+ }
64
+ return {
65
+ get: () => n.shown,
66
+ to: l,
67
+ jump: s,
68
+ subscribe: (e) => (t.add(e), () => {
69
+ t.delete(e);
70
+ }),
71
+ destroy: o
72
+ };
73
+ }
11
74
  // packages/teaching/src/lesson/lesson-locale.ts
12
- var C = i(null);
13
- function ie() {
14
- return a(C);
75
+ var A = o(null);
76
+ function oe() {
77
+ return s(A);
15
78
  }
16
79
  // packages/teaching/src/lesson/lesson-error.tsx
17
- function w(e, t) {
80
+ function j(e, t) {
18
81
  throw Error(`Lesson "${e}": ${t}`);
19
82
  }
20
- function T(e) {
83
+ function M(e) {
21
84
  throw Error(`${e} must be rendered inside a <Lesson>. Wrap it in <Lesson lesson={…} locale="…">.`);
22
85
  }
23
- function E({ children: e }) {
24
- return /* @__PURE__ */ m("span", {
86
+ function N({ children: e }) {
87
+ return /* @__PURE__ */ g("span", {
25
88
  role: "note",
26
89
  className: "xr5kp14 x1b5ytql",
27
90
  children: e
28
91
  });
29
92
  }
30
93
  // packages/teaching/src/lesson/define-lesson.ts
31
- function D({ name: e, param: t, value: n }) {
94
+ function P({ name: e, param: t, value: n }) {
32
95
  switch (t.kind) {
33
96
  case "number": return typeof n == "number" && Number.isFinite(n) && n >= t.min && n <= t.max ? void 0 : `${e} takes a number from ${t.min} to ${t.max}, not ${String(n)}.`;
34
97
  case "choice": return t.options.some((e) => e.id === n) ? void 0 : `${e} takes one of ${t.options.map((e) => e.id).join(", ")}, not ${String(n)}.`;
35
98
  case "toggle": return typeof n == "boolean" ? void 0 : `${e} takes true or false, not ${String(n)}.`;
36
99
  }
37
100
  }
38
- function O(e, t) {
101
+ function F(e, t) {
39
102
  return Number.isFinite(t.min) && Number.isFinite(t.max) && t.min < t.max ? t.step > 0 ? t.scale === "log" && t.min <= 0 ? `${e} is on a log scale, so its min must be above zero.` : void 0 : `${e} needs a step above zero.` : `${e} needs finite bounds with min below max.`;
40
103
  }
41
- function k(e, t) {
104
+ function I(e, t) {
42
105
  if (t.kind === "number") {
43
- let n = O(e, t);
106
+ let n = F(e, t);
44
107
  if (n !== void 0) return n;
45
108
  }
46
109
  if (t.kind === "choice") {
47
110
  let n = t.options.map((e) => e.id);
48
111
  if (new Set(n).size !== n.length || n.length === 0) return `${e} needs at least one option, each with its own id.`;
49
112
  }
50
- let n = D({
113
+ let n = P({
51
114
  name: e,
52
115
  param: t,
53
116
  value: t.value
54
117
  });
55
118
  return n === void 0 ? void 0 : `the default of ${n}`;
56
119
  }
57
- function A(e) {
120
+ function L(e) {
58
121
  return e.find((t, n) => e.indexOf(t) !== n);
59
122
  }
60
- function j(e) {
123
+ function R(e) {
61
124
  let t = /* @__PURE__ */ new Set();
62
125
  return {
63
126
  view: new Proxy(e, { get(e, n, r) {
@@ -66,12 +129,12 @@ function j(e) {
66
129
  names: t
67
130
  };
68
131
  }
69
- function M(e, t) {
132
+ function z(e, t) {
70
133
  let n = new Map(Object.entries(t));
71
134
  return (e.states ?? []).flatMap((t) => Object.entries(t.values).flatMap(([r, i]) => {
72
135
  let a = n.get(r), o = `state "${t.id}" of beat "${e.id}"`;
73
136
  if (a === void 0) return [`${o} sets "${r}", which is not a param.`];
74
- let s = D({
137
+ let s = P({
75
138
  name: r,
76
139
  param: a,
77
140
  value: i
@@ -79,30 +142,34 @@ function M(e, t) {
79
142
  return s === void 0 ? [] : [`${o}: ${s}`];
80
143
  }));
81
144
  }
82
- function N(e, t) {
83
- let n = e.steps ?? 0, r = Number.isInteger(n) && n >= 0, i = A((e.states ?? []).map((e) => e.id));
145
+ function B(e, t) {
146
+ let n = e.steps ?? 0, r = Number.isInteger(n) && n >= 0, i = L((e.states ?? []).map((e) => e.id)), a = (e.params ?? []).find((e) => !Object.hasOwn(t, e));
84
147
  return [
85
148
  ...r ? [] : [`beat "${e.id}" needs a whole number of steps, not ${n}.`],
86
149
  ...i === void 0 ? [] : [`beat "${e.id}" has two states with the id "${i}".`],
87
- ...M(e, t)
150
+ ...a === void 0 ? [] : [`beat "${e.id}" owns "${a}", which is not a param.`],
151
+ ...z(e, t)
88
152
  ];
89
153
  }
90
- function P({ params: e, derivedNames: t, beats: n }) {
91
- let r = new Set(Object.keys(e)), i = t.find((e) => r.has(e)), a = A(n.map((e) => e.id));
154
+ function V(e) {
155
+ return e.params ?? [...new Set((e.states ?? []).flatMap((e) => Object.keys(e.values)))];
156
+ }
157
+ function H({ params: e, derivedNames: t, beats: n }) {
158
+ let r = new Set(Object.keys(e)), i = t.find((e) => r.has(e)), a = L(n.map((e) => e.id));
92
159
  return [
93
- ...Object.entries(e).flatMap(([e, t]) => k(e, t) ?? []),
160
+ ...Object.entries(e).flatMap(([e, t]) => I(e, t) ?? []),
94
161
  ...i === void 0 ? [] : [`"${i}" is declared as both a param and a derived value.`],
95
162
  ...a === void 0 ? [] : [`two beats share the id "${a}".`],
96
- ...n.flatMap((t) => N(t, e))
163
+ ...n.flatMap((t) => B(t, e))
97
164
  ];
98
165
  }
99
- function F(e) {
100
- let { id: t, title: n, params: r } = e, i = Object.entries(e.derived ?? {}), a = e.beats ?? [], o = Object.keys(r), s = i.map(([e]) => e), [c] = P({
166
+ function U(e) {
167
+ let { id: t, title: n, params: r } = e, i = Object.entries(e.derived ?? {}), a = e.beats ?? [], o = Object.keys(r), s = i.map(([e]) => e), [c] = H({
101
168
  params: r,
102
169
  derivedNames: s,
103
170
  beats: a
104
171
  });
105
- c !== void 0 && w(t, c);
172
+ c !== void 0 && j(t, c);
106
173
  let l = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, t.value])), u = Object.fromEntries(s.map((e) => [e, NaN]));
107
174
  function d(e) {
108
175
  let n = {
@@ -112,8 +179,8 @@ function F(e) {
112
179
  },
113
180
  results: u
114
181
  }, r = new Set(o), a = i.map(([e, i]) => {
115
- let { view: a, names: o } = j(n.known), s = i.from(a), c = [...o].find((e) => !r.has(e));
116
- return c !== void 0 && w(t, `derived "${e}" reads "${c}", which is not a param or a derived value declared before it.`), typeof s != "number" && w(t, `derived "${e}" must return a number.`), r.add(e), n.known = {
182
+ let { view: a, names: o } = R(n.known), s = i.from(a), c = [...o].find((e) => !r.has(e));
183
+ return c !== void 0 && j(t, `derived "${e}" reads "${c}", which is not a param or a derived value declared before it.`), typeof s != "number" && j(t, `derived "${e}" must return a number.`), r.add(e), n.known = {
117
184
  ...n.known,
118
185
  [e]: s
119
186
  }, n.results = {
@@ -148,7 +215,7 @@ function F(e) {
148
215
  reads: m
149
216
  };
150
217
  }
151
- function I(e) {
218
+ function W(e) {
152
219
  return {
153
220
  nodes: [...Object.entries(e.params).map(([e, t]) => ({
154
221
  name: e,
@@ -166,21 +233,21 @@ function I(e) {
166
233
  };
167
234
  }
168
235
  // packages/teaching/src/lesson/lesson-context.ts
169
- var L = i(null);
170
- function R(e) {
171
- return a(L) ?? T(e);
236
+ var G = o(null);
237
+ function K(e) {
238
+ return s(G) ?? M(e);
172
239
  }
173
- function z(e, t) {
240
+ function q(e, t) {
174
241
  let n = { scope: e };
175
242
  for (; n.scope !== null && n.scope.lesson !== t;) n.scope = n.scope.outer;
176
243
  return n.scope;
177
244
  }
178
245
  // packages/teaching/src/lesson/bound-value.tsx
179
- var B = 240, V = {
246
+ var se = 240, ce = {
180
247
  step: .01,
181
248
  large: .1,
182
249
  small: .001
183
- }, H = [
250
+ }, le = [
184
251
  "ArrowLeft",
185
252
  "ArrowRight",
186
253
  "ArrowUp",
@@ -190,23 +257,23 @@ var B = 240, V = {
190
257
  "Home",
191
258
  "End"
192
259
  ];
193
- function U({ min: e, max: t, step: n }) {
260
+ function J({ min: e, max: t, step: n }) {
194
261
  return {
195
262
  min: e,
196
263
  max: t,
197
264
  step: n
198
265
  };
199
266
  }
200
- function W(e, t) {
201
- let n = U(t);
202
- return v(S(re(e, 0, 1), n, t.scale ?? "linear"), n).value;
267
+ function Y(e, t) {
268
+ let n = J(t);
269
+ return S(w(b(e, 0, 1), n, t.scale ?? "linear"), n).value;
203
270
  }
204
- function G(e, t, n) {
271
+ function ue(e, t, n) {
205
272
  if (t.bound !== void 0) return t.bound === "min" ? n.min : n.max;
206
- let r = U(n), i = W(_(e, r, "log") + t.direction * V[t.size], n);
207
- return i === e ? x(e, t.direction, r) : i;
273
+ let r = J(n), i = Y(x(e, r, "log") + t.direction * ce[t.size], n);
274
+ return i === e ? C(e, t.direction, r) : i;
208
275
  }
209
- var K = d({
276
+ var de = p({
210
277
  name: "bound-value",
211
278
  options: {
212
279
  value: "number",
@@ -225,7 +292,7 @@ var K = d({
225
292
  }),
226
293
  sync: (e) => e.value === void 0 ? {} : { value: e.value },
227
294
  api: (e) => {
228
- let { store: t } = e, n = u(e), r = null;
295
+ let { store: t } = e, n = f(e), r = null;
229
296
  e.onDestroy(() => r?.());
230
297
  function i(e, r, i) {
231
298
  return e !== t.get().value && n("value", e, i === void 0 ? { reason: r } : {
@@ -238,27 +305,27 @@ var K = d({
238
305
  setValue(t) {
239
306
  let { min: n, max: r } = e.options(), a = Number(t);
240
307
  if (!Number.isFinite(a) || a < n || a > r) throw Error(`Give a number between ${n} and ${r}.`);
241
- return i(v(a, U(e.options())).value, "imperative");
308
+ return i(S(a, J(e.options())).value, "imperative");
242
309
  },
243
310
  keydown(n, r) {
244
- let a = b(n, { dir: p(r) ? "rtl" : "ltr" });
311
+ let a = re(n, { dir: h(r) ? "rtl" : "ltr" });
245
312
  if (a === null || n.defaultPrevented) return;
246
313
  n.preventDefault();
247
314
  let o = e.options(), { value: s } = t.get();
248
- i(o.scale === "log" ? G(s, a, o) : y(s, a, U(o)), "step-key", n);
315
+ i(o.scale === "log" ? ue(s, a, o) : ne(s, a, J(o)), "step-key", n);
249
316
  },
250
317
  pointerdown(n, a) {
251
318
  if (n.button !== 0) return;
252
319
  r?.();
253
- let o = t.get().value, s = p(a) ? -1 : 1, c = _(o, U(e.options()), e.options().scale ?? "linear"), u = 0;
254
- r = l(a, n, {
255
- threshold: f,
320
+ let o = t.get().value, s = h(a) ? -1 : 1, c = x(o, J(e.options()), e.options().scale ?? "linear"), l = 0;
321
+ r = d(a, n, {
322
+ threshold: m,
256
323
  cancelOnEscape: !0,
257
324
  onStart: () => {
258
325
  t.set({ isDragging: !0 });
259
326
  },
260
327
  onMove: ({ movementX: t, event: n }) => {
261
- u += t * s, i(W(c + u / B, e.options()), "drag", n);
328
+ l += t * s, i(Y(c + l / se, e.options()), "drag", n);
262
329
  },
263
330
  onEnd: (e, n) => {
264
331
  t.set({ isDragging: !1 }), n && i(o, "drag", e);
@@ -270,7 +337,7 @@ var K = d({
270
337
  slots: (e) => ({ root: e({
271
338
  role: "slider",
272
339
  focus: "tab-stop",
273
- keys: [...H],
340
+ keys: [...le],
274
341
  state: (e, { api: t }) => ({
275
342
  text: t.describe(e.value),
276
343
  isDragging: e.isDragging
@@ -291,16 +358,16 @@ var K = d({
291
358
  }
292
359
  }) }),
293
360
  agent: { actions: ["setValue"] }
294
- }), q = r(K, { root: "span" }).Root;
295
- function J({ min: e, max: t, step: n, scale: r, value: i }) {
361
+ }), fe = a(de, { root: "span" }).Root;
362
+ function pe({ min: e, max: t, step: n, scale: r, value: i }) {
296
363
  if (!Number.isFinite(e) || !Number.isFinite(t) || e >= t) return "BoundValue needs finite bounds with min below max.";
297
364
  if (!Number.isFinite(n) || n < 0) return "BoundValue needs a step of zero or more.";
298
365
  if (r === "log" && e <= 0) return "A log BoundValue needs a min above zero.";
299
366
  if (i !== void 0 && !(Number.isFinite(i) && i >= e && i <= t)) return `BoundValue ${i} lies outside ${e} to ${t}.`;
300
367
  }
301
- function Y({ label: e, locale: t, format: r, ...i }) {
302
- let a = J(i);
303
- return a === void 0 ? /* @__PURE__ */ m(q, {
368
+ function X({ label: e, locale: t, format: r, ...i }) {
369
+ let a = pe(i);
370
+ return a === void 0 ? /* @__PURE__ */ g(fe, {
304
371
  ...i,
305
372
  describe: (e) => n({
306
373
  value: e,
@@ -312,43 +379,43 @@ function Y({ label: e, locale: t, format: r, ...i }) {
312
379
  "aria-valuemax": i.max,
313
380
  "aria-orientation": "horizontal",
314
381
  className: "xt0psk2 x1ok0vyi xbixft xss6m8b xk4h15q xuxw1ft x7eptgl x87ps6o xx69xxh xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x81ozek xxxv2na x13qnu6 x9v5kkp x19rmrnh x7s97pk",
315
- render: (e, { text: t }) => /* @__PURE__ */ m("span", {
382
+ render: (e, { text: t }) => /* @__PURE__ */ g("span", {
316
383
  ...e,
317
384
  children: t
318
385
  })
319
- }) : /* @__PURE__ */ m("span", {
386
+ }) : /* @__PURE__ */ g("span", {
320
387
  className: "xr5kp14 x1b5ytql",
321
388
  children: a
322
389
  });
323
390
  }
324
391
  // packages/teaching/src/lesson/inline-choice.tsx
325
- var ae = 14;
326
- function oe({ param: e, value: n, isDisabled: r, onChange: i }) {
392
+ var me = 14;
393
+ function he({ param: e, value: n, isDisabled: r, onChange: i }) {
327
394
  let a = e.options.map((e) => ({
328
395
  value: e.id,
329
396
  label: e.label
330
397
  }));
331
- return /* @__PURE__ */ h(t.Root, {
398
+ return /* @__PURE__ */ _(t.Root, {
332
399
  value: n,
333
400
  items: a,
334
401
  disabled: r,
335
402
  onValueChange: (e, t) => {
336
403
  e !== null && i(e, t);
337
404
  },
338
- children: [/* @__PURE__ */ h(g, {
405
+ children: [/* @__PURE__ */ _(ee, {
339
406
  "aria-label": e.label,
340
407
  disabled: r,
341
408
  className: "x3nfvp2 x1pha0wt xfko13i x1717udv x1ghz6dp xc342km x1ok0vyi xjbqb8w xbixft xjb2p0i x1qlqyl8 x15bjb6t xk4h15q xuxw1ft x1ypdohk xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x1m8qfh3 x47ym49 x13qnu6 x9v5kkp x19rmrnh x7s97pk",
342
- children: [/* @__PURE__ */ m(ne, {}), !r && /* @__PURE__ */ m(te, {
343
- size: ae,
409
+ children: [/* @__PURE__ */ g(te, {}), !r && /* @__PURE__ */ g(y, {
410
+ size: me,
344
411
  "aria-hidden": !0,
345
412
  className: "xamitd3 x153jb6y"
346
413
  })]
347
- }), /* @__PURE__ */ m(t.Popup, {
414
+ }), /* @__PURE__ */ g(t.Popup, {
348
415
  align: "start",
349
- children: /* @__PURE__ */ m(t.List, { children: a.map((e) => /* @__PURE__ */ h(t.Item, {
416
+ children: /* @__PURE__ */ g(t.List, { children: a.map((e) => /* @__PURE__ */ _(t.Item, {
350
417
  value: e.value,
351
- children: [/* @__PURE__ */ m(t.ItemText, { children: e.label }), /* @__PURE__ */ m(t.ItemIndicator, { children: /* @__PURE__ */ m(ee, {
418
+ children: [/* @__PURE__ */ g(t.ItemText, { children: e.label }), /* @__PURE__ */ g(t.ItemIndicator, { children: /* @__PURE__ */ g(v, {
352
419
  size: 16,
353
420
  "aria-hidden": !0
354
421
  }) })]
@@ -357,15 +424,15 @@ function oe({ param: e, value: n, isDisabled: r, onChange: i }) {
357
424
  });
358
425
  }
359
426
  // packages/teaching/src/lesson/param.tsx
360
- var se = 700, X = {
427
+ var ge = 700, Z = {
361
428
  on: "on",
362
429
  off: "off"
363
430
  };
364
- function Z(e, t) {
431
+ function Q(e, t) {
365
432
  let n = new Map(Object.entries(e.lesson.params)).get(t);
366
433
  return n === void 0 ? { error: `Lesson "${e.lesson.id}" has no param "${t}". Its params: ${Object.keys(e.lesson.params).join(", ")}.` } : { param: n };
367
434
  }
368
- function Q({ param: e, value: t, locale: r, labels: i }) {
435
+ function $({ param: e, value: t, locale: r, labels: i }) {
369
436
  switch (e.kind) {
370
437
  case "number": return n({
371
438
  value: typeof t == "number" ? t : null,
@@ -376,20 +443,20 @@ function Q({ param: e, value: t, locale: r, labels: i }) {
376
443
  case "toggle": return t === !0 ? i.on : i.off;
377
444
  }
378
445
  }
379
- function ce({ name: t }) {
380
- let n = R("Param"), r = Z(n, t);
381
- if ("error" in r) return /* @__PURE__ */ m(E, { children: r.error });
446
+ function _e({ name: t }) {
447
+ let n = K("Param"), r = Q(n, t);
448
+ if ("error" in r) return /* @__PURE__ */ g(N, { children: r.error });
382
449
  let { param: i } = r, a = n.state.values[t], { isReadOnly: o } = n.state;
383
450
  switch (i.kind) {
384
- case "number": return o ? /* @__PURE__ */ m("span", {
451
+ case "number": return o ? /* @__PURE__ */ g("span", {
385
452
  className: "xss6m8b xk4h15q xuxw1ft xbixft",
386
- children: Q({
453
+ children: $({
387
454
  param: i,
388
455
  value: a,
389
456
  locale: n.locale,
390
- labels: X
457
+ labels: Z
391
458
  })
392
- }) : /* @__PURE__ */ m(Y, {
459
+ }) : /* @__PURE__ */ g(X, {
393
460
  value: typeof a == "number" ? a : i.value,
394
461
  onValueChange: (e, r) => n.api.apply(t, e, r),
395
462
  min: i.min,
@@ -400,41 +467,41 @@ function ce({ name: t }) {
400
467
  format: i.format,
401
468
  label: i.label
402
469
  });
403
- case "choice": return /* @__PURE__ */ m(oe, {
470
+ case "choice": return /* @__PURE__ */ g(he, {
404
471
  param: i,
405
472
  value: typeof a == "string" ? a : i.value,
406
473
  isDisabled: o,
407
474
  onChange: (e, r) => n.api.apply(t, e, r)
408
475
  });
409
- case "toggle": return /* @__PURE__ */ m("span", {
476
+ case "toggle": return /* @__PURE__ */ g("span", {
410
477
  className: "x3nfvp2 xxymvpz",
411
- children: /* @__PURE__ */ m(e.Root, {
478
+ children: /* @__PURE__ */ g(e.Root, {
412
479
  checked: a === !0,
413
480
  onCheckedChange: (e, r) => n.api.apply(t, e, r),
414
481
  disabled: o,
415
482
  "aria-label": i.label,
416
- children: /* @__PURE__ */ m(e.Thumb, {})
483
+ children: /* @__PURE__ */ g(e.Thumb, {})
417
484
  })
418
485
  });
419
486
  }
420
487
  }
421
- function le(e, t) {
422
- let n = s(e);
423
- o(() => {
488
+ function ve(e, t) {
489
+ let n = l(e);
490
+ c(() => {
424
491
  if (t || n.current === e) return;
425
492
  let r = globalThis.setTimeout(() => {
426
- n.current = e, c(e);
427
- }, se);
493
+ n.current = e, u(e);
494
+ }, ge);
428
495
  return () => globalThis.clearTimeout(r);
429
496
  }, [e, t]);
430
497
  }
431
- function $({ name: e, labels: t }) {
432
- let r = R("Value"), i = new Map(Object.entries(r.lesson.derived)).get(e), a = i === void 0 ? Z(r, e) : void 0, o = r.values[e], s = i === void 0 ? a !== void 0 && "param" in a ? Q({
498
+ function ye({ name: e, labels: t }) {
499
+ let r = K("Value"), i = new Map(Object.entries(r.lesson.derived)).get(e), a = i === void 0 ? Q(r, e) : void 0, o = r.values[e], s = i === void 0 ? a !== void 0 && "param" in a ? $({
433
500
  param: a.param,
434
501
  value: o,
435
502
  locale: r.locale,
436
503
  labels: {
437
- ...X,
504
+ ...Z,
438
505
  ...t
439
506
  }
440
507
  }) : void 0 : n({
@@ -442,9 +509,9 @@ function $({ name: e, labels: t }) {
442
509
  locale: r.locale,
443
510
  format: i.format
444
511
  }), c = i?.label ?? (a !== void 0 && "param" in a ? a.param.label : e);
445
- return le(s === void 0 ? "" : `${c}: ${s}`, r.state.playing !== null), s === void 0 ? /* @__PURE__ */ m(E, { children: `Lesson "${r.lesson.id}" has no param or derived value "${e}".` }) : /* @__PURE__ */ m("span", {
512
+ return ve(s === void 0 ? "" : `${c}: ${s}`, r.state.playing !== null), s === void 0 ? /* @__PURE__ */ g(N, { children: `Lesson "${r.lesson.id}" has no param or derived value "${e}".` }) : /* @__PURE__ */ g("span", {
446
513
  className: "xss6m8b xk4h15q xuxw1ft",
447
514
  children: s
448
515
  });
449
516
  }
450
- export { L as a, F as c, E as d, w as f, ie as h, Y as i, I as l, C as m, $ as n, z as o, T as p, Z as r, R as s, ce as t, D as u };
517
+ export { ae as _, G as a, V as c, P as d, N as f, oe as g, A as h, X as i, U as l, M as m, ye as n, q as o, j as p, Q as r, K as s, _e as t, W as u, D as v };