@loadmap/react 0.8.0 → 0.9.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.
package/README.md CHANGED
@@ -92,12 +92,16 @@ pans the diagram in its own box). Each compact panel opens whole over the diagra
92
92
  'controls']}` keeps only those (`LOADMAP_PANELS` lists them all: `verdict`, `live`, `limits`, `controls`, `headroom`,
93
93
  `compare`, `assumptions`). A switch beside Close, or the F key, turns full screen into **focus**: the diagram, the
94
94
  story and, of the panels listed, the verdict and the load slider. `fullScreenMode="focus"` opens full screen there
95
- (default `'panels'`). The story bar plays the story, each step for its `seconds`.
95
+ (default `'panels'`). The story bar's Play tells the story on the diagram: the whole diagram, a close-up on what each
96
+ step changes, the change, and the whole diagram again for the step's `seconds`, a short title on the board (the step's
97
+ `title`, or what it changes). The component that runs out first wears a ring that breathes while the story plays and
98
+ once it is past the target. With reduced motion the camera cuts and the ring holds still. `ref.playStory()` plays it
99
+ on the engine's clock, which `step()` advances.
96
100
 
97
101
  `useLoadmap` with `LoadmapRoot`, `Diagram`, `Verdict`, `Limits`, `Controls` and the others builds a page of your own
98
102
  layout from the same pieces. The diagram's Full screen takes the whole root: inside a `<div className="lm-side">`
99
103
  after the `Diagram`, your pieces become a box below it that scrolls on its own; a title, the `Scenarios` and the
100
104
  `Story` stay above the diagram, and the rest waits outside. The controller has the state: `lm.fullScreen`,
101
- `lm.toggleFullScreen()`, `lm.fullScreenMode`, `lm.storyPlaying`.
105
+ `lm.toggleFullScreen()`, `lm.fullScreenMode`, `lm.storyPlaying`, `lm.cue` (what the board says about the step played).
102
106
 
103
107
  Docs, live examples and the editor: https://jaim3r0jas.github.io/loadmap/ · MIT
@@ -3,8 +3,149 @@ import { compact, fmt, monthOf, multiple, multiples, pct, secs } from "@loadmap/
3
3
  import { anchor, labelsAt, layout, legPath, localElk, pointAt, structureKey } from "@loadmap/layout";
4
4
  import { memo, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { morph } from "@loadmap/layout/internal";
6
+ import { morph, shapesOf } from "@loadmap/layout/internal";
7
7
  import { createSim } from "@loadmap/sim";
8
+ // src/camera.ts
9
+ /**
10
+ * The shots of a story played, in seconds: the whole diagram first, then for each step a flight in to what it changes,
11
+ * a moment close, the change held close, a flight out, and the whole diagram for the step's own seconds. `back` is the
12
+ * flight out when the reader pauses.
13
+ */
14
+ const SHOTS = {
15
+ establish: 1.2,
16
+ in: 1,
17
+ close: .5,
18
+ out: 1,
19
+ back: .4
20
+ };
21
+ /** The change is held close until the structure has moved and settled. */
22
+ const changeSeconds = (transition) => Math.max(1.6, transition + .7);
23
+ /** A step played, from the flight in to the end of its hold on the whole diagram. */
24
+ const stepSeconds = (st, transition) => SHOTS.in + SHOTS.close + changeSeconds(transition) + SHOTS.out + st.seconds;
25
+ /** The whole story played, from the first shot of the whole diagram. */
26
+ const storySeconds = (story, transition) => story.reduce((t, st) => t + stepSeconds(st, transition), SHOTS.establish);
27
+ const whole = (s) => ({
28
+ x: 0,
29
+ y: 0,
30
+ w: s.width,
31
+ h: s.height
32
+ });
33
+ /** The component a box stands for: its stages' component, or its own. */
34
+ function boxComponent(ev, n) {
35
+ return n.stages.map((s) => ev.stages[s]?.component).find(Boolean) ?? n.component ?? void 0;
36
+ }
37
+ /**
38
+ * The boxes a step's change is about, from the values before (`a`) to the step's (`b`): the box it points at and any box
39
+ * the change reshapes; else the boxes it reshapes or an edge that comes or goes ends at; else those whose component
40
+ * changes state; else the first limit after it.
41
+ */
42
+ function targets(scene, a, b, shapes, focus) {
43
+ const ids = new Set(scene.nodes.map((n) => n.id));
44
+ const reshaped = /* @__PURE__ */ new Set();
45
+ for (const id of ids) if (shapes.a.nodes[id] !== shapes.b.nodes[id]) reshaped.add(id);
46
+ const edgesA = new Set(shapes.a.edges.map((e) => e.id));
47
+ const edgesB = new Set(shapes.b.edges.map((e) => e.id));
48
+ for (const e of [...shapes.a.edges, ...shapes.b.edges]) if (edgesA.has(e.id) !== edgesB.has(e.id)) {
49
+ for (const end of [e.from, e.to]) if (ids.has(end)) reshaped.add(end);
50
+ }
51
+ const of = (c) => scene.nodes.filter((n) => c && boxComponent(b, n) === c).map((n) => n.id);
52
+ const order = (s) => scene.nodes.filter((n) => s.has(n.id)).map((n) => n.id);
53
+ if (focus) return order(/* @__PURE__ */ new Set([...of(focus), ...reshaped]));
54
+ if (reshaped.size) return order(reshaped);
55
+ const turned = scene.nodes.filter((n) => {
56
+ const c = boxComponent(b, n);
57
+ return c && a.components[c]?.state !== b.components[c]?.state;
58
+ });
59
+ if (turned.length) return turned.map((n) => n.id);
60
+ return of(b.firstLimit?.id);
61
+ }
62
+ /** The closest the camera comes: the boxes framed never fill more than this share of the board's width. */
63
+ const MAX_ZOOM = 2.5;
64
+ /** Boxes that take more than this share of the board's width are shown on the whole diagram. */
65
+ const WIDE = .8;
66
+ /**
67
+ * The part of the scene that shows these boxes with room around them, at the scene's own shape (the board's), at most
68
+ * 2.5× closer, inside the scene. The whole scene when there is nothing to frame or it would hardly be closer; with
69
+ * `hold`, as wide as it takes instead (a framing that follows boxes as they grow never jumps out).
70
+ */
71
+ function framing(scene, ids, o = {}) {
72
+ const all = whole(scene);
73
+ const ns = scene.nodes.filter((n) => ids.includes(n.id));
74
+ if (!ns.length || !(scene.width > 0 && scene.height > 0)) return all;
75
+ const x0 = Math.min(...ns.map((n) => n.x));
76
+ const y0 = Math.min(...ns.map((n) => n.y));
77
+ const x1 = Math.max(...ns.map((n) => n.x + n.w));
78
+ const y1 = Math.max(...ns.map((n) => n.y + n.h));
79
+ const aspect = scene.width / scene.height;
80
+ let w = Math.max(x1 - x0 + 60, (y1 - y0 + 60) * aspect, scene.width / MAX_ZOOM);
81
+ if (w > WIDE * scene.width && !o.hold) return all;
82
+ w = Math.min(w, scene.width);
83
+ const h = w / aspect;
84
+ const clamp = (v, hi) => Math.max(0, Math.min(hi, v));
85
+ return {
86
+ x: clamp((x0 + x1 - w) / 2, scene.width - w),
87
+ y: clamp((y0 + y1 - h) / 2, scene.height - h),
88
+ w,
89
+ h
90
+ };
91
+ }
92
+ /** Cubic in and out. */
93
+ const ease = (t) => t < .5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
94
+ /**
95
+ * The camera `t` of the way from `a` to `b` (eased): the centre moves evenly, the size changes by the same factor
96
+ * each moment, so a zoom feels even whatever its depth.
97
+ */
98
+ function between(a, b, t) {
99
+ const k = ease(Math.max(0, Math.min(1, t)));
100
+ const w = a.w * (b.w / a.w) ** k;
101
+ const h = a.h * (b.h / a.h) ** k;
102
+ const cx = a.x + a.w / 2 + (b.x + b.w / 2 - a.x - a.w / 2) * k;
103
+ const cy = a.y + a.h / 2 + (b.y + b.h / 2 - a.y - a.h / 2) * k;
104
+ return {
105
+ x: cx - w / 2,
106
+ y: cy - h / 2,
107
+ w,
108
+ h
109
+ };
110
+ }
111
+ /** A label's first words: "Users, × today" says "Users". */
112
+ const short = (label) => label.split(",")[0].trim();
113
+ /** At most this many changed values in a title; the rest are counted. */
114
+ const TITLE_VALUES = 2;
115
+ /**
116
+ * The few words the diagram shows for a step: its own title, or what it changes ("Proposed: Gateway instances 1 → 2,
117
+ * Worker pods 3 → 6"), numbered.
118
+ */
119
+ function stepTitle(model, from, st, i) {
120
+ if (st.title) return `${i + 1} · ${st.title}`;
121
+ const say = (k, v) => {
122
+ if (k === "load") return `${fmt(v)}×`;
123
+ const def = model.params.find((x) => x.id === k)?.def;
124
+ if (typeof v === "boolean") return v ? "on" : "off";
125
+ if (def && def.kind !== "load" && "format" in def && def.format) return def.format(v);
126
+ return typeof v === "number" ? fmt(v) : String(v);
127
+ };
128
+ const changed = Object.keys(st.values).filter((k) => from[k] !== st.values[k]);
129
+ const parts = changed.slice(0, TITLE_VALUES).map((k) => {
130
+ const label = k === "load" ? model.load.label : model.params.find((x) => x.id === k)?.def.label ?? k;
131
+ const to = st.values[k];
132
+ const was = from[k];
133
+ return typeof to === "boolean" ? `${short(label)} ${say(k, to)}` : `${short(label)} ${say(k, was)} → ${say(k, to)}`;
134
+ });
135
+ if (changed.length > TITLE_VALUES) parts.push(`${changed.length - TITLE_VALUES} more`);
136
+ const what = parts.join(", ") || "Nothing changes";
137
+ return `${i + 1} · ${st.scenario && changed.length ? `${st.scenario}: ${what}` : what}`;
138
+ }
139
+ /** What the framed components show: their utilization now, or before and after the change. */
140
+ function stepDetail(a, b, components) {
141
+ return components.slice(0, 2).map((c) => {
142
+ const was = a.components[c];
143
+ const now = b?.components[c];
144
+ if (!was) return "";
145
+ const u = (x) => x == null ? "off" : pct(x);
146
+ return now ? `${was.name} ${u(was.util)} → ${u(now.util)}` : `${was.name} ${u(was.util)}`;
147
+ }).filter(Boolean).join(" · ");
148
+ }
8
149
  // src/scenarios.tsx
9
150
  /** Scenario identity colours, in declaration order; a fifth and later scenario is drawn muted. */
10
151
  const SERIES = [
@@ -611,6 +752,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
611
752
  const barRef = useRef(null);
612
753
  const boardRef = useRef(null);
613
754
  const buttonRef = useRef(null);
755
+ const titleRef = useRef(null);
614
756
  const full = lm.fullScreen;
615
757
  const [tip, setTip] = useState(null);
616
758
  const detailId = useId();
@@ -630,6 +772,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
630
772
  frame,
631
773
  reducedMotion
632
774
  ]);
775
+ useLayoutEffect(() => engine.applyCamera());
633
776
  useEffect(() => {
634
777
  if (lm.root) engine.readColors(lm.root);
635
778
  }, [
@@ -649,6 +792,24 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
649
792
  ro.observe(board);
650
793
  return () => ro.disconnect();
651
794
  }, [engine]);
795
+ const follow = () => {
796
+ const wrap = wrapRef.current;
797
+ const board = boardRef.current;
798
+ const c = engine.camera;
799
+ const title = titleRef.current;
800
+ if (!c && !engine.cue) return;
801
+ if (!wrap || !board || !engine.frame || wrap.scrollHeight <= wrap.clientHeight) {
802
+ title?.style.removeProperty("top");
803
+ title?.style.removeProperty("bottom");
804
+ return;
805
+ }
806
+ const k = board.clientHeight / engine.frame.height;
807
+ if (c) wrap.scrollTop = board.offsetTop + (c.y + c.h / 2) * k - wrap.clientHeight / 2;
808
+ if (title) {
809
+ title.style.top = `${Math.max(0, wrap.scrollTop - board.offsetTop + (barRef.current?.offsetHeight ?? 0))}px`;
810
+ title.style.bottom = "auto";
811
+ }
812
+ };
652
813
  useEffect(() => {
653
814
  let raf = 0;
654
815
  let last = 0;
@@ -658,6 +819,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
658
819
  if (!engine.paused && engine.scene) {
659
820
  engine.step(dt, { particles: !reducedMotion });
660
821
  engine.draw({ particles: !reducedMotion });
822
+ follow();
661
823
  }
662
824
  raf = requestAnimationFrame(frame);
663
825
  };
@@ -772,20 +934,30 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
772
934
  className: "lm-board",
773
935
  ref: boardRef,
774
936
  style: frame ? { aspectRatio: `${frame.width} / ${frame.height}` } : { minHeight: 240 },
775
- children: [frame && /* @__PURE__ */ jsx(Structure, {
776
- lm,
777
- scene: frame,
778
- svgRef,
779
- rates: reducedMotion,
780
- setTip,
781
- onClick: onNodeClick ? onClick : void 0,
782
- selected
783
- }), /* @__PURE__ */ jsx("canvas", {
784
- ref: canvasRef,
785
- hidden: reducedMotion
786
- })]
937
+ children: [
938
+ frame && /* @__PURE__ */ jsx(Structure, {
939
+ lm,
940
+ scene: frame,
941
+ svgRef,
942
+ rates: reducedMotion,
943
+ setTip,
944
+ onClick: onNodeClick ? onClick : void 0,
945
+ selected
946
+ }),
947
+ /* @__PURE__ */ jsx("canvas", {
948
+ ref: canvasRef,
949
+ hidden: reducedMotion
950
+ }),
951
+ lm.cue && /* @__PURE__ */ jsxs("div", {
952
+ className: "lm-title",
953
+ "data-top": lm.cue.top || void 0,
954
+ "aria-hidden": "true",
955
+ ref: titleRef,
956
+ children: [/* @__PURE__ */ jsx("b", { children: lm.cue.title }), lm.cue.detail && /* @__PURE__ */ jsx("span", { children: lm.cue.detail })]
957
+ })
958
+ ]
787
959
  }),
788
- frame && tip && /* @__PURE__ */ jsx(Detail, {
960
+ frame && tip && !lm.storyPlaying && /* @__PURE__ */ jsx(Detail, {
789
961
  lm,
790
962
  scene: frame,
791
963
  id: tip.id,
@@ -825,10 +997,7 @@ function Legend({ lm }) {
825
997
  ]
826
998
  });
827
999
  }
828
- /** The component a box stands for: its stages' component, or its own. */
829
- function componentOf(lm, n) {
830
- return n.stages.map((s) => lm.ev.stages[s]?.component).find(Boolean) ?? n.component ?? void 0;
831
- }
1000
+ const componentOf = (lm, n) => boxComponent(lm.ev, n);
832
1001
  /** The SVG. It does not read the detail's state, so a hover re-renders the detail, not every box and edge. */
833
1002
  const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip, onClick, selected }) {
834
1003
  const marker = useId().replace(/:/g, "");
@@ -892,6 +1061,7 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip, on
892
1061
  };
893
1062
  };
894
1063
  const summary = scene.nodes.map((n) => labels.nodes[n.id]?.title).join(", ");
1064
+ const first = ev.firstLimit;
895
1065
  return /* @__PURE__ */ jsxs("svg", {
896
1066
  ref: svgRef,
897
1067
  viewBox: `0 0 ${scene.width} ${scene.height}`,
@@ -929,7 +1099,8 @@ const Structure = memo(function Structure({ lm, scene, svgRef, rates, setTip, on
929
1099
  focused: !!lm.focus && componentOf(lm, n) === lm.focus,
930
1100
  selected: selected === n.id,
931
1101
  handlers: handlers(n)
932
- }, n.id))
1102
+ }, n.id)),
1103
+ first && scene.nodes.filter((n) => componentOf(lm, n) === first.id).map((n) => /* @__PURE__ */ jsx(Halo, { n }, n.id))
933
1104
  ]
934
1105
  });
935
1106
  });
@@ -1138,6 +1309,65 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
1138
1309
  ]
1139
1310
  });
1140
1311
  }
1312
+ /** The width of the first limit's tag, in scene units. */
1313
+ const TAG_W = 72;
1314
+ /**
1315
+ * A ring around the first limit's box with a soft glow and a "first limit" tag on its top edge. The engine scales it
1316
+ * and its glow on its own clock; it is a layer of its own, so it moves nothing else. It fades with its box.
1317
+ */
1318
+ function Halo({ n }) {
1319
+ const d = 7;
1320
+ const box = {
1321
+ x: n.x - d,
1322
+ y: n.y - d,
1323
+ width: n.w + 14,
1324
+ height: n.h + 14,
1325
+ rx: 10
1326
+ };
1327
+ const tx = n.x + n.w + d - TAG_W - 8;
1328
+ return /* @__PURE__ */ jsxs("g", {
1329
+ className: "lm-halo",
1330
+ "data-halo": "",
1331
+ "data-cx": n.x + n.w / 2,
1332
+ "data-cy": n.y + n.h / 2,
1333
+ opacity: n.fade,
1334
+ pointerEvents: "none",
1335
+ children: [
1336
+ /* @__PURE__ */ jsx("rect", {
1337
+ ...box,
1338
+ "data-glow": "",
1339
+ fill: "none",
1340
+ stroke: "var(--lm-drop)",
1341
+ strokeWidth: "10",
1342
+ strokeOpacity: ".22"
1343
+ }),
1344
+ /* @__PURE__ */ jsx("rect", {
1345
+ ...box,
1346
+ fill: "none",
1347
+ stroke: "var(--lm-drop)",
1348
+ strokeWidth: "2.5"
1349
+ }),
1350
+ /* @__PURE__ */ jsx("rect", {
1351
+ x: tx,
1352
+ y: box.y - 7.5,
1353
+ width: TAG_W,
1354
+ height: "15",
1355
+ rx: "3",
1356
+ fill: "var(--lm-drop)"
1357
+ }),
1358
+ /* @__PURE__ */ jsx("text", {
1359
+ x: tx + TAG_W / 2,
1360
+ y: box.y + 3.5,
1361
+ textAnchor: "middle",
1362
+ fontSize: "9.5",
1363
+ fontWeight: "600",
1364
+ letterSpacing: ".06em",
1365
+ fill: "var(--lm-surface)",
1366
+ children: "FIRST LIMIT"
1367
+ })
1368
+ ]
1369
+ });
1370
+ }
1141
1371
  /**
1142
1372
  * A box's component in words, over the board: utilization, demand against capacity and where it came from, where it
1143
1373
  * reaches the target and 100 % (with dates, given growth), and its target in each scenario. HTML, so exports leave it out.
@@ -2075,17 +2305,18 @@ function Sparkline({ lm }) {
2075
2305
  /**
2076
2306
  * The model's story, a step at a time: the step's text, where it is, play, back and next. ← and → move through it
2077
2307
  * while the bar has the keyboard focus (the sliders keep their own arrows). The text keeps the room of the longest
2078
- * step, so stepping through it never moves what is below.
2308
+ * step, so stepping through it never moves what is below. While it plays, the bar shows the step played from the
2309
+ * moment the camera heads for it, before its values change.
2079
2310
  */
2080
2311
  function Story({ lm }) {
2081
2312
  const bar = useRef(null);
2082
2313
  const { story } = lm.model;
2083
2314
  if (!story.length) return null;
2084
- const i = lm.step;
2315
+ const i = lm.cue?.step ?? lm.step;
2085
2316
  const last = story.length - 1;
2086
2317
  const go = (to) => {
2087
2318
  const next = Math.max(0, Math.min(last, to));
2088
- if (next !== i) lm.setStep(next);
2319
+ if (next !== i || lm.storyPlaying) lm.setStep(next);
2089
2320
  };
2090
2321
  const keys = (e) => {
2091
2322
  if (e.key === "ArrowRight") go(i == null ? 0 : i + 1);
@@ -2138,7 +2369,7 @@ function Story({ lm }) {
2138
2369
  "aria-hidden": "true",
2139
2370
  children: story.map((st, k) => /* @__PURE__ */ jsx("i", {
2140
2371
  "data-state": k < i ? "done" : k === i ? "now" : void 0,
2141
- style: k === i ? { "--lm-step": `${st.seconds}s` } : void 0
2372
+ style: k === i ? { "--lm-step": `${stepSeconds(st, lm.engine.transition)}s` } : void 0
2142
2373
  }, k === i ? `${k}-${playing}` : k))
2143
2374
  }),
2144
2375
  /* @__PURE__ */ jsxs("span", {
@@ -2220,6 +2451,17 @@ const LOADMAP_CSS = `
2220
2451
  .lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }
2221
2452
  .lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }
2222
2453
  .lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
2454
+ /* the story's title over the board while it plays: a lower third, at the top when what is framed is low; a strip
2455
+ across the top of a narrow board */
2456
+ .lm-title { position: absolute; left: 12px; bottom: 12px; z-index: 1; display: grid; gap: 1px; max-width: min(34rem, calc(100% - 24px)); padding: 7px 12px 8px; border-left: 4px solid var(--lm-accent); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--lm-surface) 92%, transparent); box-shadow: 0 4px 16px rgb(0 0 0 / .12); pointer-events: none; overflow-wrap: anywhere; }
2457
+ .lm-title[data-top] { top: 12px; bottom: auto; }
2458
+ .lm-title b { font-size: .95rem; font-weight: 600; }
2459
+ .lm-title span { font: 500 .8rem var(--lm-mono); color: var(--lm-muted); }
2460
+ @container (max-width: 520px) {
2461
+ .lm-title, .lm-title[data-top] { top: 0; right: 0; bottom: auto; left: 0; max-width: none; padding: 4px 8px; border-radius: 0; box-shadow: none; }
2462
+ .lm-title b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2463
+ .lm-title span { display: none; }
2464
+ }
2223
2465
  .lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
2224
2466
  .lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
2225
2467
 
@@ -2477,6 +2719,12 @@ const TOKENS = [
2477
2719
  ];
2478
2720
  /** The stroke of a hollow dot, in scene units. */
2479
2721
  const RING = 1.4;
2722
+ /** Seconds the breathing of the first limit takes, in and out. */
2723
+ const BREATH = 2.4;
2724
+ /** Sets an attribute only when it changes: most frames change nothing. */
2725
+ function set(el, name, value) {
2726
+ if (el.getAttribute(name) !== value) el.setAttribute(name, value);
2727
+ }
2480
2728
  /**
2481
2729
  * Everything that moves, without React: the sim, the dots on the canvas, the worker fills in the SVG, and the move from
2482
2730
  * one structure to the next. React renders the structure once per scene, and once per frame while it moves; the engine
@@ -2505,6 +2753,13 @@ var Engine = class {
2505
2753
  storyStep = null;
2506
2754
  drawnFocus = null;
2507
2755
  paused = false;
2756
+ /** Flights cut and the first limit holds still. */
2757
+ reducedMotion = false;
2758
+ /** The part of the scene the board shows while the story plays; null for all of it. */
2759
+ camera = null;
2760
+ /** What the diagram says about the step the story plays; null when it does not play. */
2761
+ cue = null;
2762
+ host = null;
2508
2763
  colors = {};
2509
2764
  svg = null;
2510
2765
  canvas = null;
@@ -2520,6 +2775,9 @@ var Engine = class {
2520
2775
  frame: -1,
2521
2776
  paths: /* @__PURE__ */ new Map()
2522
2777
  };
2778
+ /** Seconds the engine has run since the last reset: the first limit breathes on it. */
2779
+ #clock = 0;
2780
+ #story = null;
2523
2781
  constructor(model, view, ev, o = {}) {
2524
2782
  this.model = model;
2525
2783
  this.view = view;
@@ -2569,6 +2827,7 @@ var Engine = class {
2569
2827
  seed: seed ?? this.#o.seed
2570
2828
  });
2571
2829
  this.#paths.clear();
2830
+ this.#clock = 0;
2572
2831
  if (this.#move && this.scene) {
2573
2832
  this.#move = null;
2574
2833
  this.#show(this.scene);
@@ -2589,6 +2848,7 @@ var Engine = class {
2589
2848
  });
2590
2849
  if (fresh) this.resize();
2591
2850
  this.drawFills();
2851
+ this.applyCamera();
2592
2852
  }
2593
2853
  /** Reads the theme tokens from the element that carries them. Call again when the theme changes. */
2594
2854
  readColors(root) {
@@ -2617,15 +2877,187 @@ var Engine = class {
2617
2877
  c.height = h;
2618
2878
  this.draw();
2619
2879
  }
2620
- /** Advances the sim, and the move to a new structure, by `dtReal` seconds. */
2880
+ /** Advances the sim, the move to a new structure and the story played, by `dtReal` seconds. */
2621
2881
  step(dtReal, o = {}) {
2622
2882
  this.#driven = this.paused;
2623
2883
  this.sim.step(dtReal, o);
2884
+ if (dtReal > 0) this.#clock += dtReal;
2624
2885
  const m = this.#move;
2625
- if (!m || dtReal <= 0) return;
2626
- m.t += dtReal / m.seconds;
2627
- if (m.t >= 1) this.#move = null;
2628
- this.#show(m.at(m.t));
2886
+ if (m && dtReal > 0) {
2887
+ m.t += dtReal / m.seconds;
2888
+ if (m.t >= 1) this.#move = null;
2889
+ this.#show(m.at(m.t));
2890
+ }
2891
+ if (this.#story) this.#direct(dtReal);
2892
+ }
2893
+ /** The story plays: from the whole diagram, step `from` and the ones after it. */
2894
+ get playing() {
2895
+ return !!this.#story && this.#story.shot !== "back";
2896
+ }
2897
+ /**
2898
+ * Plays the story from step `from` on the engine's clock: the whole diagram, then for each step a flight in to what it
2899
+ * changes, the change, a flight out and the whole diagram for its seconds. The host shows each step's values. False
2900
+ * when it cannot: nothing is drawn yet, or there is no such step.
2901
+ */
2902
+ playStory(from) {
2903
+ if (!this.frame || !this.model.story[from]) return false;
2904
+ this.#story = {
2905
+ i: from - 1,
2906
+ shot: "establish",
2907
+ t: 0,
2908
+ from: whole(this.frame),
2909
+ close: whole(this.frame),
2910
+ zoom: false,
2911
+ targets: [],
2912
+ components: [],
2913
+ before: this.ev,
2914
+ waiting: false
2915
+ };
2916
+ this.#setCamera(null);
2917
+ this.host?.playing(true);
2918
+ return true;
2919
+ }
2920
+ /** Stops the story: the camera flies back to the whole diagram (cuts with `cut`), and the step shown stays. */
2921
+ stopStory(o = {}) {
2922
+ const s = this.#story;
2923
+ if (!s) return;
2924
+ this.cue = null;
2925
+ this.host?.cue(null);
2926
+ if (s.shot !== "back") this.host?.playing(false);
2927
+ if (o.cut || !this.camera || this.reducedMotion) {
2928
+ this.#story = null;
2929
+ this.#setCamera(null);
2930
+ } else this.#story = {
2931
+ ...s,
2932
+ shot: "back",
2933
+ t: 0,
2934
+ from: this.camera
2935
+ };
2936
+ }
2937
+ /** The page has drawn the values and the structure the engine has: a step's change can run. */
2938
+ #caughtUp() {
2939
+ return !!this.scene && this.scene.key === this.wantKey && this.drawnValues === JSON.stringify(this.ev.values);
2940
+ }
2941
+ #length(s) {
2942
+ if (s.shot === "change") return changeSeconds(this.transition);
2943
+ if (s.shot === "wide") return this.model.story[s.i]?.seconds ?? 0;
2944
+ return SHOTS[s.shot];
2945
+ }
2946
+ /** For tests and recordings: the shot the story is at. */
2947
+ get story() {
2948
+ const s = this.#story;
2949
+ return s && {
2950
+ i: s.i,
2951
+ shot: s.shot,
2952
+ t: s.t
2953
+ };
2954
+ }
2955
+ #direct(dt) {
2956
+ const s = this.#story;
2957
+ const frame = this.frame;
2958
+ if (!frame) return;
2959
+ if (s.waiting) {
2960
+ if (!this.#caughtUp()) return;
2961
+ s.waiting = false;
2962
+ }
2963
+ s.t += dt;
2964
+ while (this.#story === s && s.t >= this.#length(s) && !s.waiting) {
2965
+ s.t -= this.#length(s);
2966
+ this.#next(s);
2967
+ }
2968
+ if (this.#story !== s) return;
2969
+ const p = this.#length(s) > 0 ? s.t / this.#length(s) : 1;
2970
+ const cut = this.reducedMotion;
2971
+ const all = whole(frame);
2972
+ let cam;
2973
+ if (s.shot === "in") cam = cut ? s.close : between(all, s.close, p);
2974
+ else if (s.shot === "close") cam = s.close;
2975
+ else if (s.shot === "change") cam = s.zoom ? framing(frame, s.targets, { hold: true }) : all;
2976
+ else if (s.shot === "out" || s.shot === "back") cam = cut ? all : between(s.from, all, p);
2977
+ else cam = all;
2978
+ this.#setCamera(cam);
2979
+ }
2980
+ /** The shot after `s.shot`. */
2981
+ #next(s) {
2982
+ const frame = this.frame;
2983
+ const story = this.model.story;
2984
+ if (s.shot === "back") {
2985
+ this.#story = null;
2986
+ this.#setCamera(null);
2987
+ return;
2988
+ }
2989
+ if (s.shot === "establish" || s.shot === "wide") {
2990
+ if (s.i + 1 >= story.length) {
2991
+ this.#story = null;
2992
+ this.#setCamera(null);
2993
+ this.cue = null;
2994
+ this.host?.cue(null);
2995
+ this.host?.playing(false);
2996
+ return;
2997
+ }
2998
+ const i = s.i + 1;
2999
+ const st = story[i];
3000
+ const after = this.model.evaluate(st.values);
3001
+ const host = this.host;
3002
+ const ids = host ? targets(frame, this.ev, after, {
3003
+ a: host.shapes(this.ev),
3004
+ b: host.shapes(after)
3005
+ }, st.focus) : [];
3006
+ const nodes = frame.nodes.filter((n) => ids.includes(n.id));
3007
+ const components = [...new Set(nodes.map((n) => boxComponent(after, n)).filter((c) => c != null))];
3008
+ const close = framing(frame, ids);
3009
+ const zoom = close.w < frame.width - 1e-6;
3010
+ Object.assign(s, {
3011
+ i,
3012
+ shot: "in",
3013
+ from: whole(frame),
3014
+ close,
3015
+ zoom,
3016
+ targets: ids,
3017
+ components,
3018
+ before: this.ev
3019
+ });
3020
+ this.#cue({
3021
+ step: i,
3022
+ title: stepTitle(this.model, this.ev.values, st, i),
3023
+ detail: stepDetail(this.ev, null, components),
3024
+ after: false,
3025
+ top: close.y + close.h / 2 > frame.height * .55
3026
+ });
3027
+ return;
3028
+ }
3029
+ if (s.shot === "in") s.shot = "close";
3030
+ else if (s.shot === "close") {
3031
+ s.shot = "change";
3032
+ s.waiting = true;
3033
+ this.host?.show(s.i);
3034
+ this.#cue({
3035
+ ...this.cue,
3036
+ detail: stepDetail(s.before, this.ev, s.components),
3037
+ after: true
3038
+ });
3039
+ } else if (s.shot === "change") {
3040
+ s.shot = "out";
3041
+ s.from = this.camera ?? whole(frame);
3042
+ } else if (s.shot === "out") s.shot = "wide";
3043
+ }
3044
+ #cue(c) {
3045
+ this.cue = c;
3046
+ this.host?.cue(c);
3047
+ }
3048
+ #setCamera(cam) {
3049
+ const f = this.frame;
3050
+ const all = f && cam && Math.abs(cam.x) < 1e-6 && Math.abs(cam.y) < 1e-6 && Math.abs(cam.w - f.width) < 1e-6;
3051
+ this.camera = !cam || all ? null : cam;
3052
+ this.applyCamera();
3053
+ }
3054
+ /** Points the SVG at the camera: React draws the whole scene's viewBox, the camera replaces it after each render. */
3055
+ applyCamera() {
3056
+ const f = this.frame;
3057
+ if (!this.svg || !f) return;
3058
+ const c = this.camera ?? whole(f);
3059
+ const box = `${c.x} ${c.y} ${c.w} ${c.h}`;
3060
+ if (this.svg.getAttribute("viewBox") !== box) this.svg.setAttribute("viewBox", box);
2629
3061
  }
2630
3062
  /** Draws the dots on the overlay canvas and the worker fills in the SVG. */
2631
3063
  draw(o = {}) {
@@ -2639,6 +3071,16 @@ var Engine = class {
2639
3071
  this.paintParticles(ctx, c.width / this.frame.width);
2640
3072
  }
2641
3073
  drawFills() {
3074
+ const first = this.ev.firstLimit;
3075
+ const breathe = !this.reducedMotion && (this.playing || first?.state === "warn" || first?.state === "over");
3076
+ const b = breathe ? .5 - .5 * Math.cos(2 * Math.PI * this.#clock / BREATH) : .5;
3077
+ for (const el of this.svg?.querySelectorAll("g[data-halo]") ?? []) {
3078
+ const [cx, cy] = [Number(el.dataset.cx), Number(el.dataset.cy)];
3079
+ const k = 1 + .035 * b;
3080
+ set(el, "transform", breathe ? `translate(${cx} ${cy}) scale(${k.toFixed(4)}) translate(${-cx} ${-cy})` : "");
3081
+ const glow = el.querySelector("[data-glow]");
3082
+ if (glow) set(glow, "stroke-opacity", (.1 + .25 * b).toFixed(3));
3083
+ }
2642
3084
  for (const sl of this.#slots) {
2643
3085
  const b = this.sim.slotBusy(sl.stage, sl.index);
2644
3086
  const h = b < .02 ? 0 : (sl.s - 2) * b;
@@ -2669,11 +3111,18 @@ var Engine = class {
2669
3111
  for (const id of this.#paths.keys()) if (!live.has(id)) this.#paths.delete(id);
2670
3112
  return out;
2671
3113
  }
2672
- /** Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. */
3114
+ /**
3115
+ * Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. Under the camera they
3116
+ * go where the SVG shows their places (its viewBox, centred where its shape differs), so they keep matching the bars.
3117
+ */
2673
3118
  paintParticles(ctx, scale) {
2674
- if (!this.frame) return;
3119
+ const f = this.frame;
3120
+ if (!f) return;
3121
+ const c = this.camera ?? whole(f);
3122
+ const [bw, bh] = [f.width * scale, f.height * scale];
3123
+ const k = Math.min(bw / c.w, bh / c.h);
2675
3124
  ctx.save();
2676
- ctx.transform(scale, 0, 0, scale, 0, 0);
3125
+ ctx.transform(k, 0, 0, k, (bw - c.w * k) / 2 - c.x * k, (bh - c.h * k) / 2 - c.y * k);
2677
3126
  for (const d of this.dots()) {
2678
3127
  ctx.globalAlpha = d.alpha;
2679
3128
  ctx.beginPath();
@@ -2729,15 +3178,17 @@ function useLoadmap(model, view, o = {}) {
2729
3178
  model,
2730
3179
  values: init()
2731
3180
  }));
3181
+ const evaluated = useRef(null);
2732
3182
  let values = state.values;
2733
3183
  if (state.model !== model) {
2734
3184
  values = init();
3185
+ evaluated.current = null;
2735
3186
  setState({
2736
3187
  model,
2737
3188
  values
2738
3189
  });
2739
3190
  }
2740
- const evaluated = useRef(null);
3191
+ const fresh = !evaluated.current || evaluated.current.values === values;
2741
3192
  const ev = useMemo(() => evaluated.current?.values === values ? evaluated.current.ev : model.evaluate(values), [model, values]);
2742
3193
  const engineRef = useRef(null);
2743
3194
  if (!engineRef.current || engineRef.current.model !== model || engineRef.current.view !== view) engineRef.current = new Engine(model, view, ev, o);
@@ -2750,8 +3201,15 @@ function useLoadmap(model, view, o = {}) {
2750
3201
  const [laid, setLaid] = useState(null);
2751
3202
  const scene = laid?.view === view ? laid.scene : null;
2752
3203
  const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
3204
+ engine.reducedMotion = reducedMotion;
2753
3205
  const narrowBelow = o.narrowBelow ?? 640;
2754
- useEffect(() => engine.setEvaluation(ev), [engine, ev]);
3206
+ useEffect(() => {
3207
+ if (!evaluated.current || evaluated.current.values === values) engine.setEvaluation(ev);
3208
+ }, [
3209
+ engine,
3210
+ ev,
3211
+ values
3212
+ ]);
2755
3213
  useEffect(() => {
2756
3214
  if (!root) return;
2757
3215
  setMeasure(() => canvasMeasure(getComputedStyle(root).fontFamily));
@@ -2775,7 +3233,7 @@ function useLoadmap(model, view, o = {}) {
2775
3233
  direction,
2776
3234
  measure
2777
3235
  ]);
2778
- engine.wantKey = key;
3236
+ if (fresh) engine.wantKey = key;
2779
3237
  const elk = o.elk;
2780
3238
  useEffect(() => {
2781
3239
  if (!measure || !key) return;
@@ -2803,8 +3261,8 @@ function useLoadmap(model, view, o = {}) {
2803
3261
  ]);
2804
3262
  const labels = useMemo(() => labelsAt(view, ev), [view, ev]);
2805
3263
  const valuesRef = useRef(values);
2806
- valuesRef.current = values;
2807
- const setValues = useCallback((v) => {
3264
+ if (fresh) valuesRef.current = values;
3265
+ const apply = useCallback((v) => {
2808
3266
  const next = {
2809
3267
  ...valuesRef.current,
2810
3268
  ...v
@@ -2821,6 +3279,18 @@ function useLoadmap(model, view, o = {}) {
2821
3279
  values: next
2822
3280
  });
2823
3281
  }, [engine, model]);
3282
+ const [played, setPlayed] = useState({
3283
+ engine,
3284
+ on: false,
3285
+ cue: null
3286
+ });
3287
+ const playing = played.engine === engine && played.on;
3288
+ const cue = played.engine === engine ? played.cue : null;
3289
+ const stop = useCallback(() => engine.stopStory(), [engine]);
3290
+ const setValues = useCallback((v) => {
3291
+ stop();
3292
+ apply(v);
3293
+ }, [stop, apply]);
2824
3294
  const scenario = useMemo(() => model.scenarioOf(values), [model, values]);
2825
3295
  const setScenario = useCallback((label) => {
2826
3296
  const s = model.scenarios.find((x) => x.label === label);
@@ -2831,9 +3301,9 @@ function useLoadmap(model, view, o = {}) {
2831
3301
  i: null
2832
3302
  });
2833
3303
  const step = stepState.model === model && stepState.i != null && stepState.i < model.story.length ? stepState.i : null;
2834
- const setStep = useCallback((i) => {
3304
+ const show = useCallback((i) => {
2835
3305
  const st = i == null ? void 0 : model.story[i];
2836
- if (st) setValues(st.values);
3306
+ if (st) apply(st.values);
2837
3307
  engine.wantFocus = st?.focus ?? null;
2838
3308
  engine.storyStep = st ? i : null;
2839
3309
  setStepState({
@@ -2842,36 +3312,61 @@ function useLoadmap(model, view, o = {}) {
2842
3312
  });
2843
3313
  }, [
2844
3314
  model,
2845
- setValues,
3315
+ apply,
2846
3316
  engine
2847
3317
  ]);
3318
+ const setStep = useCallback((i) => {
3319
+ stop();
3320
+ show(i);
3321
+ }, [stop, show]);
2848
3322
  const shown = step == null ? void 0 : model.story[step];
2849
3323
  const stepChanged = !!shown && Object.entries(shown.values).some(([k, v]) => values[k] !== v);
2850
3324
  const focus = shown && !stepChanged ? shown.focus ?? null : null;
2851
3325
  engine.wantFocus = focus;
2852
3326
  engine.storyStep = step;
2853
- const [playing, setPlaying] = useState(false);
2854
- if (playing && (step == null || stepChanged)) setPlaying(false);
2855
- const storyPlaying = playing && step != null && !stepChanged;
3327
+ const measureRef = useRef(measure);
3328
+ measureRef.current = measure;
3329
+ engine.host = {
3330
+ playing: (on) => setPlayed((p) => ({
3331
+ engine,
3332
+ on,
3333
+ cue: on && p.engine === engine ? p.cue : null
3334
+ })),
3335
+ show,
3336
+ cue: (c) => setPlayed((p) => ({
3337
+ engine,
3338
+ on: p.engine === engine && p.on,
3339
+ cue: c
3340
+ })),
3341
+ shapes: (e) => shapesOf(view, e, {
3342
+ direction,
3343
+ measure: measureRef.current ?? void 0
3344
+ })
3345
+ };
2856
3346
  useEffect(() => {
2857
- if (!storyPlaying || step == null) return;
2858
- const last = model.story.length - 1;
2859
- const t = setTimeout(() => step < last ? setStep(step + 1) : setPlaying(false), model.story[step].seconds * 1e3);
2860
- return () => clearTimeout(t);
3347
+ if (playing && stepChanged) stop();
2861
3348
  }, [
2862
- storyPlaying,
2863
- step,
2864
- model,
2865
- setStep
3349
+ playing,
3350
+ stepChanged,
3351
+ stop
2866
3352
  ]);
3353
+ const storyPlaying = playing && model.story.length > 0;
2867
3354
  const setStoryPlaying = useCallback((on) => {
2868
- if (on && (step == null || stepChanged || step === model.story.length - 1)) setStep(step == null || step === model.story.length - 1 ? 0 : step);
2869
- setPlaying(on && model.story.length > 0);
3355
+ if (!on) return stop();
3356
+ const last = model.story.length - 1;
3357
+ if (last < 0) return;
3358
+ const from = step == null || step === last ? 0 : stepChanged ? step : step + 1;
3359
+ if (stepChanged) show(null);
3360
+ engine.playStory(from);
3361
+ if (!document.fullscreenElement && !root?.hasAttribute("data-full")) root?.querySelector(".lm-board")?.scrollIntoView({ block: "nearest" });
2870
3362
  }, [
2871
3363
  step,
2872
3364
  stepChanged,
2873
3365
  model,
2874
- setStep
3366
+ engine,
3367
+ stop,
3368
+ show,
3369
+ root
2875
3370
  ]);
2876
3371
  const [screen, setScreen] = useState(false);
2877
3372
  const [overlay, setOverlay] = useState(false);
@@ -2946,6 +3441,7 @@ function useLoadmap(model, view, o = {}) {
2946
3441
  focus,
2947
3442
  storyPlaying,
2948
3443
  setStoryPlaying,
3444
+ cue: storyPlaying ? cue : null,
2949
3445
  fullScreen,
2950
3446
  toggleFullScreen,
2951
3447
  fullScreenMode,
@@ -3200,6 +3696,10 @@ function handleOf(lm) {
3200
3696
  setValues: (v) => lm.setValues(v),
3201
3697
  setStoryStep: (i) => lm.setStep(i),
3202
3698
  storyStep: () => engine.storyStep,
3699
+ playStory: () => {
3700
+ if (!engine.playStory(0)) throw new Error("loadmap: the story cannot play: nothing is drawn yet, or there is none");
3701
+ return storySeconds(engine.model.story, engine.transition);
3702
+ },
3203
3703
  reset: (seed) => engine.reset(seed),
3204
3704
  step: (dt) => {
3205
3705
  engine.step(dt, { particles: true });
@@ -2,6 +2,22 @@ import { Evaluation, Model, Scenario, Values } from "@loadmap/core";
2
2
  import { Direction, ElkEngine, Scene, View, labelsAt } from "@loadmap/layout";
3
3
  import { ReactNode, Ref } from "react";
4
4
  import { Particle, Sim, SimOptions } from "@loadmap/sim";
5
+ /** A part of the scene the board shows, in scene units. */
6
+ interface Rect {
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ }
12
+ /** Each box's shape by id and the edges drawn, as `shapesOf` gives them: what a change of values reshapes. */
13
+ interface Shapes {
14
+ nodes: Record<string, string>;
15
+ edges: {
16
+ id: string;
17
+ from: string;
18
+ to: string;
19
+ }[];
20
+ }
5
21
  /** A dot as it is drawn now, in scene units. */
6
22
  interface Dot {
7
23
  x: number;
@@ -12,6 +28,25 @@ interface Dot {
12
28
  /** A retry: drawn as a ring of this stroke width, inside r. */
13
29
  ring?: number;
14
30
  }
31
+ /** What the diagram says while the story plays a step: its title, and what the boxes framed show. */
32
+ interface Cue {
33
+ step: number;
34
+ title: string;
35
+ detail: string;
36
+ /** The step's values are shown. */
37
+ after: boolean;
38
+ /** The boxes framed are low on the board: the title sits at its top. */
39
+ top: boolean;
40
+ }
41
+ /** How the story player reaches the page: it starts and stops, shows a step's values and says what it is at. */
42
+ interface StoryHost {
43
+ playing(on: boolean): void;
44
+ show(i: number): void;
45
+ cue(c: Cue | null): void;
46
+ /** Each box's shape and the edges drawn at these values (`shapesOf`, with the page's direction and fonts). */
47
+ shapes(ev: Evaluation): Shapes;
48
+ }
49
+ type Shot = 'establish' | 'in' | 'close' | 'change' | 'out' | 'wide' | 'back';
15
50
  /**
16
51
  * Everything that moves, without React: the sim, the dots on the canvas, the worker fills in the SVG, and the move from
17
52
  * one structure to the next. React renders the structure once per scene, and once per frame while it moves; the engine
@@ -41,6 +76,13 @@ declare class Engine {
41
76
  storyStep: number | null;
42
77
  drawnFocus: string | null;
43
78
  paused: boolean;
79
+ /** Flights cut and the first limit holds still. */
80
+ reducedMotion: boolean;
81
+ /** The part of the scene the board shows while the story plays; null for all of it. */
82
+ camera: Rect | null;
83
+ /** What the diagram says about the step the story plays; null when it does not play. */
84
+ cue: Cue | null;
85
+ host: StoryHost | null;
44
86
  colors: Record<string, string>;
45
87
  svg: SVGSVGElement | null;
46
88
  canvas: HTMLCanvasElement | null;
@@ -64,10 +106,30 @@ declare class Engine {
64
106
  flowColor(flow: string): string;
65
107
  outcomeColor(outcome: Particle['outcome']): string;
66
108
  resize(): void;
67
- /** Advances the sim, and the move to a new structure, by `dtReal` seconds. */
109
+ /** Advances the sim, the move to a new structure and the story played, by `dtReal` seconds. */
68
110
  step(dtReal: number, o?: {
69
111
  particles?: boolean;
70
112
  }): void;
113
+ /** The story plays: from the whole diagram, step `from` and the ones after it. */
114
+ get playing(): boolean;
115
+ /**
116
+ * Plays the story from step `from` on the engine's clock: the whole diagram, then for each step a flight in to what it
117
+ * changes, the change, a flight out and the whole diagram for its seconds. The host shows each step's values. False
118
+ * when it cannot: nothing is drawn yet, or there is no such step.
119
+ */
120
+ playStory(from: number): boolean;
121
+ /** Stops the story: the camera flies back to the whole diagram (cuts with `cut`), and the step shown stays. */
122
+ stopStory(o?: {
123
+ cut?: boolean;
124
+ }): void;
125
+ /** For tests and recordings: the shot the story is at. */
126
+ get story(): {
127
+ i: number;
128
+ shot: Shot;
129
+ t: number;
130
+ } | null;
131
+ /** Points the SVG at the camera: React draws the whole scene's viewBox, the camera replaces it after each render. */
132
+ applyCamera(): void;
71
133
  /** Draws the dots on the overlay canvas and the worker fills in the SVG. */
72
134
  draw(o?: {
73
135
  particles?: boolean;
@@ -75,7 +137,10 @@ declare class Engine {
75
137
  drawFills(): void;
76
138
  /** Every dot as it is drawn now, in scene units: for the canvas, and for an SVG export. */
77
139
  dots(): Dot[];
78
- /** Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. */
140
+ /**
141
+ * Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. Under the camera they
142
+ * go where the SVG shows their places (its viewBox, centred where its shape differs), so they keep matching the bars.
143
+ */
79
144
  paintParticles(ctx: CanvasRenderingContext2D, scale: number): void;
80
145
  }
81
146
  interface LoadmapOptions<P> extends SimOptions {
@@ -114,10 +179,18 @@ interface LoadmapController<P = any> {
114
179
  setStep: (i: number | null) => void;
115
180
  /** The component the story points at now. */
116
181
  focus: string | null;
117
- /** The story plays: each step for its seconds, then the next, until the last. */
182
+ /**
183
+ * The story plays: the whole diagram, then for each step a close-up on what it changes, the change, and the whole
184
+ * diagram again for its seconds, until the last.
185
+ */
118
186
  storyPlaying: boolean;
119
- /** Plays the story from the step shown (from the first outside the story or at its end), or pauses it. */
187
+ /**
188
+ * Plays the story from the step after the one shown (from the first outside the story or at its end), or pauses it.
189
+ * A value the reader changes, a scenario or a step they pick stops it.
190
+ */
120
191
  setStoryPlaying: (on: boolean) => void;
192
+ /** What the diagram says about the step the story plays; null when it does not play. */
193
+ cue: Cue | null;
121
194
  /** The root is full screen: the browser's, or an overlay where the browser has none or refuses. */
122
195
  fullScreen: boolean;
123
196
  toggleFullScreen: () => void;
@@ -160,6 +233,12 @@ interface LoadmapHandle {
160
233
  setStoryStep(i: number | null): void;
161
234
  /** The story step shown; null outside the story. */
162
235
  storyStep(): number | null;
236
+ /**
237
+ * Plays the story from its first step on the engine's clock, as Play does: the whole diagram, then for each step a
238
+ * close-up on what it changes, the change, and the whole diagram for its seconds. `step()` advances it; returns its
239
+ * length in seconds. Picking a step or a value stops it.
240
+ */
241
+ playStory(): number;
163
242
  /** The drawn board, for capturing frames: while the structure moves, `scene` is the frame drawn. */
164
243
  board(): {
165
244
  svg: SVGSVGElement;
@@ -203,4 +282,4 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
203
282
  /** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
204
283
  declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, fullScreen, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
205
284
  declare function handleOf(lm: LoadmapController): LoadmapHandle;
206
- export { LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as h, LoadmapPanel as i, usePageTheme as l, Dot as m, Loadmap as n, LoadmapRoot as o, useLoadmap as p, LoadmapHandle as r, Theme as s, LOADMAP_PANELS as t, FullScreenMode as u };
285
+ export { LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as g, Dot as h, LoadmapPanel as i, usePageTheme as l, Cue as m, Loadmap as n, LoadmapRoot as o, useLoadmap as p, LoadmapHandle as r, Theme as s, LOADMAP_PANELS as t, FullScreenMode as u };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LoadmapProps, c as handleOf, d as LoadmapController, f as LoadmapOptions, h as Engine, i as LoadmapPanel, l as usePageTheme, m as Dot, n as Loadmap, o as LoadmapRoot, p as useLoadmap, r as LoadmapHandle, s as Theme, t as LOADMAP_PANELS, u as FullScreenMode } from "./Loadmap-VLbQ__eh.js";
1
+ import { a as LoadmapProps, c as handleOf, d as LoadmapController, f as LoadmapOptions, g as Engine, h as Dot, i as LoadmapPanel, l as usePageTheme, m as Cue, n as Loadmap, o as LoadmapRoot, p as useLoadmap, r as LoadmapHandle, s as Theme, t as LOADMAP_PANELS, u as FullScreenMode } from "./Loadmap-DIqhwkgn.js";
2
2
  import { Comparison, Model } from "@loadmap/core";
3
3
  import { fitLinear } from "@loadmap/core/calibrate";
4
4
  import { compact, fmt, multiple, pct, secs } from "@loadmap/core/format";
@@ -73,7 +73,8 @@ export declare function HeadroomChart({ lm, title }: {
73
73
  /**
74
74
  * The model's story, a step at a time: the step's text, where it is, play, back and next. ← and → move through it
75
75
  * while the bar has the keyboard focus (the sliders keep their own arrows). The text keeps the room of the longest
76
- * step, so stepping through it never moves what is below.
76
+ * step, so stepping through it never moves what is below. While it plays, the bar shows the step played from the
77
+ * moment the camera heads for it, before its values change.
77
78
  */
78
79
  export declare function Story({ lm }: {
79
80
  lm: LoadmapController;
@@ -84,7 +85,7 @@ export declare function Story({ lm }: {
84
85
  * that has its own, set on the root (`.card > .lm`) so they resolve there and reach no nested board; full screen
85
86
  * keeps both.
86
87
  */
87
- export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-root-bg, var(--lm-bg));\n display: grid; gap: 14px; padding: var(--lm-pad, 16px); min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-problems { margin: 0; padding: 10px 12px; font: .8rem/1.5 var(--lm-mono); white-space: pre-wrap; overflow-x: auto; color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-drop); border-radius: 6px; }\n.lm-note { margin: 0; font-size: .8rem; color: var(--lm-muted); }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n/* full screen (the browser's, or a fixed overlay): a column that never scrolls. The diagram as wide as the screen on\n top; under it the verdict in a line and the panels, compact, in a dock the screen sizes. The load changes what is\n in them, never their size, so it never moves the board. Focus: the diagram, the story, the verdict and the load */\n.lm-side, .lm-card > .lm-panel { display: contents; }\n.lm-panel { display: grid; gap: 14px; min-width: 0; }\n.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; background: var(--lm-bg); overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }\n.lm[data-full=\"overlay\"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }\n.lm[data-full] > * { flex: none; }\n/* a page of its own keeps the rest outside full screen, as <Loadmap> does */\n.lm[data-full] > :not(.lm-head, h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-line, .lm-dock, .lm-side) { display: none; }\n.lm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-width: 0; }\n.lm-head h2 { font-size: 1.1rem; }\n.lm[data-full] .lm-wrap { gap: 6px; }\n/* the board as large as fits (--lm-fit, from Diagram), left under the bar, so the legend starts where the board does */\n.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }\n.lm-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }\n.lm-modes { display: inline-flex; margin: 0; padding: 0; min-width: 0; border: 1px solid var(--lm-line); border-radius: 6px; overflow: hidden; }\n.lm-modes button { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 0; padding: 6px 12px; cursor: pointer; }\n.lm-modes button[aria-pressed=\"true\"] { background: var(--lm-fg); color: var(--lm-surface); }\n.lm[data-full] .lm-story { padding: 6px 12px; }\n.lm[data-full] [data-out] { display: none; }\n\n.lm-line { display: flex; align-items: center; gap: 6px 14px; min-width: 0; padding: 6px 12px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-line[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-line[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-headline { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-num { font: 600 .95em var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-link { font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; white-space: nowrap; }\n.lm-line .lm-range { flex: 0 1 380px; display: grid; grid-template-columns: auto minmax(100px, 1fr); align-items: center; gap: 10px; font-size: .84rem; }\n.lm-line output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-line input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n\n.lm-dock { display: flex; gap: 10px; min-width: 0; }\n.lm[data-full] > .lm-dock { flex: 1 1 0; min-height: clamp(200px, 26dvh, 340px); }\n.lm-tabs { display: none; margin: 0; padding: 0; border: 0; min-width: 0; }\n.lm-mini { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: grid; container-type: inline-size; }\n.lm-mini[data-mini=\"controls\"] { flex-grow: 1.25; }\n.lm-mini[data-mini=\"limits\"] { flex-grow: 1.45; }\n.lm-mini[data-mini=\"live\"] { flex-grow: .8; }\n.lm-mini[data-mini=\"headroom\"] { flex-grow: .9; }\n.lm-mini[data-mini=\"compare\"] { flex-grow: 1.3; }\n.lm-mini > .lm-card { min-height: 0; overflow: hidden; padding: 10px 12px; gap: 6px; align-content: start; }\n.lm-mini [data-clip] { visibility: hidden; }\n.lm-more { position: absolute; top: 6px; right: 6px; font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: var(--lm-surface); border: 0; border-radius: 4px; padding: 2px 6px; cursor: pointer; }\n.lm-more[data-more]:not([data-more=\"\"])::before { content: attr(data-more) \" \"; }\n.lm-mini .lm-meters { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; }\n.lm-mini .lm-meter { display: flex; align-items: baseline; gap: 8px; padding: 3px 8px; }\n.lm-mini .lm-meter b { flex: none; font-size: .9rem; }\n.lm-mini .lm-meter span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n/* one grid for every row, so the bars line up whatever the names */\n.lm-mini-limits { display: grid; grid-template-columns: minmax(0, max-content) minmax(48px, 1fr) auto auto; gap: 6px 10px; }\n.lm-mini-lim { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: .8rem; }\n.lm-mini-lim .lm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-mini-lim .lm-tag { margin-left: 5px; }\n.lm-mini-lim .lm-track { height: 9px; }\n.lm-mini-lim .lm-val { white-space: nowrap; }\n.lm-mini-lim .lm-sub { font: 400 .74rem var(--lm-mono); color: var(--lm-muted); }\n.lm-mini .lm-controls { gap: 6px; column-gap: 16px; }\n.lm-mini .lm-controls small, .lm-mini .lm-controls > h3:not(:first-child) { display: none; }\n.lm-mini .lm-controls label.lm-range { grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr); align-items: center; gap: 10px; font-size: .8rem; }\n.lm-mini .lm-select { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .8rem; }\n.lm-mini .lm-select select { width: auto; padding: 1px 6px; font-size: .78rem; }\n.lm-mini .lm-switch { font-size: .8rem; }\n.lm-mini .lm-switch input { margin-top: 2px; }\n.lm-mini .lm-presets { gap: 4px; }\n.lm-mini .lm-presets button { padding: 2px 8px; font-size: .72rem; }\n@container (min-width: 420px) {\n .lm-mini .lm-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n .lm-mini .lm-controls > :is(h3, .lm-presets), .lm-mini .lm-controls > h3 + .lm-range { grid-column: 1 / -1; }\n}\n.lm-mini .lm-compare > :not(h3:first-child, .lm-table-wrap:nth-child(3)) { display: none; }\n.lm-mini .lm-table { font-size: .76rem; }\n.lm-mini .lm-table th, .lm-mini .lm-table td { padding: 3px 8px 3px 0; }\n.lm-mini .lm-table small { display: none; }\n.lm-mini .lm-table thead th { white-space: nowrap; font-size: .6rem; }\n.lm-mini > .lm-card:has(> .lm-spark) { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }\n.lm-spark { position: relative; min-height: 0; }\n.lm-spark svg { position: absolute; inset: 0; display: block; overflow: hidden; }\n.lm-spark-th { stroke: var(--lm-muted); stroke-dasharray: 4 3; }\n.lm-spark-load { stroke: var(--lm-fg); opacity: .45; }\n.lm-spark-text { margin: 0; font-size: .76rem; color: var(--lm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n/* the drawer: the page's own panel, alone, over the right of the board */\n.lm[data-full] > .lm-drawer:not([data-drawer]) { display: none; }\n.lm[data-full] > .lm-drawer[data-drawer] { display: grid; gap: 14px; align-content: start; position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 4; width: min(640px, calc(100% - 32px)); overflow: auto; overscroll-behavior: contain; padding: 14px; background: var(--lm-bg); border: 1px solid var(--lm-line); border-radius: 10px; box-shadow: -8px 0 30px rgb(0 0 0 / .2); container-type: inline-size; }\n.lm-side[data-drawer] :is(.lm-panel, .lm-strip, .lm-charts, .lm-card):not([data-drawn]):not(.lm-panel *) { display: none; }\n.lm-side[data-drawer] .lm-strip { grid-template-columns: minmax(0, 1fr); }\n.lm-drawer-bar { display: flex; justify-content: flex-end; }\n\n/* a page of its own: its .lm-side is a box under the board that scrolls on its own, the board as large as leaves it a\n third of the screen */\n.lm[data-full] > .lm-side:not(.lm-drawer) { display: grid; gap: 14px; align-content: start; flex: 1 1 0; min-height: 33dvh; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }\n\n/* focus: the board and what runs on it in the middle of the screen */\n.lm[data-mode=\"focus\"] .lm-scenarios, .lm[data-mode=\"focus\"] > .lm-side:not(.lm-drawer) { display: none; }\n.lm[data-mode=\"focus\"] > .lm-wrap { margin-top: auto; }\n.lm[data-mode=\"focus\"] > :is(.lm-story, .lm-line) { order: 1; }\n.lm[data-mode=\"focus\"]::after { content: \"\"; order: 2; margin-top: auto; }\n.lm[data-mode=\"focus\"] > .lm-story { border-left-width: 4px; padding: 10px 14px; }\n.lm[data-mode=\"focus\"] > .lm-story p { font-size: 1.1rem; }\n\n@media (max-width: 760px) {\n .lm[data-full] { padding: 10px; gap: 8px; }\n /* the page has the title, and the legend: here they would leave the diagram no room */\n .lm[data-full] > h2, .lm[data-full] :is(.lm-head h2, .lm-legend, .lm-story legend) { display: none; }\n /* the one exception: here the diagram runs top to bottom, and shrunk to the screen it is too small to read, so it\n pans in a box of its own with the bar on top. The page never scrolls */\n .lm[data-full] .lm-board { width: 100%; }\n .lm[data-full] > .lm-wrap { height: 40dvh; overflow: auto; row-gap: 0; overscroll-behavior: contain; }\n .lm[data-mode=\"focus\"] > .lm-wrap { height: auto; flex: 1 1 0; min-height: 0; margin-top: 0; }\n .lm[data-full] .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }\n .lm[data-full] .lm-line { flex-wrap: wrap; }\n .lm[data-full] > .lm-story { padding: 6px 10px; gap: 6px 10px; }\n .lm[data-full] > .lm-story p { font-size: .84rem; }\n .lm[data-full] .lm-story button { padding: 4px 10px; }\n .lm[data-full] .lm-headline { flex-basis: 100%; }\n .lm-dock { flex-direction: column; min-height: 0; gap: 6px; }\n .lm-tabs { display: flex; flex: none; gap: 2px; border-bottom: 1px solid var(--lm-line); overflow: hidden; }\n .lm-tabs button { font: 500 .78rem var(--lm-font); color: var(--lm-muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 8px; cursor: pointer; white-space: nowrap; }\n .lm-tabs button[aria-pressed=\"true\"] { color: var(--lm-fg); border-color: var(--lm-fg); }\n .lm-mini:not([data-active]) { display: none; }\n .lm[data-full] > .lm-side[data-drawer] { inset: 8px; width: auto; }\n}\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; display: grid; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story p > span { grid-area: 1 / 1; }\n.lm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.lm-story p > span:not([data-shown]), .lm-story em:not([data-shown]) { visibility: hidden; }\n.lm-story-progress { display: flex; align-items: center; gap: 4px; }\n.lm-story-progress i { position: relative; width: 28px; height: 4px; border-radius: 2px; background: var(--lm-line); overflow: hidden; }\n.lm-story-progress i[data-state=\"done\"], .lm-story:not([data-playing]) .lm-story-progress i[data-state=\"now\"] { background: var(--lm-accent); }\n.lm-story[data-playing] .lm-story-progress i[data-state=\"now\"]::before { content: \"\"; position: absolute; inset: 0; background: var(--lm-accent); transform-origin: left; animation: lm-step var(--lm-step) linear both; }\n@keyframes lm-step { from { transform: scaleX(0); } to { transform: scaleX(1); } }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: min(17rem, calc(100% - 8px)); overflow-wrap: anywhere; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) {\n .lm-fill { transition: none; }\n .lm-story[data-playing] .lm-story-progress i[data-state=\"now\"]::before { animation: none; transform: none; }\n}\n";
88
+ export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-root-bg, var(--lm-bg));\n display: grid; gap: 14px; padding: var(--lm-pad, 16px); min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-problems { margin: 0; padding: 10px 12px; font: .8rem/1.5 var(--lm-mono); white-space: pre-wrap; overflow-x: auto; color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-drop); border-radius: 6px; }\n.lm-note { margin: 0; font-size: .8rem; color: var(--lm-muted); }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n/* the story's title over the board while it plays: a lower third, at the top when what is framed is low; a strip\n across the top of a narrow board */\n.lm-title { position: absolute; left: 12px; bottom: 12px; z-index: 1; display: grid; gap: 1px; max-width: min(34rem, calc(100% - 24px)); padding: 7px 12px 8px; border-left: 4px solid var(--lm-accent); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--lm-surface) 92%, transparent); box-shadow: 0 4px 16px rgb(0 0 0 / .12); pointer-events: none; overflow-wrap: anywhere; }\n.lm-title[data-top] { top: 12px; bottom: auto; }\n.lm-title b { font-size: .95rem; font-weight: 600; }\n.lm-title span { font: 500 .8rem var(--lm-mono); color: var(--lm-muted); }\n@container (max-width: 520px) {\n .lm-title, .lm-title[data-top] { top: 0; right: 0; bottom: auto; left: 0; max-width: none; padding: 4px 8px; border-radius: 0; box-shadow: none; }\n .lm-title b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .lm-title span { display: none; }\n}\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n/* full screen (the browser's, or a fixed overlay): a column that never scrolls. The diagram as wide as the screen on\n top; under it the verdict in a line and the panels, compact, in a dock the screen sizes. The load changes what is\n in them, never their size, so it never moves the board. Focus: the diagram, the story, the verdict and the load */\n.lm-side, .lm-card > .lm-panel { display: contents; }\n.lm-panel { display: grid; gap: 14px; min-width: 0; }\n.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; background: var(--lm-bg); overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }\n.lm[data-full=\"overlay\"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }\n.lm[data-full] > * { flex: none; }\n/* a page of its own keeps the rest outside full screen, as <Loadmap> does */\n.lm[data-full] > :not(.lm-head, h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-line, .lm-dock, .lm-side) { display: none; }\n.lm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-width: 0; }\n.lm-head h2 { font-size: 1.1rem; }\n.lm[data-full] .lm-wrap { gap: 6px; }\n/* the board as large as fits (--lm-fit, from Diagram), left under the bar, so the legend starts where the board does */\n.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }\n.lm-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }\n.lm-modes { display: inline-flex; margin: 0; padding: 0; min-width: 0; border: 1px solid var(--lm-line); border-radius: 6px; overflow: hidden; }\n.lm-modes button { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 0; padding: 6px 12px; cursor: pointer; }\n.lm-modes button[aria-pressed=\"true\"] { background: var(--lm-fg); color: var(--lm-surface); }\n.lm[data-full] .lm-story { padding: 6px 12px; }\n.lm[data-full] [data-out] { display: none; }\n\n.lm-line { display: flex; align-items: center; gap: 6px 14px; min-width: 0; padding: 6px 12px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-line[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-line[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-headline { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-num { font: 600 .95em var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-link { font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; white-space: nowrap; }\n.lm-line .lm-range { flex: 0 1 380px; display: grid; grid-template-columns: auto minmax(100px, 1fr); align-items: center; gap: 10px; font-size: .84rem; }\n.lm-line output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-line input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n\n.lm-dock { display: flex; gap: 10px; min-width: 0; }\n.lm[data-full] > .lm-dock { flex: 1 1 0; min-height: clamp(200px, 26dvh, 340px); }\n.lm-tabs { display: none; margin: 0; padding: 0; border: 0; min-width: 0; }\n.lm-mini { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: grid; container-type: inline-size; }\n.lm-mini[data-mini=\"controls\"] { flex-grow: 1.25; }\n.lm-mini[data-mini=\"limits\"] { flex-grow: 1.45; }\n.lm-mini[data-mini=\"live\"] { flex-grow: .8; }\n.lm-mini[data-mini=\"headroom\"] { flex-grow: .9; }\n.lm-mini[data-mini=\"compare\"] { flex-grow: 1.3; }\n.lm-mini > .lm-card { min-height: 0; overflow: hidden; padding: 10px 12px; gap: 6px; align-content: start; }\n.lm-mini [data-clip] { visibility: hidden; }\n.lm-more { position: absolute; top: 6px; right: 6px; font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: var(--lm-surface); border: 0; border-radius: 4px; padding: 2px 6px; cursor: pointer; }\n.lm-more[data-more]:not([data-more=\"\"])::before { content: attr(data-more) \" \"; }\n.lm-mini .lm-meters { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; }\n.lm-mini .lm-meter { display: flex; align-items: baseline; gap: 8px; padding: 3px 8px; }\n.lm-mini .lm-meter b { flex: none; font-size: .9rem; }\n.lm-mini .lm-meter span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n/* one grid for every row, so the bars line up whatever the names */\n.lm-mini-limits { display: grid; grid-template-columns: minmax(0, max-content) minmax(48px, 1fr) auto auto; gap: 6px 10px; }\n.lm-mini-lim { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: .8rem; }\n.lm-mini-lim .lm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-mini-lim .lm-tag { margin-left: 5px; }\n.lm-mini-lim .lm-track { height: 9px; }\n.lm-mini-lim .lm-val { white-space: nowrap; }\n.lm-mini-lim .lm-sub { font: 400 .74rem var(--lm-mono); color: var(--lm-muted); }\n.lm-mini .lm-controls { gap: 6px; column-gap: 16px; }\n.lm-mini .lm-controls small, .lm-mini .lm-controls > h3:not(:first-child) { display: none; }\n.lm-mini .lm-controls label.lm-range { grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr); align-items: center; gap: 10px; font-size: .8rem; }\n.lm-mini .lm-select { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .8rem; }\n.lm-mini .lm-select select { width: auto; padding: 1px 6px; font-size: .78rem; }\n.lm-mini .lm-switch { font-size: .8rem; }\n.lm-mini .lm-switch input { margin-top: 2px; }\n.lm-mini .lm-presets { gap: 4px; }\n.lm-mini .lm-presets button { padding: 2px 8px; font-size: .72rem; }\n@container (min-width: 420px) {\n .lm-mini .lm-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n .lm-mini .lm-controls > :is(h3, .lm-presets), .lm-mini .lm-controls > h3 + .lm-range { grid-column: 1 / -1; }\n}\n.lm-mini .lm-compare > :not(h3:first-child, .lm-table-wrap:nth-child(3)) { display: none; }\n.lm-mini .lm-table { font-size: .76rem; }\n.lm-mini .lm-table th, .lm-mini .lm-table td { padding: 3px 8px 3px 0; }\n.lm-mini .lm-table small { display: none; }\n.lm-mini .lm-table thead th { white-space: nowrap; font-size: .6rem; }\n.lm-mini > .lm-card:has(> .lm-spark) { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }\n.lm-spark { position: relative; min-height: 0; }\n.lm-spark svg { position: absolute; inset: 0; display: block; overflow: hidden; }\n.lm-spark-th { stroke: var(--lm-muted); stroke-dasharray: 4 3; }\n.lm-spark-load { stroke: var(--lm-fg); opacity: .45; }\n.lm-spark-text { margin: 0; font-size: .76rem; color: var(--lm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n/* the drawer: the page's own panel, alone, over the right of the board */\n.lm[data-full] > .lm-drawer:not([data-drawer]) { display: none; }\n.lm[data-full] > .lm-drawer[data-drawer] { display: grid; gap: 14px; align-content: start; position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 4; width: min(640px, calc(100% - 32px)); overflow: auto; overscroll-behavior: contain; padding: 14px; background: var(--lm-bg); border: 1px solid var(--lm-line); border-radius: 10px; box-shadow: -8px 0 30px rgb(0 0 0 / .2); container-type: inline-size; }\n.lm-side[data-drawer] :is(.lm-panel, .lm-strip, .lm-charts, .lm-card):not([data-drawn]):not(.lm-panel *) { display: none; }\n.lm-side[data-drawer] .lm-strip { grid-template-columns: minmax(0, 1fr); }\n.lm-drawer-bar { display: flex; justify-content: flex-end; }\n\n/* a page of its own: its .lm-side is a box under the board that scrolls on its own, the board as large as leaves it a\n third of the screen */\n.lm[data-full] > .lm-side:not(.lm-drawer) { display: grid; gap: 14px; align-content: start; flex: 1 1 0; min-height: 33dvh; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }\n\n/* focus: the board and what runs on it in the middle of the screen */\n.lm[data-mode=\"focus\"] .lm-scenarios, .lm[data-mode=\"focus\"] > .lm-side:not(.lm-drawer) { display: none; }\n.lm[data-mode=\"focus\"] > .lm-wrap { margin-top: auto; }\n.lm[data-mode=\"focus\"] > :is(.lm-story, .lm-line) { order: 1; }\n.lm[data-mode=\"focus\"]::after { content: \"\"; order: 2; margin-top: auto; }\n.lm[data-mode=\"focus\"] > .lm-story { border-left-width: 4px; padding: 10px 14px; }\n.lm[data-mode=\"focus\"] > .lm-story p { font-size: 1.1rem; }\n\n@media (max-width: 760px) {\n .lm[data-full] { padding: 10px; gap: 8px; }\n /* the page has the title, and the legend: here they would leave the diagram no room */\n .lm[data-full] > h2, .lm[data-full] :is(.lm-head h2, .lm-legend, .lm-story legend) { display: none; }\n /* the one exception: here the diagram runs top to bottom, and shrunk to the screen it is too small to read, so it\n pans in a box of its own with the bar on top. The page never scrolls */\n .lm[data-full] .lm-board { width: 100%; }\n .lm[data-full] > .lm-wrap { height: 40dvh; overflow: auto; row-gap: 0; overscroll-behavior: contain; }\n .lm[data-mode=\"focus\"] > .lm-wrap { height: auto; flex: 1 1 0; min-height: 0; margin-top: 0; }\n .lm[data-full] .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }\n .lm[data-full] .lm-line { flex-wrap: wrap; }\n .lm[data-full] > .lm-story { padding: 6px 10px; gap: 6px 10px; }\n .lm[data-full] > .lm-story p { font-size: .84rem; }\n .lm[data-full] .lm-story button { padding: 4px 10px; }\n .lm[data-full] .lm-headline { flex-basis: 100%; }\n .lm-dock { flex-direction: column; min-height: 0; gap: 6px; }\n .lm-tabs { display: flex; flex: none; gap: 2px; border-bottom: 1px solid var(--lm-line); overflow: hidden; }\n .lm-tabs button { font: 500 .78rem var(--lm-font); color: var(--lm-muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 8px; cursor: pointer; white-space: nowrap; }\n .lm-tabs button[aria-pressed=\"true\"] { color: var(--lm-fg); border-color: var(--lm-fg); }\n .lm-mini:not([data-active]) { display: none; }\n .lm[data-full] > .lm-side[data-drawer] { inset: 8px; width: auto; }\n}\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; display: grid; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story p > span { grid-area: 1 / 1; }\n.lm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.lm-story p > span:not([data-shown]), .lm-story em:not([data-shown]) { visibility: hidden; }\n.lm-story-progress { display: flex; align-items: center; gap: 4px; }\n.lm-story-progress i { position: relative; width: 28px; height: 4px; border-radius: 2px; background: var(--lm-line); overflow: hidden; }\n.lm-story-progress i[data-state=\"done\"], .lm-story:not([data-playing]) .lm-story-progress i[data-state=\"now\"] { background: var(--lm-accent); }\n.lm-story[data-playing] .lm-story-progress i[data-state=\"now\"]::before { content: \"\"; position: absolute; inset: 0; background: var(--lm-accent); transform-origin: left; animation: lm-step var(--lm-step) linear both; }\n@keyframes lm-step { from { transform: scaleX(0); } to { transform: scaleX(1); } }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: min(17rem, calc(100% - 8px)); overflow-wrap: anywhere; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) {\n .lm-fill { transition: none; }\n .lm-story[data-playing] .lm-story-progress i[data-state=\"now\"]::before { animation: none; transform: none; }\n}\n";
88
89
  /** Adds the stylesheet once per document. */
89
90
  export declare function injectStyles(doc?: Document): void;
90
- export { type AnyNodeDef, type ClusterDef, type DiagramProps, type Dot, type EdgeDef, type ElkEngine, type Engine, type FlowColor, type FlowView, type FullScreenMode, LOADMAP_PANELS, type Label, Loadmap, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapPanel, type LoadmapProps, LoadmapRoot, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, handleOf, multiple, node, pct, pool, secs, useLoadmap, usePageTheme };
91
+ export { type AnyNodeDef, type ClusterDef, type Cue, type DiagramProps, type Dot, type EdgeDef, type ElkEngine, type Engine, type FlowColor, type FlowView, type FullScreenMode, LOADMAP_PANELS, type Label, Loadmap, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapPanel, type LoadmapProps, LoadmapRoot, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, handleOf, multiple, node, pct, pool, secs, useLoadmap, usePageTheme };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as Compare, a as usePageTheme, b as scenarioColor, c as injectStyles, d as Controls, f as Limits, g as Diagram, h as workerElk, i as handleOf, l as Story, m as Verdict, n as Loadmap, o as useLoadmap, p as Meters, r as LoadmapRoot, s as LOADMAP_CSS, t as LOADMAP_PANELS, u as Assumptions, v as HeadroomChart, x as useComparison, y as Scenarios } from "./Loadmap-D_Kto8cB.js";
1
+ import { _ as Compare, a as usePageTheme, b as scenarioColor, c as injectStyles, d as Controls, f as Limits, g as Diagram, h as workerElk, i as handleOf, l as Story, m as Verdict, n as Loadmap, o as useLoadmap, p as Meters, r as LoadmapRoot, s as LOADMAP_CSS, t as LOADMAP_PANELS, u as Assumptions, v as HeadroomChart, x as useComparison, y as Scenarios } from "./Loadmap-CZbpcpNc.js";
2
2
  import { fitLinear } from "@loadmap/core/calibrate";
3
3
  import { compact, fmt, multiple, pct, secs } from "@loadmap/core/format";
4
4
  import { cluster, defineView, edge, node, pool } from "@loadmap/layout";
package/dist/source.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LoadmapProps } from "./Loadmap-VLbQ__eh.js";
1
+ import { a as LoadmapProps } from "./Loadmap-DIqhwkgn.js";
2
2
  import { CompileOptions } from "@loadmap/dsl";
3
3
  export interface LoadmapSourceProps extends Omit<LoadmapProps<any>, 'model' | 'view'> {
4
4
  /** The `.loadmap` text. Compiled again when its tokens change: spaces, line breaks and comments change nothing. */
package/dist/source.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as usePageTheme, c as injectStyles, n as Loadmap } from "./Loadmap-D_Kto8cB.js";
1
+ import { a as usePageTheme, c as injectStyles, n as Loadmap } from "./Loadmap-CZbpcpNc.js";
2
2
  import { useEffect, useMemo, useRef } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { compile, formatDiagnostic } from "@loadmap/dsl";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadmap/react",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Interactive capacity models for React: an architecture diagram with moving dots, the limits ranked, the verdict, scenarios and headroom.",
5
5
  "keywords": [
6
6
  "loadmap",
@@ -35,10 +35,10 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@loadmap/core": "0.8.0",
39
- "@loadmap/dsl": "0.8.0",
40
- "@loadmap/sim": "0.8.0",
41
- "@loadmap/layout": "0.8.0",
38
+ "@loadmap/core": "0.9.0",
39
+ "@loadmap/dsl": "0.9.0",
40
+ "@loadmap/sim": "0.9.0",
41
+ "@loadmap/layout": "0.9.0",
42
42
  "elkjs": "^0.12.1"
43
43
  },
44
44
  "peerDependencies": {