@mechane-ai/elements 0.67.0 → 0.68.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 (77) hide show
  1. package/dist/ai.js +225 -224
  2. package/dist/{article-anMy8fA5.js → article-Ni152e-v.js} +104 -89
  3. package/dist/article.js +1 -1
  4. package/dist/catalog.json +71 -1
  5. package/dist/{categorical-values-Bh7ZkEQn.js → categorical-values-6Iz03F1i.js} +1 -1
  6. package/dist/{cells-X8SVrZBc.js → cells-BRI8LpMU.js} +1 -1
  7. package/dist/charts/cartesian.js +1 -1
  8. package/dist/charts/cells.js +1 -1
  9. package/dist/charts/comparison.js +1 -1
  10. package/dist/charts/distribution.js +1 -1
  11. package/dist/charts/figure.js +12 -12
  12. package/dist/charts/graph.js +1 -1
  13. package/dist/charts/hierarchy.js +1 -1
  14. package/dist/charts/image.js +1 -1
  15. package/dist/charts/matrix.js +2 -2
  16. package/dist/charts/plot.js +16 -15
  17. package/dist/charts/relationship.js +1 -1
  18. package/dist/charts/text.js +1 -1
  19. package/dist/charts/timeline.js +2 -2
  20. package/dist/charts/trend.js +1 -1
  21. package/dist/charts.js +3 -3
  22. package/dist/{color-legend-CIo7DhXB.js → color-legend-4As8881l.js} +1 -1
  23. package/dist/content/markdown.js +1 -1
  24. package/dist/{dumbbell-plot-BQDGe0sQ.js → dumbbell-plot-jaQvOctJ.js} +4 -4
  25. package/dist/{embedding-map-DmmknG7A.js → embedding-map-DnZL1kvY.js} +5 -5
  26. package/dist/figure-format-BVb7yFCA.js +46 -0
  27. package/dist/{figure-frame-DlyNTDzh.js → figure-frame-96zFqsWz.js} +1 -1
  28. package/dist/{image-grid-CxEAQvTf.js → image-grid-B6fdmE9c.js} +3 -3
  29. package/dist/kits/evaluation.js +5 -5
  30. package/dist/kits/interpretability.js +8 -8
  31. package/dist/kits/operations.js +4 -4
  32. package/dist/kits/research.js +641 -229
  33. package/dist/kits/training.js +4 -4
  34. package/dist/lesson.js +3 -3
  35. package/dist/markdown-JeuBeMDZ.js +293 -0
  36. package/dist/mdx.js +4 -4
  37. package/dist/packages/charts/src/plot/index.d.ts +2 -0
  38. package/dist/packages/charts/src/plot/plot-layout.d.ts +2 -2
  39. package/dist/packages/charts/src/plot/spatial-layer.d.ts +32 -0
  40. package/dist/packages/charts/src/plot/ticks.d.ts +2 -2
  41. package/dist/packages/foundations/src/visible-motion.d.ts +1 -1
  42. package/dist/packages/kits/src/research/index.d.ts +7 -0
  43. package/dist/packages/kits/src/research/motion-clip.d.ts +41 -0
  44. package/dist/packages/kits/src/research/motion-error.d.ts +8 -0
  45. package/dist/packages/kits/src/research/motion-figure.d.ts +9 -0
  46. package/dist/packages/kits/src/research/motion-frame.d.ts +22 -0
  47. package/dist/packages/kits/src/research/motion-scene.d.ts +22 -0
  48. package/dist/packages/teaching/src/article/uncover.d.ts +2 -0
  49. package/dist/{param-CKr8EYxF.js → param-Dk92C-K1.js} +1 -1
  50. package/dist/plot-CpTwLIYN.js +101 -0
  51. package/dist/{plot-layout-CVzSbcU7.js → plot-layout-1MG72ZWn.js} +151 -101
  52. package/dist/{plot-surface-CBhI1alw.js → plot-surface-8-FZI94y.js} +1 -1
  53. package/dist/{reference-lines-C970JwWZ.js → reference-lines-C18o1yEY.js} +1 -1
  54. package/dist/{scene-C3dCxckI.js → scene-B8dppj5V.js} +7 -7
  55. package/dist/scene.js +1 -1
  56. package/dist/{slope-chart-DekEJxsy.js → slope-chart-CELflRJd.js} +5 -5
  57. package/dist/styles2.css +12 -0
  58. package/dist/{time-series-BSNnijxf.js → time-series-DtAtGoT_.js} +6 -6
  59. package/dist/{timeline-CnxfYSIg.js → timeline-CzianQir.js} +4 -4
  60. package/dist/{token-heatmap-CJaXo56P.js → token-heatmap-m6oaMwkK.js} +273 -288
  61. package/dist/{token-predictions-Bi7aKPnh.js → token-predictions-CpGVjOIs.js} +4 -4
  62. package/dist/{transport-CXj0DV6o.js → transport-DQ1yzsQl.js} +2 -2
  63. package/dist/{tree-diagram-BxOZsjr1.js → tree-diagram-D9ekymCQ.js} +4 -4
  64. package/dist/{treemap-B2yOAetT.js → treemap-DT8q65LQ.js} +5 -5
  65. package/dist/{use-tween-C1TWJwce.js → use-tween-DbXVZBR8.js} +1 -1
  66. package/dist/{violin-plot-W2L_2JRo.js → violin-plot-83HSjnQM.js} +4 -4
  67. package/dist/visible-motion-D6NwjGNz.js +24 -0
  68. package/dist/{waterfall-Bt73N2Ng.js → waterfall-DmApvdrY.js} +4 -4
  69. package/package.json +1 -1
  70. package/recipes/recorded-motion.tsx +14 -0
  71. package/skills/review-elements/SKILL.md +4 -0
  72. package/skills/review-explainer/SKILL.md +4 -0
  73. package/skills/use-elements/SKILL.md +2 -0
  74. package/skills/use-elements/references/kits.md +23 -0
  75. package/skills/write-explainer/SKILL.md +5 -0
  76. package/dist/figure-format-B8kRZMlo.js +0 -36
  77. package/dist/markdown-Diffqqm7.js +0 -313
@@ -1,14 +1,14 @@
1
1
  import { r as e } from "./tokens.stylex-dF5CACEJ.js";
2
2
  import { t } from "./chart-tones-ei3BC2AL.js";
3
- import { A as n, D as r, E as i, M as a, O as o, S as s, a as c, i as l, j as u, n as d, s as f, x as p } from "./plot-layout-CVzSbcU7.js";
3
+ import { A as n, D as r, E as i, M as a, O as o, S as s, a as c, i as l, j as u, n as d, s as f, x as p } from "./plot-layout-1MG72ZWn.js";
4
4
  import { i as ee } from "./chart-link-AE_xuxiP.js";
5
- import { r as m } from "./figure-format-B8kRZMlo.js";
5
+ import { r as m } from "./figure-format-BVb7yFCA.js";
6
6
  import { a as h, i as g, o as _ } from "./scale-C2xgZyZN.js";
7
- import { i as te, l as ne, n as re, r as v, t as ie } from "./figure-frame-DlyNTDzh.js";
7
+ import { i as te, l as ne, n as re, r as v, t as ie } from "./figure-frame-96zFqsWz.js";
8
8
  import { n as ae } from "./plot-width-D3hTycYX.js";
9
9
  import { t as y } from "./plot-axes-D5S9BnBa.js";
10
10
  import { c as b, f as x, r as S, u as C } from "./plot-marks-DgCtcd3L.js";
11
- import { n as w, r as T, t as E } from "./plot-surface-CBhI1alw.js";
11
+ import { n as w, r as T, t as E } from "./plot-surface-8-FZI94y.js";
12
12
  import { r as D } from "./path-BglsXpnO.js";
13
13
  import { t as O } from "./locate-Bcg3QcP4.js";
14
14
  import * as k from "@stylexjs/stylex";
@@ -1,9 +1,9 @@
1
1
  import { O as e, m as t } from "./src-Bkov5TTa.js";
2
2
  import { d as n, u as r, x as i } from "./src-DceyVyL0.js";
3
3
  import { t as a } from "./forms-iAOjGRTO.js";
4
- import { r as o } from "./figure-format-B8kRZMlo.js";
4
+ import { r as o } from "./figure-format-BVb7yFCA.js";
5
5
  import { n as s, t as c } from "./clock-DSm5lkNE.js";
6
- import { a as l, c as u, d, f, h as p, m, o as h, p as g, r as _, s as v, v as y } from "./param-CKr8EYxF.js";
6
+ import { a as l, c as u, d, f, h as p, m, o as h, p as g, r as _, s as v, v as y } from "./param-Dk92C-K1.js";
7
7
  import "@stylexjs/stylex";
8
8
  import { usePart as ee, usePrimitive as te } from "@ui-sdk/react/primitive";
9
9
  import { use as b, useEffect as x, useId as S, useRef as ne, useState as re, useSyncExternalStore as C } from "react";
@@ -1,14 +1,14 @@
1
1
  import { A as e, E as t } from "./src-Bkov5TTa.js";
2
2
  import { t as n } from "./accessibility-P89UG9-r.js";
3
3
  import { n as r, t as i } from "./chart-tones-ei3BC2AL.js";
4
- import { A as a, D as o, E as s, M as c, O as l, S as u, T as d, c as f, j as p, x as m } from "./plot-layout-CVzSbcU7.js";
4
+ import { A as a, D as o, E as s, M as c, O as l, S as u, T as d, c as f, j as p, x as m } from "./plot-layout-1MG72ZWn.js";
5
5
  import { i as h } from "./chart-link-AE_xuxiP.js";
6
6
  import { a as g } from "./tone-scope-DKiSw-JR.js";
7
- import { r as _ } from "./figure-format-B8kRZMlo.js";
8
- import { i as v, l as y, n as b, r as x, t as S } from "./figure-frame-DlyNTDzh.js";
7
+ import { r as _ } from "./figure-format-BVb7yFCA.js";
8
+ import { i as v, l as y, n as b, r as x, t as S } from "./figure-frame-96zFqsWz.js";
9
9
  import { n as C, t as w } from "./plot-width-D3hTycYX.js";
10
10
  import { a as T, c as E, p as D, u as O } from "./plot-marks-DgCtcd3L.js";
11
- import { r as k } from "./plot-surface-CBhI1alw.js";
11
+ import { r as k } from "./plot-surface-8-FZI94y.js";
12
12
  import { t as A } from "./label-spacing-BncjePGb.js";
13
13
  import { i as ee } from "./path-BglsXpnO.js";
14
14
  import { m as j } from "./values-963L6n1m.js";
@@ -1,12 +1,12 @@
1
1
  import { t as e } from "./chart-tones-ei3BC2AL.js";
2
- import { A as t, E as n, M as r, S as i, j as a, s as o } from "./plot-layout-CVzSbcU7.js";
3
- import { i as s, n as c, t as l } from "./categorical-values-Bh7ZkEQn.js";
2
+ import { A as t, E as n, M as r, S as i, j as a, s as o } from "./plot-layout-1MG72ZWn.js";
3
+ import { i as s, n as c, t as l } from "./categorical-values-6Iz03F1i.js";
4
4
  import { i as u } from "./chart-link-AE_xuxiP.js";
5
5
  import { a as d } from "./tone-scope-DKiSw-JR.js";
6
- import { r as f } from "./figure-format-B8kRZMlo.js";
7
- import { i as p, l as m, n as h, r as g, t as _ } from "./figure-frame-DlyNTDzh.js";
6
+ import { r as f } from "./figure-format-BVb7yFCA.js";
7
+ import { i as p, l as m, n as h, r as g, t as _ } from "./figure-frame-96zFqsWz.js";
8
8
  import { n as v } from "./plot-width-D3hTycYX.js";
9
- import { n as y, r as b } from "./plot-surface-CBhI1alw.js";
9
+ import { n as y, r as b } from "./plot-surface-8-FZI94y.js";
10
10
  import * as x from "@stylexjs/stylex";
11
11
  import { useId as S } from "react";
12
12
  import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { _ as e } from "./param-CKr8EYxF.js";
1
+ import { _ as e } from "./param-Dk92C-K1.js";
2
2
  import { useEffect as t, useState as n, useSyncExternalStore as r } from "react";
3
3
  // packages/teaching/src/time/use-tween.ts
4
4
  function i(i, a = "regular") {
@@ -1,15 +1,15 @@
1
1
  import { n as e, t } from "./chart-tones-ei3BC2AL.js";
2
- import { A as n, E as r, M as i, S as a, a as o, c as s, i as c, j as l, n as u, o as d } from "./plot-layout-CVzSbcU7.js";
2
+ import { A as n, E as r, M as i, S as a, a as o, c as s, i as c, j as l, n as u, o as d } from "./plot-layout-1MG72ZWn.js";
3
3
  import { i as f } from "./chart-link-AE_xuxiP.js";
4
4
  import { a as p } from "./tone-scope-DKiSw-JR.js";
5
- import { r as m } from "./figure-format-B8kRZMlo.js";
5
+ import { r as m } from "./figure-format-BVb7yFCA.js";
6
6
  import { a as h, o as g } from "./scale-C2xgZyZN.js";
7
7
  import { t as _ } from "./chart-cursor-1mFd48Jc.js";
8
- import { i as v, l as y, n as b, r as x, t as S } from "./figure-frame-DlyNTDzh.js";
8
+ import { i as v, l as y, n as b, r as x, t as S } from "./figure-frame-96zFqsWz.js";
9
9
  import { n as C, t as w } from "./plot-width-D3hTycYX.js";
10
10
  import { t as T } from "./plot-axes-D5S9BnBa.js";
11
11
  import { a as E, f as D, l as O, r as k, s as A } from "./plot-marks-DgCtcd3L.js";
12
- import { n as ee, r as j, t as te } from "./plot-surface-CBhI1alw.js";
12
+ import { n as ee, r as j, t as te } from "./plot-surface-8-FZI94y.js";
13
13
  import { r as ne } from "./path-BglsXpnO.js";
14
14
  import { t as M } from "./locate-Bcg3QcP4.js";
15
15
  import * as N from "@stylexjs/stylex";
@@ -0,0 +1,24 @@
1
+ import { useEffect as e, useRef as t, useState as n } from "react";
2
+ // packages/foundations/src/visible-motion.ts
3
+ function r(r, i = !1) {
4
+ let a = t(null), [o, s] = n(!1);
5
+ return e(() => {
6
+ let e = a.current;
7
+ if (!r || e === null) return;
8
+ let t = matchMedia("(prefers-reduced-motion: reduce)"), n = !1;
9
+ function o() {
10
+ let e = i || !t.matches;
11
+ s(n && !document.hidden && e);
12
+ }
13
+ let c = new IntersectionObserver((e) => {
14
+ n = e.some((e) => e.isIntersecting), o();
15
+ });
16
+ return c.observe(e), t.addEventListener("change", o), document.addEventListener("visibilitychange", o), () => {
17
+ c.disconnect(), t.removeEventListener("change", o), document.removeEventListener("visibilitychange", o);
18
+ };
19
+ }, [r, i]), {
20
+ ref: a,
21
+ isActive: r && o
22
+ };
23
+ }
24
+ export { r as t };
@@ -1,16 +1,16 @@
1
1
  import { E as e, c as t, m as n } from "./src-Bkov5TTa.js";
2
2
  import { n as r, t as i } from "./chart-tones-ei3BC2AL.js";
3
- import { A as a, E as o, M as s, S as c, f as l, j as u, l as d, s as f } from "./plot-layout-CVzSbcU7.js";
3
+ import { A as a, E as o, M as s, S as c, f as l, j as u, l as d, s as f } from "./plot-layout-1MG72ZWn.js";
4
4
  import { i as ee } from "./chart-link-AE_xuxiP.js";
5
5
  import { a as te } from "./tone-scope-DKiSw-JR.js";
6
- import { n as p, r as m } from "./figure-format-B8kRZMlo.js";
6
+ import { n as p, r as m } from "./figure-format-BVb7yFCA.js";
7
7
  import { a as h, o as ne, r as re } from "./scale-C2xgZyZN.js";
8
8
  import { t as ie } from "./chart-cursor-1mFd48Jc.js";
9
- import { i as ae, l as g, n as oe, r as se, t as _ } from "./figure-frame-DlyNTDzh.js";
9
+ import { i as ae, l as g, n as oe, r as se, t as _ } from "./figure-frame-96zFqsWz.js";
10
10
  import { n as ce } from "./plot-width-D3hTycYX.js";
11
11
  import { t as le } from "./plot-axes-D5S9BnBa.js";
12
12
  import { a as v, c as ue, f as de, r as y } from "./plot-marks-DgCtcd3L.js";
13
- import { n as b, r as fe, t as pe } from "./plot-surface-CBhI1alw.js";
13
+ import { n as b, r as fe, t as pe } from "./plot-surface-8-FZI94y.js";
14
14
  import * as x from "@stylexjs/stylex";
15
15
  import { useId as me, useState as he } from "react";
16
16
  import { stackSpans as ge } from "@ui-sdk/core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechane-ai/elements",
3
- "version": "0.67.0",
3
+ "version": "0.68.0",
4
4
  "description": "Elements by Mechane — React components for applications, AI interfaces, and analytical graphics",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,14 @@
1
+ import { MotionFigure, parseMotionClip } from '@mechane-ai/elements/kits/research';
2
+ import { useMemo, useState } from 'react';
3
+
4
+ /**
5
+ * Scrub a recorded simulation or jump to a named observation. Decode bounded JSON once per clip, handle invalid input
6
+ * at the read boundary, and key this recipe by immutable clip ID. A linked essay or application can lift the integer
7
+ * tick into its own state.
8
+ */
9
+ export function RecordedMotion({ recording }: { readonly recording: unknown }) {
10
+ const clip = useMemo(() => parseMotionClip(recording), [recording]);
11
+ const [tick, setTick] = useState(clip.first);
12
+
13
+ return <MotionFigure clip={clip} tick={tick} onTickChange={setTick} />;
14
+ }
@@ -59,6 +59,10 @@ Check 360 pixels wide, a tablet width and a wide desktop.
59
59
  - Turn on reduced motion. Fades and slides stop, and nothing waits for an animation to finish. A scene lands on its new
60
60
  state at once and a `Playback` jumps to its end.
61
61
 
62
+ - For recorded motion, seek forward and backward across a measured change. Check its exact tick, including on the
63
+ keyboard. Drag during playback, leave the viewport and enable reduced motion while playing. The paused frame must stay
64
+ readable and the controls must keep their place. Compare the same tick in the poster and the player.
65
+
62
66
  ## 5. Honest content
63
67
 
64
68
  - Unknown is not zero. A missing value shows as unavailable, and a chart draws a gap.
@@ -54,6 +54,10 @@ In order of what matters most to a learner:
54
54
  12. **Keyboard.** Every `Param` takes arrow keys; each scene and chart is one Tab stop whose arrow keys reach every
55
55
  labelled object; a draggable `ScenePoint` is its own Tab stop, a slider the arrow keys move; a pressable card turns
56
56
  on Enter or Space; in the present view Right, Space and Left move.
57
+ 13. **Guided replays.** Scroll several passages at once, then back. Check the tick against the visible passage,
58
+ including on a phone where the figure pins above the text. Drag or step one tick with the keyboard and scroll again.
59
+ The reader keeps that tick until they choose a passage or resume following the text. Both actions pause playback.
60
+ Check that the figure leaves room to read and that every control stays reachable.
57
61
 
58
62
  ## 3. Read the code once
59
63
 
@@ -86,6 +86,8 @@ persistence and every asynchronous operation.
86
86
  `AppShell.sidebarControls` for a workspace picker.
87
87
  - **Linked figures.** Give each model, run or series one id. Wrap the figures in `ToneScope` and `ChartLink` so a thing
88
88
  keeps one hue and inspecting it in one figure marks it in the others.
89
+ - **Recorded simulation.** Use the `recorded-motion` recipe and the [research kit](references/kits.md) for a draggable
90
+ spatial replay, named moments and matching stills.
89
91
  - **A chart you cannot name.** Read `chartGuide` from `/charts/figure`, or the chooser in
90
92
  [charts](references/charts.md). It lists all 50 registered charts by family, with when to use each one.
91
93
  - **Allocation report.** Show how one total divides with a parts strip above one explanatory chart. Give each part one
@@ -179,3 +179,26 @@ import { RunDashboard, RunTable } from '@mechane-ai/elements/kits/training';
179
179
  />
180
180
  </>;
181
181
  ```
182
+
183
+ ### Recorded motion
184
+
185
+ Use the `recorded-motion` recipe for spatial observations on one integer clock. Limit attachment bytes before reading
186
+ JSON. Call `parseMotionClip` once, catch invalid input at the read boundary and offer the original evidence. The reader
187
+ controls `tick` through `MotionFigure.onTickChange`. Key by clip identity when changing recordings. Keep playback local
188
+ unless a poster or essay needs the controlled `isPlaying` and `onPlayingChange` pair. Start paused until a reader asks
189
+ to play.
190
+
191
+ - Supply version 1, title, inclusive first and last ticks, hz, initial speed, and shared bounds in left, top, right,
192
+ bottom order. Y increases down the page. Supply one to eight labeled arms and a list of named moments with distinct
193
+ IDs, integer ticks and optional detail. Source metadata stays opaque.
194
+ - Within each arm, give tracks a stable ID, label, increasing `[tick, x, y]` points and inclusive end. Motion
195
+ interpolates between points and holds the final position until end. Split tracks at gaps or jumps. Use disjoint
196
+ segments of the same ID to resume. Metric `[tick, value]` pairs change exactly at the given tick. Supply measured
197
+ values separately from sampled motion. Regions take a label and bounds.
198
+ - Keep long clips sparse where motion is predictable. Preserve the exact observations behind the finding. The decoder
199
+ accepts up to one million samples across positions and metrics, 4096 segments per arm and 512 moments. Smaller focused
200
+ windows usually read better.
201
+ - Use `isInspecting` for actor coordinates and the latest moment. Optional track `notes` are increasing `[tick, text]`
202
+ pairs. Inspection shows the latest note at or before the selected tick. Use `isGuided` when adjacent prose already
203
+ offers the named jumps. It keeps a pair side by side. Use `MotionScene` at explicit ticks for stills and movies and
204
+ `motionSceneAt` for matching data. A position with `sampled: false` is an estimate.
@@ -82,6 +82,11 @@ Take the part from `explainerGuide` (in `@mechane-ai/elements/lesson/spec`), who
82
82
  params through `sets`, which keeps them on their step grid and inside their range; do not round in a handler.
83
83
  - **No `requestAnimationFrame`, timer or CSS keyframe for motion.** Change a part's props and it eases on the shared
84
84
  clock, which also gives reduced motion its end state. Drive time with `Playback`.
85
+ - **For recorded motion, let prose guide the player until the reader takes over.** Give each `ScrollyStep` the observed
86
+ tick, for example `values={{ passage: moment.tick }}`. Feed `MotionFigure` from `@mechane-ai/elements/kits/research`
87
+ the lesson value `manual ? cursor : passage`. Play and drag set `manual` and update the cursor. Keep tracking the
88
+ passage while the reader explores. A passage button pauses and selects its tick. A “Follow the text” button pauses and
89
+ returns to the current passage.
85
90
  - **No hand-placed SVG where a scene part exists.** Parts are inspectable, keyboard-reachable and themed. Draw what no
86
91
  part draws with `SceneCustom`, which hands you the scene's scales and tones.
87
92
  - **Stable ids name things, not slots.** The Queen of Hearts is `queen-hearts` in every state and figure, so it moves
@@ -1,36 +0,0 @@
1
- import { formatNumber as e } from "@ui-sdk/core/number";
2
- import { dateFormatter as t } from "@ui-sdk/core/date";
3
- // packages/charts/src/figure/figure-format.ts
4
- var n = "Unavailable";
5
- function r({ value: t, locale: r, format: i }) {
6
- return t === null || !Number.isFinite(t) ? n : e(t, r, i);
7
- }
8
- function i(e) {
9
- return typeof e == "function" ? e : {
10
- notation: "compact",
11
- ...e
12
- };
13
- }
14
- function a({ timestamp: e, locale: n, format: r }) {
15
- return typeof r == "function" ? r(e) : t(n, r).format(e);
16
- }
17
- var o = {
18
- hourCycle: "h23",
19
- year: "numeric",
20
- month: "numeric",
21
- day: "numeric",
22
- hour: "numeric",
23
- minute: "numeric",
24
- second: "numeric"
25
- }, s = 1e3;
26
- function c(e, n) {
27
- let r = t("en-US", {
28
- ...o,
29
- timeZone: n
30
- }).formatToParts(e);
31
- function i(e) {
32
- return Number(r.find((t) => t.type === e)?.value);
33
- }
34
- return Date.UTC(i("year"), i("month") - 1, i("day"), i("hour"), i("minute"), i("second")) - Math.floor(e / s) * s;
35
- }
36
- export { c as a, i, a as n, r, n as t };
@@ -1,313 +0,0 @@
1
- import { t as e } from "./use-scroll-tab-index-Dxpdh4W7.js";
2
- import { t } from "./code-block-DbW_t9U4.js";
3
- import { n, t as r } from "./content-link-BN4NPp0u.js";
4
- import { t as i } from "./viewer-styles-DsFYri4K.js";
5
- import * as a from "@stylexjs/stylex";
6
- import { Children as o, createContext as s, createElement as c, memo as l, useContext as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
7
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
8
- import { Block as v, Streamdown as y, defaultRehypePlugins as b, defaultRemarkPlugins as x, useIsCodeFenceIncomplete as S } from "streamdown";
9
- // packages/foundations/src/visible-motion.ts
10
- function C(e) {
11
- let t = p(null), [n, r] = m(!1);
12
- return d(() => {
13
- let n = t.current;
14
- if (!e || n === null) return;
15
- let i = matchMedia("(prefers-reduced-motion: reduce)"), a = !1;
16
- function o() {
17
- r(a && !document.hidden && !i.matches);
18
- }
19
- let s = new IntersectionObserver((e) => {
20
- a = e.some((e) => e.isIntersecting), o();
21
- });
22
- return s.observe(n), i.addEventListener("change", o), document.addEventListener("visibilitychange", o), () => {
23
- s.disconnect(), i.removeEventListener("change", o), document.removeEventListener("visibilitychange", o);
24
- };
25
- }, [e]), {
26
- ref: t,
27
- isActive: e && n
28
- };
29
- }
30
- // packages/content/src/markdown/markdown-options.ts
31
- var w = /* @__PURE__ */ new Set(["href", "src"]), T = {
32
- rehypePlugins: Object.entries(b).filter(([e]) => e === "sanitize").map(([, e]) => e),
33
- remarkPlugins: Object.values(x),
34
- skipHtml: !0,
35
- urlTransform: (e, t) => {
36
- if (w.has(t)) return n(e);
37
- }
38
- }, E = {
39
- root: {
40
- k7Eaqz: "xeuugli",
41
- kMwMTN: "xbixft",
42
- kMv6JI: "x1hz01jw",
43
- khiITx: "xvmahel",
44
- kGuDYH: "xtqrqnz",
45
- kLWn49: "x1ytb0s6",
46
- k63SB2: "xj57cvi",
47
- kHjlTd: "xj0a0fe",
48
- $$css: !0
49
- },
50
- block: {
51
- keoZOQ: "xyrmp21 x14l7nz5",
52
- k1K539: "x1jfksii xzboxd6",
53
- $$css: !0
54
- },
55
- heading: {
56
- keoZOQ: "x1m1vpj6 x14l7nz5",
57
- k1K539: "x1jfksii xzboxd6",
58
- k63SB2: "x1b5ytql",
59
- $$css: !0
60
- },
61
- title: {
62
- kGuDYH: "x1i2cqwi",
63
- kLWn49: "x4fansv",
64
- $$css: !0
65
- },
66
- section: {
67
- kGuDYH: "x12myhf4",
68
- kLWn49: "x1778rvt",
69
- $$css: !0
70
- },
71
- minor: {
72
- kGuDYH: "xtqrqnz",
73
- kLWn49: "x1778rvt",
74
- $$css: !0
75
- },
76
- tableRegion: {
77
- k7Eaqz: "xeuugli",
78
- ks0D6T: "x193iq5w",
79
- kXHlph: "xw2csxc",
80
- kMzoRj: "xmkeg23",
81
- kt9PQ7: "x1qhh985",
82
- ksu8eU: "x1y0btm7",
83
- kVAM5u: "x1ey3b81",
84
- $$css: !0
85
- },
86
- strong: {
87
- k63SB2: "x1b5ytql",
88
- $$css: !0
89
- },
90
- muted: {
91
- kMwMTN: "x153jb6y",
92
- $$css: !0
93
- }
94
- }, D = {
95
- default: null,
96
- muted: E.muted
97
- }, O = {
98
- regular: null,
99
- strong: E.strong
100
- }, k = s(1), A = {
101
- animation: "fadeIn",
102
- duration: 160,
103
- stagger: 14,
104
- maxBacklogMs: 100
105
- }, j = /* @__PURE__ */ new Set(["string", "number"]);
106
- function M(e) {
107
- return j.has(typeof e);
108
- }
109
- function N({ children: e, className: n }) {
110
- let r = S(), i = typeof n == "string" ? /(?:^|\s)language-([^\s]+)/u.exec(n) : null, a = i === null ? void 0 : i[1], s = o.toArray(e);
111
- return s.every(M) ? /* @__PURE__ */ g("div", {
112
- className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6",
113
- children: /* @__PURE__ */ g(t, {
114
- code: s.join(""),
115
- language: a,
116
- isStreaming: r
117
- })
118
- }) : /* @__PURE__ */ g("code", {
119
- className: "xiard35 xy8obcc x1r7kqkb x1ok0vyi x10dazmo x14w6jbu x17etxam",
120
- children: e
121
- });
122
- }
123
- function P({ level: e, children: t, id: n }) {
124
- let r = u(k), i = `h${Math.min(e + r - 1, 6)}`, o = e === 1 ? E.title : e === 2 ? E.section : E.minor;
125
- return c(i, {
126
- id: n,
127
- ...a.props(E.heading, o)
128
- }, t);
129
- }
130
- function F({ children: t }) {
131
- let n = e();
132
- return /* @__PURE__ */ g("div", {
133
- ref: n.ref,
134
- role: "region",
135
- "aria-label": "Markdown table",
136
- tabIndex: n.tabIndex,
137
- ...a.props(i.scrollRegion, E.block, E.tableRegion),
138
- children: /* @__PURE__ */ g("table", {
139
- className: "xh8yej3 x1mwwwfo xss6m8b x1yc453h x1h4wwuj x1778rvt",
140
- children: t
141
- })
142
- });
143
- }
144
- var I = s(void 0);
145
- function L(e) {
146
- let t = u(I);
147
- return t === void 0 ? /* @__PURE__ */ g(r, {
148
- href: e.href,
149
- title: e.title,
150
- children: e.children
151
- }) : t(e);
152
- }
153
- var R = {
154
- h1: (e) => /* @__PURE__ */ g(P, {
155
- ...e,
156
- level: 1
157
- }),
158
- h2: (e) => /* @__PURE__ */ g(P, {
159
- ...e,
160
- level: 2
161
- }),
162
- h3: (e) => /* @__PURE__ */ g(P, {
163
- ...e,
164
- level: 3
165
- }),
166
- h4: (e) => /* @__PURE__ */ g(P, {
167
- ...e,
168
- level: 4
169
- }),
170
- h5: (e) => /* @__PURE__ */ g(P, {
171
- ...e,
172
- level: 5
173
- }),
174
- h6: (e) => /* @__PURE__ */ g(P, {
175
- ...e,
176
- level: 6
177
- }),
178
- p: ({ children: e }) => /* @__PURE__ */ g("p", {
179
- className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6",
180
- children: e
181
- }),
182
- ul: ({ children: e }) => /* @__PURE__ */ g("ul", {
183
- className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6 x1sbza1b",
184
- children: e
185
- }),
186
- ol: ({ children: e, start: t }) => /* @__PURE__ */ g("ol", {
187
- start: t,
188
- className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6 x1sbza1b",
189
- children: e
190
- }),
191
- li: ({ children: e }) => /* @__PURE__ */ g("li", {
192
- className: "x1vblts3 xnkn1qj",
193
- children: e
194
- }),
195
- blockquote: ({ children: e }) => /* @__PURE__ */ g("blockquote", {
196
- className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6 xrxpjvj x1umj4g3 xyumdvf x1t7ytsu x97x49r x153jb6y",
197
- children: e
198
- }),
199
- code: ({ children: e, className: t }) => /* @__PURE__ */ g(N, {
200
- className: t,
201
- children: e
202
- }),
203
- inlineCode: ({ children: e }) => /* @__PURE__ */ g("code", {
204
- className: "xiard35 xy8obcc x1r7kqkb x1ok0vyi x10dazmo x14w6jbu x17etxam",
205
- children: e
206
- }),
207
- a: ({ href: e, children: t, title: n }) => /* @__PURE__ */ g(L, {
208
- kind: "link",
209
- href: e,
210
- title: n,
211
- children: t
212
- }),
213
- img: ({ src: e, alt: t, title: n }) => /* @__PURE__ */ g(L, {
214
- kind: "image",
215
- href: typeof e == "string" ? e : void 0,
216
- title: n,
217
- children: t !== void 0 && t.length > 0 ? `Open image: ${t}` : "Open image"
218
- }),
219
- table: ({ children: e }) => /* @__PURE__ */ g(F, { children: e }),
220
- thead: ({ children: e }) => /* @__PURE__ */ g("thead", { children: e }),
221
- tbody: ({ children: e }) => /* @__PURE__ */ g("tbody", { children: e }),
222
- tr: ({ children: e }) => /* @__PURE__ */ g("tr", { children: e }),
223
- th: ({ children: e }) => /* @__PURE__ */ g("th", {
224
- scope: "col",
225
- className: "xn9t2bk x1doqdfy xso031l x1q0q8m5 x1qndepd x16dsc37 x1yc453h x153jb6y xk4h15q x1r7kqkb",
226
- children: e
227
- }),
228
- td: ({ children: e }) => /* @__PURE__ */ g("td", {
229
- className: "xn9t2bk x1doqdfy xso031l x1q0q8m5 x1qndepd x16dsc37 x1yc453h",
230
- children: e
231
- }),
232
- input: ({ checked: e }) => /* @__PURE__ */ g("input", {
233
- type: "checkbox",
234
- checked: e ?? !1,
235
- disabled: !0,
236
- "aria-label": "Task item",
237
- className: "x1bzlxqo x6e7ywc"
238
- }),
239
- hr: () => /* @__PURE__ */ g("hr", { className: "xhff0hu xc342km x178xt8z x13fuv20 xhjagg4" }),
240
- strong: ({ children: e }) => /* @__PURE__ */ g("strong", {
241
- className: "x1b5ytql",
242
- children: e
243
- }),
244
- em: ({ children: e }) => /* @__PURE__ */ g("em", {
245
- className: "x1k4tb9n",
246
- children: e
247
- }),
248
- del: ({ children: e }) => /* @__PURE__ */ g("del", {
249
- className: "x5lhwog",
250
- children: e
251
- })
252
- }, z = /* @__PURE__ */ "p.span.h1.h2.h3.h4.h5.h6.ul.ol.li.blockquote.pre.code.a.img.table.thead.tbody.tr.th.td.input.hr.strong.em.del.br.sup.sub.section".split("."), B = l(({ children: e, isStreaming: t = !1, label: n, headingLevel: r = 1, tone: i = "default", weight: o = "regular", renderLink: s, remarkPlugins: c }) => {
253
- let { ref: l, isActive: u } = C(t), d = f(() => [...T.remarkPlugins ?? [], ...c ?? []], [c]);
254
- return /* @__PURE__ */ g(I, {
255
- value: s,
256
- children: /* @__PURE__ */ g(k, {
257
- value: r,
258
- children: /* @__PURE__ */ g("div", {
259
- ref: l,
260
- "data-streamdown-paused": t && !u ? "" : void 0,
261
- children: /* @__PURE__ */ g(y, {
262
- ...T,
263
- remarkPlugins: d,
264
- ...a.props(E.root, D[i], O[o]),
265
- "aria-label": n,
266
- components: R,
267
- mode: t ? "streaming" : "static",
268
- isAnimating: t,
269
- animated: t ? A : !1,
270
- controls: !1,
271
- linkSafety: { enabled: !1 },
272
- allowedElements: z,
273
- children: e
274
- })
275
- })
276
- })
277
- });
278
- });
279
- // packages/content/src/markdown/markdown-preview.tsx
280
- function V({ children: e }) {
281
- return /* @__PURE__ */ _(h, { children: [e, " "] });
282
- }
283
- var H = {
284
- p: V,
285
- li: V,
286
- h1: V,
287
- h2: V,
288
- h3: V,
289
- h4: V,
290
- h5: V,
291
- h6: V,
292
- blockquote: V,
293
- pre: V,
294
- code: ({ children: e }) => /* @__PURE__ */ g(h, { children: e }),
295
- th: V,
296
- td: V,
297
- br: () => /* @__PURE__ */ g(h, { children: " " }),
298
- img: ({ alt: e }) => /* @__PURE__ */ g(h, { children: e })
299
- };
300
- function U({ children: e }) {
301
- return /* @__PURE__ */ g(v, {
302
- ...T,
303
- content: e,
304
- components: H,
305
- allowedElements: Object.keys(H),
306
- unwrapDisallowed: !0,
307
- shouldParseIncompleteMarkdown: !1,
308
- shouldNormalizeHtmlIndentation: !1,
309
- isIncomplete: !1,
310
- index: 0
311
- });
312
- }
313
- export { B as n, C as r, U as t };