@loadmap/react 0.14.0 → 0.16.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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-cuSPntjH.js";
1
+ import { _ as Insets, 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-DmcFVIQF.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";
@@ -13,8 +13,14 @@ interface DiagramProps {
13
13
  onNodeClick?: (id: string) => void;
14
14
  /** The box drawn as selected, by its id. */
15
15
  selected?: string | null;
16
+ /**
17
+ * The board fills its container, which gives it a height, as a canvas the reader pans and zooms (the wheel alone
18
+ * zooms it), with no Full screen button. Insets are the pixels on each side that something of the page floats over:
19
+ * Fit frames the diagram in what they leave, and the legend and the zoom buttons stay clear of them.
20
+ */
21
+ canvas?: boolean | Partial<Insets>;
16
22
  }
17
- export declare function Diagram({ lm, legend, onNodeClick, selected }: DiagramProps): import("react").JSX.Element;
23
+ export declare function Diagram({ lm, legend, onNodeClick, selected, canvas }: DiagramProps): import("react").JSX.Element;
18
24
  /**
19
25
  * ELK in the worker `make` starts, falling back to the main thread: `<Loadmap elk={workerElk(…)}>` for a page whose
20
26
  * bundler inlines the worker (`@loadmap/react/elk.worker.js`), or that serves it from another place. Make it once,
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-BfO9LeOo.js";
1
+ import { S as Verdict, T as Diagram, a as usePageTheme, b as Limits, c as injectStyles, d as HeadroomChart, f as Scenarios, i as handleOf, l as Story, m as useComparison, n as Loadmap, o as useLoadmap, p as scenarioColor, r as LoadmapRoot, s as LOADMAP_CSS, t as LOADMAP_PANELS, u as Compare, v as Assumptions, w as workerElk, x as Meters, y as Controls } from "./Loadmap-GwoYUby3.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, directionOf, edge, node, pool } from "@loadmap/layout";
@@ -0,0 +1,491 @@
1
+ import { C as plusMinus, D as rankLabels, E as boxComponent, _ as whenRange, g as useSize, h as useHeadroom, m as useComparison, p as scenarioColor, u as Compare, x as Meters, y as Controls } from "./Loadmap-GwoYUby3.js";
2
+ import { reach } from "@loadmap/core";
3
+ import { compact, fmt, multiple, multiples, pct } from "@loadmap/core/format";
4
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/compact.tsx
7
+ /** The names a reader sees for the panels, on the tabs and the buttons that open them. */
8
+ const NAMES = {
9
+ verdict: "Verdict",
10
+ live: "Live",
11
+ limits: "Limits",
12
+ controls: "Load",
13
+ headroom: "Headroom",
14
+ compare: "Compare",
15
+ assumptions: "Assumptions"
16
+ };
17
+ /**
18
+ * The verdict in one line, from the same evaluation as the sentence: the load, how far the target holds, the first
19
+ * limit and how sure its capacity is, what is past capacity. The sentence is its tooltip and opens under "Why".
20
+ */
21
+ function VerdictLine({ lm, verdict = true, extra = 0, open, assumptions }) {
22
+ const { ev, model, values } = lm;
23
+ const first = ev.firstLimit;
24
+ const range = ev.target;
25
+ const target = `${pct(model.thresholds.target)} target`;
26
+ const c = first?.capacity;
27
+ const sure = !c ? "" : c.provenance === "estimated" ? `est${c.within ? ` ${plusMinus(c)}` : ""}` : plusMinus(c);
28
+ const over = ev.ranked.filter((x) => (x.util ?? 0) > model.thresholds.full);
29
+ const when = range ? whenRange(model, range) : "";
30
+ const estimated = ev.assumptions.filter((a) => a.kind === "capacity" && a.capacity.provenance === "estimated").length;
31
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
32
+ verdict && /* @__PURE__ */ jsx("p", {
33
+ className: "lm-headline",
34
+ title: ev.verdict.text,
35
+ "aria-live": "polite",
36
+ children: !first || !range ? ev.verdict.text : /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ /* @__PURE__ */ jsxs("b", {
38
+ className: "lm-num",
39
+ children: [fmt(values.load), "×"]
40
+ }),
41
+ " ·",
42
+ " ",
43
+ values.load < range.low ? /* @__PURE__ */ jsxs(Fragment, { children: [
44
+ "the ",
45
+ target,
46
+ " holds to ",
47
+ /* @__PURE__ */ jsx("b", {
48
+ className: "lm-num",
49
+ children: multiples(range, model.searchMax, true)
50
+ }),
51
+ when && ` (${when})`
52
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
53
+ "past the ",
54
+ target,
55
+ " from ",
56
+ /* @__PURE__ */ jsx("b", {
57
+ className: "lm-num",
58
+ children: multiple(range.low, model.searchMax)
59
+ })
60
+ ] }),
61
+ " ",
62
+ "· limited by ",
63
+ /* @__PURE__ */ jsx("b", { children: first.name }),
64
+ sure && /* @__PURE__ */ jsx("span", {
65
+ className: "lm-tag",
66
+ "data-kind": c?.provenance === "estimated" ? "estimated" : "range",
67
+ children: sure
68
+ }),
69
+ over.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
70
+ " ",
71
+ "· ",
72
+ /* @__PURE__ */ jsx("b", { children: over.map((x) => x.name).join(", ") }),
73
+ " past capacity"
74
+ ] })
75
+ ] })
76
+ }),
77
+ open && verdict && /* @__PURE__ */ jsx("button", {
78
+ type: "button",
79
+ className: "lm-link",
80
+ onClick: (e) => open("verdict", e.currentTarget),
81
+ children: "Why ›"
82
+ }),
83
+ open && assumptions && /* @__PURE__ */ jsxs("button", {
84
+ type: "button",
85
+ className: "lm-link",
86
+ onClick: (e) => open("assumptions", e.currentTarget),
87
+ children: [
88
+ "What this assumes · ",
89
+ ev.assumptions.length + extra,
90
+ estimated > 0 && ` (${estimated} estimated)`,
91
+ " ›"
92
+ ]
93
+ })
94
+ ] });
95
+ }
96
+ /** The order of the cards in the dock: what the reader changes first, what it changes next to it. */
97
+ const DOCK = [
98
+ "controls",
99
+ "live",
100
+ "limits",
101
+ "headroom",
102
+ "compare"
103
+ ];
104
+ /**
105
+ * Full screen's panels, compact, side by side in a box the screen sizes: what does not fit is left out whole, and
106
+ * each card opens its panel whole. A phone shows one at a time, under tabs.
107
+ */
108
+ function Dock({ lm, panels, open }) {
109
+ const shown = DOCK.filter((p) => panels.includes(p));
110
+ const [tab, setTab] = useState(null);
111
+ if (!shown.length) return null;
112
+ const active = tab && shown.includes(tab) ? tab : shown[0];
113
+ return /* @__PURE__ */ jsxs("div", {
114
+ className: "lm-dock",
115
+ children: [/* @__PURE__ */ jsx("fieldset", {
116
+ className: "lm-tabs",
117
+ "aria-label": "Panels",
118
+ children: shown.map((p) => /* @__PURE__ */ jsx("button", {
119
+ type: "button",
120
+ "aria-pressed": p === active,
121
+ onClick: () => setTab(p),
122
+ children: NAMES[p]
123
+ }, p))
124
+ }), shown.map((p) => /* @__PURE__ */ jsx(Card, {
125
+ lm,
126
+ panel: p,
127
+ open,
128
+ active: p === active
129
+ }, p))]
130
+ });
131
+ }
132
+ function Card({ lm, panel, open, active }) {
133
+ const box = useRef(null);
134
+ const more = useRef(null);
135
+ useClip(box, more);
136
+ return /* @__PURE__ */ jsxs("div", {
137
+ className: "lm-mini",
138
+ "data-mini": panel,
139
+ "data-active": active || void 0,
140
+ ref: box,
141
+ children: [panel === "controls" ? /* @__PURE__ */ jsx(Controls, { lm }) : panel === "compare" ? /* @__PURE__ */ jsx(Compare, { lm }) : /* @__PURE__ */ jsx("div", {
142
+ className: "lm-card",
143
+ children: panel === "live" ? /* @__PURE__ */ jsx(Meters, { lm }) : panel === "limits" ? /* @__PURE__ */ jsx(MiniLimits, { lm }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Headroom" }), /* @__PURE__ */ jsx(Sparkline, { lm })] })
144
+ }), /* @__PURE__ */ jsx("button", {
145
+ type: "button",
146
+ className: "lm-more",
147
+ ref: more,
148
+ "aria-label": `${NAMES[panel]}, all of it`,
149
+ onClick: (e) => open(panel, e.currentTarget),
150
+ children: "›"
151
+ })]
152
+ });
153
+ }
154
+ /** The rows a card leaves out whole when they do not fit. */
155
+ const ROWS = ".lm-meter, .lm-mini-lim, .lm-controls > *, .lm-table tbody tr";
156
+ /**
157
+ * Hides the rows that cross the bottom of the card, and counts them on its button. Runs again when the card's size
158
+ * or its rows change: the meters come and go with the load, and the order of the limits with it.
159
+ */
160
+ function useClip(box, more) {
161
+ useEffect(() => {
162
+ const card = box.current?.querySelector(".lm-card");
163
+ if (!card) return;
164
+ const clip = () => {
165
+ const r = card.getBoundingClientRect();
166
+ const bottom = r.bottom - Number.parseFloat(getComputedStyle(card).paddingBottom || "0");
167
+ let n = 0;
168
+ for (const row of card.querySelectorAll(ROWS)) {
169
+ const out = r.height > 0 && row.getBoundingClientRect().bottom > bottom + .5;
170
+ row.toggleAttribute("data-clip", out);
171
+ if (out && !row.matches("h3")) n++;
172
+ }
173
+ if (more.current) more.current.dataset.more = n ? `+${n}` : "";
174
+ };
175
+ const ro = new ResizeObserver(clip);
176
+ ro.observe(card);
177
+ const mo = new MutationObserver(clip);
178
+ mo.observe(card, {
179
+ childList: true,
180
+ subtree: true
181
+ });
182
+ clip();
183
+ return () => {
184
+ ro.disconnect();
185
+ mo.disconnect();
186
+ };
187
+ }, [box, more]);
188
+ }
189
+ /**
190
+ * The limits in their order, a line each: the name and how sure its capacity is, the bar, the utilization, where it
191
+ * is full. The first is the first limit: the verdict line names it.
192
+ */
193
+ function MiniLimits({ lm }) {
194
+ const { ev, model } = lm;
195
+ const top = Math.max(1.5, model.thresholds.full * 1.5);
196
+ const at = (u) => `${u / top * 100}%`;
197
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Where it runs out" }), /* @__PURE__ */ jsx("div", {
198
+ className: "lm-mini-limits",
199
+ children: ev.ranked.map((c) => /* @__PURE__ */ jsxs("div", {
200
+ className: "lm-mini-lim",
201
+ "data-component": c.id,
202
+ children: [
203
+ /* @__PURE__ */ jsxs("span", {
204
+ className: "lm-name",
205
+ title: c.name,
206
+ children: [c.name, c.capacity?.provenance === "estimated" ? /* @__PURE__ */ jsx("span", {
207
+ className: "lm-tag",
208
+ "data-kind": "estimated",
209
+ children: "est"
210
+ }) : !!c.capacity?.within && /* @__PURE__ */ jsx("span", {
211
+ className: "lm-tag",
212
+ "data-kind": "range",
213
+ children: "±"
214
+ })]
215
+ }),
216
+ /* @__PURE__ */ jsxs("span", {
217
+ className: "lm-track",
218
+ role: "img",
219
+ "aria-label": `${c.name} at ${c.util == null ? "off" : pct(c.util)}`,
220
+ children: [
221
+ /* @__PURE__ */ jsx("span", {
222
+ className: "lm-fill",
223
+ "data-state": c.state,
224
+ style: { width: `${Math.min(100, (c.util ?? 0) / top * 100)}%` }
225
+ }),
226
+ /* @__PURE__ */ jsx("span", {
227
+ className: "lm-tick",
228
+ style: { left: at(model.thresholds.target) }
229
+ }),
230
+ /* @__PURE__ */ jsx("span", {
231
+ className: "lm-tick",
232
+ style: { left: at(model.thresholds.full) }
233
+ })
234
+ ]
235
+ }),
236
+ /* @__PURE__ */ jsx("span", {
237
+ className: "lm-val",
238
+ children: c.util == null ? "—" : pct(c.util)
239
+ }),
240
+ /* @__PURE__ */ jsx("span", {
241
+ className: "lm-val lm-sub",
242
+ children: c.util == null ? "off" : c.full != null && !Number.isFinite(c.full) ? `full > ${fmt(model.searchMax)}×` : `full ${c.fullRange ? multiples(c.fullRange, model.searchMax, true) : multiple(c.full, model.searchMax)}`
243
+ })
244
+ ]
245
+ }, c.id))
246
+ })] });
247
+ }
248
+ /** The headroom chart as a sparkline: each scenario's line, the target, the load; where the shown one crosses it. */
249
+ function Sparkline({ lm }) {
250
+ const { model, values } = lm;
251
+ const h = useHeadroom(lm);
252
+ const [box, { width: W, height: H }] = useSize(240);
253
+ const top = Math.max(1.5, model.thresholds.full * 1.5);
254
+ const lx = (x) => W * Math.log(x / h.from) / Math.log(h.to / h.from);
255
+ const ly = (u) => 8 + (H - 10) * (1 - Math.min(u, top * 1.2) / top);
256
+ const path = (s) => {
257
+ let d = "";
258
+ let pen = false;
259
+ for (const [x, u] of s) {
260
+ if (u == null) {
261
+ pen = false;
262
+ continue;
263
+ }
264
+ d += `${pen ? "L" : "M"}${lx(x).toFixed(1)} ${ly(u).toFixed(1)}`;
265
+ pen = true;
266
+ }
267
+ return d;
268
+ };
269
+ const line = h.lines.find((l) => l.selected) ?? h.lines[0];
270
+ const target = pct(model.thresholds.target);
271
+ const reaches = line ? `${line.targetRange ? multiples(line.targetRange, model.searchMax, true) : multiple(line.target, model.searchMax)}` : "";
272
+ const when = line ? whenRange(model, line.targetRange) : "";
273
+ const loadX = lx(Math.min(h.to, Math.max(h.from, values.load)));
274
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
275
+ className: "lm-spark",
276
+ ref: box,
277
+ children: H > 0 && /* @__PURE__ */ jsxs("svg", {
278
+ width: W,
279
+ height: H,
280
+ "aria-hidden": "true",
281
+ children: [
282
+ /* @__PURE__ */ jsx("line", {
283
+ className: "lm-spark-th",
284
+ x1: 0,
285
+ x2: W,
286
+ y1: ly(model.thresholds.target),
287
+ y2: ly(model.thresholds.target)
288
+ }),
289
+ h.lines.map((l) => /* @__PURE__ */ jsx("path", {
290
+ d: path(l.envelope),
291
+ fill: "none",
292
+ stroke: scenarioColor(model, l.label),
293
+ strokeWidth: l.selected ? 2 : 1.25
294
+ }, l.label ?? "")),
295
+ /* @__PURE__ */ jsx("line", {
296
+ className: "lm-spark-load",
297
+ x1: loadX,
298
+ x2: loadX,
299
+ y1: 0,
300
+ y2: H
301
+ })
302
+ ]
303
+ })
304
+ }), line && /* @__PURE__ */ jsxs("p", {
305
+ className: "lm-spark-text",
306
+ title: `${line.label ?? "It"} reaches the ${target} target at ${reaches}`,
307
+ children: [
308
+ line.label ?? "It",
309
+ " reaches the ",
310
+ target,
311
+ " target at ",
312
+ reaches,
313
+ when && ` (${when})`,
314
+ "."
315
+ ]
316
+ })] });
317
+ }
318
+ // src/detail.tsx
319
+ /**
320
+ * A box's component in words, over the board: utilization, demand against capacity and where it came from, where it
321
+ * reaches the target and 100 % (with dates, given growth), and its target in each scenario. HTML, so exports leave it out.
322
+ */
323
+ function Detail({ lm, scene, id, board, detailId }) {
324
+ const { model, ev } = lm;
325
+ const n = scene.nodes.find((x) => x.id === id);
326
+ const cid = n && boxComponent(lm.ev, n);
327
+ const comparison = useComparison(lm);
328
+ const rows = model.scenarios.length > 1 ? comparison.rows : [];
329
+ useEffect(() => {
330
+ const el = board?.querySelector(`[data-node="${CSS.escape(id)}"]`);
331
+ el?.setAttribute("aria-describedby", detailId);
332
+ return () => el?.removeAttribute("aria-describedby");
333
+ }, [
334
+ board,
335
+ id,
336
+ detailId
337
+ ]);
338
+ const c = cid ? ev.components[cid] : void 0;
339
+ const tip = useRef(null);
340
+ const box = n && `${n.x} ${n.y} ${n.w} ${n.h}`;
341
+ useLayoutEffect(() => {
342
+ const el = tip.current;
343
+ const wrap = el?.offsetParent;
344
+ if (!el || !n || !board || !(wrap instanceof HTMLElement)) return;
345
+ const place = () => {
346
+ const p = lm.engine.viewer?.placement();
347
+ const k = p ? p.k : board.clientWidth / scene.width;
348
+ const [dx, dy] = p ? [p.dx, p.dy] : [0, 0];
349
+ const w = wrap.getBoundingClientRect();
350
+ const y = (v) => v - w.top - wrap.clientTop + wrap.scrollTop;
351
+ let lo = 0;
352
+ let hi = innerHeight;
353
+ for (let a = wrap; a; a = a.parentElement) {
354
+ if (getComputedStyle(a).overflowY === "visible") continue;
355
+ const r = a.getBoundingClientRect();
356
+ lo = Math.max(lo, r.top);
357
+ hi = Math.min(hi, r.bottom);
358
+ }
359
+ const [top, bottom] = [y(lo) + 4, y(hi) - 4];
360
+ const h = el.offsetHeight;
361
+ const boxTop = board.offsetTop + dy + n.y * k;
362
+ const boxBottom = board.offsetTop + dy + (n.y + n.h) * k;
363
+ const below = boxBottom + 6;
364
+ const above = boxTop - 6 - h;
365
+ const fits = (n.y + n.h / 2 < scene.height / 2 ? [below, above] : [above, below]).find((t) => t >= top && t + h <= bottom);
366
+ const roomier = bottom - boxBottom >= boxTop - top ? below : above;
367
+ el.style.top = `${Math.max(top, Math.min(fits ?? roomier, bottom - h))}px`;
368
+ el.style.left = `${Math.max(0, Math.min(board.offsetLeft + dx + n.x * k, wrap.clientWidth - el.offsetWidth))}px`;
369
+ };
370
+ place();
371
+ const off = lm.engine.viewer ? lm.engine.subscribe(place) : null;
372
+ const ro = new ResizeObserver(place);
373
+ ro.observe(el);
374
+ ro.observe(board);
375
+ document.addEventListener("scroll", place, {
376
+ capture: true,
377
+ passive: true
378
+ });
379
+ addEventListener("resize", place);
380
+ return () => {
381
+ off?.();
382
+ ro.disconnect();
383
+ document.removeEventListener("scroll", place, { capture: true });
384
+ removeEventListener("resize", place);
385
+ };
386
+ }, [
387
+ box,
388
+ board,
389
+ scene
390
+ ]);
391
+ if (!n || !c || !board) return null;
392
+ const at = (r, x) => r ? reach(r, model.searchMax, model.dateAt) : multiple(x, model.searchMax);
393
+ const num = (x) => Math.abs(x) >= 1e3 ? compact(x) : fmt(x);
394
+ const cap = c.capacity;
395
+ const rank = rankLabels(ev, model).get(c.id);
396
+ return /* @__PURE__ */ jsxs("div", {
397
+ id: detailId,
398
+ className: "lm-tip lm-detail",
399
+ role: "tooltip",
400
+ ref: tip,
401
+ children: [
402
+ /* @__PURE__ */ jsxs("b", { children: [c.name, rank && /* @__PURE__ */ jsx("span", {
403
+ className: "lm-tag",
404
+ "data-kind": rank.rank === 1 ? "first" : "rank",
405
+ children: rank.word
406
+ })] }),
407
+ c.util == null || !cap ? /* @__PURE__ */ jsx("span", { children: "switched off" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
408
+ /* @__PURE__ */ jsxs("span", { children: [
409
+ /* @__PURE__ */ jsx("strong", { children: pct(c.util) }),
410
+ " · ",
411
+ num(c.demand ?? 0),
412
+ " of ",
413
+ fmt(cap.value),
414
+ " ",
415
+ cap.unit,
416
+ cap.within ? ` ±${pct(cap.within)}` : ""
417
+ ] }),
418
+ /* @__PURE__ */ jsxs("span", {
419
+ className: "lm-sub",
420
+ children: [
421
+ "capacity",
422
+ " ",
423
+ /* @__PURE__ */ jsx("span", {
424
+ className: "lm-prov",
425
+ "data-kind": cap.provenance,
426
+ children: cap.provenance
427
+ }),
428
+ cap.source ? `, ${cap.source}` : ""
429
+ ]
430
+ }),
431
+ /* @__PURE__ */ jsxs("span", { children: [
432
+ pct(model.thresholds.target),
433
+ " at ",
434
+ at(c.targetRange, c.target)
435
+ ] }),
436
+ /* @__PURE__ */ jsxs("span", { children: [
437
+ pct(model.thresholds.full),
438
+ " at ",
439
+ at(c.fullRange, c.full)
440
+ ] }),
441
+ blocks(lm, n).map((line) => /* @__PURE__ */ jsx("span", { children: line }, line)),
442
+ c.over && /* @__PURE__ */ jsxs("span", {
443
+ className: "lm-sub",
444
+ children: [
445
+ "Past ",
446
+ pct(model.thresholds.full),
447
+ ": ",
448
+ c.over,
449
+ "."
450
+ ]
451
+ })
452
+ ] }),
453
+ rows.length > 0 && /* @__PURE__ */ jsxs("span", {
454
+ className: "lm-sub",
455
+ children: [
456
+ pct(model.thresholds.target),
457
+ " by scenario:",
458
+ " ",
459
+ rows.map((r, i) => {
460
+ const x = r.components.find((y) => y.id === cid);
461
+ return /* @__PURE__ */ jsxs("span", {
462
+ className: "lm-nowrap",
463
+ children: [
464
+ i > 0 && " · ",
465
+ /* @__PURE__ */ jsx("b", {
466
+ className: "lm-key",
467
+ style: { background: scenarioColor(model, r.label) }
468
+ }),
469
+ r.label,
470
+ " ",
471
+ x?.targetRange == null ? "off" : multiples(x.targetRange, model.searchMax, true)
472
+ ]
473
+ }, r.label);
474
+ })
475
+ ]
476
+ })
477
+ ]
478
+ });
479
+ }
480
+ /** What a box's building blocks do at these values: pods running, cache answers, what a stage turns away. */
481
+ function blocks(lm, n) {
482
+ const out = [];
483
+ for (const id of n.stages) {
484
+ const s = lm.ev.stages[id];
485
+ if (s?.kind === "workers" && s.autoscale) out.push(`${s.running} of ${s.pods} pods running, each held near ${pct(s.autoscale.target)}`);
486
+ if (s?.kind === "cache") out.push(`${pct(s.hit)} answered here`);
487
+ if ((s?.kind === "pass" || s?.kind === "limit" || s?.kind === "cache") && s.shed > 0) out.push(`${pct(s.shed)} of what reaches it turned away`);
488
+ }
489
+ return out;
490
+ }
491
+ export { Detail, Dock, VerdictLine };
package/dist/source.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LoadmapProps } from "./Loadmap-cuSPntjH.js";
1
+ import { a as LoadmapProps } from "./Loadmap-DmcFVIQF.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-BfO9LeOo.js";
1
+ import { a as usePageTheme, c as injectStyles, n as Loadmap } from "./Loadmap-GwoYUby3.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";