@mechane-ai/elements 0.47.0 → 0.48.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 (204) hide show
  1. package/README.md +288 -5
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/article-BXZr10QQ.js +1904 -0
  4. package/dist/article.js +1 -0
  5. package/dist/catalog.json +1389 -75
  6. package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
  7. package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
  8. package/dist/charts/cartesian.js +1 -1
  9. package/dist/charts/cells.js +1 -1
  10. package/dist/charts/comparison.js +1 -1
  11. package/dist/charts/distribution.js +1 -1
  12. package/dist/charts/figure.js +12 -12
  13. package/dist/charts/graph.js +1 -1
  14. package/dist/charts/hierarchy.js +1 -1
  15. package/dist/charts/image.js +1 -1
  16. package/dist/charts/matrix.js +3 -2
  17. package/dist/charts/plot.js +4 -4
  18. package/dist/charts/relationship.js +1 -1
  19. package/dist/charts/text.js +1 -1
  20. package/dist/charts/timeline.js +1 -1
  21. package/dist/charts/trend.js +1 -1
  22. package/dist/charts.js +2 -2
  23. package/dist/clock-DSm5lkNE.js +16 -0
  24. package/dist/collections.js +1 -1
  25. package/dist/describe-lesson-BmREzDpt.js +175 -0
  26. package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
  27. package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
  28. package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
  29. package/dist/forms.js +1 -1
  30. package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
  31. package/dist/kits/evaluation.js +5 -5
  32. package/dist/kits/interpretability.js +9 -9
  33. package/dist/kits/operations.js +4 -4
  34. package/dist/kits/training.js +4 -4
  35. package/dist/lesson/agent.js +811 -0
  36. package/dist/lesson/spec.js +661 -0
  37. package/dist/lesson.js +5 -0
  38. package/dist/mdx.js +227 -0
  39. package/dist/packages/charts/src/matrix/index.d.ts +1 -0
  40. package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
  41. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  42. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  43. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  44. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  45. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  46. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  47. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  48. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  49. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  50. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  51. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  52. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  53. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  54. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  55. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  56. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  57. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  58. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  59. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  60. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  61. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  62. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  63. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  64. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  65. package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
  66. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  67. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  68. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  69. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  70. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  71. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  72. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  73. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  74. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  75. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  76. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  77. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  78. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  79. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  80. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  81. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  82. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  83. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  84. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  85. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  86. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  87. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  88. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  89. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  90. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  91. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  92. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  93. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  94. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  95. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  96. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  97. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  98. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  99. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  100. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  101. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  102. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  103. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  104. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  105. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  106. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  107. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  108. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  109. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  110. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  111. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  112. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  113. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  114. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  115. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  116. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  117. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  118. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  119. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  120. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  121. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  122. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  123. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  124. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  125. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  126. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  127. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  128. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  129. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  130. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  131. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  132. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  133. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  134. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  135. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  136. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  137. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  138. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  139. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  140. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  141. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  142. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  143. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  144. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  145. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  146. package/dist/param-CqKUTHaO.js +450 -0
  147. package/dist/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
  148. package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
  149. package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
  150. package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
  151. package/dist/scene-0z2gbaDE.js +4938 -0
  152. package/dist/scene.js +1 -0
  153. package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
  154. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  155. package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
  156. package/dist/styles2.css +475 -18
  157. package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
  158. package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
  159. package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
  160. package/dist/transport-BJweqDPj.js +715 -0
  161. package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
  162. package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
  163. package/dist/use-tween-5HZ55_9d.js +72 -0
  164. package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
  165. package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
  166. package/package.json +26 -5
  167. package/recipes/counting-cards.tsx +656 -0
  168. package/recipes/explorable-essay.tsx +172 -0
  169. package/skills/extend-elements/SKILL.md +21 -0
  170. package/skills/plan-lesson/SKILL.md +86 -0
  171. package/skills/plan-lesson/references/plan-format.md +114 -0
  172. package/skills/plan-lesson/references/worked-plan.md +171 -0
  173. package/skills/review-elements/SKILL.md +4 -2
  174. package/skills/review-explainer/SKILL.md +97 -0
  175. package/skills/upgrade-elements/references/releases.md +65 -0
  176. package/skills/use-elements/SKILL.md +18 -16
  177. package/skills/use-elements/references/kits.md +2 -20
  178. package/skills/use-elements/references/teaching.md +36 -0
  179. package/skills/write-explainer/SKILL.md +112 -0
  180. package/skills/write-explainer/references/article.md +164 -0
  181. package/skills/write-explainer/references/lesson.md +148 -0
  182. package/skills/write-explainer/references/mdx.md +78 -0
  183. package/skills/write-explainer/references/scene-parts.md +273 -0
  184. package/skills/write-explainer/references/scene.md +168 -0
  185. package/skills/write-explainer/references/tutor.md +104 -0
  186. package/skills/write-explainer/references/worked-essay.md +459 -0
  187. package/templates/essay/AGENTS.md +14 -0
  188. package/templates/essay/README.md +59 -0
  189. package/templates/essay/index.html +17 -0
  190. package/templates/essay/package.template.json +21 -0
  191. package/templates/essay/plan.json +96 -0
  192. package/templates/essay/src/essay.mdx +97 -0
  193. package/templates/essay/src/figures.tsx +92 -0
  194. package/templates/essay/src/lesson.ts +83 -0
  195. package/templates/essay/src/main.tsx +53 -0
  196. package/templates/essay/src/mdx.d.ts +7 -0
  197. package/templates/essay/tsconfig.template.json +15 -0
  198. package/templates/essay/vite.config.template.txt +8 -0
  199. package/dist/kits/explainers.js +0 -452
  200. package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
  201. package/dist/packages/kits/src/explainers/index.d.ts +0 -8
  202. package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
  203. /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
  204. /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
@@ -0,0 +1,4938 @@
1
+ import { i as e } from "./chart-link-AE_xuxiP.js";
2
+ import { E as t, O as n, S as r, T as i, c as a, k as o, l as s, s as c, t as l, u, w as d } from "./plot-layout-CZVSJ-le.js";
3
+ import { i as f, l as p, n as m, r as h, t as g } from "./figure-frame-BJ3REgTA.js";
4
+ import { r as _, t as v } from "./plot-surface-CbVBvgqZ.js";
5
+ import { a as y, i as b, r as x } from "./tone-scope-DKiSw-JR.js";
6
+ import { a as S, h as C, l as w, o as T, t as E } from "./param-CqKUTHaO.js";
7
+ import { n as D, t as O } from "./clock-DSm5lkNE.js";
8
+ import { n as k, t as A } from "./use-tween-5HZ55_9d.js";
9
+ import { o as j, r as M } from "./scale-C2xgZyZN.js";
10
+ import { t as N } from "./chart-tones-ei3BC2AL.js";
11
+ import { r as P } from "./tokens.stylex-dF5CACEJ.js";
12
+ import { r as F } from "./figure-format-B8kRZMlo.js";
13
+ import { n as I } from "./plot-width-DcqtSgzb.js";
14
+ import { n as L, t as R } from "./label-place-Z0fryBZb.js";
15
+ import { a as ee, c as z, f as B, n as te, t as ne, u as re } from "./plot-marks-uozcbOIX.js";
16
+ import { i as ie, r as ae, t as oe } from "./path-BglsXpnO.js";
17
+ import { t as se } from "./plot-axes-DJkLW4wk.js";
18
+ import { t as ce } from "./heatmap-scale-Zte6Ya-g.js";
19
+ import { d as le, f as ue } from "./token-predictions-yerq_Oet.js";
20
+ import * as V from "@stylexjs/stylex";
21
+ import { Children as de, createContext as fe, memo as pe, use as H, useEffect as me, useId as he, useLayoutEffect as U, useMemo as ge, useRef as _e, useState as W, useSyncExternalStore as ve } from "react";
22
+ import { bindDrag as ye, dragThreshold as be } from "@ui-sdk/core";
23
+ import { Fragment as xe, jsx as G, jsxs as K } from "react/jsx-runtime";
24
+ import { clamp as Se, scrubTo as Ce } from "@ui-sdk/core/number";
25
+ import { createPortal as we } from "react-dom";
26
+ // packages/teaching/src/scene/scene-registry.ts
27
+ function Te(e, t) {
28
+ return e.length === t.length && e.every((e, n) => e === t[n]);
29
+ }
30
+ function Ee(e, t) {
31
+ let [n = 0, r = 0] = e ?? [], [i = 0, a = 0] = t ?? [];
32
+ return n === i && r === a;
33
+ }
34
+ function De(e, t) {
35
+ if (e === void 0 || t === void 0) return e === t;
36
+ let n = e.x === t.x && e.y === t.y && Ee(e.offset, t.offset), r = e.width === t.width && e.height === t.height;
37
+ return n && r && Oe(e.outset, t.outset);
38
+ }
39
+ function Oe(e, t) {
40
+ return e?.top === t?.top && e?.bottom === t?.bottom && e?.left === t?.left && e?.right === t?.right;
41
+ }
42
+ function ke(e, t) {
43
+ let n = e.kind === t.kind && e.label === t.label && e.shape === t.shape, r = e.isShown === t.isShown && e.isActive === t.isActive, i = Te(e.attaches, t.attaches) && e.track === t.track, a = e.problem === t.problem && De(e.frame, t.frame), o = e.isFloating === t.isFloating && e.order === t.order && e.room === t.room, s = n && r && o, c = Oe(e.margins, t.margins) && Oe(e.surround, t.surround);
44
+ return s && i && a && c;
45
+ }
46
+ function Ae() {
47
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = {
48
+ snapshot: void 0,
49
+ isPainted: !1,
50
+ isDrafting: !0
51
+ };
52
+ function a() {
53
+ i.snapshot = void 0;
54
+ for (let e of r) e();
55
+ }
56
+ function o() {
57
+ return i.snapshot ??= {
58
+ list: Array.from(e.values(), (e) => e.member),
59
+ duplicates: [...t.keys()]
60
+ }, i.snapshot;
61
+ }
62
+ function s(n, r) {
63
+ let i = e.get(r.id);
64
+ if (i !== void 0 && i.owner !== n) {
65
+ let e = t.get(r.id) ?? /* @__PURE__ */ new Set(), i = !e.has(n);
66
+ e.add(n), t.set(r.id, e), i && a();
67
+ } else i !== void 0 && ke(i.member, r) || (e.set(r.id, {
68
+ owner: n,
69
+ member: r
70
+ }), a());
71
+ }
72
+ function c(n, r) {
73
+ let i = t.get(r);
74
+ i?.delete(n) === !0 ? (i.size === 0 && t.delete(r), a()) : e.get(r)?.owner === n && (e.delete(r), a());
75
+ }
76
+ return {
77
+ members: o,
78
+ subscribe: (e) => (r.add(e), () => {
79
+ r.delete(e);
80
+ }),
81
+ member: (t) => e.get(t)?.member ?? (i.isDrafting ? n.get(t) : void 0),
82
+ upsert: s,
83
+ remove: c,
84
+ isPainted: () => i.isPainted,
85
+ markPainted: () => {
86
+ i.isPainted = !0;
87
+ },
88
+ draft: (e) => {
89
+ n.set(e.id, e);
90
+ },
91
+ isDrafting: () => i.isDrafting,
92
+ endDrafts: () => {
93
+ i.isDrafting && (i.isDrafting = !1, n.clear(), a());
94
+ }
95
+ };
96
+ }
97
+ function je(e) {
98
+ let t = /* @__PURE__ */ new WeakMap();
99
+ return (n) => {
100
+ let r = t.get(n);
101
+ if (r !== void 0) return r;
102
+ let i = e();
103
+ return t.set(n, i), i;
104
+ };
105
+ }
106
+ // packages/teaching/src/scene/scene-stagger.ts
107
+ var Me = {
108
+ short: 60,
109
+ regular: 120,
110
+ long: 240
111
+ };
112
+ function Ne(e) {
113
+ return typeof e == "number" ? e : e.index * Me[e.step ?? "regular"];
114
+ }
115
+ function Pe() {
116
+ let e = /* @__PURE__ */ new Set(), t = { isQueued: !1 };
117
+ function n() {
118
+ t.isQueued = !1;
119
+ let n = Map.groupBy(e, (e) => e.place.group);
120
+ e.clear();
121
+ let r = Array.from(n.values()).flatMap((e) => e.toSorted((e, t) => e.place.index - t.place.index).map((e, t) => ({
122
+ entry: e,
123
+ wait: t * Me[e.place.step ?? "regular"]
124
+ })));
125
+ for (let { entry: e, wait: t } of r) e.begin(t);
126
+ }
127
+ return { join: (r) => (e.add(r), t.isQueued || (t.isQueued = !0, queueMicrotask(n)), () => {
128
+ e.delete(r);
129
+ }) };
130
+ }
131
+ var Fe = je(Pe), Ie = {
132
+ objects: "diagram parts",
133
+ objectColumn: "Part",
134
+ missingLocale: "This scene needs a locale. Pass `locale`, or place it inside a Lesson.",
135
+ invalidBox: "The scene box needs two finite, increasing values on each axis.",
136
+ invalidAspect: "The scene aspect must be a positive, finite ratio of width to height.",
137
+ tooMany: "This scene draws at most {limit} objects. Show fewer, or group them.",
138
+ duplicateId: "Two scene objects share the id \"{id}\". Give each its own id.",
139
+ unknownId: "The {kind} \"{id}\" attaches to \"{target}\", which no object in this scene has.",
140
+ outsideBox: "The {kind} \"{id}\" sits outside the scene box.",
141
+ unknownFocus: "The focus names \"{id}\", which no object in this scene has.",
142
+ weightOutside: "The wire \"{id}\" has weight {weight}, outside the scene's weight limit of plus or minus {limit}.",
143
+ outside: "{part} must be inside a Scene."
144
+ }, Le = { objects: 1200 };
145
+ function q(e, t) {
146
+ return e.replaceAll(/\{(\w+)\}/gu, (e, n) => t[n] ?? e);
147
+ }
148
+ function Re({ box: e, aspect: t, labels: n }) {
149
+ return j(e.x) !== void 0 || j(e.y) !== void 0 ? n.invalidBox : t !== void 0 && (!Number.isFinite(t) || t <= 0) ? n.invalidAspect : void 0;
150
+ }
151
+ function ze(e, t) {
152
+ if (e === void 0) return !1;
153
+ let n = Number.isFinite(e.x) && Number.isFinite(e.y), r = e.x < t.x[0] || e.x > t.x[1], i = e.y < t.y[0] || e.y > t.y[1];
154
+ return !n || r || i;
155
+ }
156
+ function Be({ member: e, ids: t, box: n, labels: r }) {
157
+ if (e.problem !== void 0) return e.problem;
158
+ let i = e.attaches.find((e) => !t.has(e));
159
+ return i === void 0 ? ze(e.frame, n) ? q(r.outsideBox, {
160
+ kind: e.kind,
161
+ id: e.id
162
+ }) : void 0 : q(r.unknownId, {
163
+ kind: e.kind,
164
+ id: e.id,
165
+ target: i
166
+ });
167
+ }
168
+ function Ve({ members: e, focus: t, box: n, labels: r }) {
169
+ if (e.list.length > Le.objects) return q(r.tooMany, { limit: String(Le.objects) });
170
+ let [i] = e.duplicates;
171
+ if (i !== void 0) return q(r.duplicateId, { id: i });
172
+ let a = new Set(e.list.map((e) => e.id));
173
+ for (let t of e.list) {
174
+ let e = Be({
175
+ member: t,
176
+ ids: a,
177
+ box: n,
178
+ labels: r
179
+ });
180
+ if (e !== void 0) return e;
181
+ }
182
+ let o = a.size === 0 ? void 0 : t.find((e) => !a.has(e));
183
+ return o === void 0 ? void 0 : q(r.unknownFocus, { id: o });
184
+ }
185
+ // packages/teaching/src/scene/scene-context.ts
186
+ var He = .5, Ue = {
187
+ normal: 1,
188
+ context: 1,
189
+ receded: .32
190
+ };
191
+ function We() {
192
+ let e = {
193
+ box: c({
194
+ width: 1,
195
+ height: 1,
196
+ margins: {
197
+ top: 0,
198
+ right: 0,
199
+ bottom: 0,
200
+ left: 0
201
+ }
202
+ }),
203
+ domain: {
204
+ x: [0, 1],
205
+ y: [0, 1]
206
+ }
207
+ };
208
+ return {
209
+ ...e,
210
+ scalesFor: Ze(e),
211
+ isInScene: !1,
212
+ registry: Ae(),
213
+ camera: k({
214
+ x0: 0,
215
+ x1: 1,
216
+ y0: 0,
217
+ y1: 1
218
+ }),
219
+ pace: "regular",
220
+ locale: "en-US",
221
+ tone: ({ tone: e, index: t }) => e ?? x(t),
222
+ weightMax: 1,
223
+ layers: {
224
+ back: null,
225
+ wires: null,
226
+ front: null
227
+ },
228
+ labels: Ie
229
+ };
230
+ }
231
+ var Ge = fe(We());
232
+ function Ke() {}
233
+ var qe = fe({
234
+ inspected: null,
235
+ selected: null,
236
+ cursor: null,
237
+ lit: null,
238
+ isKeyboardFocused: !1,
239
+ focusPlot: Ke
240
+ });
241
+ function Je({ domain: e, low: t, high: n, range: r }) {
242
+ let i = M({
243
+ domain: e,
244
+ range: [0, 1]
245
+ }), a = e[1] - e[0];
246
+ function o(t) {
247
+ return t >= e[0] && t <= e[1] ? i.position(t) : (t - e[0]) / a;
248
+ }
249
+ let s = o(t), c = o(n) - s, l = r[1] - r[0];
250
+ return {
251
+ type: "linear",
252
+ domain: [t, n],
253
+ range: r,
254
+ position: (e) => r[0] + (o(e) - s) / c * l,
255
+ valueAt: (t) => e[0] + (s + (t - r[0]) / l * c) * a
256
+ };
257
+ }
258
+ function Ye({ values: e, x: t, y: n }) {
259
+ let r = t.position(e.x) + e.dx, i = n.position(e.y) + e.dy, a = e.width * He, o = e.height * He;
260
+ return {
261
+ left: r - a,
262
+ top: i - o,
263
+ right: r + a,
264
+ bottom: i + o
265
+ };
266
+ }
267
+ function Xe(e, t) {
268
+ let { box: n, domain: r } = e, i = Je({
269
+ domain: r.x,
270
+ low: t.x0,
271
+ high: t.x1,
272
+ range: [n.left, n.right]
273
+ }), a = Je({
274
+ domain: r.y,
275
+ low: t.y0,
276
+ high: t.y1,
277
+ range: [n.bottom, n.top]
278
+ });
279
+ return {
280
+ x: i,
281
+ y: a,
282
+ rectOf: (e) => Ye({
283
+ values: e,
284
+ x: i,
285
+ y: a
286
+ })
287
+ };
288
+ }
289
+ function Ze(e) {
290
+ let t = {
291
+ view: void 0,
292
+ scales: Xe(e, {
293
+ x0: e.domain.x[0],
294
+ x1: e.domain.x[1],
295
+ y0: e.domain.y[0],
296
+ y1: e.domain.y[1]
297
+ })
298
+ };
299
+ return (n) => (t.view !== n && (t.view = n, t.scales = Xe(e, n)), t.scales);
300
+ }
301
+ function J() {
302
+ let e = H(Ge), t = ve(e.camera.subscribe, e.camera.get, e.camera.get);
303
+ return {
304
+ ...e,
305
+ ...e.scalesFor(t),
306
+ view: t
307
+ };
308
+ }
309
+ function Qe({ id: e, marks: t, emphasis: n }) {
310
+ return n === "context" ? "context" : t.inspected === e ? "normal" : t.lit === null ? n ?? "normal" : t.lit.has(e) ? "normal" : "receded";
311
+ }
312
+ function Y(e) {
313
+ let t = J(), n = H(qe), { registry: r } = t, { id: i, kind: a, frame: o, values: s, shape: c = "box", label: l, attaches: u = [], isShown: d = !0, isActive: f = !1 } = e, { emphasis: p, problem: m, pace: h = t.pace, isFloating: g = !1, margins: _, order: v = 0, delay: y = 0, stagger: b } = e, { room: x, surround: S } = e, [C] = W(() => ({})), w = {
314
+ ...s,
315
+ x: o?.x ?? 0,
316
+ y: o?.y ?? 0,
317
+ dx: o?.offset?.[0] ?? 0,
318
+ dy: o?.offset?.[1] ?? 0,
319
+ width: o?.width ?? 0,
320
+ height: o?.height ?? 0,
321
+ opacity: +!!d
322
+ }, [T] = W(() => k({
323
+ ...w,
324
+ opacity: r.isPainted() ? 0 : w.opacity
325
+ })), [E] = W(() => ({
326
+ key: JSON.stringify(T.get()),
327
+ stop: () => void 0
328
+ })), j = ve(T.subscribe, T.get, T.get), M = Qe({
329
+ id: i,
330
+ marks: n,
331
+ emphasis: p
332
+ }), { strength: N } = A({ strength: Ue[M] }, "fast"), P = {
333
+ id: i,
334
+ kind: a,
335
+ label: l,
336
+ shape: c,
337
+ frame: o,
338
+ isFloating: g,
339
+ margins: _,
340
+ order: v,
341
+ attaches: u,
342
+ room: x,
343
+ surround: S,
344
+ isShown: d,
345
+ isActive: f,
346
+ problem: m
347
+ };
348
+ return r.isDrafting() && r.draft({
349
+ ...P,
350
+ track: T
351
+ }), U(() => {
352
+ let e = JSON.stringify(w);
353
+ if (r.upsert(C, {
354
+ ...P,
355
+ track: T
356
+ }), h === "instant" || O()) {
357
+ E.stop(), E.key = e, T.to(w, h);
358
+ return;
359
+ }
360
+ if (E.key === e) return;
361
+ E.key = e, E.stop();
362
+ function t(e) {
363
+ let t = Ne(y) + e;
364
+ if (t <= 0) {
365
+ T.to(w, h);
366
+ return;
367
+ }
368
+ let n = { start: void 0 };
369
+ E.stop = D((e) => {
370
+ n.start ??= e, e - n.start >= t && (E.stop(), T.to(w, h));
371
+ });
372
+ }
373
+ b === void 0 ? t(0) : E.stop = Fe(r).join({
374
+ place: b,
375
+ begin: t
376
+ });
377
+ }), U(() => () => r.remove(C, i), [
378
+ r,
379
+ C,
380
+ i
381
+ ]), U(() => () => {
382
+ E.stop(), T.destroy();
383
+ }, [T, E]), {
384
+ values: j,
385
+ rect: o === void 0 ? void 0 : t.rectOf(j),
386
+ isVisible: d || j.opacity > 0,
387
+ isInspected: n.inspected === i,
388
+ isSelected: n.selected === i,
389
+ isCursor: n.isKeyboardFocused && n.cursor === i,
390
+ emphasis: M,
391
+ strength: N,
392
+ focusPlot: n.focusPlot,
393
+ scene: t
394
+ };
395
+ }
396
+ function $e(e, t) {
397
+ let n = _e([]);
398
+ function r() {
399
+ let e = t(), r = n.current;
400
+ return e.length === r.length && e.every((e, t) => e === r[t]) || (n.current = e), n.current;
401
+ }
402
+ return ve(e, r, r);
403
+ }
404
+ function et(e) {
405
+ let t = J(), { registry: n } = t, r = $e(n.subscribe, () => e.map((e) => n.member(e))), i = $e(ge(() => (e) => {
406
+ let t = r.flatMap((t) => t === void 0 ? [] : [t.track.subscribe(e)]);
407
+ return () => {
408
+ for (let e of t) e();
409
+ };
410
+ }, [r]), () => r.map((e) => e?.track.get()));
411
+ return r.map((e, n) => {
412
+ let r = i[n];
413
+ return e === void 0 || r === void 0 ? void 0 : {
414
+ member: e,
415
+ values: r,
416
+ rect: e.frame === void 0 ? void 0 : t.rectOf(r)
417
+ };
418
+ });
419
+ }
420
+ // packages/teaching/src/scene/scene-geometry.ts
421
+ var tt = {
422
+ small: {
423
+ width: 64,
424
+ height: 28
425
+ },
426
+ medium: {
427
+ width: 120,
428
+ height: 40
429
+ },
430
+ large: {
431
+ width: 184,
432
+ height: 64
433
+ }
434
+ }, nt = {
435
+ small: 32,
436
+ medium: 48,
437
+ large: 72
438
+ }, X = .5, rt = 8, it = 8, at = 64, ot = 4, st = 8, ct = 2, lt = 2400, ut = 2, dt = 16;
439
+ function ft(e, t) {
440
+ return typeof e == "string" ? t === "circle" ? {
441
+ width: nt[e],
442
+ height: nt[e]
443
+ } : tt[e] : e;
444
+ }
445
+ function Z(e) {
446
+ return {
447
+ x: (e.left + e.right) * X,
448
+ y: (e.top + e.bottom) * X
449
+ };
450
+ }
451
+ function pt(e) {
452
+ if (e.length !== 0) return {
453
+ left: Math.min(...e.map((e) => e.left)),
454
+ top: Math.min(...e.map((e) => e.top)),
455
+ right: Math.max(...e.map((e) => e.right)),
456
+ bottom: Math.max(...e.map((e) => e.bottom))
457
+ };
458
+ }
459
+ function mt(e, t) {
460
+ return {
461
+ left: e.left - t,
462
+ top: e.top - t,
463
+ right: e.right + t,
464
+ bottom: e.bottom + t
465
+ };
466
+ }
467
+ function ht(e, t) {
468
+ return !(e.right <= t.left || t.right <= e.left) && !(e.bottom <= t.top || t.bottom <= e.top);
469
+ }
470
+ function gt(e, t) {
471
+ let n = Math.min(e.right, t.right) - Math.max(e.left, t.left), r = Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top);
472
+ return Math.max(0, n) * Math.max(0, r);
473
+ }
474
+ function _t({ rect: e, from: t, to: n }) {
475
+ let r = n.x - t.x, i = n.y - t.y, a = [
476
+ {
477
+ step: -r,
478
+ room: t.x - e.left
479
+ },
480
+ {
481
+ step: r,
482
+ room: e.right - t.x
483
+ },
484
+ {
485
+ step: -i,
486
+ room: t.y - e.top
487
+ },
488
+ {
489
+ step: i,
490
+ room: e.bottom - t.y
491
+ }
492
+ ];
493
+ if (a.some((e) => e.step === 0 && e.room < 0)) return 0;
494
+ let o = Math.max(0, ...a.filter((e) => e.step < 0).map((e) => e.room / e.step)), s = Math.min(1, ...a.filter((e) => e.step > 0).map((e) => e.room / e.step));
495
+ return s > o ? (s - o) * Math.hypot(r, i) : 0;
496
+ }
497
+ function vt({ center: e, corner: t, step: n, radius: r }) {
498
+ let i = e.x - t.x, a = e.y - t.y, o = n.x * n.x + n.y * n.y, s = i * n.x + a * n.y, c = i * i + a * a - r * r, l = Math.max(0, s * s - o * c);
499
+ return (-s + Math.sqrt(l)) / o;
500
+ }
501
+ function yt({ rect: e, shape: t, toward: n }) {
502
+ let r = Z(e), i = (e.right - e.left) * X, a = (e.bottom - e.top) * X, o = {
503
+ x: n.x - r.x,
504
+ y: n.y - r.y
505
+ };
506
+ if (i <= 0 || a <= 0 || o.x === 0 && o.y === 0) return r;
507
+ if (t === "circle") {
508
+ let e = 1 / Math.hypot(o.x / i, o.y / a);
509
+ return {
510
+ x: r.x + o.x * e,
511
+ y: r.y + o.y * e
512
+ };
513
+ }
514
+ let s = o.x === 0 ? Infinity : i / Math.abs(o.x), c = o.y === 0 ? Infinity : a / Math.abs(o.y), l = Math.min(s, c), u = {
515
+ x: r.x + o.x * l,
516
+ y: r.y + o.y * l
517
+ }, d = t === "pill" ? Math.min(i, a) : 0, f = Math.abs(u.x - r.x) > i - d;
518
+ if (d === 0 || !f || Math.abs(u.y - r.y) <= a - d) return u;
519
+ let p = vt({
520
+ center: r,
521
+ corner: {
522
+ x: r.x + Math.sign(o.x) * (i - d),
523
+ y: r.y + Math.sign(o.y) * (a - d)
524
+ },
525
+ step: o,
526
+ radius: d
527
+ });
528
+ return {
529
+ x: r.x + o.x * p,
530
+ y: r.y + o.y * p
531
+ };
532
+ }
533
+ function bt({ rect: e, axis: t, sign: n }) {
534
+ let r = Z(e);
535
+ return t === "x" ? {
536
+ x: n > 0 ? e.right : e.left,
537
+ y: r.y
538
+ } : {
539
+ x: r.x,
540
+ y: n > 0 ? e.bottom : e.top
541
+ };
542
+ }
543
+ function xt({ start: e, span: t, domain: n }) {
544
+ return Math.min(n[1] - t, Math.max(n[0], e));
545
+ }
546
+ function St({ domain: e, width: t, height: n, frames: r, padding: i }) {
547
+ let a = {
548
+ x0: e.x[0],
549
+ x1: e.x[1],
550
+ y0: e.y[0],
551
+ y1: e.y[1]
552
+ };
553
+ if (r.length === 0) return a;
554
+ let o = e.x[1] - e.x[0], s = e.y[1] - e.y[0], c = Math.min(...r.map((e) => e.x)), l = Math.max(...r.map((e) => e.x)), u = Math.min(...r.map((e) => e.y)), d = Math.max(...r.map((e) => e.y)), f = t - Math.max(...r.map((e) => e.width)) - ct * i, p = n - Math.max(...r.map((e) => e.height)) - ct * i, m = l === c ? st : f / (l - c) * (o / t), h = d === u ? st : p / (d - u) * (s / n), g = Math.min(st, Math.max(1, Math.min(m, h))), _ = o / g, v = s / g, y = xt({
555
+ start: (c + l) * X - _ * X,
556
+ span: _,
557
+ domain: e.x
558
+ }), b = xt({
559
+ start: (u + d) * X - v * X,
560
+ span: v,
561
+ domain: e.y
562
+ });
563
+ return {
564
+ x0: y,
565
+ x1: y + _,
566
+ y0: b,
567
+ y1: b + v
568
+ };
569
+ }
570
+ function Ct(e) {
571
+ let [t, n] = e.offset ?? [0, 0], r = e.outset ?? {};
572
+ return {
573
+ top: e.height * X - n + (r.top ?? 0),
574
+ right: e.width * X + t + (r.right ?? 0),
575
+ bottom: e.height * X + n + (r.bottom ?? 0),
576
+ left: e.width * X - t + (r.left ?? 0)
577
+ };
578
+ }
579
+ function wt({ frames: e, domain: t, innerWidth: n, innerHeight: r }) {
580
+ let i = e.map((e) => {
581
+ let i = Ct(e), a = (e.x - t.x[0]) / (t.x[1] - t.x[0]), o = (e.y - t.y[0]) / (t.y[1] - t.y[0]);
582
+ return {
583
+ top: i.top - (1 - o) * r,
584
+ right: i.right - (1 - a) * n,
585
+ bottom: i.bottom - o * r,
586
+ left: i.left - a * n
587
+ };
588
+ });
589
+ return {
590
+ top: Math.max(0, ...i.map((e) => e.top)),
591
+ right: Math.max(0, ...i.map((e) => e.right)),
592
+ bottom: Math.max(0, ...i.map((e) => e.bottom)),
593
+ left: Math.max(0, ...i.map((e) => e.left))
594
+ };
595
+ }
596
+ function Tt(e, t) {
597
+ function n(n) {
598
+ return Math.max(Math.ceil(e[n]) + rt, ...t.map((e) => e[n] ?? 0));
599
+ }
600
+ return {
601
+ top: n("top"),
602
+ right: n("right"),
603
+ bottom: n("bottom"),
604
+ left: n("left")
605
+ };
606
+ }
607
+ function Et({ frames: e, reserved: t, domain: n, width: r, height: i }) {
608
+ let a = {
609
+ margins: {
610
+ top: 0,
611
+ right: 0,
612
+ bottom: 0,
613
+ left: 0
614
+ },
615
+ rounds: 0,
616
+ isSettled: !1
617
+ };
618
+ for (; !a.isSettled && a.rounds < ot;) {
619
+ let { margins: o } = a, s = Tt(wt({
620
+ frames: e,
621
+ domain: n,
622
+ innerWidth: r - o.left - o.right,
623
+ innerHeight: i - o.top - o.bottom
624
+ }), t);
625
+ a.isSettled = s.top === o.top && s.bottom === o.bottom && s.left === o.left && s.right === o.right, a.margins = s, a.rounds += 1;
626
+ }
627
+ return a.margins;
628
+ }
629
+ function Dt(e, t, n) {
630
+ let [r, i] = e.x <= t.x ? [e, t] : [t, e], a = i.x - r.x;
631
+ return a === 0 ? 0 : Math.max(0, (Ct(r).right + Ct(i).left + n) / a);
632
+ }
633
+ function Ot({ first: e, second: t, perUnitY: n }) {
634
+ let r = Ct(e), i = Ct(t), a = -e.y * n, o = -t.y * n;
635
+ return a - r.top < o + i.bottom + it && o - i.top < a + r.bottom + it;
636
+ }
637
+ function kt({ frames: e, edged: t, links: n, domain: r, innerHeight: i, reserved: a }) {
638
+ let o = i / (r.y[1] - r.y[0]), s = e.map((t, n) => Math.max(0, ...e.slice(n + 1).map((e) => Ot({
639
+ first: t,
640
+ second: e,
641
+ perUnitY: o
642
+ }) ? Dt(t, e, it) : 0))), c = n.map((e) => Dt(e.from, e.to, Math.max(at, e.room ?? 0))), l = Math.max(0, ...s, ...c);
643
+ if (l === 0) return 0;
644
+ let u = l * (r.x[1] - r.x[0]), d = Tt(wt({
645
+ frames: t,
646
+ domain: r,
647
+ innerWidth: u,
648
+ innerHeight: i
649
+ }), a);
650
+ return Math.min(lt, Math.ceil(u + d.left + d.right));
651
+ }
652
+ function At(e) {
653
+ let t = e.map((e) => Z(e.rect)), n = Map.groupBy(e.map((e, t) => ({
654
+ item: e,
655
+ index: t
656
+ })), ({ index: e }) => t.findIndex((n, r) => {
657
+ let i = t[e] ?? n, a = Math.abs(n.x - i.x) <= dt && Math.abs(n.y - i.y) <= dt;
658
+ return r <= e && a;
659
+ }));
660
+ return new Map(Array.from(n, ([e, n]) => {
661
+ let r = n.toSorted((e, t) => e.item.order - t.item.order), i = (r.length - 1) * X, a = t[e] ?? {
662
+ x: 0,
663
+ y: 0
664
+ };
665
+ return r.map(({ item: e, index: r }, o) => {
666
+ let s = t[r] ?? a, c = n.length === 1 ? 0 : a.x + (o - i) * ut - s.x, l = n.length === 1 ? 0 : a.y - s.y, { rect: u } = e;
667
+ return [e.id, {
668
+ left: u.left + c,
669
+ right: u.right + c,
670
+ top: u.top + l,
671
+ bottom: u.bottom + l
672
+ }];
673
+ });
674
+ }).flat());
675
+ }
676
+ // packages/teaching/src/scene/scene.tsx
677
+ var jt = 24, Mt = 32, Nt = {
678
+ kVAEAm: "x1n2onr6",
679
+ kVQacm: "xb3r6kr",
680
+ $$css: !0
681
+ }, Pt = { stage: (e, t) => [
682
+ Nt,
683
+ {
684
+ kzqmXN: e == null ? e : "x5lhr3w",
685
+ kZKoxP: t == null ? t : "x16ye13r",
686
+ $$css: !0
687
+ },
688
+ {
689
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
690
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
691
+ }
692
+ ] };
693
+ function Ft(e) {
694
+ return e === null ? [] : typeof e == "string" ? [e] : e;
695
+ }
696
+ function It(e) {
697
+ return e !== void 0 && e.isShown && !e.isFloating ? e.frame : void 0;
698
+ }
699
+ function Lt(e, t) {
700
+ let n = e.member(t);
701
+ return n === void 0 ? [] : n.frame === void 0 ? n.attaches.flatMap((t) => {
702
+ let n = e.member(t)?.frame;
703
+ return n === void 0 ? [] : [n];
704
+ }) : [n.frame];
705
+ }
706
+ function Rt(e, t) {
707
+ let n = /* @__PURE__ */ new Set([...e.flatMap((e) => e.isActive && e.isShown ? [e.id] : []), ...t === null ? [] : [t]]);
708
+ if (n.size === 0) return null;
709
+ let r = e.filter((e) => e.attaches.some((e) => n.has(e))), i = e.flatMap((e) => n.has(e.id) ? e.attaches : []), a = r.flatMap((e) => e.kind === "wire" ? e.attaches : []);
710
+ return /* @__PURE__ */ new Set([
711
+ ...n,
712
+ ...r.map((e) => e.id),
713
+ ...i,
714
+ ...a
715
+ ]);
716
+ }
717
+ function zt({ cursor: e, isActive: t, scrollerRef: n, place: r }) {
718
+ return me(() => {
719
+ let i = n.current, a = e === null ? void 0 : r(e);
720
+ if (!t || i === null || a === void 0) return;
721
+ let o = Math.min(a.left - Mt, Math.max(i.scrollLeft, a.right + Mt - i.clientWidth));
722
+ i.scrollTo({ left: o });
723
+ }), null;
724
+ }
725
+ function Bt(i) {
726
+ let { x: a, y: s, height: l = "regular", aspect: u, focus: v = null, pace: b = "regular", minWidth: x, weightMax: S = 1 } = i, { labels: w, children: T, selected: E, onSelectedChange: O, ...A } = i, { emptyLabel: j = "This scene has nothing to draw.", locale: M, ...N } = A, P = C(), F = {
727
+ ...Ie,
728
+ ...w
729
+ }, I = _(l), L = he(), R = y(), ee = e(), [z] = W(Ae), [B] = W(() => k({
730
+ x0: a[0],
731
+ x1: a[1],
732
+ y0: s[0],
733
+ y1: s[1]
734
+ })), te = ve(z.subscribe, z.members, z.members), [ne, re] = W(null), [ie, ae] = W(null), [oe, se] = W(null), [ce, le] = W(!1), [ue] = W(() => ({ places: null })), fe = _e(null), pe = _e(null), H = {
735
+ x: a,
736
+ y: s
737
+ }, ge = Ft(v), ye = te.list.flatMap((e) => {
738
+ let t = It(e);
739
+ return t === void 0 ? [] : [t];
740
+ }), be = te.list.flatMap((e) => {
741
+ let { surround: t } = e;
742
+ return t === void 0 || !e.isShown ? [] : e.attaches.flatMap((e) => {
743
+ let n = It(z.member(e));
744
+ return n === void 0 ? [] : [{
745
+ ...n,
746
+ outset: t
747
+ }];
748
+ });
749
+ }), xe = [...ye, ...be], Se = te.list.flatMap((e) => e.isShown && e.margins !== void 0 ? [e.margins] : []), Ce = u === void 0 ? I.height : Math.round(I.width / u), we = Et({
750
+ frames: xe,
751
+ reserved: Se,
752
+ domain: H,
753
+ width: I.width,
754
+ height: Ce
755
+ }), Te = Ce - we.top - we.bottom, Ee = kt({
756
+ frames: ye,
757
+ edged: xe,
758
+ links: te.list.flatMap((e) => {
759
+ let [t, n] = e.kind === "wire" && e.isShown ? e.attaches : [], r = t === void 0 ? void 0 : It(z.member(t)), i = n === void 0 ? void 0 : It(z.member(n));
760
+ return r === void 0 || i === void 0 ? [] : [{
761
+ from: r,
762
+ to: i,
763
+ room: e.room
764
+ }];
765
+ }),
766
+ domain: H,
767
+ innerHeight: Te,
768
+ reserved: Se
769
+ }), De = Math.max(I.width, x ?? Ee), Oe = De === I.width ? we : Et({
770
+ frames: xe,
771
+ reserved: Se,
772
+ domain: H,
773
+ width: De,
774
+ height: Ce
775
+ }), ke = c({
776
+ width: De,
777
+ height: Ce,
778
+ margins: Oe
779
+ }), je = M ?? P, Me = St({
780
+ domain: H,
781
+ width: ke.innerWidth,
782
+ height: ke.innerHeight,
783
+ frames: ge.flatMap((e) => Lt(z, e)),
784
+ padding: jt
785
+ }), Ne = {
786
+ isInScene: !0,
787
+ registry: z,
788
+ camera: B,
789
+ box: ke,
790
+ domain: H,
791
+ pace: b,
792
+ locale: je ?? "",
793
+ tone: R,
794
+ weightMax: S,
795
+ layers: {
796
+ back: ne,
797
+ wires: ie,
798
+ front: oe
799
+ },
800
+ labels: F,
801
+ scalesFor: Ze({
802
+ box: ke,
803
+ domain: H
804
+ })
805
+ };
806
+ if (U(() => {
807
+ z.isPainted() ? B.to(Me, b) : B.jump(Me);
808
+ }), U(() => z.endDrafts(), [z]), me(() => {
809
+ let e = { stop: () => void 0 };
810
+ return e.stop = D(() => {
811
+ z.markPainted(), e.stop();
812
+ }), () => e.stop();
813
+ }, [z]), me(() => () => B.destroy(), [B]), je === null) return /* @__PURE__ */ G("span", {
814
+ className: "xr5kp14 x1hz01jw x1b5ytql",
815
+ children: F.missingLocale
816
+ });
817
+ let Pe = {
818
+ ...N,
819
+ locale: je
820
+ };
821
+ if (Pe.status === "loading") return /* @__PURE__ */ G(f, {
822
+ ...Pe,
823
+ height: l
824
+ });
825
+ let Fe = Re({
826
+ box: H,
827
+ aspect: u,
828
+ labels: F
829
+ });
830
+ if (Fe !== void 0) return /* @__PURE__ */ G(h, {
831
+ ...Pe,
832
+ message: Fe
833
+ });
834
+ if (de.toArray(T).length === 0) return /* @__PURE__ */ G(m, {
835
+ ...Pe,
836
+ children: /* @__PURE__ */ G(g, { children: j })
837
+ });
838
+ let Le = Ve({
839
+ members: te,
840
+ focus: ge,
841
+ box: H,
842
+ labels: F
843
+ }), q = Le === void 0 ? te.list.flatMap((e) => e.label !== void 0 && e.isShown ? [{
844
+ id: e.id,
845
+ label: e.label
846
+ }] : []) : [];
847
+ function ze(e) {
848
+ let t = z.member(e), n = Ne.scalesFor(B.get());
849
+ if (t !== void 0) return t.frame === void 0 ? pt(t.attaches.flatMap((e) => {
850
+ let t = z.member(e);
851
+ return t?.frame === void 0 ? [] : [Ye({
852
+ values: t.track.get(),
853
+ ...n
854
+ })];
855
+ })) : Ye({
856
+ values: t.track.get(),
857
+ ...n
858
+ });
859
+ }
860
+ function Be(e) {
861
+ return ue.places === null && (ue.places = At(q.flatMap((e) => {
862
+ let t = ze(e.id);
863
+ return t === void 0 ? [] : [{
864
+ id: e.id,
865
+ rect: t,
866
+ order: z.member(e.id)?.order ?? 0
867
+ }];
868
+ })), queueMicrotask(() => {
869
+ ue.places = null;
870
+ })), ue.places.get(e) ?? ze(e);
871
+ }
872
+ return /* @__PURE__ */ G(d, {
873
+ ...ee,
874
+ items: q,
875
+ place: Be,
876
+ selected: E ?? null,
877
+ onSelect: O,
878
+ render: (e, i) => /* @__PURE__ */ K(m, {
879
+ ...Pe,
880
+ figure: e,
881
+ footer: /* @__PURE__ */ G(r, {
882
+ id: L,
883
+ children: n(q, i.inspected)
884
+ }),
885
+ children: [
886
+ /* @__PURE__ */ K("div", {
887
+ ref: I.ref,
888
+ className: "xeuugli x41o525",
889
+ children: [Le !== void 0 && /* @__PURE__ */ G("p", {
890
+ role: "alert",
891
+ className: "x1ghz6dp x1qokhjc x1doqdfy x1ok0vyi xcqwzn xr5kp14 x1hz01jw xtqrqnz x1778rvt xj0a0fe",
892
+ children: Le
893
+ }), /* @__PURE__ */ G("div", {
894
+ ref: pe,
895
+ hidden: Le !== void 0,
896
+ className: "xw2csxc x10wlt62 xeuugli",
897
+ children: /* @__PURE__ */ K("div", {
898
+ ...V.props(Pt.stage(De, Ce)),
899
+ children: [/* @__PURE__ */ G(t, {
900
+ ref: fe,
901
+ role: "group",
902
+ "aria-label": o({
903
+ title: Pe.title,
904
+ marks: F.objects,
905
+ isSelectable: O !== void 0
906
+ }),
907
+ "aria-describedby": L,
908
+ onFocus: (e) => le(e.currentTarget.matches(":focus-visible")),
909
+ onBlur: () => le(!1),
910
+ className: "x10l6tqk x10a8y8t x1t137rt x13qnu6 x19rmrnh x9v5kkp x1bqaal x-default-marker",
911
+ children: /* @__PURE__ */ K("svg", {
912
+ "aria-hidden": !0,
913
+ width: De,
914
+ height: Ce,
915
+ viewBox: `0 0 ${De} ${Ce}`,
916
+ className: "x1lliihq xb3r6kr",
917
+ children: [
918
+ /* @__PURE__ */ G("g", { ref: re }),
919
+ /* @__PURE__ */ G("g", { ref: ae }),
920
+ /* @__PURE__ */ G("g", { ref: se })
921
+ ]
922
+ })
923
+ }), /* @__PURE__ */ G("div", {
924
+ className: "x10l6tqk x10a8y8t x47corl xc8icb0",
925
+ children: /* @__PURE__ */ G(Ge, {
926
+ value: Ne,
927
+ children: /* @__PURE__ */ G(qe, {
928
+ value: {
929
+ inspected: i.inspected,
930
+ selected: i.selected,
931
+ cursor: i.cursor,
932
+ lit: Rt(te.list, i.inspected),
933
+ isKeyboardFocused: ce,
934
+ focusPlot: () => fe.current?.focus({ preventScroll: !0 })
935
+ },
936
+ children: T
937
+ })
938
+ })
939
+ })]
940
+ })
941
+ })]
942
+ }),
943
+ /* @__PURE__ */ G(zt, {
944
+ cursor: i.cursor,
945
+ isActive: ce,
946
+ scrollerRef: pe,
947
+ place: Be
948
+ }),
949
+ /* @__PURE__ */ G(p, {
950
+ label: `${Pe.title} ${F.objects}`,
951
+ columns: [{
952
+ id: "part",
953
+ label: F.objectColumn
954
+ }],
955
+ rows: q.map((e) => ({
956
+ id: e.id,
957
+ values: [e.label]
958
+ }))
959
+ })
960
+ ]
961
+ })
962
+ });
963
+ }
964
+ // packages/teaching/src/scene/scene-layer.tsx
965
+ var Vt = { inline: {
966
+ kVAEAm: "x10l6tqk",
967
+ kbCHJM: "xu96u03",
968
+ k87sOh: "x13vifvy",
969
+ k1xSpc: "x1lliihq",
970
+ kVQacm: "xb3r6kr",
971
+ kfzvcC: "x47corl",
972
+ $$css: !0
973
+ } }, Ht = {
974
+ back: {
975
+ kY2c9j: "x1rs5lyz",
976
+ $$css: !0
977
+ },
978
+ wires: {
979
+ kY2c9j: "x1adujtu",
980
+ $$css: !0
981
+ },
982
+ front: {
983
+ kY2c9j: "x15pxy5g",
984
+ $$css: !0
985
+ }
986
+ };
987
+ function Ut({ layer: e = "front", children: t }) {
988
+ let { layers: n, box: r, isInScene: i } = H(Ge), a = n[e];
989
+ return i ? a === null ? /* @__PURE__ */ G("svg", {
990
+ "aria-hidden": !0,
991
+ width: r.width,
992
+ height: r.height,
993
+ viewBox: `0 0 ${r.width} ${r.height}`,
994
+ ...V.props(Vt.inline, Ht[e]),
995
+ children: t
996
+ }) : we(t, a) : null;
997
+ }
998
+ function Q({ part: e }) {
999
+ let { labels: t } = H(Ge);
1000
+ return /* @__PURE__ */ G("span", {
1001
+ className: "xr5kp14 x1hz01jw x1b5ytql",
1002
+ children: q(t.outside, { part: e })
1003
+ });
1004
+ }
1005
+ // packages/teaching/src/scene/scene-style.ts
1006
+ var Wt = `color-mix(in srgb, ${P.faint} 70%, ${P.muted})`, Gt = {
1007
+ inspected: {
1008
+ kMeerF: "x1qgsegg",
1009
+ k3XXqK: "xaatb59",
1010
+ kjBf7l: "xj5pgkc",
1011
+ kInvED: "x1y3gkto",
1012
+ $$css: !0
1013
+ },
1014
+ selected: {
1015
+ kMeerF: "x1de99jn",
1016
+ k3XXqK: "xaatb59",
1017
+ kjBf7l: "xj5pgkc",
1018
+ kInvED: "x1y3gkto",
1019
+ $$css: !0
1020
+ },
1021
+ cursor: {
1022
+ kMeerF: "x12ei19c",
1023
+ k3XXqK: "x107h2d7",
1024
+ kjBf7l: "xj5pgkc x1x84bn5",
1025
+ kInvED: "x1ewu8gn",
1026
+ $$css: !0
1027
+ }
1028
+ };
1029
+ function Kt({ isInspected: e, isSelected: t, isCursor: n }) {
1030
+ return [
1031
+ e && Gt.inspected,
1032
+ t && Gt.selected,
1033
+ n && Gt.cursor
1034
+ ];
1035
+ }
1036
+ // packages/teaching/src/scene/scene-node.tsx
1037
+ var qt = 180, Jt = 48, Yt = .08, Xt = 1e3, Zt = {
1038
+ rest: 2,
1039
+ lifted: 14
1040
+ }, Qt = {
1041
+ rest: 4,
1042
+ lifted: 22
1043
+ }, $t = 22, en = {
1044
+ kVAEAm: "x10l6tqk",
1045
+ kbCHJM: "xu96u03",
1046
+ k87sOh: "x13vifvy",
1047
+ kfzvcC: "x67bb7w",
1048
+ $$css: !0
1049
+ }, tn = {
1050
+ kVAEAm: "x10l6tqk",
1051
+ kpwlN0: "x10a8y8t",
1052
+ k1xSpc: "x1lliihq",
1053
+ kmaZ5I: "x1oyok0e",
1054
+ k3XXqK: "x1t137rt",
1055
+ $$css: !0
1056
+ }, nn = {
1057
+ kVAEAm: "x10l6tqk",
1058
+ kpwlN0: "x10a8y8t",
1059
+ kfzvcC: "x47corl",
1060
+ $$css: !0
1061
+ }, rn = {
1062
+ kVAEAm: "x10l6tqk",
1063
+ kpwlN0: "x10a8y8t",
1064
+ kB7OPa: "x9f619",
1065
+ k1xSpc: "x78zum5",
1066
+ kXwgrk: "xdt5ytf",
1067
+ kGNEyG: "x6s0dn4",
1068
+ kjj79g: "xl56j7k",
1069
+ kOIVth: "xfko13i",
1070
+ k8WAf4: "x10dazmo",
1071
+ kg3NbH: "x14w6jbu",
1072
+ kVQacm: "xb3r6kr",
1073
+ kMzoRj: "xvndefy",
1074
+ ksu8eU: "x1y0btm7",
1075
+ kWkggS: "xl8spv7",
1076
+ kMwMTN: "xbixft",
1077
+ kgyCeQ: "xlp1x4z",
1078
+ $$css: !0
1079
+ }, an = {
1080
+ node: (e, t, n) => [
1081
+ en,
1082
+ {
1083
+ kzqmXN: t == null ? t : "x5lhr3w",
1084
+ kZKoxP: n == null ? n : "x16ye13r",
1085
+ k3aq6I: e == null ? e : "xsqj5wx",
1086
+ $$css: !0
1087
+ },
1088
+ {
1089
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
1090
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n),
1091
+ "--x-transform": e ?? void 0
1092
+ }
1093
+ ],
1094
+ order: (e) => [{
1095
+ kY2c9j: e == null ? e : "xr3buco",
1096
+ $$css: !0
1097
+ }, { "--x-zIndex": e ?? void 0 }],
1098
+ fade: (e) => [{
1099
+ kSiTet: e == null ? e : "xb4nw82",
1100
+ $$css: !0
1101
+ }, { "--x-opacity": e ?? void 0 }],
1102
+ deep: {
1103
+ kwFjlL: "xdr3gxo",
1104
+ $$css: !0
1105
+ },
1106
+ gone: {
1107
+ k33iCy: "xlshs6z",
1108
+ kfzvcC: "x47corl",
1109
+ $$css: !0
1110
+ },
1111
+ card: (e) => [
1112
+ tn,
1113
+ {
1114
+ k3aq6I: e == null ? e : "xsqj5wx",
1115
+ $$css: !0
1116
+ },
1117
+ { "--x-transform": e ?? void 0 }
1118
+ ],
1119
+ shadow: (e, t) => [
1120
+ nn,
1121
+ {
1122
+ kGVxlE: e == null ? e : "x1iotiob",
1123
+ k3aq6I: t == null ? t : "xsqj5wx",
1124
+ $$css: !0
1125
+ },
1126
+ {
1127
+ "--x-boxShadow": e ?? void 0,
1128
+ "--x-transform": t ?? void 0
1129
+ }
1130
+ ],
1131
+ face: (e) => [
1132
+ rn,
1133
+ {
1134
+ kVAM5u: e == null ? e : "x6w5c0t",
1135
+ $$css: !0
1136
+ },
1137
+ {
1138
+ "--x-borderColor": e ?? void 0,
1139
+ "--x-backgroundColor": `color-mix(in srgb, ${e} 10%, ${P.surface})` == null ? void 0 : `color-mix(in srgb, ${e} 10%, ${P.surface})`
1140
+ }
1141
+ ],
1142
+ rich: {
1143
+ kjj79g: "x1nhvcw1",
1144
+ $$css: !0
1145
+ },
1146
+ backFace: {
1147
+ k3aq6I: "x1msufx5",
1148
+ $$css: !0
1149
+ }
1150
+ }, on = {
1151
+ box: {
1152
+ kaIpWk: "xy32g2j",
1153
+ $$css: !0
1154
+ },
1155
+ pill: {
1156
+ kaIpWk: "x1e6avla",
1157
+ $$css: !0
1158
+ },
1159
+ circle: {
1160
+ kaIpWk: "x16rqkct",
1161
+ $$css: !0
1162
+ },
1163
+ plain: {
1164
+ kVAM5u: "x9r1u3d",
1165
+ kWkggS: "xjbqb8w",
1166
+ $$css: !0
1167
+ }
1168
+ }, sn = {
1169
+ box: {
1170
+ kaIpWk: "xy32g2j",
1171
+ $$css: !0
1172
+ },
1173
+ pill: {
1174
+ kaIpWk: "x1e6avla",
1175
+ $$css: !0
1176
+ },
1177
+ circle: {
1178
+ kaIpWk: "x16rqkct",
1179
+ $$css: !0
1180
+ },
1181
+ plain: {
1182
+ kaIpWk: "xy32g2j",
1183
+ $$css: !0
1184
+ }
1185
+ };
1186
+ function cn({ id: e, at: t, offset: n, label: r, text: i, isCode: a = !1, size: o = "medium", shape: s = "box", tone: c, emphasis: l, isShown: u = !0, isActive: d = !1, turn: f = 0, lift: p = 0, tilt: m = 0, rotate: h = 0, order: g = 0, delay: _, stagger: v, pace: y, isFloating: x, back: S, backTone: C, children: w }) {
1187
+ let T = b(e), E = ft(o, s), D = Y({
1188
+ id: e,
1189
+ kind: "node",
1190
+ frame: {
1191
+ x: t[0],
1192
+ y: t[1],
1193
+ width: E.width,
1194
+ height: E.height,
1195
+ offset: n
1196
+ },
1197
+ values: {
1198
+ turn: f,
1199
+ lift: p,
1200
+ tilt: m,
1201
+ rotate: h
1202
+ },
1203
+ shape: s,
1204
+ label: r,
1205
+ isShown: u,
1206
+ isActive: d,
1207
+ emphasis: l,
1208
+ order: g,
1209
+ delay: _,
1210
+ stagger: v,
1211
+ pace: y,
1212
+ isFloating: x
1213
+ });
1214
+ if (!D.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneNode" });
1215
+ let { values: O, rect: k = {
1216
+ left: 0,
1217
+ top: 0,
1218
+ right: 0,
1219
+ bottom: 0
1220
+ } } = D, A = c ?? T ?? "neutral", j = D.emphasis === "context", M = j ? Wt : N[A], F = j ? Wt : N[C ?? A], I = Math.max(0, O.lift), L = [
1221
+ `0 ${Zt.rest + I * Zt.lifted}px`,
1222
+ `${Qt.rest + I * Qt.lifted}px`,
1223
+ `color-mix(in srgb, ${P.ink} ${Math.round(I * $t)}%, transparent)`
1224
+ ].join(" "), R = I === 0 && O.tilt === 0 && O.turn === 0, ee = `translate(${k.left}px, ${k.top}px)`, z = g + (p > 0 ? Xt : 0), B = R ? "none" : [
1225
+ `translateZ(${I * Jt}px)`,
1226
+ `rotateX(${O.tilt}deg)`,
1227
+ `rotateY(${O.turn * qt}deg)`,
1228
+ `scale(${1 + I * Yt})`
1229
+ ].join(" ");
1230
+ return /* @__PURE__ */ K("div", {
1231
+ "aria-hidden": !u || void 0,
1232
+ inert: !u,
1233
+ "data-scene-node": e,
1234
+ ...V.props(an.node(O.rotate === 0 ? ee : `${ee} rotate(${O.rotate}deg)`, O.width, O.height), an.order(z), an.fade(Math.max(0, Math.min(1, O.opacity)) * D.strength), !R && an.deep, !D.isVisible && an.gone),
1235
+ children: [I > 0 && /* @__PURE__ */ G("div", { ...V.props(an.shadow(L, `scale(${1 + I * Yt})`), sn[s]) }), /* @__PURE__ */ G(un, {
1236
+ id: e,
1237
+ transform: B,
1238
+ color: M,
1239
+ backColor: F,
1240
+ shape: s,
1241
+ isInspected: D.isInspected,
1242
+ isSelected: D.isSelected,
1243
+ isCursor: D.isCursor,
1244
+ text: i,
1245
+ isCode: a,
1246
+ hasBack: S !== void 0 || !R,
1247
+ back: S,
1248
+ focusPlot: D.focusPlot,
1249
+ children: w
1250
+ })]
1251
+ });
1252
+ }
1253
+ function ln({ id: e, transform: t, color: n, backColor: r, shape: a, isInspected: o, isSelected: s, isCursor: c, text: l, isCode: u, hasBack: d, back: f, focusPlot: p, children: m }) {
1254
+ let h = m != null;
1255
+ function g(e) {
1256
+ h || (e.preventDefault(), p());
1257
+ }
1258
+ return /* @__PURE__ */ K(i, {
1259
+ value: e,
1260
+ render: /* @__PURE__ */ G("div", {}),
1261
+ onMouseDown: g,
1262
+ ...V.props(an.card(t), ...Kt({
1263
+ isInspected: o,
1264
+ isSelected: s,
1265
+ isCursor: c
1266
+ }), sn[a]),
1267
+ children: [/* @__PURE__ */ K("div", {
1268
+ ...V.props(an.face(n), on[a], h && an.rich),
1269
+ children: [l !== void 0 && /* @__PURE__ */ G("span", {
1270
+ "aria-hidden": !0,
1271
+ ...{
1272
+ 0: { className: "x104kibb x2lah0s x193iq5w xb3r6kr x2b8uid x1ua5tub x1h7i4cw xj0a0fe x1hz01jw xtqrqnz xas2l8k xk4h15q xss6m8b" },
1273
+ 1: { className: "x104kibb x2lah0s x193iq5w xb3r6kr x2b8uid x1ua5tub x1h7i4cw xj0a0fe xtqrqnz xas2l8k xss6m8b xiard35 xj57cvi" }
1274
+ }[!!u | 0],
1275
+ children: l
1276
+ }), h && /* @__PURE__ */ G("div", {
1277
+ className: "xkh2ocl x1iyjqo2 xeuugli x2lwn1j xb3r6kr",
1278
+ children: m
1279
+ })]
1280
+ }), d && /* @__PURE__ */ G("div", {
1281
+ ...V.props(an.face(r), on[a], an.backFace),
1282
+ children: f
1283
+ })]
1284
+ });
1285
+ }
1286
+ var un = pe(ln), dn = 1.25, fn = 7, pn = 3.5, mn = 7, hn = .4, gn = .5, _n = 2, vn = .38, yn = 11, bn = 3, xn = {
1287
+ top: {
1288
+ x: 0,
1289
+ y: -1
1290
+ },
1291
+ right: {
1292
+ x: 1,
1293
+ y: 0
1294
+ },
1295
+ bottom: {
1296
+ x: 0,
1297
+ y: 1
1298
+ },
1299
+ left: {
1300
+ x: -1,
1301
+ y: 0
1302
+ }
1303
+ }, Sn = {
1304
+ kjVXCG: "xeutv01",
1305
+ kfzvcC: "x47corl",
1306
+ $$css: !0
1307
+ }, Cn = {
1308
+ fade: (e) => [{
1309
+ kSiTet: e == null ? e : "xb4nw82",
1310
+ $$css: !0
1311
+ }, { "--x-opacity": e ?? void 0 }],
1312
+ arrow: (e, t) => [
1313
+ Sn,
1314
+ {
1315
+ kDwRjp: e == null ? e : "x19zyb68",
1316
+ kSiTet: t == null ? t : "xb4nw82",
1317
+ $$css: !0
1318
+ },
1319
+ {
1320
+ "--x-fill": e ?? void 0,
1321
+ "--x-opacity": t ?? void 0
1322
+ }
1323
+ ],
1324
+ cursor: {
1325
+ kDwRjp: "xbh8q5q",
1326
+ kfzvcC: "x47corl",
1327
+ $$css: !0
1328
+ }
1329
+ };
1330
+ function wn(e, t) {
1331
+ let n = Math.hypot(t.x - e.x, t.y - e.y);
1332
+ return n === 0 ? {
1333
+ x: 1,
1334
+ y: 0
1335
+ } : {
1336
+ x: (t.x - e.x) / n,
1337
+ y: (t.y - e.y) / n
1338
+ };
1339
+ }
1340
+ function Tn(e, t) {
1341
+ let n = {
1342
+ x: -e.y,
1343
+ y: e.x
1344
+ }, r = Math.abs(e.x) >= Math.abs(e.y) ? xn.top : xn.right, i = t === "auto" ? r : xn[t], a = n.x * i.x + n.y * i.y;
1345
+ return (Math.abs(a) < vn ? n.x * r.x + n.y * r.y : a) < 0 ? {
1346
+ x: -n.x,
1347
+ y: -n.y
1348
+ } : n;
1349
+ }
1350
+ function En(e, t) {
1351
+ let n = t.x > vn ? "start" : "middle", r = t.x < -.38 ? "end" : n, i = e.y + 8 * gn, a = t.y > vn ? e.y + yn : i;
1352
+ return {
1353
+ x: e.x,
1354
+ y: t.y < -.38 ? e.y - bn : a,
1355
+ anchor: r
1356
+ };
1357
+ }
1358
+ function Dn(e) {
1359
+ let t = L({
1360
+ x: 0,
1361
+ y: 0,
1362
+ anchor: "start",
1363
+ text: e
1364
+ });
1365
+ return Math.ceil((t.right - t.left) / (_n * Math.min(hn, .6)) + fn);
1366
+ }
1367
+ function On(e) {
1368
+ return e === void 0 || e === 0 ? "neutral" : e > 0 ? "positive" : "negative";
1369
+ }
1370
+ function kn({ from: e, to: t, id: n = `${e}>${t}`, label: r, text: a, textSide: o = "auto", weight: s, tone: c, shape: l = "straight", isDashed: u = !1, hasArrow: d = !0, isShown: f = !0, isActive: p = !1, emphasis: m }) {
1371
+ let h = et([e, t]), g = h[0], _ = h[1], v = J(), y = s !== void 0 && Math.abs(s) > v.weightMax ? q(v.labels.weightOutside, {
1372
+ id: n,
1373
+ weight: F({
1374
+ value: s,
1375
+ locale: v.locale,
1376
+ format: { maximumFractionDigits: 3 }
1377
+ }),
1378
+ limit: String(v.weightMax)
1379
+ }) : void 0, b = Y({
1380
+ id: n,
1381
+ kind: "wire",
1382
+ values: { weight: s ?? 0 },
1383
+ label: r,
1384
+ attaches: [e, t],
1385
+ room: a === void 0 ? void 0 : Dn(a),
1386
+ isShown: f,
1387
+ isActive: p,
1388
+ emphasis: m,
1389
+ problem: y
1390
+ });
1391
+ if (!v.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneWire" });
1392
+ if (g === void 0 || _ === void 0) return null;
1393
+ let x = g.rect, S = _.rect;
1394
+ if (x === void 0 || S === void 0) return null;
1395
+ let C = b.values.opacity * Math.min(g.values.opacity, _.values.opacity);
1396
+ if (C <= 0) return null;
1397
+ let w = Z(x), T = Z(S), E = Math.abs(T.x - w.x) >= Math.abs(T.y - w.y) ? "x" : "y", D = (E === "x" ? T.x - w.x : T.y - w.y) < 0 ? -1 : 1, O = l === "straight", k = O ? yt({
1398
+ rect: x,
1399
+ shape: g.member.shape,
1400
+ toward: T
1401
+ }) : bt({
1402
+ rect: x,
1403
+ axis: E,
1404
+ sign: D
1405
+ }), A = O ? yt({
1406
+ rect: S,
1407
+ shape: _.member.shape,
1408
+ toward: w
1409
+ }) : bt({
1410
+ rect: S,
1411
+ axis: E,
1412
+ sign: -D
1413
+ }), j = O ? wn(k, A) : E === "x" ? {
1414
+ x: D,
1415
+ y: 0
1416
+ } : {
1417
+ x: 0,
1418
+ y: D
1419
+ }, M = d ? {
1420
+ x: A.x - j.x * fn,
1421
+ y: A.y - j.y * fn
1422
+ } : A, P = O ? ae([k, M]) : ie({
1423
+ x1: k.x,
1424
+ y1: k.y,
1425
+ x2: M.x,
1426
+ y2: M.y,
1427
+ axis: E,
1428
+ shape: l
1429
+ }), L = c ?? On(s), R = b.emphasis === "context" ? Wt : N[L], ee = Math.min(1, Math.abs(b.values.weight) / v.weightMax), B = s === void 0 ? dn : dn + ee * 4.75, te = O ? hn : gn, ne = {
1430
+ x: k.x + (M.x - k.x) * te,
1431
+ y: k.y + (M.y - k.y) * te
1432
+ }, oe = {
1433
+ x: -j.y,
1434
+ y: j.x
1435
+ }, se = Tn(j, o), ce = En({
1436
+ x: ne.x + se.x * mn,
1437
+ y: ne.y + se.y * mn
1438
+ }, se), le = [
1439
+ `M${A.x},${A.y}`,
1440
+ `L${M.x + oe.x * pn},${M.y + oe.y * pn}`,
1441
+ `L${M.x - oe.x * pn},${M.y - oe.y * pn}Z`
1442
+ ].join("");
1443
+ return /* @__PURE__ */ G(Ut, {
1444
+ layer: "wires",
1445
+ children: /* @__PURE__ */ K("g", {
1446
+ "data-scene-wire": n,
1447
+ ...V.props(Cn.fade(C)),
1448
+ children: [
1449
+ /* @__PURE__ */ G(re, {
1450
+ d: P,
1451
+ tone: L,
1452
+ width: b.isInspected ? B + 1 : B,
1453
+ stroke: u ? "dashed" : "solid",
1454
+ emphasis: b.emphasis
1455
+ }),
1456
+ d && /* @__PURE__ */ G("path", {
1457
+ d: le,
1458
+ ...V.props(Cn.arrow(R, b.strength))
1459
+ }),
1460
+ a !== void 0 && /* @__PURE__ */ G(z, {
1461
+ x: ce.x,
1462
+ y: ce.y,
1463
+ anchor: ce.anchor,
1464
+ children: a
1465
+ }),
1466
+ r !== void 0 && f && /* @__PURE__ */ G(i, {
1467
+ value: n,
1468
+ render: /* @__PURE__ */ G("path", { d: P }),
1469
+ className: "xbh8q5q xmy28x3 x1qrb80n x1bz8pot x1t137rt"
1470
+ }),
1471
+ b.isCursor && /* @__PURE__ */ G("path", {
1472
+ d: P,
1473
+ ...V.props(I.shapeCursor, Cn.cursor)
1474
+ })
1475
+ ]
1476
+ })
1477
+ });
1478
+ }
1479
+ // packages/teaching/src/scene/scene-group.tsx
1480
+ var An = 18, jn = 8, Mn = 7, Nn = 13, Pn = 6, Fn = {
1481
+ kDwRjp: "x19zyb68",
1482
+ kfJifR: "xnpr05h",
1483
+ kREpy8: "x13efnbd",
1484
+ k3XXqK: "x1t137rt",
1485
+ $$css: !0
1486
+ }, In = {
1487
+ outline: (e, t) => [
1488
+ Fn,
1489
+ {
1490
+ kjVXCG: e == null ? e : "x6mkzkt",
1491
+ kSiTet: t == null ? t : "xb4nw82",
1492
+ $$css: !0
1493
+ },
1494
+ {
1495
+ "--x-fill": `color-mix(in srgb, ${e} 6%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 6%, transparent)`,
1496
+ "--x-stroke": e ?? void 0,
1497
+ "--x-opacity": t ?? void 0
1498
+ }
1499
+ ],
1500
+ inspected: {
1501
+ kfJifR: "xvlca1e",
1502
+ $$css: !0
1503
+ },
1504
+ cursor: {
1505
+ kDwRjp: "xbh8q5q",
1506
+ kfzvcC: "x47corl",
1507
+ $$css: !0
1508
+ },
1509
+ fade: (e) => [{
1510
+ kSiTet: e == null ? e : "xb4nw82",
1511
+ $$css: !0
1512
+ }, { "--x-opacity": e ?? void 0 }]
1513
+ };
1514
+ function Ln({ id: e, label: t, text: n, around: r, tone: a, padding: o = 10, isShown: s = !0, isActive: c = !1, emphasis: l }) {
1515
+ let u = et(r), d = b(e), f = n ?? t, p = Y({
1516
+ id: e,
1517
+ kind: "group",
1518
+ values: {},
1519
+ label: t,
1520
+ attaches: r,
1521
+ surround: {
1522
+ top: o + (f === void 0 ? 0 : An),
1523
+ right: o,
1524
+ bottom: o,
1525
+ left: o
1526
+ },
1527
+ isShown: s,
1528
+ isActive: c,
1529
+ emphasis: l
1530
+ });
1531
+ if (!p.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneGroup" });
1532
+ let m = pt(u.flatMap((e) => e?.rect === void 0 || e.values.opacity <= 0 ? [] : [e.rect]));
1533
+ if (m === void 0 || p.values.opacity <= 0) return null;
1534
+ let h = mt(m, o), g = f === void 0 ? h.top : h.top - An, _ = a ?? d ?? "neutral", v = p.emphasis === "context" ? Wt : N[_], y = Math.max(h.right - h.left, (f?.length ?? 0) * Mn + 16), x = Math.min(h.left, (h.left + h.right - y) / 2), S = h.left < jn ? x : Math.max(jn, x), C = h.bottom - g, w = /* @__PURE__ */ G("rect", {
1535
+ x: S,
1536
+ y: g,
1537
+ width: y,
1538
+ height: C,
1539
+ rx: Pn,
1540
+ ry: Pn
1541
+ });
1542
+ return /* @__PURE__ */ G(Ut, {
1543
+ layer: "back",
1544
+ children: /* @__PURE__ */ K("g", {
1545
+ ...V.props(In.fade(p.strength)),
1546
+ children: [
1547
+ /* @__PURE__ */ G(i, {
1548
+ value: e,
1549
+ render: w,
1550
+ ...V.props(In.outline(v, p.values.opacity), p.isInspected && In.inspected)
1551
+ }),
1552
+ f !== void 0 && /* @__PURE__ */ G("g", {
1553
+ ...V.props(In.fade(p.values.opacity)),
1554
+ children: /* @__PURE__ */ G(z, {
1555
+ x: S + jn,
1556
+ y: g + Nn,
1557
+ isStrong: !0,
1558
+ children: f
1559
+ })
1560
+ }),
1561
+ p.isCursor && /* @__PURE__ */ G("rect", {
1562
+ x: S,
1563
+ y: g,
1564
+ width: y,
1565
+ height: C,
1566
+ rx: Pn,
1567
+ ry: Pn,
1568
+ ...V.props(I.shapeCursor, In.cursor)
1569
+ })
1570
+ ]
1571
+ })
1572
+ });
1573
+ }
1574
+ // packages/teaching/src/scene/scene-bracket.tsx
1575
+ var Rn = 6, zn = 14, Bn = 6, Vn = 6.5, Hn = 4, Un = /* @__PURE__ */ new Set(["top", "bottom"]), Wn = {
1576
+ top: "bottom",
1577
+ bottom: "top",
1578
+ left: "right",
1579
+ right: "left"
1580
+ }, Gn = { fade: (e) => [{
1581
+ kSiTet: e == null ? e : "xb4nw82",
1582
+ $$css: !0
1583
+ }, { "--x-opacity": e ?? void 0 }] };
1584
+ function Kn({ bounds: e, side: t, padding: n, textWidth: r, stage: i }) {
1585
+ let a = Math.min(i.width - r / 2 - Hn, Math.max(r / 2 + Hn, (e.left + e.right) / 2)), o = (e.top + e.bottom) / 2;
1586
+ if (Un.has(t)) {
1587
+ let r = t === "bottom" ? 1 : -1, i = t === "bottom" ? e.bottom + n : e.top - n;
1588
+ return {
1589
+ lines: [
1590
+ {
1591
+ key: "span",
1592
+ x1: e.left,
1593
+ y1: i,
1594
+ x2: e.right,
1595
+ y2: i
1596
+ },
1597
+ {
1598
+ key: "start",
1599
+ x1: e.left,
1600
+ y1: i,
1601
+ x2: e.left,
1602
+ y2: i - r * Rn
1603
+ },
1604
+ {
1605
+ key: "end",
1606
+ x1: e.right,
1607
+ y1: i,
1608
+ x2: e.right,
1609
+ y2: i - r * Rn
1610
+ }
1611
+ ],
1612
+ label: {
1613
+ x: a,
1614
+ y: t === "bottom" ? i + zn : i - Bn,
1615
+ anchor: "middle"
1616
+ },
1617
+ hit: {
1618
+ left: e.left,
1619
+ top: i - Rn,
1620
+ right: e.right,
1621
+ bottom: i + Rn
1622
+ }
1623
+ };
1624
+ }
1625
+ let s = t === "right" ? 1 : -1, c = t === "right" ? e.right + n : e.left - n;
1626
+ return {
1627
+ lines: [
1628
+ {
1629
+ key: "span",
1630
+ x1: c,
1631
+ y1: e.top,
1632
+ x2: c,
1633
+ y2: e.bottom
1634
+ },
1635
+ {
1636
+ key: "start",
1637
+ x1: c,
1638
+ y1: e.top,
1639
+ x2: c - s * Rn,
1640
+ y2: e.top
1641
+ },
1642
+ {
1643
+ key: "end",
1644
+ x1: c,
1645
+ y1: e.bottom,
1646
+ x2: c - s * Rn,
1647
+ y2: e.bottom
1648
+ }
1649
+ ],
1650
+ label: {
1651
+ x: c + s * Bn,
1652
+ y: o + Hn,
1653
+ anchor: t === "right" ? "start" : "end"
1654
+ },
1655
+ hit: {
1656
+ left: c - Rn,
1657
+ top: e.top,
1658
+ right: c + Rn,
1659
+ bottom: e.bottom
1660
+ }
1661
+ };
1662
+ }
1663
+ function qn({ bounds: e, side: t, room: n, stage: r }) {
1664
+ return {
1665
+ top: e.top,
1666
+ bottom: r.height - e.bottom,
1667
+ left: e.left,
1668
+ right: r.width - e.right
1669
+ }[t] >= n;
1670
+ }
1671
+ function Jn({ of: e, id: t = `bracket:${e[0] ?? ""}`, label: n, text: r, side: a = "bottom", padding: o = 8, isShown: s = !0 }) {
1672
+ let c = et(e), l = Y({
1673
+ id: t,
1674
+ kind: "bracket",
1675
+ values: {},
1676
+ label: n,
1677
+ attaches: e,
1678
+ isShown: s
1679
+ }), { scene: u } = l;
1680
+ if (!u.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneBracket" });
1681
+ let d = pt(c.flatMap((e) => e?.rect === void 0 ? [] : [e.rect])), f = r ?? n, p = (f?.length ?? 0) * Vn;
1682
+ if (d === void 0 || l.values.opacity <= 0) return null;
1683
+ let m = {
1684
+ width: u.box.width,
1685
+ height: u.box.height
1686
+ }, h = Kn({
1687
+ bounds: d,
1688
+ side: qn({
1689
+ bounds: d,
1690
+ side: a,
1691
+ room: o + (Un.has(a) ? 18 : p + Bn + Hn),
1692
+ stage: m
1693
+ }) ? a : Wn[a],
1694
+ padding: o,
1695
+ textWidth: p,
1696
+ stage: m
1697
+ }), { hit: g } = h;
1698
+ return /* @__PURE__ */ G(Ut, {
1699
+ layer: "front",
1700
+ children: /* @__PURE__ */ K("g", {
1701
+ ...V.props(Gn.fade(l.values.opacity)),
1702
+ children: [
1703
+ h.lines.map((e) => /* @__PURE__ */ G(B, {
1704
+ x1: e.x1,
1705
+ y1: e.y1,
1706
+ x2: e.x2,
1707
+ y2: e.y2
1708
+ }, e.key)),
1709
+ f !== void 0 && /* @__PURE__ */ G(z, {
1710
+ x: h.label.x,
1711
+ y: h.label.y,
1712
+ anchor: h.label.anchor,
1713
+ children: f
1714
+ }),
1715
+ n !== void 0 && s && /* @__PURE__ */ G(i, {
1716
+ value: t,
1717
+ render: /* @__PURE__ */ G("rect", {
1718
+ x: g.left,
1719
+ y: g.top,
1720
+ width: g.right - g.left,
1721
+ height: g.bottom - g.top
1722
+ }),
1723
+ className: "xy6m8k3 xeutv01 x1t137rt"
1724
+ })
1725
+ ]
1726
+ })
1727
+ });
1728
+ }
1729
+ // packages/teaching/src/scene/scene-obstacles.ts
1730
+ function Yn(e, t) {
1731
+ return e.left === t.left && e.right === t.right && e.top === t.top && e.bottom === t.bottom;
1732
+ }
1733
+ function Xn() {
1734
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = { version: 0 };
1735
+ function i() {
1736
+ r.version += 1;
1737
+ for (let e of n) e();
1738
+ }
1739
+ return {
1740
+ set: (t, n) => {
1741
+ n === null ? e.delete(t) : e.set(t, n), i();
1742
+ },
1743
+ claim: (e, n) => {
1744
+ let r = t.get(e);
1745
+ n === null ? t.delete(e) && i() : r !== void 0 && Yn(r, n) || (t.set(e, n), i());
1746
+ },
1747
+ lines: (t) => Array.from(e, ([e, n]) => e === t ? [] : [n]).flat(),
1748
+ taken: (e) => {
1749
+ let n = Array.from(t), r = n.findIndex(([t]) => t === e);
1750
+ return (r === -1 ? n : n.slice(0, r)).map(([, e]) => e);
1751
+ },
1752
+ version: () => r.version,
1753
+ subscribe: (e) => (n.add(e), () => {
1754
+ n.delete(e);
1755
+ })
1756
+ };
1757
+ }
1758
+ var Zn = je(Xn);
1759
+ function Qn({ id: e, line: t }) {
1760
+ let { registry: n } = J(), r = Zn(n);
1761
+ U(() => {
1762
+ r.set(e, t);
1763
+ }), U(() => () => {
1764
+ r.set(e, null);
1765
+ }, [r, e]);
1766
+ }
1767
+ function $n(e) {
1768
+ let t = J(), n = Zn(t.registry);
1769
+ return ve(n.subscribe, n.version, n.version), n.lines(e).map((e) => e.map((e) => ({
1770
+ x: t.x.position(e.x),
1771
+ y: t.y.position(e.y)
1772
+ })));
1773
+ }
1774
+ function er(e) {
1775
+ let { registry: t } = J(), n = Zn(t);
1776
+ return ve(n.subscribe, n.version, n.version), n.taken(e);
1777
+ }
1778
+ function tr(e, t) {
1779
+ let { registry: n } = J(), r = Zn(n);
1780
+ U(() => {
1781
+ r.claim(e, t);
1782
+ }), U(() => () => {
1783
+ r.claim(e, null);
1784
+ }, [r, e]);
1785
+ }
1786
+ function nr({ id: e, owner: t, spots: n, lines: r }) {
1787
+ let { box: i } = J(), a = $n(t), o = er(e), s = n.filter((e) => {
1788
+ let t = L(e);
1789
+ return t.left >= i.left && t.right <= i.right && t.top >= i.top && t.bottom <= i.bottom;
1790
+ }), c = R({
1791
+ spots: s.length > 0 ? s : n,
1792
+ lines: [...a, ...r],
1793
+ taken: o
1794
+ });
1795
+ return tr(e, c === void 0 ? null : L(c)), c;
1796
+ }
1797
+ // packages/teaching/src/scene/scene-callout.tsx
1798
+ var rr = 18, ir = 4, ar = 40, or = [
1799
+ "right",
1800
+ "left",
1801
+ "bottom",
1802
+ "top"
1803
+ ], sr = [
1804
+ "center",
1805
+ "start",
1806
+ "end"
1807
+ ], cr = [
1808
+ 1,
1809
+ .8,
1810
+ .64
1811
+ ], lr = 1e3, ur = 40, dr = 10, fr = 4, pr = 60, mr = {
1812
+ kVAEAm: "x10l6tqk",
1813
+ kbCHJM: "xu96u03",
1814
+ k87sOh: "x13vifvy",
1815
+ kB7OPa: "x9f619",
1816
+ k8WAf4: "x1hmw7ec",
1817
+ kg3NbH: "x5g2kb4",
1818
+ kMzoRj: "xmkeg23",
1819
+ ksu8eU: "x1y0btm7",
1820
+ kVAM5u: "x1ey3b81",
1821
+ kaIpWk: "x1ok0vyi",
1822
+ kWkggS: "xpvm0e4",
1823
+ kMwMTN: "xbixft",
1824
+ kMv6JI: "x1hz01jw",
1825
+ kGuDYH: "xy8obcc",
1826
+ kLWn49: "xas2l8k",
1827
+ kHjlTd: "xj0a0fe",
1828
+ kfzvcC: "x67bb7w",
1829
+ $$css: !0
1830
+ }, hr = {
1831
+ kjVXCG: "xhq4mlf",
1832
+ kfJifR: "xnpr05h",
1833
+ kDwRjp: "xbh8q5q",
1834
+ kREpy8: "x13efnbd",
1835
+ kfzvcC: "x47corl",
1836
+ $$css: !0
1837
+ }, gr = {
1838
+ kDwRjp: "x1q7gtio",
1839
+ kfzvcC: "x47corl",
1840
+ $$css: !0
1841
+ }, _r = {
1842
+ callout: (e, t) => [
1843
+ mr,
1844
+ {
1845
+ kzqmXN: t == null ? t : "x5lhr3w",
1846
+ k3aq6I: e == null ? e : "xsqj5wx",
1847
+ $$css: !0
1848
+ },
1849
+ {
1850
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
1851
+ "--x-transform": e ?? void 0
1852
+ }
1853
+ ],
1854
+ fade: (e) => [{
1855
+ kSiTet: e == null ? e : "xb4nw82",
1856
+ $$css: !0
1857
+ }, { "--x-opacity": e ?? void 0 }],
1858
+ gone: {
1859
+ k33iCy: "xlshs6z",
1860
+ $$css: !0
1861
+ },
1862
+ leader: (e) => [
1863
+ hr,
1864
+ {
1865
+ kSiTet: e == null ? e : "xb4nw82",
1866
+ $$css: !0
1867
+ },
1868
+ { "--x-opacity": e ?? void 0 }
1869
+ ],
1870
+ end: (e) => [
1871
+ gr,
1872
+ {
1873
+ kSiTet: e == null ? e : "xb4nw82",
1874
+ $$css: !0
1875
+ },
1876
+ { "--x-opacity": e ?? void 0 }
1877
+ ]
1878
+ };
1879
+ function vr({ side: e, alignment: t, target: n, size: r, stage: i }) {
1880
+ let a = Z(n), { width: o, height: s } = r, c = {
1881
+ center: a.x - o / 2,
1882
+ start: n.left,
1883
+ end: n.right - o
1884
+ }, l = {
1885
+ center: a.y - s / 2,
1886
+ start: n.top,
1887
+ end: n.bottom - s
1888
+ }, u = Math.min(i.width - o - ir, Math.max(ir, c[t])), d = Math.min(i.height - s - ir, Math.max(ir, l[t])), f = {
1889
+ right: {
1890
+ x: n.right + rr,
1891
+ y: d
1892
+ },
1893
+ left: {
1894
+ x: n.left - rr - o,
1895
+ y: d
1896
+ },
1897
+ bottom: {
1898
+ x: u,
1899
+ y: n.bottom + rr
1900
+ },
1901
+ top: {
1902
+ x: u,
1903
+ y: n.top - rr - s
1904
+ }
1905
+ }[e];
1906
+ return {
1907
+ left: f.x,
1908
+ top: f.y,
1909
+ right: f.x + o,
1910
+ bottom: f.y + s
1911
+ };
1912
+ }
1913
+ function yr(e, t) {
1914
+ return e.left >= 3 && e.right <= t.width - ir + 1 && e.top >= 3 && e.bottom <= t.height - ir + 1;
1915
+ }
1916
+ function br(e, t, n) {
1917
+ let r = Z(t), i = e.registry.members().list.filter((e) => e.isShown && e.id !== n);
1918
+ function a(t) {
1919
+ let n = e.registry.member(t);
1920
+ return n?.frame === void 0 ? void 0 : Z(e.rectOf(n.track.get()));
1921
+ }
1922
+ return {
1923
+ boxes: i.flatMap((t) => {
1924
+ let n = t.frame === void 0 ? void 0 : e.rectOf(t.track.get());
1925
+ return n === void 0 || n.left <= r.x && n.right >= r.x && n.top <= r.y && n.bottom >= r.y ? [] : [n];
1926
+ }),
1927
+ lines: i.flatMap((e) => {
1928
+ let [t, n] = e.kind === "wire" ? e.attaches.map(a) : [];
1929
+ return t === void 0 || n === void 0 ? [] : [[t, n]];
1930
+ })
1931
+ };
1932
+ }
1933
+ function xr(e, t) {
1934
+ return t.flatMap((t) => t.slice(1).map((n, r) => _t({
1935
+ rect: e,
1936
+ from: t[r] ?? n,
1937
+ to: n
1938
+ }))).reduce((e, t) => e + t, 0);
1939
+ }
1940
+ function Sr(e, t) {
1941
+ return t.map((t) => gt(e, t)).reduce((e, t) => e + t, 0);
1942
+ }
1943
+ function Cr(e, t) {
1944
+ return {
1945
+ x: Math.min(e.right, Math.max(e.left, t.x)),
1946
+ y: Math.min(e.bottom, Math.max(e.top, t.y))
1947
+ };
1948
+ }
1949
+ function wr({ scene: e, to: t, target: n, side: r, width: i, measured: a, avoided: o }) {
1950
+ let s = {
1951
+ width: e.box.width,
1952
+ height: e.box.height
1953
+ }, c = r === "auto" ? or : [r, ...or.filter((e) => e !== r)], l = a.width * a.height, u = br(e, n, t), d = [...u.boxes, ...o.boxes], f = [...u.lines, ...o.lines], p = cr.flatMap((e, t) => {
1954
+ let r = {
1955
+ width: Math.round(i * e),
1956
+ height: Math.ceil(l / Math.round(i * e))
1957
+ };
1958
+ return c.flatMap((e, i) => sr.flatMap((a, o) => {
1959
+ let c = vr({
1960
+ side: e,
1961
+ alignment: a,
1962
+ target: n,
1963
+ size: r,
1964
+ stage: s
1965
+ }), l = i * ur + o * dr + t * pr, u = Sr(c, d) * lr + xr(c, f) * fr + l;
1966
+ return yr(c, s) ? [{
1967
+ rect: c,
1968
+ cost: u
1969
+ }] : [];
1970
+ }));
1971
+ }).toSorted((e, t) => e.cost - t.cost)[0], m = vr({
1972
+ side: c[0] ?? "right",
1973
+ alignment: "center",
1974
+ target: n,
1975
+ size: a,
1976
+ stage: s
1977
+ });
1978
+ return p?.rect ?? m;
1979
+ }
1980
+ function Tr({ to: e, id: t = `callout:${e}`, side: n = "auto", width: r = 176, isShown: i = !0, children: a }) {
1981
+ let [o] = et([e]), s = Y({
1982
+ id: t,
1983
+ kind: "callout",
1984
+ values: {},
1985
+ attaches: [e],
1986
+ isShown: i
1987
+ }), [c, l] = W(null), [u, d] = W({
1988
+ width: r,
1989
+ height: ar
1990
+ }), f = {
1991
+ boxes: er(t),
1992
+ lines: $n(e)
1993
+ }, { scene: p } = s, m = o?.rect, h = m === void 0 || !p.isInScene ? void 0 : wr({
1994
+ scene: p,
1995
+ to: e,
1996
+ target: m,
1997
+ side: n,
1998
+ width: r,
1999
+ measured: u,
2000
+ avoided: f
2001
+ });
2002
+ if (tr(t, i && h !== void 0 ? h : null), U(() => {
2003
+ if (c === null) return;
2004
+ let e = new ResizeObserver(() => d((e) => e.width === c.offsetWidth && e.height === c.offsetHeight ? e : {
2005
+ width: c.offsetWidth,
2006
+ height: c.offsetHeight
2007
+ }));
2008
+ return e.observe(c), () => e.disconnect();
2009
+ }, [c]), !p.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneCallout" });
2010
+ if (o === void 0 || m === void 0 || h === void 0) return null;
2011
+ let g = s.values.opacity * o.values.opacity, _ = Cr(h, Z(m)), v = yt({
2012
+ rect: m,
2013
+ shape: o.member.shape,
2014
+ toward: _
2015
+ });
2016
+ return /* @__PURE__ */ K(xe, { children: [/* @__PURE__ */ K(Ut, {
2017
+ layer: "front",
2018
+ children: [/* @__PURE__ */ G("line", {
2019
+ x1: _.x,
2020
+ y1: _.y,
2021
+ x2: v.x,
2022
+ y2: v.y,
2023
+ ...V.props(_r.leader(g))
2024
+ }), /* @__PURE__ */ G("circle", {
2025
+ cx: v.x,
2026
+ cy: v.y,
2027
+ r: 2,
2028
+ ...V.props(_r.end(g))
2029
+ })]
2030
+ }), /* @__PURE__ */ G("div", {
2031
+ ref: l,
2032
+ "aria-hidden": !i || void 0,
2033
+ ...V.props(_r.callout(`translate(${h.left}px, ${h.top}px)`, h.right - h.left), _r.fade(g), !s.isVisible && _r.gone),
2034
+ children: a
2035
+ })] });
2036
+ }
2037
+ // packages/teaching/src/scene/scene-highlight.tsx
2038
+ var Er = 8, Dr = {
2039
+ kDwRjp: "x19zyb68",
2040
+ kfJifR: "xhr4kjn",
2041
+ kREpy8: "x13efnbd",
2042
+ kfzvcC: "x47corl",
2043
+ $$css: !0
2044
+ }, Or = { halo: (e, t) => [
2045
+ Dr,
2046
+ {
2047
+ kjVXCG: e == null ? e : "x6mkzkt",
2048
+ kSiTet: t == null ? t : "xb4nw82",
2049
+ $$css: !0
2050
+ },
2051
+ {
2052
+ "--x-fill": `color-mix(in srgb, ${e} 12%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 12%, transparent)`,
2053
+ "--x-stroke": e ?? void 0,
2054
+ "--x-opacity": t ?? void 0
2055
+ }
2056
+ ] };
2057
+ function kr({ of: e, id: t, tone: n, padding: r = 6, isShown: i = !0 }) {
2058
+ let a = typeof e == "string" ? [e] : e, o = et(a), s = Y({
2059
+ id: t ?? `highlight:${a.join(",")}`,
2060
+ kind: "highlight",
2061
+ values: {},
2062
+ attaches: a,
2063
+ isShown: i
2064
+ });
2065
+ if (!s.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneHighlight" });
2066
+ if (s.values.opacity <= 0) return null;
2067
+ let c = n === void 0 ? P.ink : N[n];
2068
+ return /* @__PURE__ */ G(Ut, {
2069
+ layer: "back",
2070
+ children: o.map((e, t) => {
2071
+ let n = e?.rect;
2072
+ if (e === void 0 || n === void 0) return null;
2073
+ let i = mt(n, r), o = e.member.shape === "circle";
2074
+ return /* @__PURE__ */ G("rect", {
2075
+ x: i.left,
2076
+ y: i.top,
2077
+ width: i.right - i.left,
2078
+ height: i.bottom - i.top,
2079
+ rx: o ? (i.right - i.left) / 2 : Er,
2080
+ ry: o ? (i.bottom - i.top) / 2 : Er,
2081
+ ...V.props(Or.halo(c, s.values.opacity * e.values.opacity))
2082
+ }, a[t]);
2083
+ })
2084
+ });
2085
+ }
2086
+ // packages/teaching/src/scene/scene-custom.tsx
2087
+ function Ar({ layer: e = "front", children: t }) {
2088
+ let n = J();
2089
+ return n.isInScene ? /* @__PURE__ */ G(Ut, {
2090
+ layer: e,
2091
+ children: t({
2092
+ x: n.x,
2093
+ y: n.y,
2094
+ box: n.box,
2095
+ view: n.view,
2096
+ tone: n.tone,
2097
+ color: (e) => N[e]
2098
+ })
2099
+ }) : /* @__PURE__ */ G(Q, { part: "SceneCustom" });
2100
+ }
2101
+ // packages/teaching/src/scene/plane/plane-hit.tsx
2102
+ var jr = {
2103
+ fade: (e) => [{
2104
+ kSiTet: Math.max(0, Math.min(1, e)) == null ? Math.max(0, Math.min(1, e)) : "xb4nw82",
2105
+ $$css: !0
2106
+ }, { "--x-opacity": Math.max(0, Math.min(1, e)) == null ? void 0 : Math.max(0, Math.min(1, e)) }],
2107
+ stroke: {
2108
+ kDwRjp: "xbh8q5q",
2109
+ kjVXCG: "xmy28x3",
2110
+ kfJifR: "x1lgcr9h",
2111
+ kfzvcC: "x1bz8pot",
2112
+ k3XXqK: "x1t137rt",
2113
+ $$css: !0
2114
+ },
2115
+ fill: {
2116
+ kDwRjp: "xy6m8k3",
2117
+ kjVXCG: "xeutv01",
2118
+ kfzvcC: "x1q24kje",
2119
+ k3XXqK: "x1t137rt",
2120
+ $$css: !0
2121
+ },
2122
+ cursor: {
2123
+ kDwRjp: "xbh8q5q",
2124
+ kfzvcC: "x47corl",
2125
+ $$css: !0
2126
+ }
2127
+ };
2128
+ function Mr({ id: e, layer: t, opacity: n, children: r }) {
2129
+ return /* @__PURE__ */ G(Ut, {
2130
+ layer: t,
2131
+ children: /* @__PURE__ */ G("g", {
2132
+ "data-scene-plane": e,
2133
+ ...V.props(jr.fade(n)),
2134
+ children: r
2135
+ })
2136
+ });
2137
+ }
2138
+ function Nr({ id: e, d: t, hasLabel: n, isCursor: r, reach: a = "stroke" }) {
2139
+ return /* @__PURE__ */ K(xe, { children: [n && /* @__PURE__ */ G(i, {
2140
+ value: e,
2141
+ render: /* @__PURE__ */ G("path", { d: t }),
2142
+ ...V.props(jr[a])
2143
+ }), r && /* @__PURE__ */ G("path", {
2144
+ d: t,
2145
+ ...V.props(I.shapeCursor, jr.cursor)
2146
+ })] });
2147
+ }
2148
+ // packages/teaching/src/scene/plane/scene-axes.tsx
2149
+ var Pr = { maximumFractionDigits: 2 }, Fr = 96, Ir = 56, Lr = [a.compact, a.tall];
2150
+ function Rr(e) {
2151
+ return {
2152
+ label: e?.label ?? "",
2153
+ format: e?.format ?? Pr
2154
+ };
2155
+ }
2156
+ function zr({ axis: e, domain: t, length: n, spacing: r, locale: i }) {
2157
+ let a = e?.label !== void 0, o = Rr(e);
2158
+ if (e?.ticks === void 0) return l({
2159
+ axis: o,
2160
+ domain: t,
2161
+ length: n,
2162
+ spacing: r,
2163
+ locale: i,
2164
+ hasTitle: a
2165
+ });
2166
+ let s = e.ticks.filter((e) => e >= t[0] && e <= t[1]);
2167
+ return {
2168
+ values: s,
2169
+ labels: u({
2170
+ values: s,
2171
+ axis: o,
2172
+ locale: i,
2173
+ hasTitle: a
2174
+ })
2175
+ };
2176
+ }
2177
+ function Br(e, t) {
2178
+ return e.values.map((n, r) => ({
2179
+ key: String(n),
2180
+ position: t(n),
2181
+ label: e.labels[r] ?? ""
2182
+ }));
2183
+ }
2184
+ function Vr({ id: e = "axes", x: t, y: n, grid: r = "y", isShown: i = !0 }) {
2185
+ let a = J(), { box: o, view: c, domain: l, locale: u } = a, d = t?.label !== void 0, f = n?.label !== void 0, p = Lr.flatMap((e) => zr({
2186
+ axis: n,
2187
+ domain: l.y,
2188
+ length: e,
2189
+ spacing: Ir,
2190
+ locale: u
2191
+ }).labels), m = Y({
2192
+ id: e,
2193
+ kind: "axes",
2194
+ values: {},
2195
+ margins: s({
2196
+ width: o.width,
2197
+ valueLabels: p,
2198
+ hasXTitle: d,
2199
+ hasYTitle: f
2200
+ }),
2201
+ isShown: i
2202
+ }), [h, g] = l.x, [_, v] = l.y, y = h < 0 && g > 0, b = _ < 0 && v > 0;
2203
+ if (Qn({
2204
+ id: `${e}:zero-x`,
2205
+ line: y ? [{
2206
+ x: 0,
2207
+ y: _
2208
+ }, {
2209
+ x: 0,
2210
+ y: v
2211
+ }] : []
2212
+ }), Qn({
2213
+ id: `${e}:zero-y`,
2214
+ line: b ? [{
2215
+ x: h,
2216
+ y: 0
2217
+ }, {
2218
+ x: g,
2219
+ y: 0
2220
+ }] : []
2221
+ }), !a.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneAxes" });
2222
+ if (!m.isVisible) return null;
2223
+ let x = zr({
2224
+ axis: t,
2225
+ domain: [c.x0, c.x1],
2226
+ length: o.innerWidth,
2227
+ spacing: Fr,
2228
+ locale: u
2229
+ }), S = zr({
2230
+ axis: n,
2231
+ domain: [c.y0, c.y1],
2232
+ length: o.innerHeight,
2233
+ spacing: Ir,
2234
+ locale: u
2235
+ }), C = c.x0 < 0 && c.x1 > 0, w = c.y0 < 0 && c.y1 > 0;
2236
+ return /* @__PURE__ */ K(Mr, {
2237
+ id: e,
2238
+ layer: "back",
2239
+ opacity: m.values.opacity,
2240
+ children: [
2241
+ /* @__PURE__ */ G(se, {
2242
+ box: o,
2243
+ xTicks: Br(x, a.x.position),
2244
+ yTicks: Br(S, a.y.position),
2245
+ xTitle: t?.label,
2246
+ yTitle: n?.label,
2247
+ grid: r
2248
+ }),
2249
+ C && /* @__PURE__ */ G(B, {
2250
+ x1: a.x.position(0),
2251
+ x2: a.x.position(0),
2252
+ y1: o.top,
2253
+ y2: o.bottom
2254
+ }),
2255
+ w && /* @__PURE__ */ G(B, {
2256
+ x1: o.left,
2257
+ x2: o.right,
2258
+ y1: a.y.position(0),
2259
+ y2: a.y.position(0)
2260
+ })
2261
+ ]
2262
+ });
2263
+ }
2264
+ // packages/teaching/src/scene/plane/plane-labels.ts
2265
+ var Hr = {
2266
+ curveSource: "The curve \"{id}\" needs `points` or `of`, and not both.",
2267
+ curveTooMany: "The curve \"{id}\" takes at most {limit} points. Pass fewer, or use `of`.",
2268
+ curveOrder: "The curve \"{id}\" needs at least two points with strictly increasing x.",
2269
+ curveValue: "The curve \"{id}\" gives a value that is not a number at x = {x}.",
2270
+ pointLabel: "The point \"{id}\" can be moved, so it needs a `label` for the readout.",
2271
+ pointOutsideLesson: "The point \"{id}\" sets lesson params, so it must be inside a Lesson.",
2272
+ pointParam: "The point \"{id}\" sets \"{name}\", which lesson \"{lesson}\" does not declare as a number param.",
2273
+ pointMovable: " Use the arrow keys to move it.",
2274
+ regionShape: "The region \"{id}\" needs one of `between`, `above`, `below` or `points`.",
2275
+ ruleAxis: "The rule \"{id}\" needs `x` or `y`, and not both.",
2276
+ projectionSource: "The projection \"{id}\" needs `of` or `at`, and not both.",
2277
+ notFinite: "The {kind} \"{id}\" has a value that is not a finite number."
2278
+ }, Ur = {
2279
+ coarse: 60,
2280
+ regular: 160,
2281
+ fine: 400
2282
+ }, Wr = {
2283
+ curvePoints: 2e3,
2284
+ polygonPoints: 200
2285
+ }, Gr = {
2286
+ thin: 1.25,
2287
+ regular: 1.75,
2288
+ thick: 3
2289
+ }, Kr = .5;
2290
+ function qr(e, t) {
2291
+ return Number.isFinite(e) ? Math.min(t[1], Math.max(t[0], e)) : (t[0] + t[1]) * Kr;
2292
+ }
2293
+ function Jr(e, t) {
2294
+ return [qr(e[0], t.x), qr(e[1], t.y)];
2295
+ }
2296
+ function Yr(e, t) {
2297
+ return Array.from({ length: t }, (n, r) => e[0] + (e[1] - e[0]) * r / (t - 1));
2298
+ }
2299
+ function Xr(e, t) {
2300
+ let n = {
2301
+ low: 0,
2302
+ high: e.length
2303
+ };
2304
+ for (; n.low < n.high;) {
2305
+ let r = Math.floor((n.low + n.high) * Kr);
2306
+ (e[r]?.[0] ?? Infinity) < t ? n.low = r + 1 : n.high = r;
2307
+ }
2308
+ return n.low;
2309
+ }
2310
+ function Zr(e, t) {
2311
+ let n = Xr(e, t), r = e[n], i = e[n - 1];
2312
+ return r === void 0 ? i?.[1] ?? 0 : i === void 0 || r[0] === t ? r[1] : i[1] + (r[1] - i[1]) * (t - i[0]) / (r[0] - i[0]);
2313
+ }
2314
+ function Qr({ xs: e, ys: t, from: n, to: r }) {
2315
+ let i = e.map((e, n) => [e, t[n] ?? 0]), a = i.flatMap(([e, t]) => e > n && e < r ? [{
2316
+ x: e,
2317
+ y: t
2318
+ }] : []);
2319
+ return [
2320
+ {
2321
+ x: n,
2322
+ y: Zr(i, n)
2323
+ },
2324
+ ...a,
2325
+ {
2326
+ x: r,
2327
+ y: Zr(i, r)
2328
+ }
2329
+ ];
2330
+ }
2331
+ function $r(e) {
2332
+ let t = { sum: 0 };
2333
+ for (let n of e) t.sum += n;
2334
+ return t.sum / Math.max(1, e.length);
2335
+ }
2336
+ function ei(e) {
2337
+ return {
2338
+ x: $r(e.map((e) => e.x)),
2339
+ y: $r(e.map((e) => e.y))
2340
+ };
2341
+ }
2342
+ // packages/teaching/src/scene/plane/scene-curve.tsx
2343
+ var ti = 1, ni = .5;
2344
+ function ri(e) {
2345
+ return e.every(([e, t]) => Number.isFinite(e) && Number.isFinite(t)) && e.every((t, n) => n === 0 || t[0] > (e[n - 1]?.[0] ?? 0));
2346
+ }
2347
+ function ii({ id: e, points: t, of: n, xs: r, domain: i, labels: a }) {
2348
+ let o = {
2349
+ ys: r.map(() => 0),
2350
+ from: i[0],
2351
+ to: i[1]
2352
+ };
2353
+ if (n !== void 0 && t === void 0) {
2354
+ let t = r.map((e) => n(e)), i = t.findIndex((e) => !Number.isFinite(e));
2355
+ return i === -1 ? {
2356
+ ...o,
2357
+ ys: t,
2358
+ problem: void 0
2359
+ } : {
2360
+ ...o,
2361
+ problem: q(a.curveValue, {
2362
+ id: e,
2363
+ x: String(r[i])
2364
+ })
2365
+ };
2366
+ }
2367
+ if (t === void 0 || n !== void 0) return {
2368
+ ...o,
2369
+ problem: q(a.curveSource, { id: e })
2370
+ };
2371
+ if (t.length > Wr.curvePoints) return {
2372
+ ...o,
2373
+ problem: q(a.curveTooMany, {
2374
+ id: e,
2375
+ limit: String(Wr.curvePoints)
2376
+ })
2377
+ };
2378
+ if (t.length < 2 || !ri(t)) return {
2379
+ ...o,
2380
+ problem: q(a.curveOrder, { id: e })
2381
+ };
2382
+ let s = Math.max(i[0], t[0]?.[0] ?? i[0]), c = Math.max(s, Math.min(i[1], t.at(-1)?.[0] ?? i[1]));
2383
+ return {
2384
+ ys: r.map((e) => Zr(t, e)),
2385
+ from: s,
2386
+ to: c,
2387
+ problem: void 0
2388
+ };
2389
+ }
2390
+ function ai({ id: e, points: t, of: n, resolution: r = "regular", label: i, tone: a, emphasis: o, isDashed: s = !1, thickness: c = "regular", fillTo: l, isShown: u = !0, isActive: d = !1, pace: f, labels: p }) {
2391
+ let m = J(), h = b(e), [g, _] = m.domain.x, y = ge(() => Yr([g, _], Ur[r]), [
2392
+ g,
2393
+ _,
2394
+ r
2395
+ ]), x = ge(() => ii({
2396
+ id: e,
2397
+ points: t,
2398
+ of: n,
2399
+ xs: y,
2400
+ domain: [g, _],
2401
+ labels: {
2402
+ ...Hr,
2403
+ ...p
2404
+ }
2405
+ }), [
2406
+ e,
2407
+ t,
2408
+ n,
2409
+ y,
2410
+ g,
2411
+ _,
2412
+ p
2413
+ ]), S = {
2414
+ ...Object.fromEntries(x.ys.map((e, t) => [`y${t}`, e])),
2415
+ from: x.from,
2416
+ to: x.to,
2417
+ base: l ?? 0
2418
+ }, C = (x.from + x.to) * ni, w = Y({
2419
+ id: e,
2420
+ kind: "curve",
2421
+ frame: {
2422
+ x: C,
2423
+ y: qr(Zr(y.map((e, t) => [e, x.ys[t] ?? 0]), C), m.domain.y),
2424
+ width: 0,
2425
+ height: 0
2426
+ },
2427
+ isFloating: !0,
2428
+ values: S,
2429
+ label: i,
2430
+ isShown: u,
2431
+ isActive: d,
2432
+ emphasis: o,
2433
+ problem: x.problem,
2434
+ pace: f
2435
+ }), T = w.values, E = Qr({
2436
+ xs: y,
2437
+ ys: y.map((e, t) => T[`y${t}`] ?? 0),
2438
+ from: T.from,
2439
+ to: T.to
2440
+ });
2441
+ if (Qn({
2442
+ id: e,
2443
+ line: w.isVisible && x.problem === void 0 ? E : []
2444
+ }), !w.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneCurve" });
2445
+ if (!w.isVisible || x.problem !== void 0) return null;
2446
+ let D = E.map((e) => ({
2447
+ x: m.x.position(e.x),
2448
+ y: m.y.position(e.y)
2449
+ })), O = ae(D), k = m.y.position(T.base), A = Gr[c] + (w.isInspected ? ti : 0), j = a ?? h ?? "series1";
2450
+ return /* @__PURE__ */ G(Mr, {
2451
+ id: e,
2452
+ layer: "wires",
2453
+ opacity: T.opacity,
2454
+ children: /* @__PURE__ */ K(v, {
2455
+ box: m.box,
2456
+ children: [
2457
+ l !== void 0 && /* @__PURE__ */ G(ne, {
2458
+ d: oe(D.map((e) => ({
2459
+ x: e.x,
2460
+ y0: k,
2461
+ y1: e.y
2462
+ }))),
2463
+ tone: j,
2464
+ emphasis: w.emphasis,
2465
+ isPale: !0
2466
+ }),
2467
+ /* @__PURE__ */ G(re, {
2468
+ d: O,
2469
+ tone: j,
2470
+ width: A,
2471
+ stroke: s ? "dashed" : "solid",
2472
+ emphasis: w.emphasis
2473
+ }),
2474
+ /* @__PURE__ */ G(Nr, {
2475
+ id: e,
2476
+ d: O,
2477
+ hasLabel: i !== void 0 && u,
2478
+ isCursor: w.isCursor
2479
+ })
2480
+ ]
2481
+ })
2482
+ });
2483
+ }
2484
+ // packages/teaching/src/scene/plane/plane-label.tsx
2485
+ var oi = 11, si = 16, ci = 4;
2486
+ function li({ x: e, y: t, text: n }) {
2487
+ return [
2488
+ {
2489
+ x: e + oi,
2490
+ y: t - oi,
2491
+ anchor: "start",
2492
+ text: n
2493
+ },
2494
+ {
2495
+ x: e + oi,
2496
+ y: t + si,
2497
+ anchor: "start",
2498
+ text: n
2499
+ },
2500
+ {
2501
+ x: e - oi,
2502
+ y: t - oi,
2503
+ anchor: "end",
2504
+ text: n
2505
+ },
2506
+ {
2507
+ x: e - oi,
2508
+ y: t + si,
2509
+ anchor: "end",
2510
+ text: n
2511
+ },
2512
+ {
2513
+ x: e,
2514
+ y: t - oi - ci,
2515
+ anchor: "middle",
2516
+ text: n
2517
+ },
2518
+ {
2519
+ x: e,
2520
+ y: t + si + ci,
2521
+ anchor: "middle",
2522
+ text: n
2523
+ },
2524
+ {
2525
+ x: e + oi,
2526
+ y: t + ci,
2527
+ anchor: "start",
2528
+ text: n
2529
+ },
2530
+ {
2531
+ x: e - oi,
2532
+ y: t + ci,
2533
+ anchor: "end",
2534
+ text: n
2535
+ }
2536
+ ];
2537
+ }
2538
+ function ui({ owner: e, name: t, spots: n, lines: r = [], isStrong: i = !1 }) {
2539
+ let a = nr({
2540
+ id: `${e}:${t}`,
2541
+ owner: e,
2542
+ spots: n,
2543
+ lines: r
2544
+ });
2545
+ return a === void 0 ? null : /* @__PURE__ */ G(z, {
2546
+ x: a.x,
2547
+ y: a.y,
2548
+ anchor: a.anchor,
2549
+ isStrong: i,
2550
+ children: a.text
2551
+ });
2552
+ }
2553
+ // packages/teaching/src/scene/plane/scene-point.tsx
2554
+ var di = 6, fi = 14, pi = 100, mi = 10, hi = "[role=\"group\"][tabindex]", gi = {
2555
+ ArrowRight: [1, 0],
2556
+ ArrowLeft: [-1, 0],
2557
+ ArrowUp: [0, 1],
2558
+ ArrowDown: [0, -1]
2559
+ }, _i = {
2560
+ kVAEAm: "x10l6tqk",
2561
+ kbCHJM: "xu96u03",
2562
+ k87sOh: "x13vifvy",
2563
+ kzqmXN: "xgd8bvy",
2564
+ kZKoxP: "x1fgtraw",
2565
+ kfzvcC: "x67bb7w",
2566
+ $$css: !0
2567
+ }, vi = {
2568
+ target: (e) => [
2569
+ _i,
2570
+ {
2571
+ k3aq6I: e == null ? e : "xsqj5wx",
2572
+ $$css: !0
2573
+ },
2574
+ { "--x-transform": e ?? void 0 }
2575
+ ],
2576
+ movable: {
2577
+ kkrTdU: "x1jm3nie",
2578
+ kFalU9: "x5ve5x3",
2579
+ $$css: !0
2580
+ },
2581
+ dragging: {
2582
+ kkrTdU: "xi9pz9s",
2583
+ $$css: !0
2584
+ },
2585
+ mark: {
2586
+ kVAEAm: "x10l6tqk",
2587
+ kpwlN0: "x10a8y8t",
2588
+ kaIpWk: "x16rqkct",
2589
+ k3XXqK: "x1t137rt",
2590
+ $$css: !0
2591
+ }
2592
+ };
2593
+ function yi(e, { min: t, max: n, step: r }) {
2594
+ return r === void 0 ? Se(e, t, n) : Ce(Se(e, t, n), {
2595
+ min: t,
2596
+ max: n,
2597
+ step: r
2598
+ }).value;
2599
+ }
2600
+ function bi(e, t, n) {
2601
+ return n === void 0 ? {
2602
+ min: e[0],
2603
+ max: e[1],
2604
+ step: t
2605
+ } : {
2606
+ min: n.min,
2607
+ max: n.max,
2608
+ step: n.step
2609
+ };
2610
+ }
2611
+ function xi({ id: e, sets: t, scope: n, labels: r }) {
2612
+ if (n === null) return q(r.pointOutsideLesson, { id: e });
2613
+ let i = ["x", "y"].flatMap((e) => {
2614
+ let r = t[e], i = r === void 0 ? void 0 : n.lesson.params[r];
2615
+ return r === void 0 ? [] : [{
2616
+ axis: e,
2617
+ name: r,
2618
+ param: i?.kind === "number" ? i : void 0
2619
+ }];
2620
+ }), a = i.find((e) => e.param === void 0);
2621
+ return a === void 0 ? Object.fromEntries(i.map((e) => [e.axis, e.param])) : q(r.pointParam, {
2622
+ id: e,
2623
+ name: a.name,
2624
+ lesson: n.lesson.id
2625
+ });
2626
+ }
2627
+ function Si(e, { at: t, grids: n, along: r }) {
2628
+ let i = r === "y" ? t[0] : yi(e[0], n.x);
2629
+ if (typeof r == "function") {
2630
+ let e = r(i);
2631
+ return [i, Number.isFinite(e) ? Se(e, n.y.min, n.y.max) : t[1]];
2632
+ }
2633
+ return [i, r === "x" ? t[1] : yi(e[1], n.y)];
2634
+ }
2635
+ function Ci(e, t) {
2636
+ let n = gi[e.key], r = e.altKey || e.ctrlKey || e.metaKey, { at: i, grids: a, along: o } = t;
2637
+ if (n === void 0 || r) return;
2638
+ let s = n[0] !== 0;
2639
+ if (o === "x" && !s || o === "y" && s) return;
2640
+ let c = e.shiftKey ? mi : 1, l = (a.x.step ?? (a.x.max - a.x.min) / pi) * c, u = (a.y.step ?? (a.y.max - a.y.min) / pi) * c;
2641
+ return Si(typeof o == "function" ? [i[0] + (n[0] + n[1]) * l, i[1]] : [i[0] + n[0] * l, i[1] + n[1] * u], t);
2642
+ }
2643
+ function wi({ id: e, at: t, label: n, text: r, tone: a, emphasis: o, isShown: s = !0, isActive: c = !1, onMove: l, sets: u, snap: d, along: f, pace: p, labels: m }) {
2644
+ let h = J(), g = H(qe), _ = b(e), v = {
2645
+ ...Hr,
2646
+ ...m
2647
+ }, [y, x] = W(!1), C = _e(null), w = _e(null), T = H(S), E = l !== void 0 || u !== void 0, D = u === void 0 ? {} : xi({
2648
+ id: e,
2649
+ sets: u,
2650
+ scope: T,
2651
+ labels: v
2652
+ }), O = typeof D == "string" ? {} : D, k = O.x !== void 0 && O.y === void 0, A = O.y !== void 0 && O.x === void 0 ? "y" : void 0, j = {
2653
+ at: t,
2654
+ grids: {
2655
+ x: bi(h.domain.x, d, O.x),
2656
+ y: bi(h.domain.y, d, O.y)
2657
+ },
2658
+ along: f ?? (k ? "x" : A)
2659
+ };
2660
+ function M(e, t) {
2661
+ let n = Object.fromEntries(["x", "y"].flatMap((t, n) => {
2662
+ let r = u?.[t];
2663
+ return r === void 0 || O[t] === void 0 ? [] : [[r, e[n]]];
2664
+ }));
2665
+ T !== null && Object.keys(n).length > 0 && T.api.setParams(n, t), l?.(e, t);
2666
+ }
2667
+ let N = _e({
2668
+ scene: h,
2669
+ constraint: j,
2670
+ move: M
2671
+ }), P = E && n === void 0 ? q(v.pointLabel, { id: e }) : void 0, F = typeof D == "string" ? D : P, [I, L] = t, R = Y({
2672
+ id: e,
2673
+ kind: "point",
2674
+ frame: {
2675
+ x: I,
2676
+ y: L,
2677
+ width: 12,
2678
+ height: 12
2679
+ },
2680
+ isFloating: !0,
2681
+ values: {},
2682
+ shape: "circle",
2683
+ label: E && n !== void 0 ? `${n}${v.pointMovable}` : n,
2684
+ isShown: s,
2685
+ isActive: c,
2686
+ emphasis: o,
2687
+ problem: F,
2688
+ pace: y ? "instant" : p
2689
+ }), z = R.isVisible && F === void 0;
2690
+ Qn({
2691
+ id: e,
2692
+ line: z ? [{
2693
+ x: I,
2694
+ y: L
2695
+ }] : []
2696
+ });
2697
+ let B = g.cursor === e, te = E && B && R.isVisible;
2698
+ me(() => {
2699
+ N.current = {
2700
+ scene: h,
2701
+ constraint: j,
2702
+ move: M
2703
+ };
2704
+ }), me(() => () => w.current?.(), []), me(() => {
2705
+ if (!te) return;
2706
+ function e(e) {
2707
+ let t = C.current?.closest("figure"), { target: n } = e, r = n instanceof Element && t?.contains(n) === !0 && n.matches(hi) ? Ci(e, N.current.constraint) : void 0;
2708
+ if (r === void 0) return;
2709
+ e.preventDefault(), e.stopPropagation();
2710
+ let i = N.current.constraint.at;
2711
+ (r[0] !== i[0] || r[1] !== i[1]) && N.current.move(r, {
2712
+ reason: "step-key",
2713
+ event: e
2714
+ });
2715
+ }
2716
+ return document.addEventListener("keydown", e, !0), () => document.removeEventListener("keydown", e, !0);
2717
+ }, [te]);
2718
+ function ne(e) {
2719
+ e.preventDefault(), R.focusPlot();
2720
+ }
2721
+ function re(e) {
2722
+ let t = e.currentTarget;
2723
+ if (!E || e.button !== 0) return;
2724
+ let n = t.getBoundingClientRect(), r = {
2725
+ x: n.left + n.width / 2 - e.clientX,
2726
+ y: n.top + n.height / 2 - e.clientY
2727
+ }, i = N.current.constraint.at;
2728
+ w.current?.(), w.current = ye(t, e.nativeEvent, {
2729
+ threshold: be,
2730
+ cancelOnEscape: !0,
2731
+ onStart: () => {
2732
+ x(!0);
2733
+ },
2734
+ onMove: ({ x: e, y: n, event: i }) => {
2735
+ let a = t.parentElement?.getBoundingClientRect(), { scene: o, constraint: s, move: c } = N.current;
2736
+ if (a === void 0) return;
2737
+ let l = Si([o.x.valueAt(e + r.x - a.left), o.y.valueAt(n + r.y - a.top)], s);
2738
+ (l[0] !== s.at[0] || l[1] !== s.at[1]) && c(l, {
2739
+ reason: "drag",
2740
+ event: i
2741
+ });
2742
+ },
2743
+ onEnd: (e, t) => {
2744
+ x(!1), t && N.current.move(i, {
2745
+ reason: "drag",
2746
+ event: e
2747
+ });
2748
+ }
2749
+ });
2750
+ }
2751
+ if (!h.isInScene) return /* @__PURE__ */ G(Q, { part: "ScenePoint" });
2752
+ if (!z || R.rect === void 0) return null;
2753
+ let { x: ie, y: ae } = Z(R.rect), oe = a ?? _ ?? "series1";
2754
+ return /* @__PURE__ */ K(xe, { children: [/* @__PURE__ */ K(Mr, {
2755
+ id: e,
2756
+ layer: "front",
2757
+ opacity: R.values.opacity,
2758
+ children: [/* @__PURE__ */ G(ee, {
2759
+ x: ie,
2760
+ y: ae,
2761
+ tone: oe,
2762
+ radius: di,
2763
+ emphasis: R.emphasis,
2764
+ isInspected: R.isInspected,
2765
+ isSelected: R.isSelected
2766
+ }), r !== void 0 && /* @__PURE__ */ G(ui, {
2767
+ owner: e,
2768
+ name: "text",
2769
+ spots: li({
2770
+ x: ie,
2771
+ y: ae,
2772
+ text: r
2773
+ }),
2774
+ lines: [[{
2775
+ x: ie,
2776
+ y: ae
2777
+ }]]
2778
+ })]
2779
+ }), n !== void 0 && s && /* @__PURE__ */ G("div", {
2780
+ ref: C,
2781
+ "data-scene-point": e,
2782
+ onMouseDown: ne,
2783
+ onPointerDown: re,
2784
+ ...V.props(vi.target(`translate(${ie - fi}px, ${ae - fi}px)`), E && vi.movable, y && vi.dragging),
2785
+ children: /* @__PURE__ */ G(i, {
2786
+ value: e,
2787
+ render: /* @__PURE__ */ G("div", {}),
2788
+ ...V.props(vi.mark, ...Kt({
2789
+ ...R,
2790
+ isInspected: !1,
2791
+ isSelected: !1
2792
+ }))
2793
+ })
2794
+ })] });
2795
+ }
2796
+ // packages/teaching/src/scene/plane/scene-projection.tsx
2797
+ var Ti = { maximumFractionDigits: 2 }, Ei = 6, Di = 6, Oi = 14;
2798
+ function ki({ id: e, of: t, at: n, format: r = Ti, tone: i, isShown: a = !0, pace: o, labels: s }) {
2799
+ let c = J(), l = b(e), u = {
2800
+ ...Hr,
2801
+ ...s
2802
+ }, d = et(t === void 0 ? [] : [t])[0], f = t === void 0 != (n === void 0), p = Y({
2803
+ id: e,
2804
+ kind: "projection",
2805
+ frame: n === void 0 ? void 0 : {
2806
+ x: n[0],
2807
+ y: n[1],
2808
+ width: 0,
2809
+ height: 0
2810
+ },
2811
+ isFloating: !0,
2812
+ values: {},
2813
+ attaches: t === void 0 ? [] : [t],
2814
+ isShown: a,
2815
+ problem: f ? void 0 : q(u.projectionSource, { id: e }),
2816
+ pace: o
2817
+ });
2818
+ if (!c.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneProjection" });
2819
+ let m = d === void 0 ? p.rect : d.rect;
2820
+ if (!p.isVisible || !f || m === void 0) return null;
2821
+ let { box: h, locale: g } = c, { x: _, y: v } = Z(m), y = i ?? l ?? "neutral", x = F({
2822
+ value: c.x.valueAt(_),
2823
+ locale: g,
2824
+ format: r
2825
+ }), S = F({
2826
+ value: c.y.valueAt(v),
2827
+ locale: g,
2828
+ format: r
2829
+ }), C = [[{
2830
+ x: _,
2831
+ y: v
2832
+ }, {
2833
+ x: _,
2834
+ y: h.bottom
2835
+ }], [{
2836
+ x: _,
2837
+ y: v
2838
+ }, {
2839
+ x: h.left,
2840
+ y: v
2841
+ }]];
2842
+ return /* @__PURE__ */ K(Mr, {
2843
+ id: e,
2844
+ layer: "front",
2845
+ opacity: p.values.opacity,
2846
+ children: [
2847
+ /* @__PURE__ */ G(B, {
2848
+ x1: _,
2849
+ y1: v,
2850
+ x2: _,
2851
+ y2: h.bottom,
2852
+ stroke: "dashed",
2853
+ tone: y
2854
+ }),
2855
+ /* @__PURE__ */ G(B, {
2856
+ x1: _,
2857
+ y1: v,
2858
+ x2: h.left,
2859
+ y2: v,
2860
+ stroke: "dashed",
2861
+ tone: y
2862
+ }),
2863
+ /* @__PURE__ */ G(ui, {
2864
+ owner: e,
2865
+ name: "across",
2866
+ spots: [{
2867
+ x: _ + Ei,
2868
+ y: h.bottom - Ei,
2869
+ anchor: "start",
2870
+ text: x
2871
+ }, {
2872
+ x: _ - Ei,
2873
+ y: h.bottom - Ei,
2874
+ anchor: "end",
2875
+ text: x
2876
+ }],
2877
+ lines: C,
2878
+ isStrong: !0
2879
+ }),
2880
+ /* @__PURE__ */ G(ui, {
2881
+ owner: e,
2882
+ name: "up",
2883
+ spots: [{
2884
+ x: h.left + Ei,
2885
+ y: v - Di,
2886
+ anchor: "start",
2887
+ text: S
2888
+ }, {
2889
+ x: h.left + Ei,
2890
+ y: v + Oi,
2891
+ anchor: "start",
2892
+ text: S
2893
+ }],
2894
+ lines: C,
2895
+ isStrong: !0
2896
+ })
2897
+ ]
2898
+ });
2899
+ }
2900
+ // packages/teaching/src/scene/plane/scene-region.tsx
2901
+ var Ai = 3, ji = 16, Mi = 8, Ni = 4, Pi = [
2902
+ .5,
2903
+ .25,
2904
+ .75
2905
+ ];
2906
+ function Fi(e, t) {
2907
+ let { between: n, above: r, below: i, points: a } = e, o = [
2908
+ n,
2909
+ r,
2910
+ i,
2911
+ a
2912
+ ].filter((e) => e !== void 0), [s, c] = t.x, [l, u] = t.y;
2913
+ return o.length === 1 ? n === void 0 ? r === void 0 ? i === void 0 ? a ?? [] : [
2914
+ [s, l],
2915
+ [c, l],
2916
+ [c, i],
2917
+ [s, i]
2918
+ ] : [
2919
+ [s, r],
2920
+ [c, r],
2921
+ [c, u],
2922
+ [s, u]
2923
+ ] : [
2924
+ [n[0], l],
2925
+ [n[1], l],
2926
+ [n[1], u],
2927
+ [n[0], u]
2928
+ ] : [];
2929
+ }
2930
+ function Ii({ id: e, corners: t, labels: n }) {
2931
+ return t.length < Ai || t.length > Wr.polygonPoints ? q(n.regionShape, { id: e }) : t.every(([e, t]) => Number.isFinite(e) && Number.isFinite(t)) ? void 0 : q(n.notFinite, {
2932
+ kind: "region",
2933
+ id: e
2934
+ });
2935
+ }
2936
+ function Li({ id: e, between: t, above: n, below: r, points: i, label: a, text: o, tone: s, emphasis: c, isShown: l = !0, isActive: u = !1, pace: d, labels: f }) {
2937
+ let p = J(), m = b(e), h = {
2938
+ ...Hr,
2939
+ ...f
2940
+ }, g = Fi({
2941
+ between: t,
2942
+ above: n,
2943
+ below: r,
2944
+ points: i
2945
+ }, p.domain), _ = Ii({
2946
+ id: e,
2947
+ corners: g,
2948
+ labels: h
2949
+ }), y = _ === void 0 ? g : [], x = Object.fromEntries(y.flatMap(([e, t], n) => [[`cx${n}`, e], [`cy${n}`, t]])), S = ei(y.map(([e, t]) => ({
2950
+ x: e,
2951
+ y: t
2952
+ }))), [C, w] = Jr([S.x, S.y], p.domain), T = Y({
2953
+ id: e,
2954
+ kind: "region",
2955
+ frame: {
2956
+ x: C,
2957
+ y: w,
2958
+ width: 0,
2959
+ height: 0
2960
+ },
2961
+ isFloating: !0,
2962
+ values: x,
2963
+ label: a,
2964
+ isShown: l,
2965
+ isActive: u,
2966
+ emphasis: c,
2967
+ problem: _,
2968
+ pace: d
2969
+ });
2970
+ if (!p.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneRegion" });
2971
+ if (!T.isVisible || _ !== void 0) return null;
2972
+ let { values: E } = T, D = y.map((e, t) => ({
2973
+ x: p.x.position(E[`cx${t}`] ?? 0),
2974
+ y: p.y.position(E[`cy${t}`] ?? 0)
2975
+ })), O = `${ae(D)}Z`, k = {
2976
+ x: p.x.position(S.x),
2977
+ y: p.y.position(S.y)
2978
+ }, A = Math.min(...D.map((e) => e.y)), j = Math.max(...D.map((e) => e.y)), M = s ?? m ?? "neutral", N = Math.max(Math.min(...D.map((e) => e.x)), p.box.left), P = Math.min(Math.max(...D.map((e) => e.x)), p.box.right), F = [
2979
+ Math.max(A, p.box.top) + ji,
2980
+ k.y + Ni,
2981
+ Math.min(j, p.box.bottom) - Mi
2982
+ ];
2983
+ return /* @__PURE__ */ K(Mr, {
2984
+ id: e,
2985
+ layer: "back",
2986
+ opacity: E.opacity,
2987
+ children: [/* @__PURE__ */ K(v, {
2988
+ box: p.box,
2989
+ children: [/* @__PURE__ */ G(te, {
2990
+ d: O,
2991
+ tone: M,
2992
+ emphasis: T.emphasis
2993
+ }), /* @__PURE__ */ G(Nr, {
2994
+ id: e,
2995
+ d: O,
2996
+ hasLabel: a !== void 0 && l,
2997
+ isCursor: T.isCursor,
2998
+ reach: "fill"
2999
+ })]
3000
+ }), o !== void 0 && /* @__PURE__ */ G(ui, {
3001
+ owner: e,
3002
+ name: "text",
3003
+ spots: F.flatMap((e) => Pi.map((t) => ({
3004
+ x: N + (P - N) * t,
3005
+ y: e,
3006
+ anchor: "middle",
3007
+ text: o
3008
+ })))
3009
+ })]
3010
+ });
3011
+ }
3012
+ // packages/teaching/src/scene/plane/scene-rule.tsx
3013
+ var Ri = 6, zi = 14, Bi = 6, Vi = 12, Hi = [
3014
+ .75,
3015
+ .25,
3016
+ .5
3017
+ ];
3018
+ function Ui({ box: e, at: t, text: n }) {
3019
+ let r = Hi.map((t) => e.left + e.innerWidth * t);
3020
+ return [t - Ri, t + zi].flatMap((t) => [
3021
+ {
3022
+ x: e.right - Bi,
3023
+ y: t,
3024
+ anchor: "end",
3025
+ text: n
3026
+ },
3027
+ {
3028
+ x: e.left + Bi,
3029
+ y: t,
3030
+ anchor: "start",
3031
+ text: n
3032
+ },
3033
+ ...r.map((e) => ({
3034
+ x: e,
3035
+ y: t,
3036
+ anchor: "middle",
3037
+ text: n
3038
+ }))
3039
+ ]);
3040
+ }
3041
+ function Wi({ box: e, at: t, text: n }) {
3042
+ let r = Hi.map((t) => e.top + e.innerHeight * t);
3043
+ return [t + Bi, t - Bi].flatMap((i) => {
3044
+ let a = i > t ? "start" : "end";
3045
+ return [
3046
+ {
3047
+ x: i,
3048
+ y: e.top + Vi,
3049
+ anchor: a,
3050
+ text: n
3051
+ },
3052
+ {
3053
+ x: i,
3054
+ y: e.bottom - Bi,
3055
+ anchor: a,
3056
+ text: n
3057
+ },
3058
+ ...r.map((e) => ({
3059
+ x: i,
3060
+ y: e,
3061
+ anchor: a,
3062
+ text: n
3063
+ }))
3064
+ ];
3065
+ });
3066
+ }
3067
+ function Gi({ id: e, x: t, y: n, label: r, text: i, tone: a, emphasis: o, isDashed: s = !0, isShown: c = !0, isActive: l = !1, pace: u, labels: d }) {
3068
+ let f = J(), p = b(e), m = {
3069
+ ...Hr,
3070
+ ...d
3071
+ }, h = t !== void 0, g = (h ? t : n) ?? 0, _ = t === void 0 != (n === void 0), y = Number.isFinite(g), [x, S] = f.domain.x, [C, w] = f.domain.y, T = _ ? void 0 : q(m.ruleAxis, { id: e }), E = y ? void 0 : q(m.notFinite, {
3072
+ kind: "rule",
3073
+ id: e
3074
+ }), D = qr(y ? g : 0, h ? f.domain.x : f.domain.y), O = Y({
3075
+ id: e,
3076
+ kind: "rule",
3077
+ frame: h ? {
3078
+ x: D,
3079
+ y: (C + w) / 2,
3080
+ width: 0,
3081
+ height: 0
3082
+ } : {
3083
+ x: (x + S) / 2,
3084
+ y: D,
3085
+ width: 0,
3086
+ height: 0
3087
+ },
3088
+ isFloating: !0,
3089
+ values: { value: y ? g : 0 },
3090
+ label: r,
3091
+ isShown: c,
3092
+ isActive: l,
3093
+ emphasis: o,
3094
+ problem: T ?? E,
3095
+ pace: u
3096
+ });
3097
+ if (Qn({
3098
+ id: e,
3099
+ line: [h ? {
3100
+ x: O.values.value,
3101
+ y: C
3102
+ } : {
3103
+ x,
3104
+ y: O.values.value
3105
+ }, h ? {
3106
+ x: O.values.value,
3107
+ y: w
3108
+ } : {
3109
+ x: S,
3110
+ y: O.values.value
3111
+ }]
3112
+ }), !f.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneRule" });
3113
+ if (!O.isVisible || T !== void 0 || E !== void 0) return null;
3114
+ let { box: k } = f, A = O.values.value, j = h ? f.x.position(A) : f.y.position(A), M = s ? "dashed" : "solid", N = a ?? p, P = h ? {
3115
+ x1: j,
3116
+ y1: k.top,
3117
+ x2: j,
3118
+ y2: k.bottom
3119
+ } : {
3120
+ x1: k.left,
3121
+ y1: j,
3122
+ x2: k.right,
3123
+ y2: j
3124
+ }, F = ae([{
3125
+ x: P.x1,
3126
+ y: P.y1
3127
+ }, {
3128
+ x: P.x2,
3129
+ y: P.y2
3130
+ }]), I = h ? Wi : Ui;
3131
+ return /* @__PURE__ */ K(Mr, {
3132
+ id: e,
3133
+ layer: "back",
3134
+ opacity: O.values.opacity * O.strength,
3135
+ children: [/* @__PURE__ */ K(v, {
3136
+ box: k,
3137
+ children: [/* @__PURE__ */ G(B, {
3138
+ ...P,
3139
+ stroke: M,
3140
+ tone: N
3141
+ }), /* @__PURE__ */ G(Nr, {
3142
+ id: e,
3143
+ d: F,
3144
+ hasLabel: r !== void 0 && c,
3145
+ isCursor: O.isCursor
3146
+ })]
3147
+ }), i !== void 0 && /* @__PURE__ */ G(ui, {
3148
+ owner: e,
3149
+ name: "text",
3150
+ spots: I({
3151
+ box: k,
3152
+ at: j,
3153
+ text: i
3154
+ })
3155
+ })]
3156
+ });
3157
+ }
3158
+ // packages/teaching/src/scene/plane/scene-vector.tsx
3159
+ var Ki = [0, 0], qi = 10, Ji = 5, Yi = 4, Xi = 1, Zi = .5;
3160
+ function Qi(e, t) {
3161
+ let n = Math.hypot(t.x - e.x, t.y - e.y);
3162
+ return n === 0 ? {
3163
+ x: 1,
3164
+ y: 0
3165
+ } : {
3166
+ x: (t.x - e.x) / n,
3167
+ y: (t.y - e.y) / n
3168
+ };
3169
+ }
3170
+ function $i({ id: e, to: t, from: n = Ki, label: r, text: i, tone: a, emphasis: o, isDashed: s = !1, thickness: c = "regular", isShown: l = !0, isActive: u = !1, pace: d, labels: f }) {
3171
+ let p = J(), m = b(e), h = {
3172
+ ...Hr,
3173
+ ...f
3174
+ }, g = [...n, ...t].every((e) => Number.isFinite(e)), _ = g ? {
3175
+ fx: n[0],
3176
+ fy: n[1],
3177
+ tx: t[0],
3178
+ ty: t[1]
3179
+ } : {
3180
+ fx: 0,
3181
+ fy: 0,
3182
+ tx: 0,
3183
+ ty: 0
3184
+ }, [y, x] = Jr([(_.fx + _.tx) * Zi, (_.fy + _.ty) * Zi], p.domain), S = Y({
3185
+ id: e,
3186
+ kind: "vector",
3187
+ frame: {
3188
+ x: y,
3189
+ y: x,
3190
+ width: 0,
3191
+ height: 0
3192
+ },
3193
+ isFloating: !0,
3194
+ values: _,
3195
+ label: r,
3196
+ isShown: l,
3197
+ isActive: u,
3198
+ emphasis: o,
3199
+ problem: g ? void 0 : q(h.notFinite, {
3200
+ kind: "vector",
3201
+ id: e
3202
+ }),
3203
+ pace: d
3204
+ });
3205
+ if (Qn({
3206
+ id: e,
3207
+ line: S.isVisible && g ? [{
3208
+ x: S.values.fx,
3209
+ y: S.values.fy
3210
+ }, {
3211
+ x: S.values.tx,
3212
+ y: S.values.ty
3213
+ }] : []
3214
+ }), !p.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneVector" });
3215
+ if (!S.isVisible || !g) return null;
3216
+ let { values: C } = S, w = {
3217
+ x: p.x.position(C.fx),
3218
+ y: p.y.position(C.fy)
3219
+ }, T = {
3220
+ x: p.x.position(C.tx),
3221
+ y: p.y.position(C.ty)
3222
+ }, E = Qi(w, T), D = {
3223
+ x: T.x - E.x * qi,
3224
+ y: T.y - E.y * qi
3225
+ }, O = {
3226
+ x: D.x - E.y * Ji,
3227
+ y: D.y + E.x * Ji
3228
+ }, k = {
3229
+ x: D.x + E.y * Ji,
3230
+ y: D.y - E.x * Ji
3231
+ }, A = ae([w, T]), j = `${A}${ae([
3232
+ O,
3233
+ T,
3234
+ k
3235
+ ])}`, M = Gr[c] + (S.isInspected ? Xi : 0), N = a ?? m ?? "series2";
3236
+ return /* @__PURE__ */ K(Mr, {
3237
+ id: e,
3238
+ layer: "front",
3239
+ opacity: C.opacity,
3240
+ children: [/* @__PURE__ */ K(v, {
3241
+ box: p.box,
3242
+ children: [/* @__PURE__ */ G(re, {
3243
+ d: j,
3244
+ tone: N,
3245
+ width: M,
3246
+ stroke: s ? "dashed" : "solid",
3247
+ emphasis: S.emphasis
3248
+ }), /* @__PURE__ */ G(Nr, {
3249
+ id: e,
3250
+ d: A,
3251
+ hasLabel: r !== void 0 && l,
3252
+ isCursor: S.isCursor
3253
+ })]
3254
+ }), i !== void 0 && /* @__PURE__ */ G(ui, {
3255
+ owner: e,
3256
+ name: "text",
3257
+ spots: li({
3258
+ x: T.x + E.x * Yi,
3259
+ y: T.y + E.y * Yi,
3260
+ text: i
3261
+ }),
3262
+ lines: [[w, T]]
3263
+ })]
3264
+ });
3265
+ }
3266
+ // packages/teaching/src/scene/shapes/stack-book.ts
3267
+ function ea() {
3268
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = {
3269
+ isDirty: !1,
3270
+ version: 0
3271
+ };
3272
+ function i(t) {
3273
+ for (let [n, r] of e) {
3274
+ let e = r.cards.indexOf(t);
3275
+ if (e !== -1) return {
3276
+ stackId: n,
3277
+ spec: r,
3278
+ index: e
3279
+ };
3280
+ }
3281
+ }
3282
+ return {
3283
+ set: (n, i) => {
3284
+ if (i === void 0) {
3285
+ r.isDirty = e.delete(n) || r.isDirty, t.delete(n);
3286
+ return;
3287
+ }
3288
+ let a = JSON.stringify(i);
3289
+ t.get(n) !== a && (t.set(n, a), e.set(n, i), r.isDirty = !0);
3290
+ },
3291
+ flush: () => {
3292
+ if (r.isDirty) {
3293
+ r.isDirty = !1, r.version += 1;
3294
+ for (let e of n) e();
3295
+ }
3296
+ },
3297
+ slotOf: i,
3298
+ sharedCard: (t) => e.get(t)?.cards.find((e) => {
3299
+ let n = i(e);
3300
+ return n !== void 0 && n.stackId !== t;
3301
+ }),
3302
+ version: () => r.version,
3303
+ subscribe: (e) => (n.add(e), () => {
3304
+ n.delete(e);
3305
+ })
3306
+ };
3307
+ }
3308
+ var ta = je(ea), na = {
3309
+ small: {
3310
+ width: 56,
3311
+ height: 78
3312
+ },
3313
+ medium: {
3314
+ width: 84,
3315
+ height: 118
3316
+ },
3317
+ large: {
3318
+ width: 144,
3319
+ height: 202
3320
+ }
3321
+ }, ra = {
3322
+ small: 4,
3323
+ medium: 12,
3324
+ large: 24
3325
+ }, ia = {
3326
+ depthMax: 8,
3327
+ across: 1.5,
3328
+ up: 2
3329
+ }, aa = {
3330
+ overlap: .3,
3331
+ arc: 12,
3332
+ turn: 14
3333
+ }, oa = .5, sa = Math.PI / 180;
3334
+ function ca({ layout: e, count: t, size: n, gap: r, index: i }) {
3335
+ let a = na[n], o = ra[r], s = (Math.max(t, 1) - 1) * oa, c = i - s;
3336
+ switch (e) {
3337
+ case "pile": {
3338
+ let e = Math.min(i, ia.depthMax);
3339
+ return {
3340
+ offset: [e * ia.across, -e * ia.up],
3341
+ rotate: 0
3342
+ };
3343
+ }
3344
+ case "row": return {
3345
+ offset: [c * (a.width + o), 0],
3346
+ rotate: 0
3347
+ };
3348
+ case "column": return {
3349
+ offset: [0, c * (a.height + o)],
3350
+ rotate: 0
3351
+ };
3352
+ case "fan": {
3353
+ let e = s === 0 ? 0 : c / s;
3354
+ return {
3355
+ offset: [c * (a.width * aa.overlap + o), aa.arc * e * e],
3356
+ rotate: aa.turn * e
3357
+ };
3358
+ }
3359
+ }
3360
+ }
3361
+ function la(e) {
3362
+ let t = na[e.size], n = Array.from({ length: Math.max(e.count, 1) }, (n, r) => {
3363
+ let { offset: i, rotate: a } = ca({
3364
+ ...e,
3365
+ index: r
3366
+ }), o = Math.abs(Math.cos(a * sa)), s = Math.abs(Math.sin(a * sa)), c = (t.width * o + t.height * s) * oa, l = (t.width * s + t.height * o) * oa;
3367
+ return {
3368
+ left: i[0] - c,
3369
+ right: i[0] + c,
3370
+ top: i[1] - l,
3371
+ bottom: i[1] + l
3372
+ };
3373
+ }), r = Math.min(...n.map((e) => e.left)), i = Math.max(...n.map((e) => e.right)), a = Math.min(...n.map((e) => e.top)), o = Math.max(...n.map((e) => e.bottom));
3374
+ return {
3375
+ offset: [(r + i) * oa, (a + o) * oa],
3376
+ width: i - r,
3377
+ height: o - a
3378
+ };
3379
+ }
3380
+ // packages/teaching/src/scene/shapes/scene-card.tsx
3381
+ var ua = [
3382
+ "A",
3383
+ "2",
3384
+ "3",
3385
+ "4",
3386
+ "5",
3387
+ "6",
3388
+ "7",
3389
+ "8",
3390
+ "9",
3391
+ "10",
3392
+ "J",
3393
+ "Q",
3394
+ "K"
3395
+ ], da = [
3396
+ "heart",
3397
+ "diamond",
3398
+ "spade",
3399
+ "club"
3400
+ ], fa = {
3401
+ ranks: {
3402
+ A: "Ace",
3403
+ 2: "2",
3404
+ 3: "3",
3405
+ 4: "4",
3406
+ 5: "5",
3407
+ 6: "6",
3408
+ 7: "7",
3409
+ 8: "8",
3410
+ 9: "9",
3411
+ 10: "10",
3412
+ J: "Jack",
3413
+ Q: "Queen",
3414
+ K: "King"
3415
+ },
3416
+ suits: {
3417
+ heart: "Hearts",
3418
+ diamond: "Diamonds",
3419
+ spade: "Spades",
3420
+ club: "Clubs"
3421
+ },
3422
+ name: "{rank} of {suit}",
3423
+ faceDown: "A card, face down",
3424
+ noPlace: "The card \"{id}\" has no place. Give it `at`, or list it in a SceneStack declared before it."
3425
+ }, pa = {
3426
+ heart: "negative",
3427
+ diamond: "negative",
3428
+ spade: "series1",
3429
+ club: "series1"
3430
+ }, ma = {
3431
+ heart: "♥",
3432
+ diamond: "♦",
3433
+ spade: "♠",
3434
+ club: "♣"
3435
+ }, ha = 100, ga = {
3436
+ kSGwAc: "xkh2ocl",
3437
+ kzQI83: "x1iyjqo2",
3438
+ kaIpWk: "x1ok0vyi",
3439
+ kMzoRj: "xmkeg23",
3440
+ ksu8eU: "x1y0btm7",
3441
+ kVAM5u: "x6w5c0t",
3442
+ $$css: !0
3443
+ }, _a = {
3444
+ face: {
3445
+ kVAEAm: "x1n2onr6",
3446
+ kzqmXN: "xh8yej3",
3447
+ kZKoxP: "x5yr21d",
3448
+ $$css: !0
3449
+ },
3450
+ corner: {
3451
+ kVAEAm: "x10l6tqk",
3452
+ k1xSpc: "x78zum5",
3453
+ kXwgrk: "xdt5ytf",
3454
+ kGNEyG: "x6s0dn4",
3455
+ kLWn49: "xo5v014",
3456
+ kMv6JI: "x1hz01jw",
3457
+ k63SB2: "xtjd4bd",
3458
+ kcqcaj: "xss6m8b",
3459
+ $$css: !0
3460
+ },
3461
+ topLeft: {
3462
+ k87sOh: "x13vifvy",
3463
+ kbCHJM: "xu96u03",
3464
+ $$css: !0
3465
+ },
3466
+ bottomRight: {
3467
+ kCIrl2: "x3m8u43",
3468
+ krVfgx: "x1ey2m1c",
3469
+ k3aq6I: "x19jd1h0",
3470
+ $$css: !0
3471
+ },
3472
+ inkColor: (e) => [{
3473
+ kMwMTN: e == null ? e : "x14rh7hd",
3474
+ $$css: !0
3475
+ }, { "--x-color": e ?? void 0 }],
3476
+ pip: {
3477
+ kLWn49: "xo5v014",
3478
+ $$css: !0
3479
+ },
3480
+ lattice: (e) => [
3481
+ ga,
3482
+ {
3483
+ kKwaWg: [`repeating-linear-gradient(45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`, `repeating-linear-gradient(-45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`].join(", ") == null ? [`repeating-linear-gradient(45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`, `repeating-linear-gradient(-45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`].join(", ") : "x1e87kdn",
3484
+ $$css: !0
3485
+ },
3486
+ {
3487
+ "--x-backgroundImage": [`repeating-linear-gradient(45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`, `repeating-linear-gradient(-45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`].join(", ") == null ? void 0 : [`repeating-linear-gradient(45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`, `repeating-linear-gradient(-45deg, color-mix(in srgb, ${e} 45%, transparent) 0 1.5px, transparent 1.5px 7px)`].join(", "),
3488
+ "--x-borderColor": `color-mix(in srgb, ${e} 55%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 55%, transparent)`
3489
+ }
3490
+ ]
3491
+ }, va = {
3492
+ small: {
3493
+ kGuDYH: "xfifm61",
3494
+ $$css: !0
3495
+ },
3496
+ medium: {
3497
+ kGuDYH: "x1j61zf2",
3498
+ $$css: !0
3499
+ },
3500
+ large: {
3501
+ kGuDYH: "x1pvqxga",
3502
+ $$css: !0
3503
+ }
3504
+ }, ya = {
3505
+ small: {
3506
+ kGuDYH: "x1j6dyjg",
3507
+ $$css: !0
3508
+ },
3509
+ medium: {
3510
+ kGuDYH: "x1jvydc1",
3511
+ $$css: !0
3512
+ },
3513
+ large: {
3514
+ kGuDYH: "x1i1m3gp",
3515
+ $$css: !0
3516
+ }
3517
+ }, ba = {
3518
+ small: {
3519
+ kGuDYH: "x1ewwscv",
3520
+ $$css: !0
3521
+ },
3522
+ medium: {
3523
+ kGuDYH: "x102p7hv",
3524
+ $$css: !0
3525
+ },
3526
+ large: {
3527
+ kGuDYH: "xpgl8qd",
3528
+ $$css: !0
3529
+ }
3530
+ };
3531
+ function xa({ rank: e, suit: t, labels: n }) {
3532
+ return q(n.name, {
3533
+ rank: n.ranks[e],
3534
+ suit: n.suits[t]
3535
+ });
3536
+ }
3537
+ function Sa({ rank: e, suit: t, size: n, placement: r }) {
3538
+ return /* @__PURE__ */ K("span", {
3539
+ "aria-hidden": !0,
3540
+ ...V.props(_a.corner, va[n], r),
3541
+ children: [/* @__PURE__ */ G("span", { children: e }), /* @__PURE__ */ G("span", {
3542
+ ...V.props(ya[n]),
3543
+ children: ma[t]
3544
+ })]
3545
+ });
3546
+ }
3547
+ function Ca({ rank: e, suit: t, size: n, color: r, name: i, children: a }) {
3548
+ let o = a != null;
3549
+ return /* @__PURE__ */ K("div", {
3550
+ role: "img",
3551
+ "aria-label": i,
3552
+ ...V.props(_a.face, _a.inkColor(r)),
3553
+ children: [
3554
+ /* @__PURE__ */ G(Sa, {
3555
+ rank: e,
3556
+ suit: t,
3557
+ size: n,
3558
+ placement: _a.topLeft
3559
+ }),
3560
+ /* @__PURE__ */ G("div", {
3561
+ "aria-hidden": !0,
3562
+ className: "x10l6tqk x10a8y8t x78zum5 x6s0dn4 xl56j7k",
3563
+ children: o ? a : /* @__PURE__ */ G("span", {
3564
+ ...V.props(_a.pip, ba[n]),
3565
+ children: ma[t]
3566
+ })
3567
+ }),
3568
+ /* @__PURE__ */ G(Sa, {
3569
+ rank: e,
3570
+ suit: t,
3571
+ size: n,
3572
+ placement: _a.bottomRight
3573
+ })
3574
+ ]
3575
+ });
3576
+ }
3577
+ function wa({ id: e, at: t, offset: n, rotate: r, rank: i, suit: a, text: o, label: s, isFaceUp: c = !0, lift: l = 0, tilt: u = 0, size: d = "medium", tone: f, emphasis: p, isShown: m = !0, isActive: h = !1, back: g, children: _, order: v, delay: y, pace: x, labels: S }) {
3578
+ let { registry: C } = J(), w = ta(C), T = {
3579
+ ...fa,
3580
+ ...S
3581
+ }, E = b(e), D = b(a ?? "");
3582
+ ve(w.subscribe, w.version, w.version);
3583
+ let O = w.slotOf(e), k = O?.spec.size ?? d, A = O === void 0 ? void 0 : ca({
3584
+ ...O.spec,
3585
+ count: O.spec.cards.length,
3586
+ index: O.index
3587
+ });
3588
+ if (O === void 0 && t === void 0) return /* @__PURE__ */ G("span", {
3589
+ className: "xr5kp14 x1hz01jw xy8obcc",
3590
+ children: q(T.noPlace, { id: e })
3591
+ });
3592
+ let j = a === void 0 ? "neutral" : pa[a], M = f ?? E ?? D ?? j, P = i !== void 0 && a !== void 0, F = P ? xa({
3593
+ rank: i,
3594
+ suit: a,
3595
+ labels: T
3596
+ }) : o, I = s ?? (c || F === void 0 ? F : q(T.faceDown, { name: F })), L = P ? "neutral" : M, R = O !== void 0 && O.spec.layout !== "pile", ee = (O?.index ?? 0) + (R ? ha : 0);
3597
+ return /* @__PURE__ */ G(cn, {
3598
+ id: e,
3599
+ at: O?.spec.at ?? t ?? [0, 0],
3600
+ offset: A?.offset ?? n,
3601
+ rotate: A?.rotate ?? r,
3602
+ size: na[k],
3603
+ text: P ? void 0 : o,
3604
+ label: I,
3605
+ tone: M,
3606
+ emphasis: p,
3607
+ isShown: m,
3608
+ isActive: h,
3609
+ isFloating: O !== void 0,
3610
+ turn: +!c,
3611
+ lift: l,
3612
+ tilt: u,
3613
+ order: v ?? ee,
3614
+ delay: y,
3615
+ stagger: O?.spec.stagger === void 0 ? void 0 : {
3616
+ group: O.stackId,
3617
+ index: O.index,
3618
+ step: O.spec.stagger
3619
+ },
3620
+ pace: x,
3621
+ backTone: L,
3622
+ back: g ?? /* @__PURE__ */ G("div", { ...V.props(_a.lattice(N[L])) }),
3623
+ children: P ? /* @__PURE__ */ G(Ca, {
3624
+ rank: i,
3625
+ suit: a,
3626
+ size: k,
3627
+ color: N[M],
3628
+ name: F ?? "",
3629
+ children: _
3630
+ }) : _
3631
+ });
3632
+ }
3633
+ // packages/teaching/src/scene/shapes/scene-stack.tsx
3634
+ var Ta = {
3635
+ sharedCard: "The stack \"{id}\" lists the card \"{card}\", which another stack lists too. A card sits in one stack.",
3636
+ repeatedCard: "The stack \"{id}\" lists the card \"{card}\" twice."
3637
+ };
3638
+ function Ea(e) {
3639
+ return e.find((t, n) => e.indexOf(t) !== n);
3640
+ }
3641
+ function Da({ id: e, at: t, cards: n, layout: r = "pile", gap: i = "medium", size: a = "medium", stagger: o, label: s, labels: c }) {
3642
+ let l = J(), u = ta(l.registry), d = {
3643
+ ...Ta,
3644
+ ...c
3645
+ }, f = la({
3646
+ layout: r,
3647
+ count: n.length,
3648
+ size: a,
3649
+ gap: i
3650
+ }), p = u.sharedCard(e), m = Ea(n), h = [p === void 0 ? void 0 : q(d.sharedCard, {
3651
+ id: e,
3652
+ card: p
3653
+ }), m === void 0 ? void 0 : q(d.repeatedCard, {
3654
+ id: e,
3655
+ card: m
3656
+ })];
3657
+ return u.set(e, {
3658
+ at: t,
3659
+ layout: r,
3660
+ size: a,
3661
+ gap: i,
3662
+ cards: n,
3663
+ stagger: o
3664
+ }), U(() => {
3665
+ u.flush();
3666
+ }), U(() => () => {
3667
+ u.set(e, void 0), u.flush();
3668
+ }, [u, e]), Y({
3669
+ id: e,
3670
+ kind: "stack",
3671
+ frame: {
3672
+ x: t[0],
3673
+ y: t[1],
3674
+ offset: f.offset,
3675
+ width: f.width,
3676
+ height: f.height
3677
+ },
3678
+ values: {},
3679
+ label: s,
3680
+ attaches: n,
3681
+ problem: h.find((e) => e !== void 0)
3682
+ }), l.isInScene ? null : /* @__PURE__ */ G(Q, { part: "SceneStack" });
3683
+ }
3684
+ // packages/teaching/src/scene/shapes/scene-slot.tsx
3685
+ var Oa = -1, ka = 16, Aa = 20;
3686
+ function ja(e) {
3687
+ let t = na[e];
3688
+ return {
3689
+ width: t.width + ka,
3690
+ height: t.height + ka
3691
+ };
3692
+ }
3693
+ var Ma = {
3694
+ ksu8eU: "x1y0btm7",
3695
+ kWkggS: "xl8spv7",
3696
+ $$css: !0
3697
+ }, Na = {
3698
+ slot: {
3699
+ kVAEAm: "x10l6tqk",
3700
+ kbCHJM: "xu96u03",
3701
+ k87sOh: "x13vifvy",
3702
+ kY2c9j: "x8knxv4",
3703
+ kB7OPa: "x9f619",
3704
+ kfzvcC: "x67bb7w",
3705
+ kMzoRj: "xvndefy",
3706
+ ksu8eU: "xbsl7fq",
3707
+ kVAM5u: "xqrc7c3",
3708
+ kaIpWk: "xy32g2j",
3709
+ k3XXqK: "x1t137rt",
3710
+ $$css: !0
3711
+ },
3712
+ place: (e, t) => [{
3713
+ k3aq6I: e == null ? e : "xsqj5wx",
3714
+ kSiTet: t == null ? t : "xb4nw82",
3715
+ $$css: !0
3716
+ }, {
3717
+ "--x-transform": e ?? void 0,
3718
+ "--x-opacity": t ?? void 0
3719
+ }],
3720
+ box: (e, t) => [{
3721
+ kzqmXN: e == null ? e : "x5lhr3w",
3722
+ kZKoxP: t == null ? t : "x16ye13r",
3723
+ $$css: !0
3724
+ }, {
3725
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
3726
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
3727
+ }],
3728
+ active: (e) => [
3729
+ Ma,
3730
+ {
3731
+ kVAM5u: e == null ? e : "x6w5c0t",
3732
+ $$css: !0
3733
+ },
3734
+ {
3735
+ "--x-borderColor": e ?? void 0,
3736
+ "--x-backgroundColor": `color-mix(in srgb, ${e} 8%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 8%, transparent)`
3737
+ }
3738
+ ],
3739
+ gone: {
3740
+ k33iCy: "xlshs6z",
3741
+ kfzvcC: "x47corl",
3742
+ $$css: !0
3743
+ }
3744
+ };
3745
+ function Pa({ id: e, at: t, size: n = "medium", text: r, label: a, isActive: o = !1, tone: s = "neutral", emphasis: c, isShown: l = !0 }) {
3746
+ let u = typeof n == "string" ? ja(n) : n, d = Y({
3747
+ id: e,
3748
+ kind: "slot",
3749
+ frame: {
3750
+ x: t[0],
3751
+ y: t[1],
3752
+ width: u.width,
3753
+ height: u.height,
3754
+ outset: r === void 0 ? void 0 : { top: Aa }
3755
+ },
3756
+ values: {},
3757
+ label: a,
3758
+ isShown: l,
3759
+ isActive: o,
3760
+ emphasis: c,
3761
+ order: Oa
3762
+ });
3763
+ if (!d.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneSlot" });
3764
+ let { rect: f = {
3765
+ left: 0,
3766
+ top: 0,
3767
+ right: 0,
3768
+ bottom: 0
3769
+ }, values: p } = d, m = N[s], h = Math.max(0, Math.min(1, p.opacity)) * d.strength;
3770
+ return /* @__PURE__ */ G(i, {
3771
+ value: e,
3772
+ render: /* @__PURE__ */ G("div", { "data-scene-slot": e }),
3773
+ ...V.props(Na.slot, Na.place(`translate(${f.left}px, ${f.top}px)`, h), Na.box(p.width, p.height), o && Na.active(m), !d.isVisible && Na.gone, ...Kt(d)),
3774
+ children: r !== void 0 && /* @__PURE__ */ G("span", {
3775
+ "aria-hidden": !0,
3776
+ className: "x10l6tqk x17y0mx6 x10w3d4m x1cjbxdm xb3r6kr xlyipyv xuxw1ft x153jb6y x1hz01jw xy8obcc xas2l8k",
3777
+ children: r
3778
+ })
3779
+ });
3780
+ }
3781
+ // packages/teaching/src/scene/shapes/cell-color.ts
3782
+ function Fa({ value: e, palette: t, domain: n }) {
3783
+ let r = e === void 0 || e < n[0] || e > n[1];
3784
+ if (!(t === void 0 || r)) return ce(e, {
3785
+ domain: n,
3786
+ palette: t
3787
+ });
3788
+ }
3789
+ // packages/teaching/src/scene/shapes/cell-grid.ts
3790
+ var Ia = {
3791
+ small: {
3792
+ width: 40,
3793
+ height: 28
3794
+ },
3795
+ medium: {
3796
+ width: 56,
3797
+ height: 36
3798
+ },
3799
+ large: {
3800
+ width: 76,
3801
+ height: 46
3802
+ }
3803
+ }, La = 2, Ra = .5;
3804
+ function za(e) {
3805
+ return typeof e == "number" ? [e] : e;
3806
+ }
3807
+ function Ba({ values: e, cells: t, direction: n }) {
3808
+ if (t !== void 0) return t;
3809
+ let r = (e ?? []).map(za);
3810
+ return ((e ?? []).every((e) => typeof e == "number") && n === "row" ? [r.flat()] : r).map((e) => e.map((e) => ({ value: e })));
3811
+ }
3812
+ function Va({ rows: e, columns: t, size: n }) {
3813
+ let r = Ia[n];
3814
+ return {
3815
+ width: t * r.width + Math.max(t - 1, 0) * 2,
3816
+ height: e * r.height + Math.max(e - 1, 0) * 2
3817
+ };
3818
+ }
3819
+ function Ha({ row: e, column: t, rows: n, columns: r, size: i }) {
3820
+ let a = Ia[i];
3821
+ return [(t - (r - 1) * Ra) * (a.width + 2), (e - (n - 1) * Ra) * (a.height + 2)];
3822
+ }
3823
+ function Ua({ grid: e, palette: t, domain: n }) {
3824
+ if (n !== void 0) return n;
3825
+ let r = Math.max(0, ...e.flatMap((e) => e.map((e) => Math.abs(e.value ?? 0)))), i = r === 0 ? 1 : r;
3826
+ return t === "diverging" ? [-i, i] : [0, i];
3827
+ }
3828
+ // packages/teaching/src/scene/shapes/scene-cells.tsx
3829
+ var Wa = {
3830
+ cell: "{row}, {column}: {value}",
3831
+ inRow: "{column}: {value}",
3832
+ inColumn: "{row}: {value}",
3833
+ rowName: "Row {index}",
3834
+ columnName: "Column {index}",
3835
+ noCells: "The cells \"{id}\" have nothing to draw. Give `values` or `cells`.",
3836
+ ragged: "The cells \"{id}\" have rows of different lengths.",
3837
+ rowLabelCount: "The cells \"{id}\" have {count} rows but {labels} row labels.",
3838
+ columnLabelCount: "The cells \"{id}\" have {count} columns but {labels} column labels."
3839
+ }, Ga = 6, Ka = 20, qa = { maximumFractionDigits: 2 }, Ja = {
3840
+ kB7OPa: "x9f619",
3841
+ k1xSpc: "x78zum5",
3842
+ kGNEyG: "x6s0dn4",
3843
+ kjj79g: "xl56j7k",
3844
+ k7Eaqz: "xeuugli",
3845
+ kVQacm: "xb3r6kr",
3846
+ kMzoRj: "xmkeg23",
3847
+ ksu8eU: "x1y0btm7",
3848
+ kVAM5u: "x1ey3b81",
3849
+ kMwMTN: "xbixft",
3850
+ kMv6JI: "x1hz01jw",
3851
+ kGuDYH: "xtqrqnz",
3852
+ kcqcaj: "xss6m8b",
3853
+ kfzvcC: "x67bb7w",
3854
+ k3XXqK: "x1t137rt",
3855
+ $$css: !0
3856
+ }, Ya = {
3857
+ k87sOh: "xcrr8yc",
3858
+ $$css: !0
3859
+ }, Xa = {
3860
+ kbCHJM: "xgq9j65",
3861
+ k1xSpc: "x78zum5",
3862
+ kGNEyG: "x6s0dn4",
3863
+ kjj79g: "x13a6bvl",
3864
+ $$css: !0
3865
+ }, $ = {
3866
+ grid: {
3867
+ kVAEAm: "x10l6tqk",
3868
+ kbCHJM: "xu96u03",
3869
+ k87sOh: "x13vifvy",
3870
+ k1xSpc: "xrvj5dj",
3871
+ kfzvcC: "x47corl",
3872
+ $$css: !0
3873
+ },
3874
+ place: (e, t) => [{
3875
+ k3aq6I: e == null ? e : "xsqj5wx",
3876
+ kSiTet: t == null ? t : "xb4nw82",
3877
+ $$css: !0
3878
+ }, {
3879
+ "--x-transform": e ?? void 0,
3880
+ "--x-opacity": t ?? void 0
3881
+ }],
3882
+ box: (e, t) => [{
3883
+ kzqmXN: e == null ? e : "x5lhr3w",
3884
+ kZKoxP: t == null ? t : "x16ye13r",
3885
+ $$css: !0
3886
+ }, {
3887
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
3888
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
3889
+ }],
3890
+ tracks: (e, t, n) => [{
3891
+ kumcoG: e == null ? e : "xqketvx",
3892
+ kJBjZk: t == null ? t : "xhij9v2",
3893
+ kOIVth: n == null ? n : "x1pidvrl",
3894
+ $$css: !0
3895
+ }, {
3896
+ "--x-gridTemplateColumns": e ?? void 0,
3897
+ "--x-gridAutoRows": t ?? void 0,
3898
+ "--x-gap": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
3899
+ }],
3900
+ gone: {
3901
+ k33iCy: "xlshs6z",
3902
+ $$css: !0
3903
+ },
3904
+ ring: {
3905
+ kVAEAm: "x10l6tqk",
3906
+ kpwlN0: "x1y3onse",
3907
+ kfzvcC: "x47corl",
3908
+ kaIpWk: "x1ok0vyi",
3909
+ $$css: !0
3910
+ },
3911
+ cell: (e, t) => [
3912
+ Ja,
3913
+ {
3914
+ kWkggS: (e ?? P.surface) == null ? e ?? P.surface : "xl8spv7",
3915
+ kSiTet: t == null ? t : "xb4nw82",
3916
+ $$css: !0
3917
+ },
3918
+ {
3919
+ "--x-backgroundColor": (e ?? P.surface) == null ? void 0 : e ?? P.surface,
3920
+ "--x-opacity": t ?? void 0
3921
+ }
3922
+ ],
3923
+ highlighted: {
3924
+ kVAM5u: "x159tnba",
3925
+ kMzoRj: "xdh2fpr",
3926
+ $$css: !0
3927
+ },
3928
+ label: {
3929
+ kVAEAm: "x10l6tqk",
3930
+ kVQacm: "xb3r6kr",
3931
+ kg5iWk: "xlyipyv",
3932
+ khDVqt: "xuxw1ft",
3933
+ kMwMTN: "x153jb6y",
3934
+ kMv6JI: "x1hz01jw",
3935
+ kGuDYH: "xy8obcc",
3936
+ kLWn49: "xas2l8k",
3937
+ k9WMMc: "x2b8uid",
3938
+ kfzvcC: "x47corl",
3939
+ $$css: !0
3940
+ },
3941
+ columnLabel: (e, t) => [
3942
+ Ya,
3943
+ {
3944
+ kbCHJM: e == null ? e : "xgq9j65",
3945
+ kzqmXN: t == null ? t : "x5lhr3w",
3946
+ $$css: !0
3947
+ },
3948
+ {
3949
+ "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
3950
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
3951
+ }
3952
+ ],
3953
+ rowLabel: (e, t, n) => [
3954
+ Xa,
3955
+ {
3956
+ k87sOh: e == null ? e : "xjbys53",
3957
+ kZKoxP: t == null ? t : "x16ye13r",
3958
+ kzqmXN: n == null ? n : "x5lhr3w",
3959
+ $$css: !0
3960
+ },
3961
+ {
3962
+ "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
3963
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
3964
+ "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(-(n + Ga)),
3965
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
3966
+ }
3967
+ ],
3968
+ strong: {
3969
+ kMwMTN: "xbixft",
3970
+ k63SB2: "x1b5ytql",
3971
+ $$css: !0
3972
+ }
3973
+ };
3974
+ function Za({ id: e, at: t, row: n, column: r, rows: a, columns: o, cell: s, size: c, name: l, format: u, palette: d, domain: f, isHighlighted: p, isShown: m, emphasis: h }) {
3975
+ let g = Ia[c], _ = Y({
3976
+ id: e,
3977
+ kind: "cell",
3978
+ frame: {
3979
+ x: t[0],
3980
+ y: t[1],
3981
+ offset: Ha({
3982
+ row: n,
3983
+ column: r,
3984
+ rows: a,
3985
+ columns: o,
3986
+ size: c
3987
+ }),
3988
+ ...g
3989
+ },
3990
+ isFloating: !0,
3991
+ values: { value: s.value ?? 0 },
3992
+ label: s.label ?? l,
3993
+ isShown: m,
3994
+ emphasis: h
3995
+ }), v = _.values.value, y = s.text ?? (s.value === void 0 ? "" : F({
3996
+ value: v,
3997
+ locale: _.scene.locale,
3998
+ format: u
3999
+ })), b = Fa({
4000
+ value: s.value === void 0 ? void 0 : v,
4001
+ palette: d,
4002
+ domain: f
4003
+ });
4004
+ return /* @__PURE__ */ G(i, {
4005
+ value: e,
4006
+ render: /* @__PURE__ */ G("div", {
4007
+ role: "img",
4008
+ "aria-label": s.label ?? l,
4009
+ "data-scene-cell": e
4010
+ }),
4011
+ ...V.props($.cell(b, Math.max(0, Math.min(1, _.values.opacity)) * _.strength), p && $.highlighted, !_.isVisible && $.gone, ...Kt(_)),
4012
+ children: /* @__PURE__ */ G("span", {
4013
+ "aria-hidden": !0,
4014
+ children: y
4015
+ })
4016
+ });
4017
+ }
4018
+ function Qa(e) {
4019
+ let t = (e ?? []).map((e) => {
4020
+ let t = L({
4021
+ x: 0,
4022
+ y: 0,
4023
+ anchor: "start",
4024
+ text: e
4025
+ });
4026
+ return t.right - t.left;
4027
+ });
4028
+ return Math.ceil(Math.max(0, ...t));
4029
+ }
4030
+ function $a({ grid: e, props: t, labels: n }) {
4031
+ let { id: r, rowLabels: i, columnLabels: a } = t, o = e[0]?.length ?? 0;
4032
+ return e.length === 0 || o === 0 ? q(n.noCells, { id: r }) : e.some((e) => e.length !== o) ? q(n.ragged, { id: r }) : i !== void 0 && i.length !== e.length ? q(n.rowLabelCount, {
4033
+ id: r,
4034
+ count: String(e.length),
4035
+ labels: String(i.length)
4036
+ }) : a !== void 0 && a.length !== o ? q(n.columnLabelCount, {
4037
+ id: r,
4038
+ count: String(o),
4039
+ labels: String(a.length)
4040
+ }) : void 0;
4041
+ }
4042
+ function eo(e) {
4043
+ let { id: t, at: n, values: r, cells: i, direction: a = "row", format: o = qa, palette: s, domain: c } = e, { size: l = "medium", rowLabels: u, columnLabels: d, highlight: f, label: p, emphasis: m, isShown: h = !0 } = e, g = {
4044
+ ...Wa,
4045
+ ...e.labels
4046
+ }, _ = Ba({
4047
+ values: r,
4048
+ cells: i,
4049
+ direction: a
4050
+ }), v = _.length, y = _[0]?.length ?? 0, b = Va({
4051
+ rows: v,
4052
+ columns: y,
4053
+ size: l
4054
+ }), x = $a({
4055
+ grid: _,
4056
+ props: e,
4057
+ labels: g
4058
+ }), S = Qa(u), C = u === void 0 ? 0 : S + Ga, w = d === void 0 ? 0 : Ka, T = Y({
4059
+ id: t,
4060
+ kind: "cells",
4061
+ frame: {
4062
+ x: n[0],
4063
+ y: n[1],
4064
+ width: b.width,
4065
+ height: b.height,
4066
+ outset: {
4067
+ left: C,
4068
+ top: w
4069
+ }
4070
+ },
4071
+ values: {},
4072
+ label: p,
4073
+ isShown: h,
4074
+ emphasis: m,
4075
+ problem: x
4076
+ });
4077
+ if (!T.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneCells" });
4078
+ if (x !== void 0) return null;
4079
+ let { rect: E = {
4080
+ left: 0,
4081
+ top: 0,
4082
+ right: 0,
4083
+ bottom: 0
4084
+ } } = T, D = Ia[l], O = Ua({
4085
+ grid: _,
4086
+ palette: s,
4087
+ domain: c
4088
+ }), k = (d ?? []).map((e, n) => ({
4089
+ key: `${t}.column.${n}`,
4090
+ index: n,
4091
+ text: e
4092
+ })), A = (u ?? []).map((e, n) => ({
4093
+ key: `${t}.row.${n}`,
4094
+ index: n,
4095
+ text: e
4096
+ })), j = v === 1, M = y === 1;
4097
+ return /* @__PURE__ */ K("div", {
4098
+ "aria-hidden": !h || void 0,
4099
+ inert: !h,
4100
+ "data-scene-cells": t,
4101
+ ...V.props(!T.isVisible && $.gone, $.grid, $.place(`translate(${E.left}px, ${E.top}px)`, Math.max(0, Math.min(1, T.values.opacity))), $.box(b.width, b.height), $.tracks(`repeat(${y}, ${D.width}px)`, `${D.height}px`, 2)),
4102
+ children: [
4103
+ T.isInspected || T.isCursor ? /* @__PURE__ */ G("span", { ...V.props($.ring, ...Kt(T)) }) : null,
4104
+ k.map((e) => /* @__PURE__ */ G("span", {
4105
+ "aria-hidden": !0,
4106
+ ...V.props($.label, $.columnLabel(e.index * (D.width + 2), D.width), f?.column === e.index && $.strong),
4107
+ children: e.text
4108
+ }, e.key)),
4109
+ A.map((e) => /* @__PURE__ */ G("span", {
4110
+ "aria-hidden": !0,
4111
+ ...V.props($.label, $.rowLabel(e.index * (D.height + 2), D.height, S), f?.row === e.index && $.strong),
4112
+ children: e.text
4113
+ }, e.key)),
4114
+ _.flatMap((e, r) => e.map((e, i) => {
4115
+ let a = e.id ?? `${t}.${r}.${i}`, c = u?.[r] ?? q(g.rowName, { index: String(r + 1) }), p = d?.[i] ?? q(g.columnName, { index: String(i + 1) }), _ = e.text ?? (e.value === void 0 ? "" : F({
4116
+ value: e.value,
4117
+ locale: T.scene.locale,
4118
+ format: o
4119
+ })), b = j ? g.inRow : g.cell, x = q(M && !j ? g.inColumn : b, {
4120
+ row: c,
4121
+ column: p,
4122
+ value: _
4123
+ }), S = f?.row === void 0 || f.row === r, C = f?.column === void 0 || f.column === i, w = f !== void 0 && (f.row !== void 0 || f.column !== void 0);
4124
+ return /* @__PURE__ */ G(Za, {
4125
+ id: a,
4126
+ at: n,
4127
+ row: r,
4128
+ column: i,
4129
+ rows: v,
4130
+ columns: y,
4131
+ cell: e,
4132
+ size: l,
4133
+ name: x,
4134
+ format: o,
4135
+ palette: s,
4136
+ domain: O,
4137
+ isHighlighted: w && S && C,
4138
+ isShown: h,
4139
+ emphasis: m
4140
+ }, a);
4141
+ }))
4142
+ ]
4143
+ });
4144
+ }
4145
+ // packages/teaching/src/scene/shapes/token-layout.ts
4146
+ var to = 7.4, no = 16, ro = 36, io = 176, ao = 28, oo = 44, so = .5, co = {
4147
+ small: 4,
4148
+ medium: 8,
4149
+ large: 16
4150
+ };
4151
+ function lo({ text: e, caption: t }) {
4152
+ let n = Math.max(Array.from(e).length, Array.from(t ?? "").length);
4153
+ return {
4154
+ width: Math.min(io, Math.max(ro, Math.ceil(n * to + no))),
4155
+ height: t === void 0 ? ao : oo
4156
+ };
4157
+ }
4158
+ function uo(e) {
4159
+ let t = { value: 0 };
4160
+ for (let n of e) t.value += n;
4161
+ return t.value;
4162
+ }
4163
+ function fo(e, t) {
4164
+ return uo(e.map((e) => e.width)) + Math.max(e.length - 1, 0) * t;
4165
+ }
4166
+ function po({ boxes: e, wrapWidth: t, space: n }) {
4167
+ let r = {
4168
+ start: 0,
4169
+ rows: []
4170
+ };
4171
+ for (; r.start < e.length;) {
4172
+ let i = e.slice(r.start), a = i.map((e, r) => fo(i.slice(0, r + 1), n) <= t), o = a.indexOf(!1), s = Math.max(1, o === -1 ? a.length : o);
4173
+ r.rows = [...r.rows, Array.from({ length: s }, (e, t) => r.start + t)], r.start += s;
4174
+ }
4175
+ return r.rows;
4176
+ }
4177
+ function mo({ boxes: e, wrapWidth: t, gap: n }) {
4178
+ let r = co[n], i = po({
4179
+ boxes: e,
4180
+ wrapWidth: t,
4181
+ space: r
4182
+ }), a = i.map((t) => Math.max(...t.map((t) => e[t]?.height ?? 0))), o = Math.max(0, ...i.map((t) => fo(t.map((t) => e[t] ?? {
4183
+ width: 0,
4184
+ height: 0
4185
+ }), r))), s = uo(a) + Math.max(i.length - 1, 0) * r;
4186
+ return {
4187
+ offsets: e.map((t, n) => {
4188
+ let c = i.findIndex((e) => e.includes(n)), l = i[c] ?? [], u = uo(l.slice(0, l.indexOf(n)).map((t) => (e[t]?.width ?? 0) + r)), d = uo(a.slice(0, c).map((e) => e + r));
4189
+ return [u + t.width * so - o * so, d + (a[c] ?? 0) * so - s * so];
4190
+ }),
4191
+ width: o,
4192
+ height: s
4193
+ };
4194
+ }
4195
+ // packages/teaching/src/scene/shapes/scene-token.tsx
4196
+ var ho = {
4197
+ plain: "{token}",
4198
+ withProbability: "{token}, probability {probability}",
4199
+ withId: "{token}, token id {id}",
4200
+ withBoth: "{token}, token id {id}, probability {probability}"
4201
+ }, go = {
4202
+ style: "percent",
4203
+ maximumFractionDigits: 1
4204
+ }, _o = {
4205
+ kVAEAm: "x10l6tqk",
4206
+ kbCHJM: "xu96u03",
4207
+ krVfgx: "x1ey2m1c",
4208
+ kZKoxP: "xuoj239",
4209
+ kzqmXN: "x5lhr3w",
4210
+ $$css: !0
4211
+ }, vo = {
4212
+ token: {
4213
+ kVAEAm: "x10l6tqk",
4214
+ kbCHJM: "xu96u03",
4215
+ k87sOh: "x13vifvy",
4216
+ kB7OPa: "x9f619",
4217
+ k1xSpc: "x78zum5",
4218
+ kXwgrk: "xdt5ytf",
4219
+ kGNEyG: "x6s0dn4",
4220
+ kjj79g: "xl56j7k",
4221
+ kVQacm: "xb3r6kr",
4222
+ kMzoRj: "xmkeg23",
4223
+ ksu8eU: "x1y0btm7",
4224
+ kaIpWk: "x1ok0vyi",
4225
+ kWkggS: "x1r7kqkb",
4226
+ kMwMTN: "xbixft",
4227
+ kGuDYH: "xy8obcc",
4228
+ kLWn49: "xas2l8k",
4229
+ kfzvcC: "x67bb7w",
4230
+ k3XXqK: "x1t137rt",
4231
+ $$css: !0
4232
+ },
4233
+ place: (e, t) => [{
4234
+ k3aq6I: e == null ? e : "xsqj5wx",
4235
+ kSiTet: t == null ? t : "xb4nw82",
4236
+ $$css: !0
4237
+ }, {
4238
+ "--x-transform": e ?? void 0,
4239
+ "--x-opacity": t ?? void 0
4240
+ }],
4241
+ box: (e, t) => [{
4242
+ kzqmXN: e == null ? e : "x5lhr3w",
4243
+ kZKoxP: t == null ? t : "x16ye13r",
4244
+ $$css: !0
4245
+ }, {
4246
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
4247
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
4248
+ }],
4249
+ outline: (e) => [{
4250
+ kVAM5u: e == null ? e : "x6w5c0t",
4251
+ $$css: !0
4252
+ }, { "--x-borderColor": e ?? void 0 }],
4253
+ gone: {
4254
+ k33iCy: "xlshs6z",
4255
+ kfzvcC: "x47corl",
4256
+ $$css: !0
4257
+ },
4258
+ bar: (e, t) => [
4259
+ _o,
4260
+ {
4261
+ kWkggS: e == null ? e : "xl8spv7",
4262
+ $$css: !0
4263
+ },
4264
+ {
4265
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(`${t * 100}%`),
4266
+ "--x-backgroundColor": e ?? void 0
4267
+ }
4268
+ ]
4269
+ };
4270
+ function yo({ tokenId: e, probability: t }) {
4271
+ let n = [e === void 0 ? void 0 : String(e), t].filter((e) => e !== void 0);
4272
+ return n.length === 0 ? void 0 : n.join(" · ");
4273
+ }
4274
+ function bo({ id: e, at: t, offset: n, text: r, tokenId: a, probability: o, format: s = go, tone: c, label: l, emphasis: u, isShown: d = !0, isActive: f = !1, isFloating: p, labels: m }) {
4275
+ let h = {
4276
+ ...ho,
4277
+ ...m
4278
+ }, { locale: g } = J();
4279
+ function _(e) {
4280
+ return F({
4281
+ value: e,
4282
+ locale: g,
4283
+ format: s
4284
+ });
4285
+ }
4286
+ let v = lo({
4287
+ text: r,
4288
+ caption: yo({
4289
+ tokenId: a,
4290
+ probability: o === void 0 ? void 0 : _(o)
4291
+ })
4292
+ }), y = a !== void 0, b = o !== void 0, x = [
4293
+ h.plain,
4294
+ h.withId,
4295
+ h.withProbability,
4296
+ h.withBoth
4297
+ ][Number(y) + 2 * Number(b)] ?? h.plain, S = l ?? q(x, {
4298
+ token: ue(r),
4299
+ id: String(a ?? ""),
4300
+ probability: o === void 0 ? "" : _(o)
4301
+ }), C = Y({
4302
+ id: e,
4303
+ kind: "token",
4304
+ frame: {
4305
+ x: t[0],
4306
+ y: t[1],
4307
+ offset: n,
4308
+ width: v.width,
4309
+ height: v.height
4310
+ },
4311
+ isFloating: p,
4312
+ values: { probability: o ?? 0 },
4313
+ label: S,
4314
+ isShown: d,
4315
+ isActive: f,
4316
+ emphasis: u
4317
+ });
4318
+ if (!C.scene.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneToken" });
4319
+ let { rect: w = {
4320
+ left: 0,
4321
+ top: 0,
4322
+ right: 0,
4323
+ bottom: 0
4324
+ }, values: T } = C, E = yo({
4325
+ tokenId: a,
4326
+ probability: o === void 0 ? void 0 : _(T.probability)
4327
+ }), D = c === void 0 ? P.line : N[c];
4328
+ return /* @__PURE__ */ K(i, {
4329
+ value: e,
4330
+ render: /* @__PURE__ */ G("div", {
4331
+ role: "img",
4332
+ "aria-label": S,
4333
+ "data-scene-token": e,
4334
+ inert: !d
4335
+ }),
4336
+ ...V.props(vo.token, vo.place(`translate(${w.left}px, ${w.top}px)`, Math.max(0, Math.min(1, T.opacity)) * C.strength), vo.box(T.width, T.height), vo.outline(D), !C.isVisible && vo.gone, ...Kt(C)),
4337
+ children: [
4338
+ /* @__PURE__ */ G("span", {
4339
+ "aria-hidden": !0,
4340
+ className: "x193iq5w xb3r6kr xlyipyv xuxw1ft",
4341
+ children: /* @__PURE__ */ G(le, {
4342
+ text: r,
4343
+ shouldWrap: !1
4344
+ })
4345
+ }),
4346
+ E !== void 0 && /* @__PURE__ */ G("span", {
4347
+ "aria-hidden": !0,
4348
+ className: "x153jb6y xiard35 x1j6dyjg x1xxsxie xss6m8b xuxw1ft",
4349
+ children: E
4350
+ }),
4351
+ b && /* @__PURE__ */ G("span", {
4352
+ "aria-hidden": !0,
4353
+ ...V.props(vo.bar(N[c ?? "series1"], Math.max(0, Math.min(1, T.probability))))
4354
+ })
4355
+ ]
4356
+ });
4357
+ }
4358
+ // packages/teaching/src/scene/shapes/scene-tokens.tsx
4359
+ var xo = 480;
4360
+ function So({ id: e, at: t, tokens: n, wrapWidth: r = xo, gap: i = "medium", format: a, label: o, emphasis: s, isShown: c = !0 }) {
4361
+ let { locale: l } = J(), u = mo({
4362
+ boxes: n.map((e) => lo({
4363
+ text: e.text,
4364
+ caption: yo({
4365
+ tokenId: e.tokenId,
4366
+ probability: e.probability === void 0 ? void 0 : F({
4367
+ value: e.probability,
4368
+ locale: l,
4369
+ format: a ?? go
4370
+ })
4371
+ })
4372
+ })),
4373
+ wrapWidth: r,
4374
+ gap: i
4375
+ });
4376
+ return Y({
4377
+ id: e,
4378
+ kind: "tokens",
4379
+ frame: {
4380
+ x: t[0],
4381
+ y: t[1],
4382
+ width: u.width,
4383
+ height: u.height
4384
+ },
4385
+ values: {},
4386
+ label: o,
4387
+ isShown: c,
4388
+ emphasis: s
4389
+ }).scene.isInScene ? n.map((t, n) => ({
4390
+ key: `${e}.${n}`,
4391
+ token: t,
4392
+ offset: u.offsets[n]
4393
+ })).map(({ key: e, token: n, offset: r }) => /* @__PURE__ */ G(bo, {
4394
+ id: e,
4395
+ at: t,
4396
+ offset: r,
4397
+ isFloating: !0,
4398
+ text: n.text,
4399
+ tokenId: n.tokenId,
4400
+ probability: n.probability,
4401
+ format: a,
4402
+ tone: n.tone,
4403
+ label: n.label,
4404
+ emphasis: s,
4405
+ isShown: c
4406
+ }, e)) : /* @__PURE__ */ G(Q, { part: "SceneTokens" });
4407
+ }
4408
+ // packages/teaching/src/scene/flow/flow-layout.ts
4409
+ var Co = .5;
4410
+ function wo(e, t) {
4411
+ let n = {
4412
+ reached: /* @__PURE__ */ new Set(),
4413
+ pending: t
4414
+ };
4415
+ for (; n.pending.length > 0;) {
4416
+ let [t = "", ...r] = n.pending, i = !n.reached.has(t);
4417
+ n.reached = i ? /* @__PURE__ */ new Set([...n.reached, t]) : n.reached, n.pending = i ? [...r, ...e.edges.filter((e) => e.to === t).map((e) => e.from)] : r;
4418
+ }
4419
+ return n.reached;
4420
+ }
4421
+ function To(e) {
4422
+ let t = e.toSorted((e, t) => e - t), n = t[Math.floor((t.length - 1) * Co)] ?? 0;
4423
+ return (n + (t[Math.ceil((t.length - 1) * Co)] ?? n)) * Co;
4424
+ }
4425
+ function Eo(e, t) {
4426
+ let n = new Set(e.nodes.map((e) => e.name));
4427
+ return t.find((e) => !n.has(e));
4428
+ }
4429
+ function Do({ members: e, inputs: t, fractions: n }) {
4430
+ return e.map((e, r) => {
4431
+ let i = t(e.name).flatMap((e) => n.get(e) ?? []), a = i.length === 0 ? Infinity : To(i);
4432
+ return {
4433
+ name: e.name,
4434
+ index: r,
4435
+ key: a
4436
+ };
4437
+ }).toSorted((e, t) => {
4438
+ let n = e.key - t.key;
4439
+ return n === 0 || Number.isNaN(n) ? e.index - t.index : n;
4440
+ }).map((e) => e.name);
4441
+ }
4442
+ function Oo(e, t) {
4443
+ let n = t === void 0 ? void 0 : wo(e, t), r = e.nodes.filter((e) => n === void 0 || n.has(e.name)), i = new Set(r.map((e) => e.name)), a = e.edges.filter((e) => i.has(e.from) && i.has(e.to)), o = {
4444
+ depth: /* @__PURE__ */ new Map(),
4445
+ unplaced: r
4446
+ };
4447
+ function s(e) {
4448
+ return a.filter((t) => t.to === e).map((e) => e.from);
4449
+ }
4450
+ for (; o.unplaced.length > 0;) {
4451
+ let [e, ...t] = o.unplaced, n = o.depth, r = e === void 0 ? [] : s(e.name).map((e) => n.get(e) ?? 0), i = e === void 0 ? [] : [[e.name, e.kind === "param" ? 0 : 1 + Math.max(0, ...r)]];
4452
+ o.depth = new Map([...n, ...i]), o.unplaced = t;
4453
+ }
4454
+ let { depth: c } = o, l = new Map(r.map((e) => {
4455
+ let t = a.filter((t) => t.from === e.name).map((e) => c.get(e.to) ?? 1), n = c.get(e.name) ?? 0, r = t.length === 0 ? 0 : Math.max(0, Math.min(...t) - 1);
4456
+ return [e.name, e.kind === "param" ? r : n];
4457
+ })), u = 1 + Math.max(0, ...l.values()), d = {
4458
+ fractions: /* @__PURE__ */ new Map(),
4459
+ rows: /* @__PURE__ */ new Map()
4460
+ }, f = Array.from({ length: u }, (e, t) => t);
4461
+ for (; f.length > 0;) {
4462
+ let e = f.shift(), t = Do({
4463
+ members: r.filter((t) => l.get(t.name) === e),
4464
+ inputs: s,
4465
+ fractions: d.fractions
4466
+ });
4467
+ d.rows = new Map([...d.rows, ...t.map((e, t) => [e, t])]), d.fractions = new Map([...d.fractions, ...t.map((e, n) => [e, (n + Co) / t.length])]);
4468
+ }
4469
+ let p = r.map((e) => ({
4470
+ ...e,
4471
+ layer: l.get(e.name) ?? 0,
4472
+ row: d.rows.get(e.name) ?? 0
4473
+ }));
4474
+ return {
4475
+ slots: p,
4476
+ edges: a,
4477
+ layers: u,
4478
+ rows: Math.max(1, ...Array.from({ length: u }, (e, t) => p.filter((e) => e.layer === t).length))
4479
+ };
4480
+ }
4481
+ function ko({ index: e, count: t, size: n }) {
4482
+ return n <= 1 ? Co : (e + (n - t) * Co) / (n - 1);
4483
+ }
4484
+ function Ao({ plan: e, box: t, direction: n }) {
4485
+ let r = n === "across", i = r ? t.x : t.y, a = r ? t.y : t.x;
4486
+ return new Map(e.slots.map((t) => {
4487
+ let n = e.slots.filter((e) => e.layer === t.layer).length, o = ko({
4488
+ index: t.layer,
4489
+ count: e.layers,
4490
+ size: e.layers
4491
+ }), s = ko({
4492
+ index: t.row,
4493
+ count: n,
4494
+ size: e.rows
4495
+ }), c = r ? i[0] + o * (i[1] - i[0]) : i[1] - o * (i[1] - i[0]), l = r ? a[1] - s * (a[1] - a[0]) : a[0] + s * (a[1] - a[0]), u = r ? [c, l] : [l, c];
4496
+ return [t.name, u];
4497
+ }));
4498
+ }
4499
+ // packages/teaching/src/scene/flow/flow-pulse.tsx
4500
+ var jo = 3, Mo = 6, No = 10, Po = 4.5, Fo = .85, Io = .5, Lo = {
4501
+ kDwRjp: "x19zyb68",
4502
+ kfJifR: "xvlca1e",
4503
+ kfzvcC: "x47corl",
4504
+ $$css: !0
4505
+ }, Ro = {
4506
+ kjVXCG: "xaep1og",
4507
+ kfJifR: "xhr4kjn",
4508
+ kfzvcC: "x47corl",
4509
+ $$css: !0
4510
+ }, zo = {
4511
+ ring: (e, t) => [
4512
+ Lo,
4513
+ {
4514
+ kjVXCG: e == null ? e : "x6mkzkt",
4515
+ kSiTet: t == null ? t : "xb4nw82",
4516
+ $$css: !0
4517
+ },
4518
+ {
4519
+ "--x-fill": `color-mix(in srgb, ${e} 10%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 10%, transparent)`,
4520
+ "--x-stroke": e ?? void 0,
4521
+ "--x-opacity": t ?? void 0
4522
+ }
4523
+ ],
4524
+ still: {
4525
+ k5rJSQ: "x15lqr97",
4526
+ $$css: !0
4527
+ },
4528
+ dot: (e) => [
4529
+ Ro,
4530
+ {
4531
+ kDwRjp: e == null ? e : "x19zyb68",
4532
+ $$css: !0
4533
+ },
4534
+ { "--x-fill": e ?? void 0 }
4535
+ ]
4536
+ };
4537
+ function Bo(e, t) {
4538
+ return e.size === t.size && [...e].every(([e, n]) => t.get(e) === n);
4539
+ }
4540
+ function Vo(e, t) {
4541
+ let n = e - t;
4542
+ return n <= 0 || n >= 1 ? 0 : Math.sin(n * Math.PI);
4543
+ }
4544
+ function Ho({ plan: e, values: t, pace: n, tone: r }) {
4545
+ let [i] = W(() => k({ wave: 0 })), [a] = W(() => ({
4546
+ target: 0,
4547
+ end: 0
4548
+ })), [o, s] = W(null), c = _e(t), l = ve(i.subscribe, i.get, i.get), u = o === null ? [] : [...o.steps.keys()], d = et(u);
4549
+ if (U(() => {
4550
+ let r = c.current;
4551
+ c.current = t;
4552
+ let l = e.slots.filter((e) => !Object.is(r[e.name], t[e.name]));
4553
+ if (l.length === 0) return;
4554
+ let u = Math.min(...l.map((e) => e.layer)), d = new Map(l.map((e) => [e.name, e.layer - u])), f = O() || n === "instant";
4555
+ if (o !== null && !o.isStill && i.get().wave < a.end && !f && Bo(o.steps, d)) return;
4556
+ let p = e.edges.filter((e) => d.has(e.from) && d.has(e.to));
4557
+ s({
4558
+ steps: d,
4559
+ edges: p,
4560
+ isStill: f
4561
+ }), i.jump({ wave: 0 }), a.target = 0, a.end = f ? 0 : 1 + Math.max(...d.values()), f || (a.target = 1, i.to({ wave: 1 }, n));
4562
+ }), me(() => i.subscribe(() => {
4563
+ i.get().wave >= a.target && a.target < a.end && (a.target += 1, i.to({ wave: a.target }, n));
4564
+ }), [
4565
+ i,
4566
+ a,
4567
+ n
4568
+ ]), me(() => i.destroy, [i]), o === null) return null;
4569
+ let f = r === void 0 ? P.ink : N[r], p = new Map(u.flatMap((e, t) => {
4570
+ let n = d[t]?.rect;
4571
+ return n === void 0 ? [] : [[e, n]];
4572
+ })), m = u.flatMap((e) => {
4573
+ let t = p.get(e), n = o.steps.get(e) ?? 0, r = o.isStill ? Fo : Vo(l.wave, n);
4574
+ if (t === void 0 || r <= 0) return [];
4575
+ let i = mt(t, jo + (o.isStill ? 0 : Mo * r));
4576
+ return [/* @__PURE__ */ G("rect", {
4577
+ "data-flow-pulse": e,
4578
+ x: i.left,
4579
+ y: i.top,
4580
+ width: i.right - i.left,
4581
+ height: i.bottom - i.top,
4582
+ rx: No,
4583
+ ry: No,
4584
+ ...V.props(zo.ring(f, r), o.isStill && zo.still)
4585
+ }, e)];
4586
+ }), h = o.isStill ? [] : o.edges.flatMap((e) => {
4587
+ let t = p.get(e.from), n = p.get(e.to), r = o.steps.get(e.from) ?? 0, i = o.steps.get(e.to) ?? 0, a = (l.wave - r - Io) / Math.max(1, i - r);
4588
+ if (t === void 0 || n === void 0 || !(a > 0 && a < 1)) return [];
4589
+ let s = yt({
4590
+ rect: t,
4591
+ shape: "box",
4592
+ toward: Z(n)
4593
+ }), c = yt({
4594
+ rect: n,
4595
+ shape: "box",
4596
+ toward: Z(t)
4597
+ });
4598
+ return [/* @__PURE__ */ G("circle", {
4599
+ "data-flow-dot": `${e.from}>${e.to}`,
4600
+ cx: s.x + (c.x - s.x) * a,
4601
+ cy: s.y + (c.y - s.y) * a,
4602
+ r: Po,
4603
+ ...V.props(zo.dot(f))
4604
+ }, `${e.from}>${e.to}`)];
4605
+ });
4606
+ return /* @__PURE__ */ K(xe, { children: [/* @__PURE__ */ G(Ut, {
4607
+ layer: "back",
4608
+ children: m
4609
+ }), /* @__PURE__ */ G(Ut, {
4610
+ layer: "front",
4611
+ children: h
4612
+ })] });
4613
+ }
4614
+ // packages/teaching/src/scene/flow/scene-flow.tsx
4615
+ var Uo = {
4616
+ noLesson: "SceneFlow needs a Lesson around it that renders its lesson.",
4617
+ unknownName: "The flow names \"{name}\", which lesson \"{lesson}\" does not declare.",
4618
+ crowded: "The flow stacks {count} values in one column, and this plot holds {limit}. Show fewer with `names`.",
4619
+ node: "{label}: {value}",
4620
+ formula: ", {formula}",
4621
+ reads: ". Reads {names}",
4622
+ on: "on",
4623
+ off: "off"
4624
+ }, Wo = {
4625
+ width: 128,
4626
+ height: 64
4627
+ }, Go = 16, Ko = [
4628
+ "compact",
4629
+ "regular",
4630
+ "tall"
4631
+ ];
4632
+ function qo(e) {
4633
+ let t = H(S);
4634
+ return e === void 0 ? t : T(t, e);
4635
+ }
4636
+ function Jo({ param: e, value: t, locale: n, labels: r }) {
4637
+ return e.kind === "number" ? F({
4638
+ value: typeof t == "number" ? t : null,
4639
+ locale: n,
4640
+ format: e.format
4641
+ }) : e.kind === "toggle" ? t === !0 ? r.on : r.off : e.options.find((e) => e.id === t)?.label ?? String(t);
4642
+ }
4643
+ function Yo({ problem: e }) {
4644
+ return Y({
4645
+ id: "scene-flow:problem",
4646
+ kind: "flow",
4647
+ values: {},
4648
+ problem: e
4649
+ }), null;
4650
+ }
4651
+ function Xo(e, t) {
4652
+ let n = e - t - 16;
4653
+ return 1 + Math.max(0, Math.floor(n / (t + Go)));
4654
+ }
4655
+ function Zo({ scope: e, plan: t, box: n, layout: r, formula: i, size: a, tone: o, labels: s }) {
4656
+ let c = J(), { lesson: l, values: u, locale: d } = e, f = Ao({
4657
+ plan: t,
4658
+ box: n,
4659
+ direction: r
4660
+ }), p = new Map(Object.entries(l.params)), m = new Map(Object.entries(l.derived)), h = new Map(t.slots.map((e) => [e.name, e.label])), g = new Map(Object.entries(i));
4661
+ return /* @__PURE__ */ K(xe, { children: [
4662
+ t.slots.map((e) => {
4663
+ let r = p.get(e.name), i = m.get(e.name)?.format, o = u[e.name], c = r === void 0 ? F({
4664
+ value: typeof o == "number" ? o : null,
4665
+ locale: d,
4666
+ format: i ?? {}
4667
+ }) : Jo({
4668
+ param: r,
4669
+ value: o,
4670
+ locale: d,
4671
+ labels: s
4672
+ }), l = t.edges.filter((t) => t.to === e.name).map((e) => h.get(e.from) ?? ""), _ = g.get(e.name), v = [
4673
+ q(s.node, {
4674
+ label: e.label,
4675
+ value: c
4676
+ }),
4677
+ _ === void 0 ? "" : q(s.formula, { formula: _ }),
4678
+ l.length === 0 ? "" : q(s.reads, { names: l.join(", ") })
4679
+ ].join("");
4680
+ return /* @__PURE__ */ G(cn, {
4681
+ id: e.name,
4682
+ at: f.get(e.name) ?? [n.x[0], n.y[0]],
4683
+ size: a,
4684
+ text: e.label,
4685
+ label: v,
4686
+ children: r === void 0 ? /* @__PURE__ */ G("span", {
4687
+ className: "x1lliihq x2b8uid x1hz01jw xtqrqnz xss6m8b x1b5ytql xuxw1ft xb3r6kr xlyipyv",
4688
+ children: c
4689
+ }) : /* @__PURE__ */ G("span", {
4690
+ className: "x78zum5 xl56j7k x1hz01jw",
4691
+ children: /* @__PURE__ */ G(E, { name: e.name })
4692
+ })
4693
+ }, e.name);
4694
+ }),
4695
+ t.edges.map((e) => /* @__PURE__ */ G(kn, {
4696
+ from: e.from,
4697
+ to: e.to
4698
+ }, `${e.from}>${e.to}`)),
4699
+ /* @__PURE__ */ G(Ho, {
4700
+ plan: t,
4701
+ values: u,
4702
+ pace: c.pace,
4703
+ tone: o
4704
+ })
4705
+ ] });
4706
+ }
4707
+ function Qo({ lesson: e, names: t, layout: n = "across", at: r, formula: i = {}, size: a = Wo, tone: o, labels: s }) {
4708
+ let c = J(), l = qo(e), u = {
4709
+ ...Uo,
4710
+ ...s
4711
+ };
4712
+ if (!c.isInScene) return /* @__PURE__ */ G(Q, { part: "SceneFlow" });
4713
+ if (l === null) return /* @__PURE__ */ G(Yo, { problem: u.noLesson });
4714
+ let d = w(l.lesson), f = t === void 0 ? void 0 : Eo(d, t);
4715
+ if (f !== void 0) return /* @__PURE__ */ G(Yo, { problem: q(u.unknownName, {
4716
+ name: f,
4717
+ lesson: l.lesson.id
4718
+ }) });
4719
+ let p = Oo(d, t), m = r ?? c.domain, h = n === "across" ? p.rows : p.layers, g = c.box.innerHeight / (c.domain.y[1] - c.domain.y[0]), _ = Math.abs(m.y[1] - m.y[0]) * g;
4720
+ if ((h > 1 ? _ / (h - 1) : Infinity) < a.height + Go) {
4721
+ let e = 1 + Math.max(0, Math.floor(_ / (a.height + Go)));
4722
+ return /* @__PURE__ */ G(Yo, { problem: q(u.crowded, {
4723
+ count: String(h),
4724
+ limit: String(e)
4725
+ }) });
4726
+ }
4727
+ return /* @__PURE__ */ G(S, {
4728
+ value: l,
4729
+ children: /* @__PURE__ */ G(Zo, {
4730
+ scope: l,
4731
+ plan: p,
4732
+ box: m,
4733
+ layout: n,
4734
+ formula: i,
4735
+ size: a,
4736
+ tone: o,
4737
+ labels: u
4738
+ })
4739
+ });
4740
+ }
4741
+ function $o({ lesson: e, names: t, layout: n = "across", formula: r, size: i = Wo, tone: o, labels: s, title: c, height: l, children: u, ...d }) {
4742
+ let f = qo(e), p = f === null ? void 0 : Oo(w(f.lesson), t), m = p?.layers ?? 1, h = p?.rows ?? 1, g = n === "across", _ = g ? m : h, v = g ? h : m, y = Ko.find((e) => Xo(a[e], i.height) >= v) ?? "tall";
4743
+ return /* @__PURE__ */ K(Bt, {
4744
+ ...d,
4745
+ labels: s,
4746
+ title: c ?? f?.lesson.title ?? "",
4747
+ x: [0, Math.max(1, _ - 1)],
4748
+ y: [0, Math.max(1, v - 1)],
4749
+ height: l ?? y,
4750
+ children: [/* @__PURE__ */ G(Qo, {
4751
+ lesson: e,
4752
+ names: t,
4753
+ layout: n,
4754
+ formula: r,
4755
+ size: i,
4756
+ tone: o,
4757
+ labels: s
4758
+ }), u]
4759
+ });
4760
+ }
4761
+ // packages/teaching/src/scene/morph/morph-scope.tsx
4762
+ var es = { unknownFigure: "MorphScope shows \"{name}\", which is not one of its figures: {names}." }, ts = ["data-scene-node", "data-chart-mark"], ns = "[data-scene-node] [data-chart-mark], [data-scene-wire] [data-chart-mark]", rs = 1 / 3, is = {
4763
+ kJuA4N: "x15r89dc",
4764
+ k7Eaqz: "xeuugli",
4765
+ $$css: !0
4766
+ }, as = {
4767
+ kVAEAm: "x10l6tqk",
4768
+ kbCHJM: "xu96u03",
4769
+ k87sOh: "x13vifvy",
4770
+ kB7OPa: "x9f619",
4771
+ kMzoRj: "xvndefy",
4772
+ ksu8eU: "x1y0btm7",
4773
+ kaIpWk: "xy32g2j",
4774
+ kWkggS: "xl8spv7",
4775
+ $$css: !0
4776
+ }, os = {
4777
+ figure: (e) => [
4778
+ is,
4779
+ {
4780
+ kSiTet: e == null ? e : "xb4nw82",
4781
+ $$css: !0
4782
+ },
4783
+ { "--x-opacity": e ?? void 0 }
4784
+ ],
4785
+ hidden: {
4786
+ k33iCy: "xlshs6z",
4787
+ kfzvcC: "x47corl",
4788
+ $$css: !0
4789
+ },
4790
+ place: (e, t, n) => [{
4791
+ kzqmXN: t == null ? t : "x5lhr3w",
4792
+ kZKoxP: n == null ? n : "x16ye13r",
4793
+ k3aq6I: e == null ? e : "xsqj5wx",
4794
+ $$css: !0
4795
+ }, {
4796
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
4797
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n),
4798
+ "--x-transform": e ?? void 0
4799
+ }],
4800
+ ghost: (e) => [
4801
+ as,
4802
+ {
4803
+ kVAM5u: e == null ? e : "x6w5c0t",
4804
+ $$css: !0
4805
+ },
4806
+ {
4807
+ "--x-borderColor": e ?? void 0,
4808
+ "--x-backgroundColor": `color-mix(in srgb, ${e} 18%, ${P.surface})` == null ? void 0 : `color-mix(in srgb, ${e} 18%, ${P.surface})`
4809
+ }
4810
+ ],
4811
+ fade: (e) => [{
4812
+ kSiTet: e == null ? e : "xb4nw82",
4813
+ $$css: !0
4814
+ }, { "--x-opacity": e ?? void 0 }]
4815
+ };
4816
+ function ss(e) {
4817
+ return (e.right - e.left) * (e.bottom - e.top);
4818
+ }
4819
+ function cs(e, t) {
4820
+ let n = ts.map((e) => `[${e}]`).join(","), r = Array.from(e.querySelectorAll(n)).filter((e) => !e.matches(ns)).map((e) => {
4821
+ let n = ts.map((t) => e.getAttribute(t)).find((e) => e !== null) ?? "", r = e.getBoundingClientRect();
4822
+ return {
4823
+ id: n,
4824
+ rect: {
4825
+ left: r.left - t.left,
4826
+ top: r.top - t.top,
4827
+ right: r.right - t.left,
4828
+ bottom: r.bottom - t.top
4829
+ }
4830
+ };
4831
+ }).toSorted((e, t) => ss(t.rect) - ss(e.rect));
4832
+ return new Map(r.map((e) => [e.id, e.rect]));
4833
+ }
4834
+ function ls(e, t, n) {
4835
+ return e + (t - e) * n;
4836
+ }
4837
+ function us(e) {
4838
+ return Math.min(1, Math.max(0, e));
4839
+ }
4840
+ function ds({ name: e, show: t, flight: n, progress: r }) {
4841
+ return e === t ? n === null ? 1 : us((r - .6666666666666667) / rs) : n?.from === e ? us(1 - r / rs) : 0;
4842
+ }
4843
+ function fs({ name: e, opacity: t, isShown: n, setRoot: r, children: i }) {
4844
+ return /* @__PURE__ */ G("div", {
4845
+ ref: (t) => r(e, t),
4846
+ "data-morph-figure": e,
4847
+ "aria-hidden": !n || void 0,
4848
+ inert: !n,
4849
+ ...V.props(os.figure(t), t === 0 && os.hidden),
4850
+ children: i
4851
+ });
4852
+ }
4853
+ function ps({ travel: e, progress: t, tone: n }) {
4854
+ let r = b(e.id), { from: i, to: a } = e, o = ls(i.left, a.left, t), s = ls(i.top, a.top, t), c = ls(i.right - i.left, a.right - a.left, t), l = ls(i.bottom - i.top, a.bottom - a.top, t), u = us(Math.min(t, 1 - t) / rs), d = N[n ?? r ?? "neutral"];
4855
+ return /* @__PURE__ */ G("div", {
4856
+ "data-morph-ghost": e.id,
4857
+ ...V.props(os.ghost(d), os.place(`translate(${o}px, ${s}px)`, c, l), os.fade(u))
4858
+ });
4859
+ }
4860
+ function ms({ tween: e, flight: t, tones: n }) {
4861
+ let { progress: r } = ve(e.subscribe, e.get, e.get), i = new Map(Object.entries(n));
4862
+ return t === null || !(r > 0 && r < 1) ? null : /* @__PURE__ */ G("div", {
4863
+ "aria-hidden": !0,
4864
+ className: "x10l6tqk x10a8y8t xb3r6kr x47corl",
4865
+ children: t.travels.map((e) => /* @__PURE__ */ G(ps, {
4866
+ travel: e,
4867
+ progress: r,
4868
+ tone: i.get(e.id)
4869
+ }, e.id))
4870
+ });
4871
+ }
4872
+ function hs({ tween: e, flight: t, show: n, figures: r, setRoot: i }) {
4873
+ let { progress: a } = ve(e.subscribe, e.get, e.get);
4874
+ return Object.entries(r).map(([e, r]) => /* @__PURE__ */ G(fs, {
4875
+ name: e,
4876
+ opacity: ds({
4877
+ name: e,
4878
+ show: n,
4879
+ flight: t,
4880
+ progress: a
4881
+ }),
4882
+ isShown: e === n,
4883
+ setRoot: i,
4884
+ children: r
4885
+ }, e));
4886
+ }
4887
+ function gs({ figures: e, show: t, pace: n = "slow", tones: r = {}, labels: i }) {
4888
+ let a = {
4889
+ ...es,
4890
+ ...i
4891
+ }, o = _e(null), [s] = W(() => /* @__PURE__ */ new Map()), [c] = W(() => k({ progress: 1 })), [l, u] = W(null), d = _e(t), f = Object.keys(e), p = f.includes(t);
4892
+ return U(() => {
4893
+ let e = d.current, r = o.current;
4894
+ if (d.current = t, e === t || r === null) return;
4895
+ let i = r.getBoundingClientRect(), a = s.get(e), l = s.get(t), f = a === void 0 ? /* @__PURE__ */ new Map() : cs(a, i), p = l === void 0 ? /* @__PURE__ */ new Map() : cs(l, i), m = [...f].flatMap(([e, t]) => {
4896
+ let n = p.get(e);
4897
+ return n === void 0 ? [] : [{
4898
+ id: e,
4899
+ from: t,
4900
+ to: n
4901
+ }];
4902
+ });
4903
+ u({
4904
+ from: e,
4905
+ travels: m
4906
+ }), c.jump({ progress: 0 }), c.to({ progress: 1 }, n);
4907
+ }, [
4908
+ t,
4909
+ n,
4910
+ s,
4911
+ c
4912
+ ]), me(() => c.destroy, [c]), p ? /* @__PURE__ */ K("div", {
4913
+ ref: o,
4914
+ "data-morph-scope": "",
4915
+ className: "x1n2onr6 xrvj5dj xeuugli",
4916
+ children: [/* @__PURE__ */ G(hs, {
4917
+ tween: c,
4918
+ flight: l,
4919
+ show: t,
4920
+ figures: e,
4921
+ setRoot: (e, t) => {
4922
+ t === null ? s.delete(e) : s.set(e, t);
4923
+ }
4924
+ }), /* @__PURE__ */ G(ms, {
4925
+ tween: c,
4926
+ flight: l,
4927
+ tones: r
4928
+ })]
4929
+ }) : /* @__PURE__ */ G("span", {
4930
+ role: "note",
4931
+ className: "xr5kp14 x1hz01jw x1b5ytql",
4932
+ children: q(a.unknownFigure, {
4933
+ name: t,
4934
+ names: f.join(", ")
4935
+ })
4936
+ });
4937
+ }
4938
+ export { Ut as $, ra as A, Gr as B, wa as C, pa as D, fa as E, ki as F, Tr as G, Vr as H, wi as I, Ln as J, Qn as K, ai as L, $i as M, Gi as N, na as O, Li as P, Kt as Q, Ur as R, Ta as S, da as T, Ar as U, Hr as V, kr as W, cn as X, kn as Y, Wt as Z, Wa as _, Me as _t, Wo as a, Z as at, Pa as b, Ao as c, tt as ct, ho as d, J as dt, Q as et, go as f, et as ft, eo as g, Le as gt, co as h, Ie as ht, Qo as i, mt as it, ca as j, la as k, So as l, bt as lt, mo as m, q as mt, es as n, yt as nt, Uo as o, ht as ot, lo as p, Y as pt, Jn as q, $o as r, ft as rt, Oo as s, nt as st, gs as t, Bt as tt, bo as u, pt as ut, La as v, je as vt, ua as w, Da as x, Ia as y, Wr as z };