@mechane-ai/elements 0.68.0 → 0.69.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 (69) hide show
  1. package/dist/ai.js +1 -1
  2. package/dist/{article-Ni152e-v.js → article-CTSxWe4y.js} +1 -1
  3. package/dist/article.js +1 -1
  4. package/dist/catalog.json +67 -7
  5. package/dist/{categorical-values-6Iz03F1i.js → categorical-values-DwomVcSd.js} +1 -1
  6. package/dist/charts/cartesian.js +1 -1
  7. package/dist/charts/comparison.js +1 -1
  8. package/dist/charts/distribution.js +1 -1
  9. package/dist/charts/figure.js +12 -12
  10. package/dist/charts/graph.js +1 -1
  11. package/dist/charts/hierarchy.js +1 -1
  12. package/dist/charts/image.js +1 -1
  13. package/dist/charts/matrix.js +1 -1
  14. package/dist/charts/plot.js +6 -6
  15. package/dist/charts/relationship.js +1 -1
  16. package/dist/charts/text.js +1 -1
  17. package/dist/charts/timeline.js +2 -2
  18. package/dist/charts/trend.js +1 -1
  19. package/dist/charts.js +2 -2
  20. package/dist/content.js +1 -1
  21. package/dist/{dumbbell-plot-jaQvOctJ.js → dumbbell-plot-S4RyfxmW.js} +4 -4
  22. package/dist/{embedding-map-DnZL1kvY.js → embedding-map-Bm7aTA6z.js} +3 -3
  23. package/dist/{figure-frame-96zFqsWz.js → figure-frame-BHCNceS4.js} +1 -1
  24. package/dist/{image-grid-B6fdmE9c.js → image-grid-TTrLxvaI.js} +2 -2
  25. package/dist/kits/evaluation.js +3 -3
  26. package/dist/kits/interpretability.js +6 -6
  27. package/dist/kits/operations.js +3 -3
  28. package/dist/kits/research.js +801 -356
  29. package/dist/kits/training.js +2 -2
  30. package/dist/locate-Dcq5ZZSk.js +14 -0
  31. package/dist/mdx.js +2 -2
  32. package/dist/packages/charts/src/plot/index.d.ts +1 -0
  33. package/dist/packages/charts/src/plot/locate.d.ts +3 -1
  34. package/dist/packages/charts/src/plot/spatial-layer.d.ts +5 -1
  35. package/dist/packages/charts/src/plot/step-history.d.ts +13 -0
  36. package/dist/packages/content/src/timeline-scrubber.d.ts +3 -1
  37. package/dist/packages/kits/src/research/index.d.ts +8 -1
  38. package/dist/packages/kits/src/research/motion-clip.d.ts +1 -39
  39. package/dist/packages/kits/src/research/motion-figure.d.ts +4 -1
  40. package/dist/packages/kits/src/research/motion-frame.d.ts +3 -3
  41. package/dist/packages/kits/src/research/motion-inspection.d.ts +14 -0
  42. package/dist/packages/kits/src/research/motion-location.d.ts +9 -0
  43. package/dist/packages/kits/src/research/motion-scene.d.ts +9 -2
  44. package/dist/packages/kits/src/research/motion-types.d.ts +54 -0
  45. package/dist/packages/kits/src/research/motion-view.d.ts +9 -0
  46. package/dist/packages/kits/src/research/native-motion-figure.d.ts +17 -0
  47. package/dist/packages/kits/src/research/native-motion.d.ts +18 -0
  48. package/dist/plot-BIYlgY2B.js +223 -0
  49. package/dist/{plot-layout-1MG72ZWn.js → plot-layout-CNNFMC8H.js} +1 -1
  50. package/dist/{plot-surface-8-FZI94y.js → plot-surface-BSjoNIva.js} +1 -1
  51. package/dist/{reference-lines-C18o1yEY.js → reference-lines-Bet_hRyA.js} +1 -1
  52. package/dist/{scene-B8dppj5V.js → scene-C88Xkz4l.js} +4 -4
  53. package/dist/scene.js +1 -1
  54. package/dist/{slope-chart-CELflRJd.js → slope-chart-B6Mtcta2.js} +5 -5
  55. package/dist/{src-BsqbWDxS.js → src-DCozYUGI.js} +146 -131
  56. package/dist/styles2.css +4 -4
  57. package/dist/{time-series-DtAtGoT_.js → time-series-DJk-2Mt0.js} +6 -6
  58. package/dist/{timeline-CzianQir.js → timeline-BHpj7i7K.js} +3 -3
  59. package/dist/{token-heatmap-m6oaMwkK.js → token-heatmap-DEqEaoGE.js} +2 -2
  60. package/dist/{token-predictions-CpGVjOIs.js → token-predictions-Bjdh0K-A.js} +4 -4
  61. package/dist/{tree-diagram-D9ekymCQ.js → tree-diagram-BxSDOBFj.js} +3 -3
  62. package/dist/{treemap-DT8q65LQ.js → treemap-DzHAp4ia.js} +4 -4
  63. package/dist/{violin-plot-83HSjnQM.js → violin-plot-B4Cf38Y9.js} +4 -4
  64. package/dist/{waterfall-DmApvdrY.js → waterfall-C9_pHZzv.js} +3 -3
  65. package/package.json +1 -1
  66. package/skills/review-elements/SKILL.md +3 -1
  67. package/skills/use-elements/references/kits.md +10 -0
  68. package/dist/locate-Bcg3QcP4.js +0 -11
  69. package/dist/plot-CpTwLIYN.js +0 -101
@@ -2,20 +2,22 @@ import { r as e } from "../figure-format-BVb7yFCA.js";
2
2
  import { d as t, h as n, n as r, o as i } from "../src-Dc1t1ugL.js";
3
3
  import { E as a, c as o, f as s, h as c, m as l, o as u, p as d, r as f, t as p, v as m } from "../src-Bkov5TTa.js";
4
4
  import { n as h } from "../src-na2DdkKI.js";
5
- import { a as g, t as _ } from "../tree-diagram-D9ekymCQ.js";
5
+ import { a as g, t as _ } from "../tree-diagram-BxSDOBFj.js";
6
6
  import { p as v, s as y } from "../src-CIyuaSCi.js";
7
- import { p as b, u as x } from "../src-DceyVyL0.js";
8
- import { f as S } from "../time-series-DtAtGoT_.js";
9
- import { i as C, l as w, r as ee } from "../src-BsqbWDxS.js";
10
- import { n as T, r as E } from "../figure-frame-96zFqsWz.js";
11
- import { r as D } from "../tone-scope-DKiSw-JR.js";
12
- import { t as O } from "../plot-CpTwLIYN.js";
13
- import { t as te } from "../visible-motion-D6NwjGNz.js";
7
+ import { c as b, p as x, u as S } from "../src-DceyVyL0.js";
8
+ import { f as C } from "../time-series-DJk-2Mt0.js";
9
+ import { i as w, l as ee, r as T } from "../src-DCozYUGI.js";
10
+ import { n as E, r as D } from "../figure-frame-BHCNceS4.js";
11
+ import { T as O } from "../plot-layout-CNNFMC8H.js";
12
+ import { r as k } from "../tone-scope-DKiSw-JR.js";
13
+ import { n as A, t as te } from "../plot-BIYlgY2B.js";
14
+ import { t as ne } from "../visible-motion-D6NwjGNz.js";
15
+ import { t as re } from "../forms-iAOjGRTO.js";
14
16
  import "@stylexjs/stylex";
15
- import { useEffect as ne, useEffectEvent as k, useMemo as re, useState as A } from "react";
16
- import { Fragment as ie, jsx as j, jsxs as M } from "react/jsx-runtime";
17
+ import { useEffect as ie, useEffectEvent as ae, useMemo as j, useRef as M, useState as N } from "react";
18
+ import { Fragment as P, jsx as F, jsxs as I } from "react/jsx-runtime";
17
19
  // packages/kits/src/research/finding-card.tsx
18
- var N = {
20
+ var oe = {
19
21
  limitation: "Limitation",
20
22
  details: "Full notes & evidence",
21
23
  sources: "Sources",
@@ -25,58 +27,58 @@ var N = {
25
27
  falsified: "Falsified",
26
28
  open: "Open"
27
29
  }
28
- }, P = {
30
+ }, L = {
29
31
  supported: "positive",
30
32
  mixed: "warning",
31
33
  falsified: "negative",
32
34
  open: "neutral"
33
35
  };
34
- function ae({ title: t, claim: n, locale: i, status: a, index: s, limitation: u, metrics: g = [], sources: _ = [], author: v, recordedAt: y, recordedLabel: b, details: x, actions: S, labels: C }) {
36
+ function R({ title: t, claim: n, locale: i, status: a, index: s, limitation: u, metrics: g = [], sources: _ = [], author: v, recordedAt: y, recordedLabel: b, details: x, actions: S, labels: C }) {
35
37
  let w = {
36
- ...N,
38
+ ...oe,
37
39
  ...C,
38
40
  statusLabels: {
39
- ...N.statusLabels,
41
+ ...oe.statusLabels,
40
42
  ...C?.statusLabels
41
43
  }
42
44
  };
43
- return /* @__PURE__ */ j(d, {
45
+ return /* @__PURE__ */ F(d, {
44
46
  title: t,
45
47
  index: s,
46
- meta: /* @__PURE__ */ M(l, { children: [/* @__PURE__ */ j(p, {
47
- tone: P[a],
48
+ meta: /* @__PURE__ */ I(l, { children: [/* @__PURE__ */ F(p, {
49
+ tone: L[a],
48
50
  children: w.statusLabels[a]
49
51
  }), S] }),
50
- footer: v !== void 0 || y !== void 0 || _.length > 0 ? /* @__PURE__ */ M(l, {
52
+ footer: v !== void 0 || y !== void 0 || _.length > 0 ? /* @__PURE__ */ I(l, {
51
53
  shouldSpaceBetween: !0,
52
- children: [/* @__PURE__ */ M(l, { children: [v !== void 0 && /* @__PURE__ */ j(o, {
54
+ children: [/* @__PURE__ */ I(l, { children: [v !== void 0 && /* @__PURE__ */ F(o, {
53
55
  variant: "caption",
54
56
  tone: "muted",
55
57
  children: v
56
- }), y !== void 0 && /* @__PURE__ */ j(r, {
58
+ }), y !== void 0 && /* @__PURE__ */ F(r, {
57
59
  dateTime: y,
58
60
  label: b ?? y
59
- })] }), _.length > 0 && /* @__PURE__ */ M(l, { children: [/* @__PURE__ */ M(o, {
61
+ })] }), _.length > 0 && /* @__PURE__ */ I(l, { children: [/* @__PURE__ */ I(o, {
60
62
  variant: "caption",
61
63
  tone: "muted",
62
64
  children: [w.sources, ":"]
63
- }), _.map((e) => e.summary !== void 0 && e.href !== void 0 ? /* @__PURE__ */ M(h.Root, { children: [/* @__PURE__ */ j(h.Trigger, {
65
+ }), _.map((e) => e.summary !== void 0 && e.href !== void 0 ? /* @__PURE__ */ I(h.Root, { children: [/* @__PURE__ */ F(h.Trigger, {
64
66
  href: e.href,
65
- children: /* @__PURE__ */ j(f, { children: e.label })
66
- }), /* @__PURE__ */ j(h.Popup, { children: /* @__PURE__ */ M(c, {
67
+ children: /* @__PURE__ */ F(f, { children: e.label })
68
+ }), /* @__PURE__ */ F(h.Popup, { children: /* @__PURE__ */ I(c, {
67
69
  isCompact: !0,
68
- children: [/* @__PURE__ */ j(o, { children: e.label }), /* @__PURE__ */ j(o, {
70
+ children: [/* @__PURE__ */ F(o, { children: e.label }), /* @__PURE__ */ F(o, {
69
71
  variant: "caption",
70
72
  tone: "muted",
71
73
  children: e.summary
72
74
  })]
73
- }) })] }, e.id) : /* @__PURE__ */ j(f, { children: e.label }, e.id))] })]
75
+ }) })] }, e.id) : /* @__PURE__ */ F(f, { children: e.label }, e.id))] })]
74
76
  }) : void 0,
75
- children: /* @__PURE__ */ M(c, {
77
+ children: /* @__PURE__ */ I(c, {
76
78
  isCompact: !0,
77
79
  children: [
78
- /* @__PURE__ */ j(o, { children: n }),
79
- g.length > 0 && /* @__PURE__ */ j(l, { children: g.map((t) => /* @__PURE__ */ M(p, {
80
+ /* @__PURE__ */ F(o, { children: n }),
81
+ g.length > 0 && /* @__PURE__ */ F(l, { children: g.map((t) => /* @__PURE__ */ I(p, {
80
82
  tone: t.tone ?? "neutral",
81
83
  children: [
82
84
  t.label,
@@ -88,7 +90,7 @@ function ae({ title: t, claim: n, locale: i, status: a, index: s, limitation: u,
88
90
  })
89
91
  ]
90
92
  }, t.label)) }),
91
- u !== void 0 && /* @__PURE__ */ M(o, {
93
+ u !== void 0 && /* @__PURE__ */ I(o, {
92
94
  variant: "caption",
93
95
  tone: "muted",
94
96
  children: [
@@ -97,28 +99,28 @@ function ae({ title: t, claim: n, locale: i, status: a, index: s, limitation: u,
97
99
  u
98
100
  ]
99
101
  }),
100
- x !== void 0 && /* @__PURE__ */ M(m.Root, { children: [/* @__PURE__ */ j(m.Trigger, {
102
+ x !== void 0 && /* @__PURE__ */ I(m.Root, { children: [/* @__PURE__ */ F(m.Trigger, {
101
103
  variant: "inline",
102
104
  children: w.details
103
- }), /* @__PURE__ */ j(m.Panel, { children: x })] })
105
+ }), /* @__PURE__ */ F(m.Panel, { children: x })] })
104
106
  ]
105
107
  })
106
108
  });
107
109
  }
108
110
  // packages/kits/src/research/lineage-graph.tsx
109
- var oe = 152, se = 56, ce = 32, F = 12, I = 16, L = 32, le = 16, ue = 16, R = 12, de = 640, z = 240, fe = 64, B = "General", pe = {
111
+ var z = 152, B = 56, se = 32, ce = 12, V = 16, le = 32, H = 16, ue = 16, de = 12, fe = 640, pe = 240, me = 64, he = "General", ge = {
110
112
  baseline: "series5",
111
113
  milestone: "positive",
112
114
  branch: "series1",
113
115
  merge: "series3",
114
116
  killed: "negative"
115
- }, me = {
117
+ }, _e = {
116
118
  baseline: "neutral",
117
119
  milestone: "positive",
118
120
  branch: "neutral",
119
121
  merge: "warning",
120
122
  killed: "negative"
121
- }, V = {
123
+ }, ve = {
122
124
  frontier: "Frontier",
123
125
  all: "All",
124
126
  metric: "Score",
@@ -135,7 +137,7 @@ var oe = 152, se = 56, ce = 32, F = 12, I = 16, L = 32, le = 16, ue = 16, R = 12
135
137
  killed: "Killed"
136
138
  }
137
139
  };
138
- function he(e, t, n) {
140
+ function ye(e, t, n) {
139
141
  let r = t.get(e.id) ?? 0;
140
142
  for (let i of e.parentIds) if (n.has(i)) {
141
143
  let e = (t.get(i) ?? 0) + 1;
@@ -143,13 +145,13 @@ function he(e, t, n) {
143
145
  }
144
146
  return r;
145
147
  }
146
- function ge(e) {
148
+ function be(e) {
147
149
  let t = /* @__PURE__ */ new Map(), n = new Set(e.map((e) => e.id));
148
150
  for (let n of e) t.set(n.id, 0);
149
- for (let r = 0; r < fe; r += 1) {
151
+ for (let r = 0; r < me; r += 1) {
150
152
  let r = [];
151
153
  for (let i of e) {
152
- let e = he(i, t, n);
154
+ let e = ye(i, t, n);
153
155
  e !== t.get(i.id) && r.push([i.id, e]);
154
156
  }
155
157
  if (r.length === 0) break;
@@ -157,7 +159,7 @@ function ge(e) {
157
159
  }
158
160
  return t;
159
161
  }
160
- function _e(e) {
162
+ function xe(e) {
161
163
  let t = /* @__PURE__ */ new Set(), n = new Map(e.map((e) => [e.id, e]));
162
164
  function r(e) {
163
165
  if (t.has(e)) return;
@@ -168,7 +170,7 @@ function _e(e) {
168
170
  for (let t of e) t.kind !== "killed" && r(t.id);
169
171
  return e.filter((e) => t.has(e.id));
170
172
  }
171
- function ve({ node: t, locale: n, valueFormat: r, deltaFormat: i }) {
173
+ function Se({ node: t, locale: n, valueFormat: r, deltaFormat: i }) {
172
174
  let a = [];
173
175
  if (t.metric !== null && t.metric !== void 0 && a.push(r === void 0 ? String(t.metric) : e({
174
176
  value: t.metric,
@@ -184,34 +186,34 @@ function ve({ node: t, locale: n, valueFormat: r, deltaFormat: i }) {
184
186
  }
185
187
  return t.caption === void 0 ? a.length > 0 ? a.join(" · ") : t.summary : t.caption;
186
188
  }
187
- function ye(e) {
188
- let t = ge(e), n = /* @__PURE__ */ new Map();
189
+ function Ce(e) {
190
+ let t = be(e), n = /* @__PURE__ */ new Map();
189
191
  for (let r of e) n.set(r.id, r.column ?? t.get(r.id) ?? 0);
190
192
  return n;
191
193
  }
192
- function be({ nodes: e, locale: t, valueFormat: n, deltaFormat: r }) {
193
- let i = ye(e), a = Math.max(0, ...Array.from(i.values())), o = e.some((e) => e.lane !== void 0), s = [];
194
+ function we({ nodes: e, locale: t, valueFormat: n, deltaFormat: r }) {
195
+ let i = Ce(e), a = Math.max(0, ...Array.from(i.values())), o = e.some((e) => e.lane !== void 0), s = [];
194
196
  if (o) for (let t of e) {
195
- let e = t.lane ?? B;
197
+ let e = t.lane ?? he;
196
198
  s.includes(e) || s.push(e);
197
199
  }
198
- else s.push(B);
199
- let c = (a + 1) * oe + a * ce, l = [], u = [], d = I;
200
+ else s.push(he);
201
+ let c = (a + 1) * z + a * se, l = [], u = [], d = V;
200
202
  for (let a of s) {
201
- let s = o ? e.filter((e) => (e.lane ?? B) === a) : e, f = /* @__PURE__ */ new Map();
203
+ let s = o ? e.filter((e) => (e.lane ?? he) === a) : e, f = /* @__PURE__ */ new Map();
202
204
  for (let e of s) {
203
205
  let t = i.get(e.id) ?? 0, n = f.get(t) ?? [];
204
206
  n.push(e), f.set(t, n);
205
207
  }
206
- let p = Math.max(1, ...Array.from(f.values(), (e) => e.length)), m = p * se + (p - 1) * F, h = d, g = o ? h + L : h, _ = o ? L + m + le : m;
208
+ let p = Math.max(1, ...Array.from(f.values(), (e) => e.length)), m = p * B + (p - 1) * ce, h = d, g = o ? h + le : h, _ = o ? le + m + H : m;
207
209
  for (let [e, i] of f.entries()) {
208
- let a = I + (o ? ue : 0) + e * 184;
210
+ let a = V + (o ? ue : 0) + e * 184;
209
211
  for (let [e, o] of i.entries()) {
210
212
  let i = g + e * 68;
211
213
  l.push({
212
214
  id: o.id,
213
215
  label: o.label,
214
- description: ve({
216
+ description: Se({
215
217
  node: o,
216
218
  locale: t,
217
219
  valueFormat: n,
@@ -219,21 +221,21 @@ function be({ nodes: e, locale: t, valueFormat: n, deltaFormat: r }) {
219
221
  }),
220
222
  x: a,
221
223
  y: i,
222
- width: oe,
223
- height: se,
224
- tone: pe[o.kind]
224
+ width: z,
225
+ height: B,
226
+ tone: ge[o.kind]
225
227
  });
226
228
  }
227
229
  }
228
230
  o && u.push({
229
231
  id: `lane:${a}`,
230
232
  label: a,
231
- x: I,
233
+ x: V,
232
234
  y: h,
233
235
  width: c + 32,
234
236
  height: _,
235
237
  nodeIds: s.map((e) => e.id)
236
- }), d = h + _ + (o ? R : F);
238
+ }), d = h + _ + (o ? de : ce);
237
239
  }
238
240
  let f = new Set(e.map((e) => e.id)), p = [];
239
241
  for (let t of e) for (let e of t.parentIds) f.has(e) && p.push({
@@ -248,79 +250,79 @@ function be({ nodes: e, locale: t, valueFormat: n, deltaFormat: r }) {
248
250
  relationEdges: p,
249
251
  relationGroups: u,
250
252
  width: c + 32 + (o ? 32 : 0),
251
- height: Math.max(z, d + I - (o ? R : F))
253
+ height: Math.max(pe, d + V - (o ? de : ce))
252
254
  };
253
255
  }
254
- function xe({ node: e, labels: t, detailItems: n }) {
255
- return /* @__PURE__ */ M(c, {
256
+ function Te({ node: e, labels: t, detailItems: n }) {
257
+ return /* @__PURE__ */ I(c, {
256
258
  isCompact: !0,
257
259
  children: [
258
- /* @__PURE__ */ j(s, {}),
259
- /* @__PURE__ */ M(l, {
260
+ /* @__PURE__ */ F(s, {}),
261
+ /* @__PURE__ */ I(l, {
260
262
  shouldSpaceBetween: !0,
261
- children: [/* @__PURE__ */ M(l, { children: [/* @__PURE__ */ j(o, { children: /* @__PURE__ */ j("strong", { children: e.label }) }), e.timestamp === void 0 ? null : /* @__PURE__ */ j(p, {
263
+ children: [/* @__PURE__ */ I(l, { children: [/* @__PURE__ */ F(o, { children: /* @__PURE__ */ F("strong", { children: e.label }) }), e.timestamp === void 0 ? null : /* @__PURE__ */ F(p, {
262
264
  tone: "neutral",
263
265
  children: e.timestamp
264
- })] }), /* @__PURE__ */ j(p, {
265
- tone: me[e.kind],
266
+ })] }), /* @__PURE__ */ F(p, {
267
+ tone: _e[e.kind],
266
268
  children: t.kinds[e.kind]
267
269
  })]
268
270
  }),
269
- e.summary === void 0 ? null : /* @__PURE__ */ j(o, { children: e.summary }),
270
- e.detail === void 0 ? null : /* @__PURE__ */ j(o, {
271
+ e.summary === void 0 ? null : /* @__PURE__ */ F(o, { children: e.summary }),
272
+ e.detail === void 0 ? null : /* @__PURE__ */ F(o, {
271
273
  tone: "muted",
272
274
  children: e.detail
273
275
  }),
274
- n.length === 0 ? null : /* @__PURE__ */ j(i, { items: n })
276
+ n.length === 0 ? null : /* @__PURE__ */ F(i, { items: n })
275
277
  ]
276
278
  });
277
279
  }
278
- function Se({ nodes: t, valueLabel: n, valueFormat: r, deltaFormat: i, defaultScope: a = "frontier", selected: o, onSelectedChange: s, labels: l, actions: d, ...f }) {
279
- let [p, m] = A(a), [h, _] = A(null), y = {
280
- ...V,
280
+ function Ee({ nodes: t, valueLabel: n, valueFormat: r, deltaFormat: i, defaultScope: a = "frontier", selected: o, onSelectedChange: s, labels: l, actions: d, ...f }) {
281
+ let [p, m] = N(a), [h, _] = N(null), y = {
282
+ ...ve,
281
283
  ...l,
282
284
  kinds: {
283
- ...V.kinds,
285
+ ...ve.kinds,
284
286
  ...l?.kinds
285
287
  }
286
288
  };
287
- if (f.status === "loading") return /* @__PURE__ */ j(g, {
289
+ if (f.status === "loading") return /* @__PURE__ */ F(g, {
288
290
  ...f,
289
291
  nodes: [],
290
292
  edges: [],
291
- width: de,
292
- height: z
293
+ width: fe,
294
+ height: pe
293
295
  });
294
- if (t.length === 0) return /* @__PURE__ */ j(v, {
296
+ if (t.length === 0) return /* @__PURE__ */ F(v, {
295
297
  title: f.title,
296
298
  children: y.empty
297
299
  });
298
- if (new Set(t.map((e) => e.id)).size !== t.length) return /* @__PURE__ */ j(u, {
300
+ if (new Set(t.map((e) => e.id)).size !== t.length) return /* @__PURE__ */ F(u, {
299
301
  tone: "negative",
300
302
  role: "alert",
301
303
  children: "Lineage nodes must have unique identifiers."
302
304
  });
303
- let b = _e(t), S = b.length < t.length, C = p === "frontier" && S ? b : t, w = o === void 0 ? h : o;
305
+ let b = xe(t), x = b.length < t.length, C = p === "frontier" && x ? b : t, w = o === void 0 ? h : o;
304
306
  function ee(e, t) {
305
307
  o === void 0 && _(e), s?.(e, t);
306
308
  }
307
- let T = be({
309
+ let T = we({
308
310
  nodes: C,
309
311
  locale: f.locale,
310
312
  valueFormat: r,
311
313
  deltaFormat: i
312
- }), E = w === null ? void 0 : C.find((e) => e.id === w), D = new Map(t.map((e) => [e.id, e])), O = S ? /* @__PURE__ */ M(ie, { children: [/* @__PURE__ */ M(x.Root, {
314
+ }), E = w === null ? void 0 : C.find((e) => e.id === w), D = new Map(t.map((e) => [e.id, e])), O = x ? /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ I(S.Root, {
313
315
  "aria-label": `${f.title} scope`,
314
316
  value: p,
315
317
  onValueChange: (e) => m(e === "all" ? "all" : "frontier"),
316
- children: [/* @__PURE__ */ j(x.Item, {
318
+ children: [/* @__PURE__ */ F(S.Item, {
317
319
  value: "frontier",
318
320
  children: `${y.frontier} (${b.length})`
319
- }), /* @__PURE__ */ j(x.Item, {
321
+ }), /* @__PURE__ */ F(S.Item, {
320
322
  value: "all",
321
323
  children: `${y.all} (${t.length})`
322
324
  })]
323
- }), d] }) : d, te = E === void 0 ? [] : [
325
+ }), d] }) : d, k = E === void 0 ? [] : [
324
326
  ...E.lane === void 0 ? [] : [{
325
327
  label: y.lane,
326
328
  value: E.lane
@@ -350,7 +352,7 @@ function Se({ nodes: t, valueLabel: n, valueFormat: r, deltaFormat: i, defaultSc
350
352
  value: E.source
351
353
  }]
352
354
  ];
353
- return /* @__PURE__ */ M(c, { children: [/* @__PURE__ */ j(g, {
355
+ return /* @__PURE__ */ I(c, { children: [/* @__PURE__ */ F(g, {
354
356
  ...f,
355
357
  actions: O,
356
358
  nodes: T.relationNodes,
@@ -360,26 +362,26 @@ function Se({ nodes: t, valueLabel: n, valueFormat: r, deltaFormat: i, defaultSc
360
362
  height: T.height,
361
363
  selected: w,
362
364
  onSelectedChange: ee
363
- }), E === void 0 ? null : /* @__PURE__ */ j(xe, {
365
+ }), E === void 0 ? null : /* @__PURE__ */ F(Te, {
364
366
  node: E,
365
367
  labels: y,
366
- detailItems: te
368
+ detailItems: k
367
369
  })] });
368
370
  }
369
371
  // packages/kits/src/research/milestone-path.tsx
370
- var H = {
372
+ var De = {
371
373
  baseline: "series5",
372
374
  result: "series1",
373
375
  breakthrough: "positive",
374
376
  counterexample: "negative",
375
377
  decision: "series3"
376
- }, Ce = {
378
+ }, Oe = {
377
379
  baseline: "neutral",
378
380
  result: "neutral",
379
381
  breakthrough: "positive",
380
382
  counterexample: "negative",
381
383
  decision: "warning"
382
- }, we = {
384
+ }, ke = {
383
385
  metric: "Score",
384
386
  delta: "Change",
385
387
  limitation: "Limitation",
@@ -393,16 +395,16 @@ var H = {
393
395
  decision: "Decision"
394
396
  }
395
397
  };
396
- function Te({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, selected: d, onSelectedChange: f, labels: m, ...h }) {
398
+ function Ae({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, selected: d, onSelectedChange: f, labels: m, ...h }) {
397
399
  let g = {
398
- ...we,
400
+ ...ke,
399
401
  ...m,
400
402
  kinds: {
401
- ...we.kinds,
403
+ ...ke.kinds,
402
404
  ...m?.kinds
403
405
  }
404
406
  };
405
- if (h.status === "loading") return /* @__PURE__ */ j(_, {
407
+ if (h.status === "loading") return /* @__PURE__ */ F(_, {
406
408
  ...h,
407
409
  nodes: [],
408
410
  direction: "right",
@@ -410,16 +412,16 @@ function Te({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, sele
410
412
  valueLabel: n,
411
413
  valueFormat: r
412
414
  });
413
- if (t.length === 0) return /* @__PURE__ */ j(v, {
415
+ if (t.length === 0) return /* @__PURE__ */ F(v, {
414
416
  title: h.title,
415
417
  children: g.empty
416
418
  });
417
- if (new Set(t.map((e) => e.id)).size !== t.length) return /* @__PURE__ */ j(u, {
419
+ if (new Set(t.map((e) => e.id)).size !== t.length) return /* @__PURE__ */ F(u, {
418
420
  tone: "negative",
419
421
  role: "alert",
420
422
  children: "Milestones must have unique identifiers."
421
423
  });
422
- if (t.filter((e) => e.parentId === null).length !== 1) return /* @__PURE__ */ j(u, {
424
+ if (t.filter((e) => e.parentId === null).length !== 1) return /* @__PURE__ */ F(u, {
423
425
  tone: "negative",
424
426
  role: "alert",
425
427
  children: "MilestonePath requires exactly one root milestone (parentId: null)."
@@ -430,13 +432,13 @@ function Te({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, sele
430
432
  label: e.label,
431
433
  detail: e.wave === void 0 ? g.kinds[e.kind] : `${e.wave} · ${g.kinds[e.kind]}`,
432
434
  value: e.metric ?? null,
433
- tone: H[e.kind]
435
+ tone: De[e.kind]
434
436
  })), b = Array.from(new Set(t.map((e) => e.kind))).map((e) => ({
435
437
  id: e,
436
438
  label: g.kinds[e],
437
- tone: H[e]
439
+ tone: De[e]
438
440
  })), x = t.find((e) => e.id === d) ?? null;
439
- return /* @__PURE__ */ M(c, { children: [/* @__PURE__ */ j(_, {
441
+ return /* @__PURE__ */ I(c, { children: [/* @__PURE__ */ F(_, {
440
442
  ...h,
441
443
  nodes: y,
442
444
  direction: "right",
@@ -446,25 +448,25 @@ function Te({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, sele
446
448
  toneLegend: b,
447
449
  selected: d,
448
450
  onSelectedChange: f
449
- }), x !== null && /* @__PURE__ */ M(c, {
451
+ }), x !== null && /* @__PURE__ */ I(c, {
450
452
  isCompact: !0,
451
453
  children: [
452
- /* @__PURE__ */ j(s, {}),
453
- /* @__PURE__ */ M(l, {
454
+ /* @__PURE__ */ F(s, {}),
455
+ /* @__PURE__ */ I(l, {
454
456
  shouldSpaceBetween: !0,
455
- children: [/* @__PURE__ */ M(l, { children: [x.wave !== void 0 && /* @__PURE__ */ j(p, {
457
+ children: [/* @__PURE__ */ I(l, { children: [x.wave !== void 0 && /* @__PURE__ */ F(p, {
456
458
  tone: "neutral",
457
459
  children: x.wave
458
- }), /* @__PURE__ */ j(o, { children: /* @__PURE__ */ j("strong", { children: x.label }) })] }), /* @__PURE__ */ j(p, {
459
- tone: Ce[x.kind],
460
+ }), /* @__PURE__ */ F(o, { children: /* @__PURE__ */ F("strong", { children: x.label }) })] }), /* @__PURE__ */ F(p, {
461
+ tone: Oe[x.kind],
460
462
  children: g.kinds[x.kind]
461
463
  })]
462
464
  }),
463
- /* @__PURE__ */ j(o, {
465
+ /* @__PURE__ */ F(o, {
464
466
  tone: "muted",
465
467
  children: x.claim
466
468
  }),
467
- /* @__PURE__ */ j(i, { items: [
469
+ /* @__PURE__ */ F(i, { items: [
468
470
  ...x.metric === void 0 ? [] : [{
469
471
  label: g.metric,
470
472
  value: e({
@@ -494,7 +496,7 @@ function Te({ milestones: t, valueLabel: n, valueFormat: r, deltaFormat: a, sele
494
496
  })] });
495
497
  }
496
498
  // packages/kits/src/research/specimen-diff.tsx
497
- var Ee = {
499
+ var je = {
498
500
  breakdownTitle: "Paired outcome flips",
499
501
  all: "All",
500
502
  gained: "Gained",
@@ -507,26 +509,26 @@ var Ee = {
507
509
  candidate: "Candidate",
508
510
  outcome: "Outcome",
509
511
  empty: "No paired specimens available for these two runs."
510
- }, De = {
512
+ }, Me = {
511
513
  gained: "positive",
512
514
  regressed: "negative",
513
515
  both_pass: "neutral",
514
516
  both_fail: "neutral"
515
- }, Oe = /* @__PURE__ */ new Set([
517
+ }, Ne = /* @__PURE__ */ new Set([
516
518
  "gained",
517
519
  "regressed",
518
520
  "both_pass",
519
521
  "both_fail"
520
522
  ]);
521
- function ke(e) {
522
- return e !== null && Oe.has(e);
523
+ function Pe(e) {
524
+ return e !== null && Ne.has(e);
523
525
  }
524
- function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterChange: s, onSelectRow: l, labels: u, ...d }) {
526
+ function Fe({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterChange: s, onSelectRow: l, labels: u, ...d }) {
525
527
  let m = {
526
- ...Ee,
528
+ ...je,
527
529
  ...u
528
530
  };
529
- if (e.length === 0) return /* @__PURE__ */ j(v, {
531
+ if (e.length === 0) return /* @__PURE__ */ F(v, {
530
532
  title: d.title,
531
533
  children: m.empty
532
534
  });
@@ -547,7 +549,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
547
549
  id: "specimen",
548
550
  label: m.specimen,
549
551
  role: "primary",
550
- cell: (e) => /* @__PURE__ */ j(t, {
552
+ cell: (e) => /* @__PURE__ */ F(t, {
551
553
  secondary: e.family,
552
554
  children: e.prompt
553
555
  })
@@ -556,16 +558,16 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
556
558
  id: "expected",
557
559
  label: m.expected,
558
560
  role: "text",
559
- cell: (e) => /* @__PURE__ */ j(f, { children: e.expected })
561
+ cell: (e) => /* @__PURE__ */ F(f, { children: e.expected })
560
562
  },
561
563
  {
562
564
  id: "baseline",
563
565
  label: r.trim() === "" ? m.baseline : r,
564
566
  role: "text",
565
567
  isSecondary: !0,
566
- cell: (e) => /* @__PURE__ */ j(o, {
568
+ cell: (e) => /* @__PURE__ */ F(o, {
567
569
  variant: "mono",
568
- children: /* @__PURE__ */ j(C, {
570
+ children: /* @__PURE__ */ F(w, {
569
571
  text: e.baselineOutput,
570
572
  query: e.expected,
571
573
  tone: "accent"
@@ -576,9 +578,9 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
576
578
  id: "candidate",
577
579
  label: i.trim() === "" ? m.candidate : i,
578
580
  role: "text",
579
- cell: (e) => /* @__PURE__ */ j(o, {
581
+ cell: (e) => /* @__PURE__ */ F(o, {
580
582
  variant: "mono",
581
- children: /* @__PURE__ */ j(C, {
583
+ children: /* @__PURE__ */ F(w, {
582
584
  text: e.candidateOutput,
583
585
  query: e.expected,
584
586
  tone: "accent"
@@ -589,16 +591,16 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
589
591
  id: "outcome",
590
592
  label: m.outcome,
591
593
  role: "status",
592
- cell: (e) => /* @__PURE__ */ j(p, {
593
- tone: De[e.outcome],
594
+ cell: (e) => /* @__PURE__ */ F(p, {
595
+ tone: Me[e.outcome],
594
596
  children: _[e.outcome]
595
597
  })
596
598
  }
597
599
  ];
598
- return /* @__PURE__ */ M(c, {
600
+ return /* @__PURE__ */ I(c, {
599
601
  isCompact: !0,
600
602
  children: [
601
- /* @__PURE__ */ j(S, {
603
+ /* @__PURE__ */ F(C, {
602
604
  title: m.breakdownTitle,
603
605
  description: d.description,
604
606
  locale: d.locale,
@@ -634,17 +636,17 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
634
636
  ],
635
637
  selected: a === "all" ? null : a,
636
638
  onSelectedChange: (e) => {
637
- ke(e) ? s(e === a ? "all" : e) : s("all");
639
+ Pe(e) ? s(e === a ? "all" : e) : s("all");
638
640
  }
639
641
  }),
640
- /* @__PURE__ */ M(x.Root, {
642
+ /* @__PURE__ */ I(S.Root, {
641
643
  "aria-label": m.outcome,
642
644
  value: a,
643
645
  onValueChange: (e) => {
644
646
  s(e);
645
647
  },
646
648
  children: [
647
- /* @__PURE__ */ M(x.Item, {
649
+ /* @__PURE__ */ I(S.Item, {
648
650
  value: "all",
649
651
  children: [
650
652
  m.all,
@@ -653,7 +655,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
653
655
  ")"
654
656
  ]
655
657
  }),
656
- /* @__PURE__ */ M(x.Item, {
658
+ /* @__PURE__ */ I(S.Item, {
657
659
  value: "gained",
658
660
  children: [
659
661
  m.gained,
@@ -662,7 +664,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
662
664
  ")"
663
665
  ]
664
666
  }),
665
- /* @__PURE__ */ M(x.Item, {
667
+ /* @__PURE__ */ I(S.Item, {
666
668
  value: "regressed",
667
669
  children: [
668
670
  m.regressed,
@@ -671,7 +673,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
671
673
  ")"
672
674
  ]
673
675
  }),
674
- /* @__PURE__ */ M(x.Item, {
676
+ /* @__PURE__ */ I(S.Item, {
675
677
  value: "both_pass",
676
678
  children: [
677
679
  m.bothPass,
@@ -680,7 +682,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
680
682
  ")"
681
683
  ]
682
684
  }),
683
- /* @__PURE__ */ M(x.Item, {
685
+ /* @__PURE__ */ I(S.Item, {
684
686
  value: "both_fail",
685
687
  children: [
686
688
  m.bothFail,
@@ -691,7 +693,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
691
693
  })
692
694
  ]
693
695
  }),
694
- /* @__PURE__ */ j(n, {
696
+ /* @__PURE__ */ F(n, {
695
697
  caption: d.title,
696
698
  hideCaption: !0,
697
699
  columns: y,
@@ -717,7 +719,7 @@ function Ae({ rows: e, baselineLabel: r, candidateLabel: i, filter: a, onFilterC
717
719
  });
718
720
  }
719
721
  // packages/kits/src/research/work-heartbeat.tsx
720
- var je = {
722
+ var Ie = {
721
723
  title: "Active work reports",
722
724
  empty: "No active or recent work reports.",
723
725
  nextCheckpoint: "Next checkpoint",
@@ -728,54 +730,54 @@ var je = {
728
730
  overdue: "Update overdue",
729
731
  stopped: "Stopped"
730
732
  }
731
- }, Me = {
733
+ }, Le = {
732
734
  running: "positive",
733
735
  completed: "neutral",
734
736
  blocked: "negative",
735
737
  overdue: "warning",
736
738
  stopped: "neutral"
737
739
  };
738
- function Ne(e) {
740
+ function Re(e) {
739
741
  return e === void 0 ? null : Number.isFinite(e.completed) && Number.isFinite(e.total) && e.total > 0 ? e : null;
740
742
  }
741
- function Pe({ reports: t, locale: n, labels: i }) {
743
+ function ze({ reports: t, locale: n, labels: i }) {
742
744
  let a = {
743
- ...je,
745
+ ...Ie,
744
746
  ...i,
745
747
  states: {
746
- ...je.states,
748
+ ...Ie.states,
747
749
  ...i?.states
748
750
  }
749
751
  };
750
- return t.length === 0 ? /* @__PURE__ */ j("div", {
752
+ return t.length === 0 ? /* @__PURE__ */ F("div", {
751
753
  className: "x1qokhjc",
752
- children: /* @__PURE__ */ j(o, {
754
+ children: /* @__PURE__ */ F(o, {
753
755
  variant: "caption",
754
756
  tone: "muted",
755
757
  children: a.empty
756
758
  })
757
- }) : /* @__PURE__ */ j("ul", {
759
+ }) : /* @__PURE__ */ F("ul", {
758
760
  className: "xe8uvvx x1ghz6dp x1717udv x178xt8z x13fuv20 xhjagg4",
759
761
  children: t.map((t) => {
760
- let i = Ne(t.progress), s = i === null ? null : Math.max(0, Math.min(100, i.completed / i.total * 100)), d = t.nextCheckpoint !== void 0 || t.executionRef !== void 0;
761
- return /* @__PURE__ */ M("li", {
762
+ let i = Re(t.progress), s = i === null ? null : Math.max(0, Math.min(100, i.completed / i.total * 100)), d = t.nextCheckpoint !== void 0 || t.executionRef !== void 0;
763
+ return /* @__PURE__ */ I("li", {
762
764
  className: "x78zum5 xdt5ytf x1hnptsi x1qokhjc xso031l x1q0q8m5 x1qndepd",
763
765
  children: [
764
- /* @__PURE__ */ M(l, {
766
+ /* @__PURE__ */ I(l, {
765
767
  shouldSpaceBetween: !0,
766
- children: [/* @__PURE__ */ j(o, { children: /* @__PURE__ */ j("strong", { children: t.title }) }), /* @__PURE__ */ M(l, { children: [/* @__PURE__ */ j(u, {
767
- tone: Me[t.state],
768
+ children: [/* @__PURE__ */ F(o, { children: /* @__PURE__ */ F("strong", { children: t.title }) }), /* @__PURE__ */ I(l, { children: [/* @__PURE__ */ F(u, {
769
+ tone: Le[t.state],
768
770
  children: a.states[t.state]
769
- }), /* @__PURE__ */ j(r, {
771
+ }), /* @__PURE__ */ F(r, {
770
772
  dateTime: t.observedAt,
771
773
  label: t.observedLabel
772
774
  })] })]
773
775
  }),
774
- i !== null && s !== null && /* @__PURE__ */ M(c, {
776
+ i !== null && s !== null && /* @__PURE__ */ I(c, {
775
777
  isCompact: !0,
776
- children: [/* @__PURE__ */ M(l, {
778
+ children: [/* @__PURE__ */ I(l, {
777
779
  shouldSpaceBetween: !0,
778
- children: [/* @__PURE__ */ M(o, {
780
+ children: [/* @__PURE__ */ I(o, {
779
781
  variant: "caption",
780
782
  tone: "muted",
781
783
  children: [
@@ -794,7 +796,7 @@ function Pe({ reports: t, locale: n, labels: i }) {
794
796
  " ",
795
797
  i.unit
796
798
  ]
797
- }), /* @__PURE__ */ j(p, {
799
+ }), /* @__PURE__ */ F(p, {
798
800
  tone: "neutral",
799
801
  children: e({
800
802
  value: s / 100,
@@ -805,7 +807,7 @@ function Pe({ reports: t, locale: n, labels: i }) {
805
807
  }
806
808
  })
807
809
  })]
808
- }), /* @__PURE__ */ j(y, {
810
+ }), /* @__PURE__ */ F(y, {
809
811
  label: t.title,
810
812
  value: i.completed,
811
813
  max: i.total,
@@ -819,9 +821,9 @@ function Pe({ reports: t, locale: n, labels: i }) {
819
821
  })
820
822
  })]
821
823
  }),
822
- d && /* @__PURE__ */ M(l, {
824
+ d && /* @__PURE__ */ I(l, {
823
825
  shouldSpaceBetween: !0,
824
- children: [t.nextCheckpoint === void 0 ? /* @__PURE__ */ j("span", {}) : /* @__PURE__ */ M(o, {
826
+ children: [t.nextCheckpoint === void 0 ? /* @__PURE__ */ F("span", {}) : /* @__PURE__ */ I(o, {
825
827
  variant: "caption",
826
828
  tone: "muted",
827
829
  children: [
@@ -829,7 +831,7 @@ function Pe({ reports: t, locale: n, labels: i }) {
829
831
  ": ",
830
832
  t.nextCheckpoint
831
833
  ]
832
- }), t.executionRef !== void 0 && /* @__PURE__ */ j(f, { children: t.executionRef })]
834
+ }), t.executionRef !== void 0 && /* @__PURE__ */ F(f, { children: t.executionRef })]
833
835
  })
834
836
  ]
835
837
  }, t.id);
@@ -840,15 +842,56 @@ function Pe({ reports: t, locale: n, labels: i }) {
840
842
  function U(e) {
841
843
  throw Error(e);
842
844
  }
843
- function Fe({ title: e, locale: t, first: n, last: r }) {
844
- return /* @__PURE__ */ j(E, {
845
+ function Be({ title: e, locale: t, first: n, last: r }) {
846
+ return /* @__PURE__ */ F(D, {
845
847
  title: e,
846
848
  locale: t,
847
849
  message: `Choose an integer tick from ${n} through ${r}.`
848
850
  });
849
851
  }
852
+ var W = [
853
+ 1,
854
+ 2,
855
+ 4,
856
+ 8
857
+ ], Ve = {
858
+ selected: null,
859
+ zoom: 1,
860
+ isFollowing: !1,
861
+ showTrails: !0,
862
+ showRegions: !0
863
+ };
864
+ function G(e, t) {
865
+ let n = t.selected, r = (n == null ? void 0 : e.arms[n.arm])?.tracks.some((e) => e.id === n?.id) === !0 ? n ?? null : null, i = W.find((e) => e === t.zoom) ?? 1, a = e.arms.some((e) => e.metrics?.some((e) => e.label === t.metric) === !0);
866
+ return {
867
+ selected: r,
868
+ zoom: i,
869
+ isFollowing: i > 1 && r !== null && t.isFollowing === !0,
870
+ showTrails: t.showTrails !== !1,
871
+ showRegions: t.showRegions !== !1,
872
+ ...a && t.metric !== void 0 ? { metric: t.metric } : {}
873
+ };
874
+ }
875
+ function He(e, t) {
876
+ return t.metric ?? e.arms.find((e) => (e.metrics?.length ?? 0) > 0)?.metrics?.[0]?.label;
877
+ }
878
+ var Ue = 2;
879
+ function We([e, t], n, r) {
880
+ let i = (t - e) / r, a = Math.max(e, Math.min(t - i, n - i / Ue));
881
+ return [a, a + i];
882
+ }
883
+ function Ge(e, t, n) {
884
+ if (t.zoom === 1) return e;
885
+ let [r, i, a, o] = e, s = t.isFollowing ? n : void 0, [c, l] = We([r, a], s?.x ?? (r + a) / Ue, t.zoom), [u, d] = We([i, o], s?.y ?? (i + o) / Ue, t.zoom);
886
+ return [
887
+ c,
888
+ u,
889
+ l,
890
+ d
891
+ ];
892
+ }
850
893
  // packages/kits/src/research/motion-clip.ts
851
- var W = {
894
+ var K = {
852
895
  text: 4096,
853
896
  span: 1e-9,
854
897
  rate: 1e9,
@@ -858,135 +901,167 @@ var W = {
858
901
  metrics: 64,
859
902
  moments: 512,
860
903
  arms: 8
861
- }, G = {
904
+ }, q = {
862
905
  bounds: 4,
863
906
  point: 3,
864
907
  pair: 2
865
908
  };
866
- function K(e, t) {
909
+ function J(e, t) {
867
910
  e || U(t);
868
911
  }
869
- function q(e) {
912
+ function Y(e) {
870
913
  return typeof e != "object" || !e || Array.isArray(e) ? U("Expected a motion record.") : Object.fromEntries(Object.entries(e));
871
914
  }
872
- function J(e, t, n = 0) {
915
+ function X(e, t, n = 0) {
873
916
  return !Array.isArray(e) || e.length < n || e.length > t ? U(`Expected between ${n} and ${t} motion items.`) : e;
874
917
  }
875
- function Y(e) {
876
- return typeof e != "string" || e.length > W.text || e.trim().length === 0 ? U("Expected a nonempty motion label or ID.") : e;
918
+ function Z(e) {
919
+ return typeof e != "string" || e.length > K.text || e.trim().length === 0 ? U("Expected a nonempty motion label or ID.") : e;
877
920
  }
878
- function X(e) {
921
+ function Q(e) {
879
922
  return typeof e != "number" || !Number.isFinite(e) || Math.abs(e) > 2 ** 53 - 1 ? U("Expected a finite motion value in range.") : e;
880
923
  }
881
- function Ie(e) {
882
- let [t, n, r, i] = J(e, G.bounds, G.bounds), a = [
883
- X(t),
884
- X(n),
885
- X(r),
886
- X(i)
924
+ function Ke(e) {
925
+ let [t, n, r, i] = X(e, q.bounds, q.bounds), a = [
926
+ Q(t),
927
+ Q(n),
928
+ Q(r),
929
+ Q(i)
887
930
  ];
888
- return K(a[2] - a[0] >= W.span && a[3] - a[1] >= W.span, "Motion bounds must increase along both axes."), a;
931
+ return J(a[2] - a[0] >= K.span && a[3] - a[1] >= K.span, "Motion bounds must increase along both axes."), a;
889
932
  }
890
- function Z(e) {
891
- let t = X(e);
892
- return K(Number.isSafeInteger(t), "Motion ticks must be integers."), t;
933
+ function qe(e) {
934
+ let t = Q(e);
935
+ return J(Number.isSafeInteger(t), "Motion ticks must be integers."), t;
893
936
  }
894
- function Le(e) {
895
- let t = q(e);
896
- K(t.version === 1, "Unsupported motion clip version.");
897
- let n = Z(t.first), r = Z(t.last);
898
- K(r >= n && Number.isSafeInteger(r - n), "Invalid motion tick range.");
899
- let i = X(t.hz), a = X(t.speed);
900
- K(i > 0 && a > 0 && i * a <= W.rate, "Expected a positive motion tick rate and speed in range.");
937
+ function Je(e) {
938
+ let t = Y(e);
939
+ J(t.version === 1, "Unsupported motion clip version.");
940
+ let n = qe(t.first), r = qe(t.last);
941
+ J(r >= n && Number.isSafeInteger(r - n), "Invalid motion tick range.");
942
+ let i = Q(t.hz), a = Q(t.speed);
943
+ J(i > 0 && a > 0 && i * a <= K.rate, "Expected a positive motion tick rate and speed in range.");
901
944
  function o(e) {
902
- let t = Z(e);
903
- return K(t >= n && t <= r, "Tick outside the motion window."), t;
945
+ let t = qe(e);
946
+ return J(t >= n && t <= r, "Tick outside the motion window."), t;
904
947
  }
905
- let s = { remaining: W.samples };
948
+ let s = { remaining: K.samples };
906
949
  function c(e, t, n) {
907
- let r = J(e, s.remaining, 1);
908
- s.remaining -= r.length;
909
- let i = -Infinity;
910
- return r.map((e) => {
911
- let r = J(e, t, t), a = o(r[0]);
912
- return K(a > i, "Sample ticks must increase within each series."), i = a, n(a, r);
950
+ let [r, i] = typeof t == "number" ? [t, t] : t, a = X(e, s.remaining, 1);
951
+ s.remaining -= a.length;
952
+ let c = -Infinity;
953
+ return a.map((e) => {
954
+ let t = X(e, i, r), a = o(t[0]);
955
+ return J(a > c, "Sample ticks must increase within each series."), c = a, n(a, t);
913
956
  });
914
957
  }
915
958
  function l(e) {
916
- let t = q(e), r = J(t.tracks, W.tracks).map((e) => {
917
- let t = q(e), r = c(t.points, G.point, (e, t) => [
959
+ let t = Y(e), r = X(t.tracks, K.tracks).map((e) => {
960
+ let t = Y(e), r = c(t.points, q.point, (e, t) => [
918
961
  e,
919
- X(t[1]),
920
- X(t[2])
962
+ Q(t[1]),
963
+ Q(t[2])
921
964
  ]), i = o(t.end);
922
- K(i >= (r.at(-1)?.[0] ?? n), "Track ends before its last sample.");
923
- let a = t.notes === void 0 ? [] : c(t.notes, G.pair, (e, t) => [e, Y(t[1])]);
965
+ J(i >= (r.at(-1)?.[0] ?? n), "Track ends before its last sample.");
966
+ let a = t.notes === void 0 ? [] : c(t.notes, [q.pair, q.point], (e, t) => {
967
+ let n = Z(t[1]);
968
+ if (t.length === q.pair) return [e, n];
969
+ let r = X(t[2], q.pair, q.pair);
970
+ return [
971
+ e,
972
+ n,
973
+ [Q(r[0]), Q(r[1])]
974
+ ];
975
+ });
924
976
  return {
925
- id: Y(t.id),
926
- label: Y(t.label),
977
+ id: Z(t.id),
978
+ label: Z(t.label),
927
979
  points: r,
928
980
  end: i,
929
981
  notes: a
930
982
  };
931
983
  }), i = r.toSorted((e, t) => e.id === t.id ? e.end - t.end : e.id > t.id ? 1 : -1);
932
- K(i.every((e, t) => {
984
+ J(i.every((e, t) => {
933
985
  let r = i[t - 1];
934
986
  return r === void 0 || r.id !== e.id || r.end < (e.points[0]?.[0] ?? n);
935
987
  }), "Segments of the same track overlap.");
936
- let a = J(t.regions === void 0 ? [] : t.regions, W.regions).map((e) => {
937
- let t = q(e);
988
+ let a = X(t.regions === void 0 ? [] : t.regions, K.regions).map((e) => {
989
+ let t = Y(e);
938
990
  return {
939
- label: Y(t.label),
940
- bounds: Ie(t.bounds)
991
+ label: Z(t.label),
992
+ bounds: Ke(t.bounds)
941
993
  };
942
- }), s = J(t.metrics === void 0 ? [] : t.metrics, W.metrics).map((e) => {
943
- let t = q(e);
994
+ }), s = X(t.metrics === void 0 ? [] : t.metrics, K.metrics).map((e) => {
995
+ let t = Y(e);
944
996
  return {
945
- label: Y(t.label),
946
- values: c(t.values, G.pair, (e, t) => [e, X(t[1])])
997
+ label: Z(t.label),
998
+ values: c(t.values, q.pair, (e, t) => [e, Q(t[1])])
947
999
  };
948
1000
  });
949
1001
  return {
950
- label: Y(t.label),
1002
+ label: Z(t.label),
951
1003
  tracks: r,
952
1004
  regions: a,
953
1005
  metrics: s
954
1006
  };
955
1007
  }
956
- let u = J(t.moments, W.moments).map((e) => {
957
- let t = q(e), n = t.detail;
1008
+ let u = X(t.arms, K.arms, 1).map(l);
1009
+ function d(e) {
1010
+ let t = Y(e), n = W.find((e) => e === t.zoom);
1011
+ J(t.zoom === void 0 || n !== void 0, "Moment zoom must be a listed level.");
1012
+ let r = t.selected, i = r == null ? null : Y(r), a = t.metric;
1013
+ function o(e, n) {
1014
+ let r = t[e];
1015
+ return r === void 0 ? n : typeof r == "boolean" ? r : U("Moment layer settings must be true or false.");
1016
+ }
1017
+ let s = G({ arms: u }, {
1018
+ selected: i === null ? null : {
1019
+ arm: qe(i.arm),
1020
+ id: Z(i.id)
1021
+ },
1022
+ zoom: n ?? 1,
1023
+ isFollowing: o("isFollowing", !1),
1024
+ showTrails: o("showTrails", !0),
1025
+ showRegions: o("showRegions", !0),
1026
+ ...a === void 0 ? {} : { metric: Z(a) }
1027
+ });
1028
+ return J(i === null || s.selected !== null, "Moment selection must name an existing track and arm."), J(t.isFollowing !== !0 || s.isFollowing, "Following a moment needs an actor and a zoomed camera."), J(a === void 0 || s.metric === a, "Moment metric must name a recorded measure."), s;
1029
+ }
1030
+ let f = X(t.moments, K.moments).map((e) => {
1031
+ let t = Y(e), n = t.detail;
958
1032
  return {
959
- id: Y(t.id),
960
- label: Y(t.label),
1033
+ id: Z(t.id),
1034
+ label: Z(t.label),
961
1035
  tick: o(t.tick),
962
- ...n === void 0 ? {} : { detail: Y(n) }
1036
+ ...t.view === void 0 ? {} : { view: d(t.view) },
1037
+ ...n === void 0 ? {} : { detail: Z(n) }
963
1038
  };
964
1039
  });
965
- return K(new Set(u.map((e) => e.id)).size === u.length, "Motion moment IDs must be unique."), {
1040
+ return J(new Set(f.map((e) => e.id)).size === f.length, "Motion moment IDs must be unique."), {
966
1041
  version: 1,
967
- title: Y(t.title),
1042
+ title: Z(t.title),
968
1043
  first: n,
969
1044
  last: r,
970
1045
  hz: i,
971
1046
  speed: a,
972
- bounds: Ie(t.bounds),
973
- arms: J(t.arms, W.arms, 1).map(l),
974
- moments: u,
1047
+ bounds: Ke(t.bounds),
1048
+ arms: u,
1049
+ moments: f,
975
1050
  source: t.source
976
1051
  };
977
1052
  }
978
1053
  // packages/kits/src/research/motion-frame.ts
979
- var Re = 2, ze = 12;
980
- function Q(e, t) {
1054
+ var Ye = 2, Xe = 12;
1055
+ function Ze(e, t) {
981
1056
  let n = 0, r = e.length;
982
1057
  for (; n < r;) {
983
- let i = Math.floor((n + r) / Re);
1058
+ let i = Math.floor((n + r) / Ye);
984
1059
  (e[i]?.[0] ?? Infinity) <= t ? n = i + 1 : r = i;
985
1060
  }
986
1061
  return n - 1;
987
1062
  }
988
- function Be(e, t) {
989
- let n = Q(e, t), r = e[n];
1063
+ function Qe(e, t) {
1064
+ let n = Ze(e, t), r = e[n];
990
1065
  if (r === void 0) return null;
991
1066
  let i = e[n + 1] ?? r, a = i === r ? 0 : (t - r[0]) / (i[0] - r[0]);
992
1067
  return {
@@ -995,12 +1070,12 @@ function Be(e, t) {
995
1070
  sampled: r[0] === t
996
1071
  };
997
1072
  }
998
- function Ve(e, t, n) {
1073
+ function $e(e, t, n) {
999
1074
  return e.flatMap(({ id: e, label: r, points: i, end: a, notes: o = [] }) => {
1000
1075
  if (t > a) return [];
1001
- let s = Be(i, t);
1076
+ let s = Qe(i, t);
1002
1077
  if (s === null) return [];
1003
- let c = Math.max(i[0]?.[0] ?? t, t - n), l = Array.from({ length: 13 }, (e, n) => Be(i, c + (t - c) * n / ze)), u = l.flatMap((e, t) => {
1078
+ let c = Math.max(i[0]?.[0] ?? t, t - n), l = Array.from({ length: 13 }, (e, n) => Qe(i, c + (t - c) * n / Xe)), u = l.flatMap((e, t) => {
1004
1079
  let n = l[t - 1];
1005
1080
  return e === null || n?.x === e.x && n.y === e.y ? [] : [[e.x, e.y]];
1006
1081
  });
@@ -1009,24 +1084,29 @@ function Ve(e, t, n) {
1009
1084
  label: r,
1010
1085
  ...s,
1011
1086
  trail: u,
1012
- note: o[Q(o, t)]
1087
+ note: o[Ze(o, t)]
1013
1088
  }];
1014
1089
  });
1015
1090
  }
1016
- function He(e, t) {
1091
+ function et(e, t) {
1017
1092
  return !Number.isSafeInteger(t) || t < e.first || t > e.last ? U("Choose an integer tick inside the motion window.") : e.arms.map((n) => ({
1018
1093
  label: n.label,
1019
1094
  regions: n.regions ?? [],
1020
- actors: Ve(n.tracks, t, e.hz),
1095
+ actors: $e(n.tracks, t, e.hz),
1021
1096
  metrics: (n.metrics ?? []).map(({ label: e, values: n }) => ({
1022
1097
  label: e,
1023
- value: n[Q(n, t)]?.[1] ?? null
1098
+ value: n[Ze(n, t)]?.[1] ?? null
1024
1099
  }))
1025
1100
  }));
1026
1101
  }
1027
1102
  // packages/kits/src/research/motion-scene.tsx
1028
- var Ue = {
1103
+ var tt = {
1029
1104
  tick: "Tick",
1105
+ metric: "Metric history",
1106
+ zoom: "Zoom",
1107
+ follow: "Follow actor",
1108
+ trails: "Trails",
1109
+ regions: "Regions",
1030
1110
  start: "Start",
1031
1111
  moment: "Jump to moment",
1032
1112
  actor: "Inspect actor",
@@ -1034,214 +1114,579 @@ var Ue = {
1034
1114
  interpolated: "Estimated",
1035
1115
  absent: "No position recorded"
1036
1116
  };
1037
- function We({ frame: e, arm: t, isCompact: n, index: r, bounds: i, isInspecting: a, format: s, labels: u }) {
1038
- let [d, f] = A(null), p = a ? d : null, m = e.actors.find((e) => e.id === p), h = t.tracks.length === 1 ? t.tracks[0]?.points[0] : void 0, g = m?.note === void 0 ? null : /* @__PURE__ */ M(o, {
1117
+ function nt({ frame: e, view: t, onSelect: n, arm: r, isCompact: i, index: a, bounds: s, isInspecting: u, format: d, labels: f, metric: p }) {
1118
+ let m = t.selected?.arm === a ? t.selected.id : null, h = e.actors.find((e) => e.id === m), g = r.tracks.length === 1 ? r.tracks[0]?.points[0] : void 0, _ = h?.note === void 0 ? null : /* @__PURE__ */ I(o, {
1039
1119
  variant: "caption",
1040
1120
  children: [
1041
- s.format(m.note[0]),
1121
+ d.format(h.note[0]),
1042
1122
  " · ",
1043
- m.note[1]
1123
+ h.note[1]
1044
1124
  ]
1045
- }), _ = a && t.tracks.length > 0, v = [
1125
+ }), v = u ? e.metrics.filter((e) => e.label === p) : e.metrics.slice(0, 2), y = u && r.tracks.length > 0, b = u ? r.label : [
1046
1126
  e.label,
1047
1127
  ...e.regions.map((e) => e.label),
1048
- ...e.actors.map((e) => `${e.label} (${s.format(e.x)}, ${s.format(e.y)})`)
1128
+ ...e.actors.map((e) => `${e.label} (${d.format(e.x)}, ${d.format(e.y)})`)
1049
1129
  ].join(", ");
1050
- return /* @__PURE__ */ M(c, {
1130
+ return /* @__PURE__ */ I(c, {
1051
1131
  isCompact: !0,
1052
1132
  children: [
1053
- /* @__PURE__ */ M(l, {
1133
+ /* @__PURE__ */ I(l, {
1054
1134
  shouldSpaceBetween: !0,
1055
- children: [/* @__PURE__ */ j(o, { children: /* @__PURE__ */ j("strong", { children: e.label }) }), e.metrics.map(({ label: e, value: t }) => /* @__PURE__ */ M(o, { children: [
1135
+ children: [/* @__PURE__ */ I(l, { children: [/* @__PURE__ */ F(O, { tone: k(a) }), /* @__PURE__ */ F(o, { children: /* @__PURE__ */ F("strong", { children: e.label }) })] }), v.map(({ label: e, value: t }) => /* @__PURE__ */ I(o, { children: [
1056
1136
  e,
1057
1137
  " ",
1058
- /* @__PURE__ */ j("strong", { children: t === null ? "—" : s.format(t) })
1138
+ /* @__PURE__ */ F("strong", { children: t === null ? "—" : d.format(t) })
1059
1139
  ] }, e))]
1060
1140
  }),
1061
- /* @__PURE__ */ j(O, {
1062
- isCompact: n,
1063
- origin: h === void 0 ? void 0 : {
1064
- x: h[1],
1065
- y: h[2],
1066
- label: u.start
1141
+ /* @__PURE__ */ F(A, {
1142
+ destination: h?.note?.[2],
1143
+ isCompact: i,
1144
+ origin: g === void 0 ? void 0 : {
1145
+ x: g[1],
1146
+ y: g[2],
1147
+ label: f.start
1067
1148
  },
1068
- locale: s.resolvedOptions().locale,
1069
- isDense: t.tracks.length > 6,
1070
- bounds: i,
1071
- label: v,
1072
- regions: e.regions,
1149
+ locale: d.resolvedOptions().locale,
1150
+ isDense: r.tracks.length > 6,
1151
+ bounds: s,
1152
+ label: b,
1153
+ regions: t.showRegions ? e.regions : [],
1154
+ showTrails: t.showTrails,
1155
+ onSelectedChange: u ? n : void 0,
1073
1156
  points: e.actors,
1074
- tone: D(r),
1075
- shape: r % 2 == 0 ? "circle" : "diamond",
1076
- selected: p
1157
+ tone: k(a),
1158
+ shape: a % 2 == 0 ? "circle" : "diamond",
1159
+ selected: m
1077
1160
  }),
1078
- _ && /* @__PURE__ */ M(l, { children: [
1079
- /* @__PURE__ */ j(b, {
1080
- label: u.actor,
1081
- placeholder: u.actor,
1082
- items: Array.from(new Map(t.tracks.map((e) => [e.id, e.label])), ([e, t]) => ({
1161
+ y && /* @__PURE__ */ I(l, { children: [
1162
+ /* @__PURE__ */ F(x, {
1163
+ label: f.actor,
1164
+ placeholder: f.actor,
1165
+ items: Array.from(new Map(r.tracks.map((e) => [e.id, e.label])), ([e, t]) => ({
1083
1166
  value: e,
1084
1167
  label: `${t} · ${e}`
1085
1168
  })),
1086
- value: p,
1087
- onValueChange: f
1169
+ value: m,
1170
+ onValueChange: n
1088
1171
  }),
1089
- p !== null && /* @__PURE__ */ j(o, {
1172
+ m !== null && /* @__PURE__ */ F(o, {
1090
1173
  variant: "caption",
1091
- children: m === void 0 ? u.absent : `${m.sampled ? u.sampled : u.interpolated} · ${s.format(m.x)}, ${s.format(m.y)}`
1174
+ children: h === void 0 ? f.absent : `${h.sampled ? f.sampled : f.interpolated} · ${d.format(h.x)}, ${d.format(h.y)}`
1092
1175
  }),
1093
- g
1176
+ _
1094
1177
  ] })
1095
1178
  ]
1096
1179
  });
1097
1180
  }
1098
- function $({ clip: e, tick: t, isInspecting: n = !1, isGuided: r = !1, locale: i = "en-US", labels: a }) {
1099
- let s = {
1100
- ...Ue,
1101
- ...a
1102
- }, c = new Intl.NumberFormat(i, { maximumFractionDigits: 6 });
1103
- if (!Number.isSafeInteger(t) || t < e.first || t > e.last) return /* @__PURE__ */ j(Fe, {
1181
+ function rt({ clip: e, view: t, onViewChange: n, tick: r, isInspecting: i = !1, isGuided: a = !1, locale: s = "en-US", labels: c }) {
1182
+ let l = {
1183
+ ...tt,
1184
+ ...c
1185
+ }, u = new Intl.NumberFormat(s, { maximumFractionDigits: 6 }), [d, f] = N(Ve), p = j(() => G(e, t ?? d), [
1186
+ e,
1187
+ t,
1188
+ d
1189
+ ]);
1190
+ if (!Number.isSafeInteger(r) || r < e.first || r > e.last) return /* @__PURE__ */ F(Be, {
1104
1191
  title: e.title,
1105
- locale: i,
1192
+ locale: s,
1106
1193
  first: e.first,
1107
1194
  last: e.last
1108
1195
  });
1109
- let l = He(e, t);
1110
- return /* @__PURE__ */ j(T, {
1196
+ let m = He(e, p), h = et(e, r), g = p.selected, _ = g === null ? void 0 : h[g.arm]?.actors.find((e) => e.id === g.id), v = Ge(e.bounds, p, _);
1197
+ function y(e, r) {
1198
+ let i = {
1199
+ ...p,
1200
+ selected: r === null ? null : {
1201
+ arm: e,
1202
+ id: r
1203
+ },
1204
+ isFollowing: r !== null && p.isFollowing
1205
+ };
1206
+ t === void 0 && f(i), n?.(i);
1207
+ }
1208
+ return /* @__PURE__ */ F(E, {
1111
1209
  title: e.title,
1112
- locale: i,
1113
- actions: /* @__PURE__ */ M(o, {
1210
+ locale: s,
1211
+ actions: /* @__PURE__ */ I(o, {
1114
1212
  variant: "caption",
1115
1213
  children: [
1116
- s.tick,
1214
+ l.tick,
1117
1215
  " ",
1118
- c.format(t)
1216
+ u.format(r)
1119
1217
  ]
1120
1218
  }),
1121
- children: /* @__PURE__ */ j("div", {
1219
+ children: /* @__PURE__ */ F("div", {
1122
1220
  ...{
1123
1221
  0: { className: "xrvj5dj x1yqo59v x1j825kq xeuugli" },
1124
1222
  1: { className: "xrvj5dj xeuugli xnby9oq x1j825kq" }
1125
- }[!!(r && e.arms.length === 2) | 0],
1126
- children: e.arms.map((t, i) => {
1127
- let a = l[i];
1128
- return a === void 0 ? null : /* @__PURE__ */ j(We, {
1129
- isCompact: r,
1130
- arm: t,
1131
- index: i,
1132
- bounds: e.bounds,
1133
- frame: a,
1134
- isInspecting: n,
1135
- format: c,
1136
- labels: s
1137
- }, t.label);
1223
+ }[!!(a && e.arms.length === 2) | 0],
1224
+ children: e.arms.map((e, t) => {
1225
+ let n = h[t];
1226
+ return n === void 0 ? null : /* @__PURE__ */ F(nt, {
1227
+ isCompact: a,
1228
+ arm: e,
1229
+ metric: m,
1230
+ index: t,
1231
+ view: p,
1232
+ onSelect: (e) => y(t, e),
1233
+ bounds: v,
1234
+ frame: n,
1235
+ isInspecting: i,
1236
+ format: u,
1237
+ labels: l
1238
+ }, e.label);
1239
+ })
1240
+ })
1241
+ });
1242
+ }
1243
+ // packages/kits/src/research/motion-inspection.tsx
1244
+ function it({ label: e, isChecked: t, onChange: n, isDisabled: r = !1 }) {
1245
+ return /* @__PURE__ */ F(re.Root, {
1246
+ disabled: r,
1247
+ children: /* @__PURE__ */ F(re.Label, { children: /* @__PURE__ */ I(l, { children: [/* @__PURE__ */ F(b.Root, {
1248
+ checked: t,
1249
+ onCheckedChange: n,
1250
+ disabled: r,
1251
+ children: /* @__PURE__ */ F(b.Indicator, {})
1252
+ }), e] }) })
1253
+ });
1254
+ }
1255
+ function at({ clip: e, view: t, onChange: n, labels: r, hasMap: i }) {
1256
+ let a = j(() => [...new Set(e.arms.flatMap((e) => (e.metrics ?? []).map((e) => e.label)))], [e]), o = t.metric ?? a[0] ?? null, s = e.arms.some((e) => (e.regions?.length ?? 0) > 0);
1257
+ return /* @__PURE__ */ I(l, { children: [a.length > 0 && /* @__PURE__ */ F(x, {
1258
+ label: r.metric,
1259
+ items: a.map((e) => ({
1260
+ value: e,
1261
+ label: e
1262
+ })),
1263
+ value: o,
1264
+ onValueChange: (e) => {
1265
+ e !== null && n({
1266
+ ...t,
1267
+ metric: e
1268
+ });
1269
+ }
1270
+ }), i && /* @__PURE__ */ I(P, { children: [
1271
+ /* @__PURE__ */ F(x, {
1272
+ label: r.zoom,
1273
+ items: W.map((e) => ({
1274
+ value: String(e),
1275
+ label: `${e}×`
1276
+ })),
1277
+ value: String(t.zoom),
1278
+ onValueChange: (e) => {
1279
+ let r = W.find((t) => String(t) === e);
1280
+ r !== void 0 && n({
1281
+ ...t,
1282
+ zoom: r,
1283
+ isFollowing: r > 1 && t.isFollowing
1284
+ });
1285
+ }
1286
+ }),
1287
+ /* @__PURE__ */ F(it, {
1288
+ label: r.trails,
1289
+ isChecked: t.showTrails,
1290
+ onChange: (e) => n({
1291
+ ...t,
1292
+ showTrails: e
1293
+ })
1294
+ }),
1295
+ s && /* @__PURE__ */ F(it, {
1296
+ label: r.regions,
1297
+ isChecked: t.showRegions,
1298
+ onChange: (e) => n({
1299
+ ...t,
1300
+ showRegions: e
1301
+ })
1302
+ }),
1303
+ /* @__PURE__ */ F(it, {
1304
+ label: r.follow,
1305
+ isChecked: t.isFollowing,
1306
+ isDisabled: t.selected === null,
1307
+ onChange: (e) => n({
1308
+ ...t,
1309
+ isFollowing: e,
1310
+ zoom: e && t.zoom === 1 ? 2 : t.zoom
1138
1311
  })
1139
1312
  })
1313
+ ] })] });
1314
+ }
1315
+ function ot({ clip: e, metric: t }) {
1316
+ let n = j(() => e.arms.flatMap((e, n) => {
1317
+ let r = e.metrics?.find((e) => e.label === t);
1318
+ return r === void 0 ? [] : [{
1319
+ id: String(n),
1320
+ tone: k(n),
1321
+ values: r.values
1322
+ }];
1323
+ }), [e, t]);
1324
+ return /* @__PURE__ */ F(te, {
1325
+ series: n,
1326
+ first: e.first,
1327
+ last: e.last
1140
1328
  });
1141
1329
  }
1142
1330
  // packages/kits/src/research/motion-figure.tsx
1143
- function Ge({ clip: e, tick: t, onTickChange: n, isPlaying: r, onPlayingChange: i, isInspecting: s = !1, isGuided: u = !1, locale: d = "en-US", labels: f }) {
1144
- let p = {
1145
- ...Ue,
1146
- ...f
1147
- }, [m, h] = A(!1), [g, _] = A(e.speed), v = r ?? m, { ref: y, isActive: x } = te(v, !0), S = re(() => e.moments.map(({ id: e, label: t, tick: n }) => ({
1331
+ function st({ clip: e, scene: t, speed: n, onSpeedChange: r, view: i, onViewChange: s, tick: u, onTickChange: d, isPlaying: f, onPlayingChange: p, isInspecting: m = !1, isGuided: h = !1, locale: g = "en-US", labels: _ }) {
1332
+ let v = {
1333
+ ...tt,
1334
+ ..._
1335
+ }, [y, b] = N(!1), [S, C] = N(e.speed), w = n ?? S, [E, D] = N(Ve), O = j(() => G(e, i ?? E), [
1336
+ e,
1337
+ i,
1338
+ E
1339
+ ]), k = He(e, O);
1340
+ function A(e) {
1341
+ i === void 0 && D(e), s?.(e), (e.selected?.id !== O.selected?.id || e.selected?.arm !== O.selected?.arm) && R(!1);
1342
+ }
1343
+ function te(e) {
1344
+ n === void 0 && C(e), r?.(e);
1345
+ }
1346
+ let re = f ?? y, { ref: M, isActive: P } = ne(re, !0), oe = j(() => e.moments.map(({ id: e, label: t, tick: n }) => ({
1148
1347
  id: e,
1149
1348
  label: t,
1150
1349
  position: n
1151
- })), [e]), C = re(() => new Intl.NumberFormat(d), [d]);
1152
- function T(a) {
1153
- a && t === e.last && n(e.first), r === void 0 && h(a), i?.(a);
1350
+ })), [e]), L = j(() => new Intl.NumberFormat(g), [g]);
1351
+ function R(t) {
1352
+ t && u === e.last && d(e.first), f === void 0 && b(t), p?.(t);
1353
+ }
1354
+ function z(t) {
1355
+ R(!1), d(Math.min(e.last, Math.max(e.first, t)));
1154
1356
  }
1155
- function E(t) {
1156
- T(!1), n(Math.min(e.last, Math.max(e.first, t)));
1357
+ function B(t) {
1358
+ z(t.tick), t.view !== void 0 && A(G(e, t.view));
1157
1359
  }
1158
- let D = k(() => T(!1));
1159
- ne(() => {
1360
+ let se = ae(() => R(!1));
1361
+ ie(() => {
1160
1362
  let e = matchMedia("(prefers-reduced-motion: reduce)");
1161
1363
  function t() {
1162
- e.matches && D();
1364
+ e.matches && se();
1163
1365
  }
1164
1366
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
1165
1367
  }, []);
1166
- let O = k(() => t), ie = k((r) => {
1167
- r !== t && n(r), r === e.last && T(!1);
1368
+ let ce = ae(() => u), V = ae((t) => {
1369
+ t !== u && d(t), t === e.last && R(!1);
1168
1370
  });
1169
- ne(() => {
1170
- if (!x) return;
1171
- let t = performance.now(), n = O(), r = requestAnimationFrame(i);
1371
+ ie(() => {
1372
+ if (!P) return;
1373
+ let t = performance.now(), n = ce(), r = requestAnimationFrame(i);
1172
1374
  function i(a) {
1173
- let o = Math.max(0, a - t), s = Math.floor(o * e.hz * g / 1e3), c = Math.min(e.last, n + s);
1174
- ie(c), c !== e.last && (r = requestAnimationFrame(i));
1375
+ let o = Math.max(0, a - t), s = Math.floor(o * e.hz * w / 1e3), c = Math.min(e.last, n + s);
1376
+ V(c), c !== e.last && (r = requestAnimationFrame(i));
1175
1377
  }
1176
1378
  return () => cancelAnimationFrame(r);
1177
1379
  }, [
1178
1380
  e.hz,
1179
1381
  e.last,
1180
- x,
1181
- g
1382
+ P,
1383
+ w
1182
1384
  ]);
1183
- let N = e.moments.find((e) => e.tick === t), P = e.moments.filter((e) => e.tick <= t).toSorted((e, t) => t.tick - e.tick)[0];
1184
- return /* @__PURE__ */ j("div", {
1185
- ref: y,
1186
- children: /* @__PURE__ */ M(c, {
1385
+ let le = e.moments.find((e) => e.tick === u), H = e.moments.filter((e) => e.tick <= u).toSorted((e, t) => t.tick - e.tick)[0];
1386
+ return /* @__PURE__ */ F("div", {
1387
+ ref: M,
1388
+ children: /* @__PURE__ */ I(c, {
1187
1389
  isCompact: !0,
1188
1390
  children: [
1189
- /* @__PURE__ */ j($, {
1190
- isGuided: u,
1391
+ t ?? /* @__PURE__ */ F(rt, {
1392
+ view: O,
1393
+ onViewChange: A,
1394
+ isGuided: h,
1395
+ clip: e,
1396
+ tick: u,
1397
+ isInspecting: m,
1398
+ locale: g,
1399
+ labels: v
1400
+ }),
1401
+ m && /* @__PURE__ */ F(at, {
1402
+ hasMap: t == null,
1191
1403
  clip: e,
1192
- tick: t,
1193
- isInspecting: s,
1194
- locale: d,
1195
- labels: p
1404
+ view: O,
1405
+ onChange: A,
1406
+ labels: v
1196
1407
  }),
1197
- /* @__PURE__ */ j(ee, {
1198
- label: p.tick,
1408
+ /* @__PURE__ */ F(T, {
1409
+ backdrop: m && k !== void 0 ? /* @__PURE__ */ F(ot, {
1410
+ clip: e,
1411
+ metric: k
1412
+ }) : void 0,
1413
+ label: v.tick,
1199
1414
  min: e.first,
1200
1415
  max: e.last,
1201
- value: t,
1202
- markers: S,
1203
- onValueChange: E,
1204
- onScrubStart: () => T(!1),
1205
- onMarkerSelect: () => T(!1),
1206
- formatValue: (e) => C.format(e)
1416
+ value: u,
1417
+ markers: oe,
1418
+ onValueChange: z,
1419
+ onScrubStart: () => R(!1),
1420
+ onMarkerSelect: (t) => {
1421
+ let n = e.moments.find((e) => e.id === t.id);
1422
+ n !== void 0 && B(n);
1423
+ },
1424
+ formatValue: (e) => L.format(e)
1207
1425
  }),
1208
- /* @__PURE__ */ j(w, {
1209
- isPlaying: v,
1210
- onPlayingChange: T,
1211
- speed: g,
1212
- onSpeedChange: _,
1213
- onStepBackward: () => E(t - 1),
1214
- onStepForward: () => E(t + 1),
1426
+ /* @__PURE__ */ F(ee, {
1427
+ isPlaying: re,
1428
+ onPlayingChange: R,
1429
+ speed: w,
1430
+ onSpeedChange: te,
1431
+ onStepBackward: () => z(u - 1),
1432
+ onStepForward: () => z(u + 1),
1215
1433
  isDisabled: e.first === e.last
1216
1434
  }),
1217
- u || e.moments.length === 0 ? null : e.moments.length <= 5 ? /* @__PURE__ */ j(l, { children: e.moments.map((e) => /* @__PURE__ */ j(a, {
1218
- variant: e === N ? "outline" : "ghost",
1219
- onClick: () => E(e.tick),
1435
+ h || e.moments.length === 0 ? null : e.moments.length <= 5 ? /* @__PURE__ */ F(l, { children: e.moments.map((e) => /* @__PURE__ */ F(a, {
1436
+ variant: e === le ? "outline" : "ghost",
1437
+ onClick: () => B(e),
1220
1438
  children: e.label
1221
- }, e.id)) }) : /* @__PURE__ */ j(b, {
1222
- label: p.moment,
1223
- placeholder: p.moment,
1439
+ }, e.id)) }) : /* @__PURE__ */ F(x, {
1440
+ label: v.moment,
1441
+ placeholder: v.moment,
1224
1442
  items: e.moments.map(({ id: e, label: t, tick: n }) => ({
1225
1443
  value: e,
1226
- label: `${C.format(n)} · ${t}`
1444
+ label: `${L.format(n)} · ${t}`
1227
1445
  })),
1228
- value: N?.id ?? null,
1446
+ value: le?.id ?? null,
1229
1447
  onValueChange: (t) => {
1230
1448
  let n = e.moments.find((e) => e.id === t);
1231
- n !== void 0 && E(n.tick);
1449
+ n !== void 0 && B(n);
1232
1450
  }
1233
1451
  }),
1234
- s && P !== void 0 && /* @__PURE__ */ M(o, {
1452
+ m && H !== void 0 && /* @__PURE__ */ I(o, {
1235
1453
  variant: "caption",
1236
1454
  children: [
1237
- C.format(P.tick),
1455
+ L.format(H.tick),
1238
1456
  " · ",
1239
- P.label,
1240
- P.detail === void 0 ? "" : ` · ${P.detail}`
1457
+ H.label,
1458
+ H.detail === void 0 ? "" : ` · ${H.detail}`
1241
1459
  ]
1242
1460
  })
1243
1461
  ]
1244
1462
  })
1245
1463
  });
1246
1464
  }
1247
- export { ae as FindingCard, Se as LineageGraph, Te as MilestonePath, Ge as MotionFigure, $ as MotionScene, Ae as SpecimenDiff, Pe as WorkHeartbeat, He as motionSceneAt, Le as parseMotionClip };
1465
+ // packages/kits/src/research/motion-location.ts
1466
+ function ct(e, t) {
1467
+ let n = e.get(t);
1468
+ if (n === null || !/^-?\d+$/.test(n)) return;
1469
+ let r = Number(n);
1470
+ return Number.isSafeInteger(r) ? r : void 0;
1471
+ }
1472
+ function lt(e, t) {
1473
+ let n = ct(t, "arm"), r = t.get("actor")?.replace(/^~/u, "") ?? null, i = t.get("metric")?.replace(/^~/u, "") ?? null, a = W.find((e) => e === ct(t, "zoom")) ?? 1;
1474
+ return {
1475
+ tick: Math.max(e.first, Math.min(e.last, ct(t, "tick") ?? e.first)),
1476
+ isNative: t.get("footage") === "1",
1477
+ view: G(e, {
1478
+ selected: n !== void 0 && r !== null ? {
1479
+ arm: n,
1480
+ id: r
1481
+ } : null,
1482
+ zoom: a,
1483
+ isFollowing: t.get("follow") === "1",
1484
+ showTrails: t.get("trails") !== "0",
1485
+ showRegions: t.get("regions") !== "0",
1486
+ ...i === null ? {} : { metric: i }
1487
+ })
1488
+ };
1489
+ }
1490
+ function ut(e, t, n = !1) {
1491
+ let r = new URLSearchParams({ tick: String(e) });
1492
+ return t.selected !== null && (r.set("arm", String(t.selected.arm)), r.set("actor", `~${t.selected.id}`)), t.zoom !== 1 && r.set("zoom", String(t.zoom)), t.isFollowing && r.set("follow", "1"), t.showTrails || r.set("trails", "0"), t.showRegions || r.set("regions", "0"), t.metric !== void 0 && r.set("metric", `~${t.metric}`), n && r.set("footage", "1"), r;
1493
+ }
1494
+ // packages/kits/src/research/native-motion.ts
1495
+ var dt = 16, ft = 2, pt = 2, mt = 2701, ht = 64, gt = /[^a-f0-9]/u;
1496
+ function _t(e) {
1497
+ return typeof e != "string" || e.length !== ht || gt.test(e) ? U("Invalid native footage fingerprint.") : e;
1498
+ }
1499
+ function vt(e) {
1500
+ return typeof e == "number" && Number.isFinite(e) ? e : U("Expected finite native footage timing.");
1501
+ }
1502
+ function yt(e) {
1503
+ let t = vt(e);
1504
+ return Number.isSafeInteger(t) ? t : U("Expected an integer frame tick or arm.");
1505
+ }
1506
+ function bt(e, t) {
1507
+ if (typeof e != "object" || !e || Array.isArray(e)) return U("Expected a native footage mapping.");
1508
+ let n = Object.fromEntries(Object.entries(e)), { version: r, ticks: i } = n, a = _t(n.clipSha256), o = _t(n.movieSha256), s = yt(n.arm), c = yt(n.firstTick), l = yt(n.lastTick), u = vt(n.fps), d = vt(n.secondsPerTick), f = vt(n.startSeconds);
1509
+ if (r !== 1 || s < 0 || s >= t.arms.length) return U("Unknown native footage version or recording arm.");
1510
+ if (c < t.first || l > t.last || l < c) return U("Native footage lies outside the recording.");
1511
+ if (u <= 0 || f < 0 || d <= 0) return U("Invalid native footage timing.");
1512
+ if (!Array.isArray(i) || i.length === 0 || i.length > mt) return U("Invalid native footage frame count.");
1513
+ if (i[0] !== c || i.at(-1) !== l || !Number.isFinite(f + i.length / u)) return U("Invalid native footage frame range.");
1514
+ let p = c;
1515
+ return {
1516
+ version: r,
1517
+ arm: s,
1518
+ firstTick: c,
1519
+ lastTick: l,
1520
+ secondsPerTick: d,
1521
+ startSeconds: f,
1522
+ fps: u,
1523
+ ticks: i.map((e) => {
1524
+ let t = yt(e);
1525
+ return t < p || t > l ? U("Native footage ticks must be ordered.") : (p = t, t);
1526
+ }),
1527
+ clipSha256: a,
1528
+ movieSha256: o
1529
+ };
1530
+ }
1531
+ async function xt(e) {
1532
+ let t = await crypto.subtle.digest("SHA-256", await e.arrayBuffer());
1533
+ return Array.from(new Uint8Array(t), (e) => e.toString(dt).padStart(ft, "0")).join("");
1534
+ }
1535
+ async function St(e, t, n) {
1536
+ let [r, i] = await Promise.all([xt(e), xt(t)]);
1537
+ (r !== n.clipSha256 || i !== n.movieSha256) && U("Native footage does not match the recording.");
1538
+ }
1539
+ function Ct(e, t) {
1540
+ let n = 0, r = e.ticks.length;
1541
+ for (; n + 1 < r;) {
1542
+ let i = n + Math.floor((r - n) / pt);
1543
+ (e.ticks[i] ?? e.lastTick) <= t ? n = i : r = i;
1544
+ }
1545
+ return e.startSeconds + n / e.fps;
1546
+ }
1547
+ // packages/kits/src/research/native-motion-figure.tsx
1548
+ var $ = {
1549
+ minRate: .25,
1550
+ maxRate: 4,
1551
+ driftFrames: 2,
1552
+ seekTolerance: .001
1553
+ };
1554
+ function wt({ source: e, tick: t, rate: n, isPlaying: r, label: i, onError: a }) {
1555
+ let o = M(null), { ref: s, isActive: c } = ne(r, !0), [l, u] = N(!1), [d, f] = N(!0), { mapping: p } = e, m = n * p.secondsPerTick, h = m >= $.minRate && m <= $.maxRate, g = c && t < p.lastTick && d && h, _ = Ct(p, t), v = g ? $.driftFrames / p.fps : $.seekTolerance;
1556
+ return ie(() => {
1557
+ let e = o.current;
1558
+ e !== null && l && Math.abs(e.currentTime - _) > v && (e.currentTime = _);
1559
+ }, [
1560
+ _,
1561
+ v,
1562
+ l
1563
+ ]), ie(() => {
1564
+ let e = o.current;
1565
+ if (e === null || !l || !g) return;
1566
+ let t = !0;
1567
+ return e.playbackRate = m, e.play().catch(() => {
1568
+ t && f(!1);
1569
+ }), () => {
1570
+ t = !1, e.pause();
1571
+ };
1572
+ }, [
1573
+ g,
1574
+ m,
1575
+ l
1576
+ ]), /* @__PURE__ */ F("div", {
1577
+ ref: s,
1578
+ children: /* @__PURE__ */ F("video", {
1579
+ ref: o,
1580
+ src: e.src,
1581
+ muted: !0,
1582
+ playsInline: !0,
1583
+ preload: "auto",
1584
+ "aria-label": i,
1585
+ onError: a,
1586
+ onLoadedMetadata: (e) => {
1587
+ let t = Ct(p, p.lastTick);
1588
+ !Number.isFinite(e.currentTarget.duration) || t >= e.currentTarget.duration + $.seekTolerance ? a() : u(!0);
1589
+ },
1590
+ className: "x1lliihq xh8yej3 x186iv6y xcwfpss x19kjcj4"
1591
+ })
1592
+ });
1593
+ }
1594
+ function Tt({ native: e, isNative: t, onNativeChange: n, isPlaying: r, onPlayingChange: i, speed: s, onSpeedChange: u, ...d }) {
1595
+ let f = d.locale ?? "en-US", p = j(() => new Intl.NumberFormat(f), [f]), [m, h] = N(!1), [g, _] = N(!1), [v, y] = N(d.clip.speed), b = t ?? m, x = r ?? g, C = s ?? v, [w, ee] = N(null), [T, D] = N(void 0), O = e !== void 0 && "load" in e ? e : void 0, k = e !== void 0 && "src" in e ? e : w?.request === O ? w?.source : void 0;
1596
+ function A(e) {
1597
+ D(void 0), h(e), n?.(e);
1598
+ }
1599
+ let te = ae(() => D(e));
1600
+ ie(() => {
1601
+ if (!b || O === void 0 || w?.request === O) return;
1602
+ let e = !0;
1603
+ return O.load().then((t) => {
1604
+ e && ee({
1605
+ request: O,
1606
+ source: t
1607
+ });
1608
+ }, () => {
1609
+ e && te();
1610
+ }), () => {
1611
+ e = !1;
1612
+ };
1613
+ }, [
1614
+ O,
1615
+ b,
1616
+ w?.request
1617
+ ]);
1618
+ function ne(e) {
1619
+ _(e), i?.(e);
1620
+ }
1621
+ function re(e) {
1622
+ y(e), u?.(e);
1623
+ }
1624
+ let M = k?.mapping, P = M !== void 0 && d.tick >= M.firstTick && d.tick <= M.lastTick, oe = e !== void 0 && T === e, L = b && !oe ? k : void 0, R = L !== void 0 && P, z = L !== void 0 && M !== void 0 && !P;
1625
+ return /* @__PURE__ */ I(c, {
1626
+ isCompact: !0,
1627
+ children: [
1628
+ e !== void 0 && /* @__PURE__ */ I(S.Root, {
1629
+ "aria-label": "Replay view",
1630
+ value: b ? "footage" : "map",
1631
+ onValueChange: (e) => A(e === "footage"),
1632
+ children: [/* @__PURE__ */ F(S.Item, {
1633
+ value: "map",
1634
+ children: "Map"
1635
+ }), /* @__PURE__ */ F(S.Item, {
1636
+ value: "footage",
1637
+ children: "Footage"
1638
+ })]
1639
+ }),
1640
+ b && oe && /* @__PURE__ */ F(o, {
1641
+ role: "status",
1642
+ variant: "caption",
1643
+ children: "Footage unavailable. Showing the map."
1644
+ }),
1645
+ z && /* @__PURE__ */ I(l, { children: [/* @__PURE__ */ I(o, {
1646
+ variant: "caption",
1647
+ children: [
1648
+ "Footage covers ticks ",
1649
+ M.firstTick,
1650
+ "–",
1651
+ M.lastTick,
1652
+ "."
1653
+ ]
1654
+ }), /* @__PURE__ */ F(a, {
1655
+ variant: "ghost",
1656
+ onClick: () => {
1657
+ ne(!1), d.onTickChange(M.firstTick);
1658
+ },
1659
+ children: "Go to footage"
1660
+ })] }),
1661
+ /* @__PURE__ */ F(st, {
1662
+ ...d,
1663
+ isPlaying: x,
1664
+ onPlayingChange: ne,
1665
+ speed: C,
1666
+ onSpeedChange: re,
1667
+ scene: R ? /* @__PURE__ */ F(E, {
1668
+ title: d.clip.title,
1669
+ locale: f,
1670
+ description: d.clip.arms[L.mapping.arm]?.label,
1671
+ actions: /* @__PURE__ */ I(o, {
1672
+ variant: "caption",
1673
+ children: [
1674
+ d.labels?.tick ?? "Tick",
1675
+ " ",
1676
+ p.format(d.tick)
1677
+ ]
1678
+ }),
1679
+ children: /* @__PURE__ */ F(wt, {
1680
+ source: L,
1681
+ tick: d.tick,
1682
+ isPlaying: x,
1683
+ rate: C * d.clip.hz,
1684
+ label: d.clip.arms[L.mapping.arm]?.label ?? d.clip.title,
1685
+ onError: () => D(e)
1686
+ }, L.src)
1687
+ }) : d.scene
1688
+ })
1689
+ ]
1690
+ });
1691
+ }
1692
+ export { R as FindingCard, Ee as LineageGraph, Ae as MilestonePath, st as MotionFigure, rt as MotionScene, Tt as NativeMotionFigure, Fe as SpecimenDiff, ze as WorkHeartbeat, Ve as defaultMotionView, et as motionSceneAt, xt as motionSha256, Ct as nativeMotionTime, G as normalizeMotionView, Je as parseMotionClip, bt as parseNativeMotionMapping, lt as readMotionLocation, St as verifyNativeMotion, ut as writeMotionLocation };