strata-react 2.1.23 → 2.2.1
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 +1 -0
- package/dist/index.d.ts +357 -1
- package/dist/index.js +1929 -4
- package/dist/index.js.map +1 -1
- package/dist/microphone-Bt02Ky5u.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystem
|
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { useRef, useState } from "react";
|
|
13
13
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
14
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Brush, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUp, CircleAlert, CircleCheck, CircleDashed, Clock as Clock$1, CloudOff, Columns2, Ellipsis, Eraser, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, Hand, Highlighter, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, MousePointer2, Paintbrush, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, PenLine, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
14
|
+
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Brush, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUp, CircleAlert, CircleCheck, CircleDashed, Clock as Clock$1, CloudOff, Columns2, Ellipsis, Eraser, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, Hand, Highlighter, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, MousePointer2, Paintbrush, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, PenLine, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
15
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
|
|
17
17
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -22947,7 +22947,7 @@ function BoxOverlay({ label, of, boxes, state, onChoose, fillLit = true }) {
|
|
|
22947
22947
|
const lit = on || id === state.pointed;
|
|
22948
22948
|
const filled = lit && fillLit;
|
|
22949
22949
|
const repeat = n >= order.length;
|
|
22950
|
-
return /* @__PURE__ */ jsx("rect", {
|
|
22950
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
22951
22951
|
"data-box-id": id,
|
|
22952
22952
|
role: "button",
|
|
22953
22953
|
"aria-label": b.label,
|
|
@@ -22973,7 +22973,17 @@ function BoxOverlay({ label, of, boxes, state, onChoose, fillLit = true }) {
|
|
|
22973
22973
|
onPointerUp: (e) => e.stopPropagation(),
|
|
22974
22974
|
onClick: () => choose(id),
|
|
22975
22975
|
onKeyDown: (e) => move(id, e)
|
|
22976
|
-
}, repeat
|
|
22976
|
+
}), !repeat && b.points && b.points.map((pt, pi) => /* @__PURE__ */ jsx("circle", {
|
|
22977
|
+
"aria-hidden": "true",
|
|
22978
|
+
cx: pt.x,
|
|
22979
|
+
cy: pt.y,
|
|
22980
|
+
r: Math.max(2, Math.min(of.w, of.h) * .01),
|
|
22981
|
+
fill: STROKE[tone],
|
|
22982
|
+
stroke: "var(--card)",
|
|
22983
|
+
strokeWidth: 1,
|
|
22984
|
+
vectorEffect: "non-scaling-stroke",
|
|
22985
|
+
pointerEvents: "none"
|
|
22986
|
+
}, `${id}:pt:${pi}`))] }, repeat ? `${id}:raised` : id);
|
|
22977
22987
|
})
|
|
22978
22988
|
});
|
|
22979
22989
|
}
|
|
@@ -26249,5 +26259,1920 @@ function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYY
|
|
|
26249
26259
|
});
|
|
26250
26260
|
}
|
|
26251
26261
|
|
|
26252
|
-
|
|
26262
|
+
// src/lib/eval-charts.ts
|
|
26263
|
+
/**
|
|
26264
|
+
* Compute clean 1-2-5 axis bounds and tick positions covering `[rawMin, rawMax]`.
|
|
26265
|
+
* Never crops a value: the returned `[min, max]` always contains `[rawMin, rawMax]`.
|
|
26266
|
+
*/
|
|
26267
|
+
function niceScale(rawMin, rawMax, targetTicks = 5) {
|
|
26268
|
+
if (!Number.isFinite(rawMin) || !Number.isFinite(rawMax)) return {
|
|
26269
|
+
min: 0,
|
|
26270
|
+
max: 1,
|
|
26271
|
+
ticks: [
|
|
26272
|
+
0,
|
|
26273
|
+
.5,
|
|
26274
|
+
1
|
|
26275
|
+
],
|
|
26276
|
+
step: .5
|
|
26277
|
+
};
|
|
26278
|
+
let lo = Math.min(rawMin, rawMax);
|
|
26279
|
+
let hi = Math.max(rawMin, rawMax);
|
|
26280
|
+
if (lo === hi) {
|
|
26281
|
+
const pad = lo === 0 ? 1 : Math.abs(lo) * .2;
|
|
26282
|
+
lo -= pad;
|
|
26283
|
+
hi += pad;
|
|
26284
|
+
}
|
|
26285
|
+
const roughStep = (hi - lo) / Math.max(2, targetTicks - 1);
|
|
26286
|
+
const mag = 10 ** Math.floor(Math.log10(roughStep));
|
|
26287
|
+
const norm = roughStep / mag;
|
|
26288
|
+
const step = (norm <= 1.5 ? 1 : norm <= 3 ? 2 : norm <= 7 ? 5 : 10) * mag;
|
|
26289
|
+
const min = Math.floor(lo / step) * step;
|
|
26290
|
+
const max = Math.ceil(hi / step) * step;
|
|
26291
|
+
const ticks = [];
|
|
26292
|
+
const count = Math.round((max - min) / step);
|
|
26293
|
+
for (let i = 0; i <= count; i++) {
|
|
26294
|
+
const val = Number((min + i * step).toPrecision(12));
|
|
26295
|
+
ticks.push(Object.is(val, -0) ? 0 : val);
|
|
26296
|
+
}
|
|
26297
|
+
return {
|
|
26298
|
+
min: ticks[0] ?? min,
|
|
26299
|
+
max: ticks[ticks.length - 1] ?? max,
|
|
26300
|
+
ticks,
|
|
26301
|
+
step
|
|
26302
|
+
};
|
|
26303
|
+
}
|
|
26304
|
+
/**
|
|
26305
|
+
* Return the non-dominated (Pareto optimal) point IDs and the frontier points ordered along `x`.
|
|
26306
|
+
* A point A dominates B when A is at least as good on both axes and strictly better on at least one.
|
|
26307
|
+
*/
|
|
26308
|
+
function paretoFrontier(points, xDirection, yDirection) {
|
|
26309
|
+
const valid = points.filter((p) => Number.isFinite(p.x) && Number.isFinite(p.y));
|
|
26310
|
+
const betterOrEqualX = (a, b) => xDirection === "higher" ? a >= b : a <= b;
|
|
26311
|
+
const strictlyBetterX = (a, b) => xDirection === "higher" ? a > b : a < b;
|
|
26312
|
+
const betterOrEqualY = (a, b) => yDirection === "higher" ? a >= b : a <= b;
|
|
26313
|
+
const strictlyBetterY = (a, b) => yDirection === "higher" ? a > b : a < b;
|
|
26314
|
+
const ordered = [...valid.filter((candidate) => {
|
|
26315
|
+
return !valid.some((other) => other !== candidate && betterOrEqualX(other.x, candidate.x) && betterOrEqualY(other.y, candidate.y) && (strictlyBetterX(other.x, candidate.x) || strictlyBetterY(other.y, candidate.y)));
|
|
26316
|
+
})].sort((a, b) => a.x === b.x ? a.y - b.y : a.x - b.x);
|
|
26317
|
+
return {
|
|
26318
|
+
ids: new Set(ordered.map((p) => p.id)),
|
|
26319
|
+
ordered
|
|
26320
|
+
};
|
|
26321
|
+
}
|
|
26322
|
+
function linearQuantile(sorted, q) {
|
|
26323
|
+
if (sorted.length === 0) return NaN;
|
|
26324
|
+
if (sorted.length === 1) return sorted[0];
|
|
26325
|
+
const pos = (sorted.length - 1) * q;
|
|
26326
|
+
const lo = Math.floor(pos);
|
|
26327
|
+
const hi = Math.ceil(pos);
|
|
26328
|
+
const frac = pos - lo;
|
|
26329
|
+
return sorted[lo] + (sorted[hi] - sorted[lo]) * frac;
|
|
26330
|
+
}
|
|
26331
|
+
/** Compute five-number summary + mean for finite numeric observations. */
|
|
26332
|
+
function summarizeDistribution(values) {
|
|
26333
|
+
const finite = values.filter(Number.isFinite).sort((a, b) => a - b);
|
|
26334
|
+
if (finite.length === 0) return null;
|
|
26335
|
+
let sum = 0;
|
|
26336
|
+
for (const v of finite) sum += v;
|
|
26337
|
+
return {
|
|
26338
|
+
n: finite.length,
|
|
26339
|
+
min: finite[0],
|
|
26340
|
+
p25: linearQuantile(finite, .25),
|
|
26341
|
+
median: linearQuantile(finite, .5),
|
|
26342
|
+
p75: linearQuantile(finite, .75),
|
|
26343
|
+
max: finite[finite.length - 1],
|
|
26344
|
+
mean: sum / finite.length
|
|
26345
|
+
};
|
|
26346
|
+
}
|
|
26347
|
+
/** Empirical cumulative distribution function points `(x, proportion in [0, 1])`. */
|
|
26348
|
+
function ecdfPoints(values) {
|
|
26349
|
+
const finite = values.filter(Number.isFinite).sort((a, b) => a - b);
|
|
26350
|
+
const n = finite.length;
|
|
26351
|
+
if (n === 0) return [];
|
|
26352
|
+
const out = [];
|
|
26353
|
+
for (let i = 0; i < n; i++) {
|
|
26354
|
+
const x = finite[i];
|
|
26355
|
+
if (i < n - 1 && finite[i + 1] === x) continue;
|
|
26356
|
+
out.push({
|
|
26357
|
+
x,
|
|
26358
|
+
y: (i + 1) / n
|
|
26359
|
+
});
|
|
26360
|
+
}
|
|
26361
|
+
return out;
|
|
26362
|
+
}
|
|
26363
|
+
/** Deterministic jitter in `[-1, 1]` from a string/number key so visual snapshots never drift. */
|
|
26364
|
+
function deterministicJitter(key) {
|
|
26365
|
+
const s = String(key);
|
|
26366
|
+
let h = 2166136261;
|
|
26367
|
+
for (let i = 0; i < s.length; i++) {
|
|
26368
|
+
h ^= s.charCodeAt(i);
|
|
26369
|
+
h = Math.imul(h, 16777619);
|
|
26370
|
+
}
|
|
26371
|
+
return (h >>> 0) / 4294967295 * 2 - 1;
|
|
26372
|
+
}
|
|
26373
|
+
/** Categorical chart colours from the Strata token contract (`--chart-1`…`--chart-5`). */
|
|
26374
|
+
const CHART_COLOURS = [
|
|
26375
|
+
"var(--chart-1)",
|
|
26376
|
+
"var(--chart-2)",
|
|
26377
|
+
"var(--chart-3)",
|
|
26378
|
+
"var(--chart-4)",
|
|
26379
|
+
"var(--chart-5)"
|
|
26380
|
+
];
|
|
26381
|
+
function chartColour(index) {
|
|
26382
|
+
return CHART_COLOURS[(index % CHART_COLOURS.length + CHART_COLOURS.length) % CHART_COLOURS.length];
|
|
26383
|
+
}
|
|
26384
|
+
/**
|
|
26385
|
+
* Measure a container's pixel width with ResizeObserver, falling back cleanly in jsdom/SSR.
|
|
26386
|
+
* Returns a callback ref so conditionally mounted containers (e.g. tab/mode switches) always
|
|
26387
|
+
* reattach observation when mounted and disconnect when unmounted.
|
|
26388
|
+
*/
|
|
26389
|
+
function useContainerWidth(fallback = 560) {
|
|
26390
|
+
const [node, setNode] = React.useState(null);
|
|
26391
|
+
const [width, setWidth] = React.useState(fallback);
|
|
26392
|
+
React.useLayoutEffect(() => {
|
|
26393
|
+
if (!node) return;
|
|
26394
|
+
const measure = () => {
|
|
26395
|
+
const w = node.getBoundingClientRect().width;
|
|
26396
|
+
if (w > 0) setWidth(Math.round(w));
|
|
26397
|
+
};
|
|
26398
|
+
measure();
|
|
26399
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
26400
|
+
const ro = new ResizeObserver(measure);
|
|
26401
|
+
ro.observe(node);
|
|
26402
|
+
return () => ro.disconnect();
|
|
26403
|
+
}, [node]);
|
|
26404
|
+
return [setNode, width];
|
|
26405
|
+
}
|
|
26406
|
+
|
|
26407
|
+
// src/components/forest-plot.tsx
|
|
26408
|
+
const PLOT_PAD_X = 14;
|
|
26409
|
+
const ROW_H$1 = 44;
|
|
26410
|
+
const AXIS_H = 28;
|
|
26411
|
+
const VERDICT_COLOUR = {
|
|
26412
|
+
neutral: "var(--muted-foreground)",
|
|
26413
|
+
info: "var(--info)",
|
|
26414
|
+
success: "var(--success)",
|
|
26415
|
+
warning: "var(--warning)",
|
|
26416
|
+
danger: "var(--danger)"
|
|
26417
|
+
};
|
|
26418
|
+
/** Horizontal forest plot of paired effect estimates with confidence intervals, minimum-effect band, guardrails and verdicts. */
|
|
26419
|
+
function ForestPlot({ label, rows, formatValue, reference = 0, referenceLabel = "No change", minEffect, minEffectLabel, worseLabel = "Worse", betterLabel = "Better", note, selectedId, onSelect, className }) {
|
|
26420
|
+
const [plotRef, plotWidth] = useContainerWidth(360);
|
|
26421
|
+
const scale = React.useMemo(() => {
|
|
26422
|
+
const vals = [reference];
|
|
26423
|
+
if (minEffect !== void 0 && Number.isFinite(minEffect)) vals.push(minEffect);
|
|
26424
|
+
for (const r of rows) {
|
|
26425
|
+
if (r.estimate !== null && Number.isFinite(r.estimate)) vals.push(r.estimate);
|
|
26426
|
+
if (r.low !== void 0 && r.low !== null && Number.isFinite(r.low)) vals.push(r.low);
|
|
26427
|
+
if (r.high !== void 0 && r.high !== null && Number.isFinite(r.high)) vals.push(r.high);
|
|
26428
|
+
}
|
|
26429
|
+
const rawMin = Math.min(...vals);
|
|
26430
|
+
const rawMax = Math.max(...vals);
|
|
26431
|
+
return niceScale(rawMin, rawMax, 5);
|
|
26432
|
+
}, [
|
|
26433
|
+
rows,
|
|
26434
|
+
reference,
|
|
26435
|
+
minEffect
|
|
26436
|
+
]);
|
|
26437
|
+
const innerW = Math.max(120, plotWidth - 28);
|
|
26438
|
+
const span = scale.max - scale.min || 1;
|
|
26439
|
+
const xOf = (v) => PLOT_PAD_X + (v - scale.min) / span * innerW;
|
|
26440
|
+
const refX = xOf(reference);
|
|
26441
|
+
const minEffX = minEffect !== void 0 && Number.isFinite(minEffect) ? xOf(minEffect) : null;
|
|
26442
|
+
const hasGuards = rows.some((r) => r.guards && r.guards.length > 0);
|
|
26443
|
+
const hasVerdicts = rows.some((r) => r.verdict);
|
|
26444
|
+
const labelTicks = React.useMemo(() => {
|
|
26445
|
+
const maxLabels = Math.max(2, Math.floor(innerW / 68));
|
|
26446
|
+
if (scale.ticks.length <= maxLabels) return scale.ticks;
|
|
26447
|
+
const stride = Math.ceil(scale.ticks.length / maxLabels);
|
|
26448
|
+
const picked = scale.ticks.filter((_, idx) => idx % stride === 0);
|
|
26449
|
+
const last = scale.ticks[scale.ticks.length - 1];
|
|
26450
|
+
if (last !== void 0 && picked[picked.length - 1] !== last && innerW - (xOf(picked[picked.length - 1]) - PLOT_PAD_X) > 48) picked.push(last);
|
|
26451
|
+
return picked;
|
|
26452
|
+
}, [scale.ticks, innerW]);
|
|
26453
|
+
const gridCols = `minmax(145px, 1.2fr) minmax(220px, 2fr) minmax(150px, auto) 44px${hasGuards ? " minmax(100px, auto)" : ""}${hasVerdicts ? " 90px" : ""}`;
|
|
26454
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
26455
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
26456
|
+
children: [
|
|
26457
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
26458
|
+
className: "flex flex-wrap items-baseline justify-between gap-2 border-b border-border px-4 py-2.5",
|
|
26459
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
26460
|
+
className: "type-label text-foreground",
|
|
26461
|
+
children: label
|
|
26462
|
+
}), note && /* @__PURE__ */ jsx("span", {
|
|
26463
|
+
className: "type-caption text-muted-foreground",
|
|
26464
|
+
children: note
|
|
26465
|
+
})]
|
|
26466
|
+
}),
|
|
26467
|
+
/* @__PURE__ */ jsx("div", {
|
|
26468
|
+
className: "overflow-x-auto",
|
|
26469
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
26470
|
+
className: "min-w-160",
|
|
26471
|
+
children: [
|
|
26472
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26473
|
+
className: "grid items-end gap-3 border-b border-border bg-surface-sunken px-4 py-1.5 type-caption text-muted-foreground",
|
|
26474
|
+
style: { gridTemplateColumns: gridCols },
|
|
26475
|
+
children: [
|
|
26476
|
+
/* @__PURE__ */ jsx("div", { children: "Candidate" }),
|
|
26477
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26478
|
+
ref: plotRef,
|
|
26479
|
+
className: "flex items-center justify-between gap-2 px-1",
|
|
26480
|
+
children: [
|
|
26481
|
+
/* @__PURE__ */ jsxs("span", {
|
|
26482
|
+
className: "inline-flex items-center gap-1",
|
|
26483
|
+
children: [/* @__PURE__ */ jsx(ArrowLeft, {
|
|
26484
|
+
"aria-hidden": true,
|
|
26485
|
+
className: "size-3"
|
|
26486
|
+
}), worseLabel]
|
|
26487
|
+
}),
|
|
26488
|
+
/* @__PURE__ */ jsx("span", {
|
|
26489
|
+
className: "text-foreground/70",
|
|
26490
|
+
children: referenceLabel
|
|
26491
|
+
}),
|
|
26492
|
+
/* @__PURE__ */ jsxs("span", {
|
|
26493
|
+
className: "inline-flex items-center gap-1",
|
|
26494
|
+
children: [betterLabel, /* @__PURE__ */ jsx(ArrowRight, {
|
|
26495
|
+
"aria-hidden": true,
|
|
26496
|
+
className: "size-3"
|
|
26497
|
+
})]
|
|
26498
|
+
})
|
|
26499
|
+
]
|
|
26500
|
+
}),
|
|
26501
|
+
/* @__PURE__ */ jsx("div", {
|
|
26502
|
+
className: "text-right",
|
|
26503
|
+
children: "Effect (CI)"
|
|
26504
|
+
}),
|
|
26505
|
+
/* @__PURE__ */ jsx("div", {
|
|
26506
|
+
className: "text-right",
|
|
26507
|
+
children: "N"
|
|
26508
|
+
}),
|
|
26509
|
+
hasGuards && /* @__PURE__ */ jsx("div", { children: "Guards" }),
|
|
26510
|
+
hasVerdicts && /* @__PURE__ */ jsx("div", {
|
|
26511
|
+
className: "text-right",
|
|
26512
|
+
children: "Verdict"
|
|
26513
|
+
})
|
|
26514
|
+
]
|
|
26515
|
+
}),
|
|
26516
|
+
/* @__PURE__ */ jsx("div", {
|
|
26517
|
+
role: "list",
|
|
26518
|
+
"aria-label": label,
|
|
26519
|
+
className: "divide-y divide-border",
|
|
26520
|
+
children: rows.map((row) => {
|
|
26521
|
+
const isSelected = selectedId === row.id;
|
|
26522
|
+
const interactive = Boolean(onSelect);
|
|
26523
|
+
const pointColour = row.baseline ? "var(--muted-foreground)" : row.verdict ? VERDICT_COLOUR[row.verdict.tone] : "var(--primary)";
|
|
26524
|
+
const hasInterval = row.low !== void 0 && row.low !== null && row.high !== void 0 && row.high !== null && Number.isFinite(row.low) && Number.isFinite(row.high);
|
|
26525
|
+
const hasEstimate = row.estimate !== null && Number.isFinite(row.estimate);
|
|
26526
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26527
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26528
|
+
className: "min-w-0",
|
|
26529
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
26530
|
+
className: cn("truncate type-label", row.baseline ? "text-muted-foreground" : "text-foreground"),
|
|
26531
|
+
children: row.label
|
|
26532
|
+
}), row.subtitle && /* @__PURE__ */ jsx("div", {
|
|
26533
|
+
className: "truncate type-caption text-muted-foreground",
|
|
26534
|
+
children: row.subtitle
|
|
26535
|
+
})]
|
|
26536
|
+
}),
|
|
26537
|
+
/* @__PURE__ */ jsx("div", {
|
|
26538
|
+
className: "h-11 w-full",
|
|
26539
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
26540
|
+
width: plotWidth,
|
|
26541
|
+
height: ROW_H$1,
|
|
26542
|
+
className: "block h-full w-full overflow-visible",
|
|
26543
|
+
"aria-hidden": "true",
|
|
26544
|
+
children: [
|
|
26545
|
+
scale.ticks.map((t) => {
|
|
26546
|
+
const tx = xOf(t);
|
|
26547
|
+
return /* @__PURE__ */ jsx("line", {
|
|
26548
|
+
x1: tx,
|
|
26549
|
+
x2: tx,
|
|
26550
|
+
y1: 0,
|
|
26551
|
+
y2: ROW_H$1,
|
|
26552
|
+
stroke: "var(--border)",
|
|
26553
|
+
strokeOpacity: t === reference ? 0 : .55,
|
|
26554
|
+
strokeWidth: 1
|
|
26555
|
+
}, t);
|
|
26556
|
+
}),
|
|
26557
|
+
minEffX !== null && /* @__PURE__ */ jsx("rect", {
|
|
26558
|
+
x: Math.min(refX, minEffX),
|
|
26559
|
+
y: 0,
|
|
26560
|
+
width: Math.max(1, Math.abs(minEffX - refX)),
|
|
26561
|
+
height: ROW_H$1,
|
|
26562
|
+
fill: "var(--primary)",
|
|
26563
|
+
fillOpacity: .09
|
|
26564
|
+
}),
|
|
26565
|
+
/* @__PURE__ */ jsx("line", {
|
|
26566
|
+
x1: refX,
|
|
26567
|
+
x2: refX,
|
|
26568
|
+
y1: 0,
|
|
26569
|
+
y2: ROW_H$1,
|
|
26570
|
+
stroke: "var(--muted-foreground)",
|
|
26571
|
+
strokeDasharray: "3 3",
|
|
26572
|
+
strokeWidth: 1.25
|
|
26573
|
+
}),
|
|
26574
|
+
minEffX !== null && /* @__PURE__ */ jsx("line", {
|
|
26575
|
+
x1: minEffX,
|
|
26576
|
+
x2: minEffX,
|
|
26577
|
+
y1: 0,
|
|
26578
|
+
y2: ROW_H$1,
|
|
26579
|
+
stroke: "var(--primary)",
|
|
26580
|
+
strokeOpacity: .55,
|
|
26581
|
+
strokeDasharray: "2 2",
|
|
26582
|
+
strokeWidth: 1
|
|
26583
|
+
}),
|
|
26584
|
+
hasInterval && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26585
|
+
/* @__PURE__ */ jsx("line", {
|
|
26586
|
+
x1: xOf(row.low),
|
|
26587
|
+
x2: xOf(row.high),
|
|
26588
|
+
y1: ROW_H$1 / 2,
|
|
26589
|
+
y2: ROW_H$1 / 2,
|
|
26590
|
+
stroke: pointColour,
|
|
26591
|
+
strokeWidth: 2,
|
|
26592
|
+
strokeLinecap: "round"
|
|
26593
|
+
}),
|
|
26594
|
+
/* @__PURE__ */ jsx("line", {
|
|
26595
|
+
x1: xOf(row.low),
|
|
26596
|
+
x2: xOf(row.low),
|
|
26597
|
+
y1: ROW_H$1 / 2 - 4,
|
|
26598
|
+
y2: 26,
|
|
26599
|
+
stroke: pointColour,
|
|
26600
|
+
strokeWidth: 1.5
|
|
26601
|
+
}),
|
|
26602
|
+
/* @__PURE__ */ jsx("line", {
|
|
26603
|
+
x1: xOf(row.high),
|
|
26604
|
+
x2: xOf(row.high),
|
|
26605
|
+
y1: ROW_H$1 / 2 - 4,
|
|
26606
|
+
y2: 26,
|
|
26607
|
+
stroke: pointColour,
|
|
26608
|
+
strokeWidth: 1.5
|
|
26609
|
+
})
|
|
26610
|
+
] }),
|
|
26611
|
+
hasEstimate && (row.baseline ? /* @__PURE__ */ jsx("polygon", {
|
|
26612
|
+
points: `${xOf(row.estimate)},${ROW_H$1 / 2 - 5} ${xOf(row.estimate) + 5},${ROW_H$1 / 2} ${xOf(row.estimate)},27 ${xOf(row.estimate) - 5},${ROW_H$1 / 2}`,
|
|
26613
|
+
fill: "var(--card)",
|
|
26614
|
+
stroke: pointColour,
|
|
26615
|
+
strokeWidth: 2
|
|
26616
|
+
}) : /* @__PURE__ */ jsx("circle", {
|
|
26617
|
+
cx: xOf(row.estimate),
|
|
26618
|
+
cy: ROW_H$1 / 2,
|
|
26619
|
+
r: isSelected ? 5.5 : 4.5,
|
|
26620
|
+
fill: pointColour,
|
|
26621
|
+
stroke: "var(--card)",
|
|
26622
|
+
strokeWidth: 1.5
|
|
26623
|
+
}))
|
|
26624
|
+
]
|
|
26625
|
+
})
|
|
26626
|
+
}),
|
|
26627
|
+
/* @__PURE__ */ jsx("div", {
|
|
26628
|
+
className: "whitespace-nowrap text-right font-mono type-caption tabular-nums",
|
|
26629
|
+
children: hasEstimate ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
26630
|
+
className: "font-medium text-foreground",
|
|
26631
|
+
children: formatValue(row.estimate)
|
|
26632
|
+
}), hasInterval && /* @__PURE__ */ jsxs("div", {
|
|
26633
|
+
className: "text-muted-foreground",
|
|
26634
|
+
children: [
|
|
26635
|
+
"[",
|
|
26636
|
+
formatValue(row.low),
|
|
26637
|
+
", ",
|
|
26638
|
+
formatValue(row.high),
|
|
26639
|
+
"]"
|
|
26640
|
+
]
|
|
26641
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
26642
|
+
className: "text-muted-foreground",
|
|
26643
|
+
children: "—"
|
|
26644
|
+
})
|
|
26645
|
+
}),
|
|
26646
|
+
/* @__PURE__ */ jsx("div", {
|
|
26647
|
+
className: "text-right font-mono type-caption tabular-nums text-muted-foreground",
|
|
26648
|
+
children: row.n
|
|
26649
|
+
}),
|
|
26650
|
+
hasGuards && /* @__PURE__ */ jsx("div", {
|
|
26651
|
+
className: "flex flex-wrap gap-1",
|
|
26652
|
+
children: row.guards?.map((g) => /* @__PURE__ */ jsxs("span", {
|
|
26653
|
+
className: cn("inline-flex items-center gap-0.5 rounded-control px-1.5 py-0.5 type-caption", g.passed === true && "bg-success-subtle text-success", g.passed === false && "bg-danger-subtle text-danger", g.passed === null && "bg-muted text-muted-foreground"),
|
|
26654
|
+
children: [
|
|
26655
|
+
g.passed === true && /* @__PURE__ */ jsx(Check, {
|
|
26656
|
+
"aria-hidden": true,
|
|
26657
|
+
className: "size-3"
|
|
26658
|
+
}),
|
|
26659
|
+
g.passed === false && /* @__PURE__ */ jsx(X, {
|
|
26660
|
+
"aria-hidden": true,
|
|
26661
|
+
className: "size-3"
|
|
26662
|
+
}),
|
|
26663
|
+
/* @__PURE__ */ jsx("span", { children: g.label })
|
|
26664
|
+
]
|
|
26665
|
+
}, g.label))
|
|
26666
|
+
}),
|
|
26667
|
+
hasVerdicts && /* @__PURE__ */ jsx("div", {
|
|
26668
|
+
className: "flex justify-end",
|
|
26669
|
+
children: row.verdict ? /* @__PURE__ */ jsx(Status, {
|
|
26670
|
+
tone: row.verdict.tone,
|
|
26671
|
+
children: row.verdict.label
|
|
26672
|
+
}) : null
|
|
26673
|
+
})
|
|
26674
|
+
] });
|
|
26675
|
+
if (interactive) return /* @__PURE__ */ jsx("div", {
|
|
26676
|
+
role: "listitem",
|
|
26677
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
26678
|
+
onPress: () => onSelect?.(row),
|
|
26679
|
+
"aria-pressed": isSelected,
|
|
26680
|
+
style: { gridTemplateColumns: gridCols },
|
|
26681
|
+
className: cn("grid w-full cursor-pointer items-center gap-3 px-4 py-1 text-left transition-state focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring", isSelected ? "bg-accent" : "hover:bg-muted/60"),
|
|
26682
|
+
children: content
|
|
26683
|
+
})
|
|
26684
|
+
}, row.id);
|
|
26685
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26686
|
+
role: "listitem",
|
|
26687
|
+
style: { gridTemplateColumns: gridCols },
|
|
26688
|
+
className: cn("grid items-center gap-3 px-4 py-1", isSelected && "bg-accent"),
|
|
26689
|
+
children: content
|
|
26690
|
+
}, row.id);
|
|
26691
|
+
})
|
|
26692
|
+
}),
|
|
26693
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26694
|
+
className: "grid items-center gap-3 border-t border-border bg-surface-sunken px-4 py-1",
|
|
26695
|
+
style: { gridTemplateColumns: gridCols },
|
|
26696
|
+
children: [
|
|
26697
|
+
/* @__PURE__ */ jsx("div", {
|
|
26698
|
+
className: "type-caption text-muted-foreground",
|
|
26699
|
+
children: minEffectLabel && /* @__PURE__ */ jsxs("span", {
|
|
26700
|
+
className: "inline-flex items-center gap-1.5",
|
|
26701
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
26702
|
+
"aria-hidden": true,
|
|
26703
|
+
className: "inline-block size-2.5 shrink-0 rounded-control border border-primary/50 bg-primary/15"
|
|
26704
|
+
}), minEffectLabel]
|
|
26705
|
+
})
|
|
26706
|
+
}),
|
|
26707
|
+
/* @__PURE__ */ jsx("svg", {
|
|
26708
|
+
width: plotWidth,
|
|
26709
|
+
height: AXIS_H,
|
|
26710
|
+
className: "block w-full overflow-visible",
|
|
26711
|
+
"aria-hidden": "true",
|
|
26712
|
+
children: labelTicks.map((t) => {
|
|
26713
|
+
const tx = xOf(t);
|
|
26714
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
26715
|
+
transform: `translate(${tx}, 0)`,
|
|
26716
|
+
children: [/* @__PURE__ */ jsx("line", {
|
|
26717
|
+
y1: 0,
|
|
26718
|
+
y2: 5,
|
|
26719
|
+
stroke: "var(--border)",
|
|
26720
|
+
strokeWidth: 1
|
|
26721
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
26722
|
+
y: 18,
|
|
26723
|
+
textAnchor: "middle",
|
|
26724
|
+
fill: "var(--muted-foreground)",
|
|
26725
|
+
fontSize: 11,
|
|
26726
|
+
fontFamily: "var(--font-mono)",
|
|
26727
|
+
children: formatValue(t)
|
|
26728
|
+
})]
|
|
26729
|
+
}, t);
|
|
26730
|
+
})
|
|
26731
|
+
}),
|
|
26732
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
26733
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
26734
|
+
hasGuards && /* @__PURE__ */ jsx("div", {}),
|
|
26735
|
+
hasVerdicts && /* @__PURE__ */ jsx("div", {})
|
|
26736
|
+
]
|
|
26737
|
+
})
|
|
26738
|
+
]
|
|
26739
|
+
})
|
|
26740
|
+
}),
|
|
26741
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsxs("table", { children: [
|
|
26742
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
26743
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
26744
|
+
/* @__PURE__ */ jsx("th", { children: "Candidate" }),
|
|
26745
|
+
/* @__PURE__ */ jsx("th", { children: "Effect" }),
|
|
26746
|
+
/* @__PURE__ */ jsx("th", { children: "Interval" }),
|
|
26747
|
+
/* @__PURE__ */ jsx("th", { children: "N" }),
|
|
26748
|
+
/* @__PURE__ */ jsx("th", { children: "Verdict" })
|
|
26749
|
+
] }) }),
|
|
26750
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((r) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
26751
|
+
/* @__PURE__ */ jsx("td", { children: r.label }),
|
|
26752
|
+
/* @__PURE__ */ jsx("td", { children: r.estimate !== null ? formatValue(r.estimate) : "Not evaluated" }),
|
|
26753
|
+
/* @__PURE__ */ jsx("td", { children: r.low !== void 0 && r.low !== null && r.high !== void 0 && r.high !== null ? `${formatValue(r.low)} to ${formatValue(r.high)}` : "None" }),
|
|
26754
|
+
/* @__PURE__ */ jsx("td", { children: r.n }),
|
|
26755
|
+
/* @__PURE__ */ jsx("td", { children: r.verdict?.label ?? "" })
|
|
26756
|
+
] }, r.id)) })
|
|
26757
|
+
] }) })
|
|
26758
|
+
]
|
|
26759
|
+
});
|
|
26760
|
+
}
|
|
26761
|
+
|
|
26762
|
+
// src/components/scatter-frontier.tsx
|
|
26763
|
+
const PAD = {
|
|
26764
|
+
top: 22,
|
|
26765
|
+
right: 24,
|
|
26766
|
+
bottom: 44,
|
|
26767
|
+
left: 64
|
|
26768
|
+
};
|
|
26769
|
+
const SHAPES = [
|
|
26770
|
+
"circle",
|
|
26771
|
+
"square",
|
|
26772
|
+
"diamond",
|
|
26773
|
+
"triangle"
|
|
26774
|
+
];
|
|
26775
|
+
function renderShape(shape, cx, cy, r, fill, stroke, strokeWidth) {
|
|
26776
|
+
switch (shape) {
|
|
26777
|
+
case "square": return /* @__PURE__ */ jsx("rect", {
|
|
26778
|
+
x: cx - r,
|
|
26779
|
+
y: cy - r,
|
|
26780
|
+
width: r * 2,
|
|
26781
|
+
height: r * 2,
|
|
26782
|
+
rx: 1.5,
|
|
26783
|
+
fill,
|
|
26784
|
+
stroke,
|
|
26785
|
+
strokeWidth
|
|
26786
|
+
});
|
|
26787
|
+
case "diamond": return /* @__PURE__ */ jsx("polygon", {
|
|
26788
|
+
points: `${cx},${cy - r * 1.25} ${cx + r * 1.25},${cy} ${cx},${cy + r * 1.25} ${cx - r * 1.25},${cy}`,
|
|
26789
|
+
fill,
|
|
26790
|
+
stroke,
|
|
26791
|
+
strokeWidth
|
|
26792
|
+
});
|
|
26793
|
+
case "triangle": return /* @__PURE__ */ jsx("polygon", {
|
|
26794
|
+
points: `${cx},${cy - r * 1.25} ${cx + r * 1.2},${cy + r} ${cx - r * 1.2},${cy + r}`,
|
|
26795
|
+
fill,
|
|
26796
|
+
stroke,
|
|
26797
|
+
strokeWidth
|
|
26798
|
+
});
|
|
26799
|
+
default: return /* @__PURE__ */ jsx("circle", {
|
|
26800
|
+
cx,
|
|
26801
|
+
cy,
|
|
26802
|
+
r,
|
|
26803
|
+
fill,
|
|
26804
|
+
stroke,
|
|
26805
|
+
strokeWidth
|
|
26806
|
+
});
|
|
26807
|
+
}
|
|
26808
|
+
}
|
|
26809
|
+
/** Interactive 2D scatter plot with automatic Pareto frontier, switchable axes, category shapes and detail readout. */
|
|
26810
|
+
function ScatterFrontier({ label, points, xAxis, yAxis, showFrontier = true, quadrants, showIntervals = false, height = 300, caveat, selectedId: controlledSelectedId, onSelect, className }) {
|
|
26811
|
+
const xAxes = Array.isArray(xAxis) ? xAxis : [xAxis];
|
|
26812
|
+
const yAxes = Array.isArray(yAxis) ? yAxis : [yAxis];
|
|
26813
|
+
const [xAxisId, setXAxisId] = React.useState(xAxes[0].id);
|
|
26814
|
+
const [yAxisId, setYAxisId] = React.useState(yAxes[0].id);
|
|
26815
|
+
const [internalSelected, setInternalSelected] = React.useState(null);
|
|
26816
|
+
const [hoveredId, setHoveredId] = React.useState(null);
|
|
26817
|
+
const activeX = xAxes.find((a) => a.id === xAxisId) ?? xAxes[0];
|
|
26818
|
+
const activeY = yAxes.find((a) => a.id === yAxisId) ?? yAxes[0];
|
|
26819
|
+
const selectedId = controlledSelectedId !== void 0 ? controlledSelectedId : internalSelected;
|
|
26820
|
+
const [containerRef, width] = useContainerWidth(560);
|
|
26821
|
+
const resolved = React.useMemo(() => {
|
|
26822
|
+
return points.map((p) => {
|
|
26823
|
+
const xv = p.values ? p.values[activeX.id] : p.x;
|
|
26824
|
+
const yv = p.values ? p.values[activeY.id] : p.y;
|
|
26825
|
+
if (typeof xv !== "number" || !Number.isFinite(xv) || typeof yv !== "number" || !Number.isFinite(yv)) return null;
|
|
26826
|
+
return {
|
|
26827
|
+
point: p,
|
|
26828
|
+
id: p.id,
|
|
26829
|
+
x: xv,
|
|
26830
|
+
y: yv
|
|
26831
|
+
};
|
|
26832
|
+
}).filter((item) => item !== null);
|
|
26833
|
+
}, [
|
|
26834
|
+
points,
|
|
26835
|
+
activeX.id,
|
|
26836
|
+
activeY.id
|
|
26837
|
+
]);
|
|
26838
|
+
const groups = React.useMemo(() => {
|
|
26839
|
+
const seen = [];
|
|
26840
|
+
for (const r of resolved) {
|
|
26841
|
+
const g = r.point.group;
|
|
26842
|
+
if (g && !seen.includes(g)) seen.push(g);
|
|
26843
|
+
}
|
|
26844
|
+
return seen;
|
|
26845
|
+
}, [resolved]);
|
|
26846
|
+
const frontier = React.useMemo(() => paretoFrontier(resolved, activeX.direction, activeY.direction), [
|
|
26847
|
+
resolved,
|
|
26848
|
+
activeX.direction,
|
|
26849
|
+
activeY.direction
|
|
26850
|
+
]);
|
|
26851
|
+
const xScale = React.useMemo(() => {
|
|
26852
|
+
const vals = [];
|
|
26853
|
+
for (const r of resolved) {
|
|
26854
|
+
vals.push(r.x);
|
|
26855
|
+
if (r.point.xLow !== void 0 && Number.isFinite(r.point.xLow)) vals.push(r.point.xLow);
|
|
26856
|
+
if (r.point.xHigh !== void 0 && Number.isFinite(r.point.xHigh)) vals.push(r.point.xHigh);
|
|
26857
|
+
}
|
|
26858
|
+
return vals.length ? niceScale(Math.min(...vals), Math.max(...vals), 5) : niceScale(0, 1, 5);
|
|
26859
|
+
}, [resolved]);
|
|
26860
|
+
const yScale = React.useMemo(() => {
|
|
26861
|
+
const vals = [];
|
|
26862
|
+
for (const r of resolved) {
|
|
26863
|
+
vals.push(r.y);
|
|
26864
|
+
if (r.point.yLow !== void 0 && Number.isFinite(r.point.yLow)) vals.push(r.point.yLow);
|
|
26865
|
+
if (r.point.yHigh !== void 0 && Number.isFinite(r.point.yHigh)) vals.push(r.point.yHigh);
|
|
26866
|
+
}
|
|
26867
|
+
return vals.length ? niceScale(Math.min(...vals), Math.max(...vals), 5) : niceScale(0, 1, 5);
|
|
26868
|
+
}, [resolved]);
|
|
26869
|
+
const innerW = Math.max(160, width - PAD.left - PAD.right);
|
|
26870
|
+
const innerH = Math.max(120, height - PAD.top - PAD.bottom);
|
|
26871
|
+
const xSpan = xScale.max - xScale.min || 1;
|
|
26872
|
+
const ySpan = yScale.max - yScale.min || 1;
|
|
26873
|
+
const px = (v) => PAD.left + (v - xScale.min) / xSpan * innerW;
|
|
26874
|
+
const py = (v) => PAD.top + (1 - (v - yScale.min) / ySpan) * innerH;
|
|
26875
|
+
const activeDetailId = selectedId ?? hoveredId;
|
|
26876
|
+
const activeDetail = resolved.find((r) => r.id === activeDetailId) ?? null;
|
|
26877
|
+
const handleSelect = (p) => {
|
|
26878
|
+
const next = selectedId === p.id ? null : p;
|
|
26879
|
+
if (controlledSelectedId === void 0) setInternalSelected(next?.id ?? null);
|
|
26880
|
+
onSelect?.(next);
|
|
26881
|
+
};
|
|
26882
|
+
const betterCornerX = activeX.direction === "higher" ? PAD.left + innerW - 6 : PAD.left + 6;
|
|
26883
|
+
const betterCornerY = activeY.direction === "higher" ? PAD.top + 12 : PAD.top + innerH - 8;
|
|
26884
|
+
const betterAnchor = activeX.direction === "higher" ? "end" : "start";
|
|
26885
|
+
const frontierPath = showFrontier && frontier.ordered.length > 1 ? frontier.ordered.map((p, i) => `${i === 0 ? "M" : "L"}${px(p.x).toFixed(1)},${py(p.y).toFixed(1)}`).join(" ") : null;
|
|
26886
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
26887
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
26888
|
+
children: [
|
|
26889
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
26890
|
+
className: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-2.5",
|
|
26891
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
26892
|
+
className: "type-label text-foreground",
|
|
26893
|
+
children: label
|
|
26894
|
+
}), (xAxes.length > 1 || yAxes.length > 1) && /* @__PURE__ */ jsxs("div", {
|
|
26895
|
+
className: "flex flex-wrap items-center gap-2",
|
|
26896
|
+
children: [yAxes.length > 1 && /* @__PURE__ */ jsxs("label", {
|
|
26897
|
+
className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground",
|
|
26898
|
+
children: [/* @__PURE__ */ jsx("span", { children: "Y:" }), /* @__PURE__ */ jsx("select", {
|
|
26899
|
+
"aria-label": "Y axis metric",
|
|
26900
|
+
value: activeY.id,
|
|
26901
|
+
onChange: (e) => setYAxisId(e.target.value),
|
|
26902
|
+
className: "rounded-control border border-border bg-background px-2 py-0.5 type-caption text-foreground focus-visible:outline-2 focus-visible:outline-ring",
|
|
26903
|
+
children: yAxes.map((a) => /* @__PURE__ */ jsx("option", {
|
|
26904
|
+
value: a.id,
|
|
26905
|
+
children: a.label
|
|
26906
|
+
}, a.id))
|
|
26907
|
+
})]
|
|
26908
|
+
}), xAxes.length > 1 && /* @__PURE__ */ jsxs("label", {
|
|
26909
|
+
className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground",
|
|
26910
|
+
children: [/* @__PURE__ */ jsx("span", { children: "X:" }), /* @__PURE__ */ jsx("select", {
|
|
26911
|
+
"aria-label": "X axis metric",
|
|
26912
|
+
value: activeX.id,
|
|
26913
|
+
onChange: (e) => setXAxisId(e.target.value),
|
|
26914
|
+
className: "rounded-control border border-border bg-background px-2 py-0.5 type-caption text-foreground focus-visible:outline-2 focus-visible:outline-ring",
|
|
26915
|
+
children: xAxes.map((a) => /* @__PURE__ */ jsx("option", {
|
|
26916
|
+
value: a.id,
|
|
26917
|
+
children: a.label
|
|
26918
|
+
}, a.id))
|
|
26919
|
+
})]
|
|
26920
|
+
})]
|
|
26921
|
+
})]
|
|
26922
|
+
}),
|
|
26923
|
+
(groups.length > 0 || showFrontier) && /* @__PURE__ */ jsxs("div", {
|
|
26924
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-border bg-surface-sunken px-4 py-1.5 type-caption text-muted-foreground",
|
|
26925
|
+
children: [groups.map((g, idx) => /* @__PURE__ */ jsxs("span", {
|
|
26926
|
+
className: "inline-flex items-center gap-1.5",
|
|
26927
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
26928
|
+
width: 12,
|
|
26929
|
+
height: 12,
|
|
26930
|
+
"aria-hidden": "true",
|
|
26931
|
+
children: renderShape(SHAPES[idx % SHAPES.length], 6, 6, 4, chartColour(idx), "var(--card)", 1)
|
|
26932
|
+
}), /* @__PURE__ */ jsx("span", { children: g })]
|
|
26933
|
+
}, g)), showFrontier && /* @__PURE__ */ jsxs("span", {
|
|
26934
|
+
className: "inline-flex items-center gap-1.5",
|
|
26935
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
26936
|
+
width: 18,
|
|
26937
|
+
height: 10,
|
|
26938
|
+
"aria-hidden": "true",
|
|
26939
|
+
children: /* @__PURE__ */ jsx("line", {
|
|
26940
|
+
x1: 0,
|
|
26941
|
+
x2: 18,
|
|
26942
|
+
y1: 5,
|
|
26943
|
+
y2: 5,
|
|
26944
|
+
stroke: "var(--primary)",
|
|
26945
|
+
strokeWidth: 1.75,
|
|
26946
|
+
strokeDasharray: "4 3"
|
|
26947
|
+
})
|
|
26948
|
+
}), /* @__PURE__ */ jsx("span", { children: "Pareto frontier" })]
|
|
26949
|
+
})]
|
|
26950
|
+
}),
|
|
26951
|
+
/* @__PURE__ */ jsx("div", {
|
|
26952
|
+
ref: containerRef,
|
|
26953
|
+
className: "px-2 pt-2",
|
|
26954
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
26955
|
+
width,
|
|
26956
|
+
height,
|
|
26957
|
+
className: "block w-full select-none overflow-visible",
|
|
26958
|
+
role: "img",
|
|
26959
|
+
"aria-label": label,
|
|
26960
|
+
children: [
|
|
26961
|
+
yScale.ticks.map((t) => {
|
|
26962
|
+
const y = py(t);
|
|
26963
|
+
return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
26964
|
+
x1: PAD.left,
|
|
26965
|
+
x2: PAD.left + innerW,
|
|
26966
|
+
y1: y,
|
|
26967
|
+
y2: y,
|
|
26968
|
+
stroke: "var(--border)",
|
|
26969
|
+
strokeOpacity: .6
|
|
26970
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
26971
|
+
x: PAD.left - 8,
|
|
26972
|
+
y: y + 3.5,
|
|
26973
|
+
textAnchor: "end",
|
|
26974
|
+
fill: "var(--muted-foreground)",
|
|
26975
|
+
fontSize: 11,
|
|
26976
|
+
fontFamily: "var(--font-mono)",
|
|
26977
|
+
children: activeY.format(t)
|
|
26978
|
+
})] }, `y-${t}`);
|
|
26979
|
+
}),
|
|
26980
|
+
xScale.ticks.map((t) => {
|
|
26981
|
+
const x = px(t);
|
|
26982
|
+
return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
26983
|
+
x1: x,
|
|
26984
|
+
x2: x,
|
|
26985
|
+
y1: PAD.top,
|
|
26986
|
+
y2: PAD.top + innerH,
|
|
26987
|
+
stroke: "var(--border)",
|
|
26988
|
+
strokeOpacity: .45
|
|
26989
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
26990
|
+
x,
|
|
26991
|
+
y: PAD.top + innerH + 16,
|
|
26992
|
+
textAnchor: "middle",
|
|
26993
|
+
fill: "var(--muted-foreground)",
|
|
26994
|
+
fontSize: 11,
|
|
26995
|
+
fontFamily: "var(--font-mono)",
|
|
26996
|
+
children: activeX.format(t)
|
|
26997
|
+
})] }, `x-${t}`);
|
|
26998
|
+
}),
|
|
26999
|
+
/* @__PURE__ */ jsxs("text", {
|
|
27000
|
+
x: PAD.left + innerW / 2,
|
|
27001
|
+
y: height - 6,
|
|
27002
|
+
textAnchor: "middle",
|
|
27003
|
+
fill: "var(--muted-foreground)",
|
|
27004
|
+
fontSize: 12,
|
|
27005
|
+
children: [
|
|
27006
|
+
activeX.label,
|
|
27007
|
+
" ",
|
|
27008
|
+
activeX.direction === "higher" ? "(higher is better)" : "(lower is better)"
|
|
27009
|
+
]
|
|
27010
|
+
}),
|
|
27011
|
+
/* @__PURE__ */ jsxs("text", {
|
|
27012
|
+
x: 14,
|
|
27013
|
+
y: PAD.top + innerH / 2,
|
|
27014
|
+
textAnchor: "middle",
|
|
27015
|
+
fill: "var(--muted-foreground)",
|
|
27016
|
+
fontSize: 12,
|
|
27017
|
+
transform: `rotate(-90, 14, ${PAD.top + innerH / 2})`,
|
|
27018
|
+
children: [
|
|
27019
|
+
activeY.label,
|
|
27020
|
+
" ",
|
|
27021
|
+
activeY.direction === "higher" ? "(higher is better)" : "(lower is better)"
|
|
27022
|
+
]
|
|
27023
|
+
}),
|
|
27024
|
+
quadrants && (() => {
|
|
27025
|
+
const sx = Math.max(PAD.left, Math.min(PAD.left + innerW, px(quadrants.xSplit)));
|
|
27026
|
+
const sy = Math.max(PAD.top, Math.min(PAD.top + innerH, py(quadrants.ySplit)));
|
|
27027
|
+
const hl = quadrants.highlight;
|
|
27028
|
+
const hlRect = hl === "topRight" ? {
|
|
27029
|
+
x: sx,
|
|
27030
|
+
y: PAD.top,
|
|
27031
|
+
w: PAD.left + innerW - sx,
|
|
27032
|
+
h: sy - PAD.top
|
|
27033
|
+
} : hl === "topLeft" ? {
|
|
27034
|
+
x: PAD.left,
|
|
27035
|
+
y: PAD.top,
|
|
27036
|
+
w: sx - PAD.left,
|
|
27037
|
+
h: sy - PAD.top
|
|
27038
|
+
} : hl === "bottomRight" ? {
|
|
27039
|
+
x: sx,
|
|
27040
|
+
y: sy,
|
|
27041
|
+
w: PAD.left + innerW - sx,
|
|
27042
|
+
h: PAD.top + innerH - sy
|
|
27043
|
+
} : hl === "bottomLeft" ? {
|
|
27044
|
+
x: PAD.left,
|
|
27045
|
+
y: sy,
|
|
27046
|
+
w: sx - PAD.left,
|
|
27047
|
+
h: PAD.top + innerH - sy
|
|
27048
|
+
} : null;
|
|
27049
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
27050
|
+
"aria-hidden": "true",
|
|
27051
|
+
children: [
|
|
27052
|
+
hlRect && hlRect.w > 0 && hlRect.h > 0 && /* @__PURE__ */ jsx("rect", {
|
|
27053
|
+
x: hlRect.x,
|
|
27054
|
+
y: hlRect.y,
|
|
27055
|
+
width: hlRect.w,
|
|
27056
|
+
height: hlRect.h,
|
|
27057
|
+
fill: "var(--primary)",
|
|
27058
|
+
fillOpacity: .07
|
|
27059
|
+
}),
|
|
27060
|
+
/* @__PURE__ */ jsx("line", {
|
|
27061
|
+
x1: sx,
|
|
27062
|
+
x2: sx,
|
|
27063
|
+
y1: PAD.top,
|
|
27064
|
+
y2: PAD.top + innerH,
|
|
27065
|
+
stroke: "var(--muted-foreground)",
|
|
27066
|
+
strokeOpacity: .5,
|
|
27067
|
+
strokeDasharray: "4 4",
|
|
27068
|
+
strokeWidth: 1.2
|
|
27069
|
+
}),
|
|
27070
|
+
/* @__PURE__ */ jsx("line", {
|
|
27071
|
+
x1: PAD.left,
|
|
27072
|
+
x2: PAD.left + innerW,
|
|
27073
|
+
y1: sy,
|
|
27074
|
+
y2: sy,
|
|
27075
|
+
stroke: "var(--muted-foreground)",
|
|
27076
|
+
strokeOpacity: .5,
|
|
27077
|
+
strokeDasharray: "4 4",
|
|
27078
|
+
strokeWidth: 1.2
|
|
27079
|
+
}),
|
|
27080
|
+
quadrants.labels?.topLeft && /* @__PURE__ */ jsx("text", {
|
|
27081
|
+
x: PAD.left + 8,
|
|
27082
|
+
y: PAD.top + 14,
|
|
27083
|
+
fill: "var(--muted-foreground)",
|
|
27084
|
+
fontSize: 10,
|
|
27085
|
+
fontWeight: 600,
|
|
27086
|
+
children: quadrants.labels.topLeft
|
|
27087
|
+
}),
|
|
27088
|
+
quadrants.labels?.topRight && /* @__PURE__ */ jsx("text", {
|
|
27089
|
+
x: PAD.left + innerW - 8,
|
|
27090
|
+
y: PAD.top + 14,
|
|
27091
|
+
textAnchor: "end",
|
|
27092
|
+
fill: hl === "topRight" ? "var(--primary)" : "var(--muted-foreground)",
|
|
27093
|
+
fontSize: 10,
|
|
27094
|
+
fontWeight: 600,
|
|
27095
|
+
children: quadrants.labels.topRight
|
|
27096
|
+
}),
|
|
27097
|
+
quadrants.labels?.bottomLeft && /* @__PURE__ */ jsx("text", {
|
|
27098
|
+
x: PAD.left + 8,
|
|
27099
|
+
y: PAD.top + innerH - 8,
|
|
27100
|
+
fill: "var(--muted-foreground)",
|
|
27101
|
+
fontSize: 10,
|
|
27102
|
+
children: quadrants.labels.bottomLeft
|
|
27103
|
+
}),
|
|
27104
|
+
quadrants.labels?.bottomRight && /* @__PURE__ */ jsx("text", {
|
|
27105
|
+
x: PAD.left + innerW - 8,
|
|
27106
|
+
y: PAD.top + innerH - 8,
|
|
27107
|
+
textAnchor: "end",
|
|
27108
|
+
fill: "var(--muted-foreground)",
|
|
27109
|
+
fontSize: 10,
|
|
27110
|
+
children: quadrants.labels.bottomRight
|
|
27111
|
+
})
|
|
27112
|
+
]
|
|
27113
|
+
});
|
|
27114
|
+
})(),
|
|
27115
|
+
!quadrants && /* @__PURE__ */ jsx("text", {
|
|
27116
|
+
x: betterCornerX,
|
|
27117
|
+
y: betterCornerY,
|
|
27118
|
+
textAnchor: betterAnchor,
|
|
27119
|
+
fill: "var(--primary)",
|
|
27120
|
+
fillOpacity: .8,
|
|
27121
|
+
fontSize: 11,
|
|
27122
|
+
fontWeight: 500,
|
|
27123
|
+
children: "Better corner"
|
|
27124
|
+
}),
|
|
27125
|
+
frontierPath && /* @__PURE__ */ jsx("path", {
|
|
27126
|
+
d: frontierPath,
|
|
27127
|
+
fill: "none",
|
|
27128
|
+
stroke: "var(--primary)",
|
|
27129
|
+
strokeWidth: 1.75,
|
|
27130
|
+
strokeDasharray: "5 4",
|
|
27131
|
+
strokeOpacity: .8
|
|
27132
|
+
}),
|
|
27133
|
+
resolved.map(({ point, id, x, y }) => {
|
|
27134
|
+
const cx = px(x);
|
|
27135
|
+
const cy = py(y);
|
|
27136
|
+
const isFrontier = frontier.ids.has(id);
|
|
27137
|
+
const isSelected = selectedId === id;
|
|
27138
|
+
const isHovered = hoveredId === id;
|
|
27139
|
+
const groupIdx = point.group ? groups.indexOf(point.group) : 0;
|
|
27140
|
+
const shape = SHAPES[Math.max(0, groupIdx) % SHAPES.length];
|
|
27141
|
+
const colour = point.group ? chartColour(Math.max(0, groupIdx)) : isFrontier ? "var(--primary)" : "var(--muted-foreground)";
|
|
27142
|
+
const showCrosshair = showIntervals || isSelected || isHovered;
|
|
27143
|
+
const labelRight = cx < PAD.left + innerW * .72;
|
|
27144
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
27145
|
+
role: "button",
|
|
27146
|
+
tabIndex: 0,
|
|
27147
|
+
"aria-label": `${point.label}: ${activeX.label} ${activeX.format(x)}, ${activeY.label} ${activeY.format(y)}${isFrontier ? ", on Pareto frontier" : ""}`,
|
|
27148
|
+
"aria-pressed": isSelected,
|
|
27149
|
+
onClick: () => handleSelect(point),
|
|
27150
|
+
onMouseEnter: () => setHoveredId(id),
|
|
27151
|
+
onMouseLeave: () => setHoveredId((prev) => prev === id ? null : prev),
|
|
27152
|
+
onKeyDown: (e) => {
|
|
27153
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
27154
|
+
e.preventDefault();
|
|
27155
|
+
handleSelect(point);
|
|
27156
|
+
}
|
|
27157
|
+
},
|
|
27158
|
+
className: "cursor-pointer outline-none focus-visible:opacity-100",
|
|
27159
|
+
children: [
|
|
27160
|
+
showCrosshair && point.xLow !== void 0 && point.xHigh !== void 0 && /* @__PURE__ */ jsx("line", {
|
|
27161
|
+
x1: px(point.xLow),
|
|
27162
|
+
x2: px(point.xHigh),
|
|
27163
|
+
y1: cy,
|
|
27164
|
+
y2: cy,
|
|
27165
|
+
stroke: colour,
|
|
27166
|
+
strokeWidth: 1.5,
|
|
27167
|
+
strokeOpacity: .7
|
|
27168
|
+
}),
|
|
27169
|
+
showCrosshair && point.yLow !== void 0 && point.yHigh !== void 0 && /* @__PURE__ */ jsx("line", {
|
|
27170
|
+
x1: cx,
|
|
27171
|
+
x2: cx,
|
|
27172
|
+
y1: py(point.yLow),
|
|
27173
|
+
y2: py(point.yHigh),
|
|
27174
|
+
stroke: colour,
|
|
27175
|
+
strokeWidth: 1.5,
|
|
27176
|
+
strokeOpacity: .7
|
|
27177
|
+
}),
|
|
27178
|
+
(isSelected || isHovered) && /* @__PURE__ */ jsx("circle", {
|
|
27179
|
+
cx,
|
|
27180
|
+
cy,
|
|
27181
|
+
r: 10,
|
|
27182
|
+
fill: colour,
|
|
27183
|
+
fillOpacity: .16,
|
|
27184
|
+
stroke: colour,
|
|
27185
|
+
strokeWidth: 1.5
|
|
27186
|
+
}),
|
|
27187
|
+
renderShape(shape, cx, cy, isSelected ? 6 : isFrontier ? 5.5 : 4.5, isFrontier || isSelected ? colour : "var(--card)", isFrontier || isSelected ? "var(--card)" : colour, isFrontier || isSelected ? 1.5 : 2),
|
|
27188
|
+
(isFrontier || isSelected || isHovered) && /* @__PURE__ */ jsx("text", {
|
|
27189
|
+
x: labelRight ? cx + 9 : cx - 9,
|
|
27190
|
+
y: cy + 3.5,
|
|
27191
|
+
textAnchor: labelRight ? "start" : "end",
|
|
27192
|
+
fill: "var(--foreground)",
|
|
27193
|
+
fontSize: 11,
|
|
27194
|
+
fontWeight: isSelected ? 600 : 500,
|
|
27195
|
+
children: point.label
|
|
27196
|
+
})
|
|
27197
|
+
]
|
|
27198
|
+
}, id);
|
|
27199
|
+
})
|
|
27200
|
+
]
|
|
27201
|
+
})
|
|
27202
|
+
}),
|
|
27203
|
+
/* @__PURE__ */ jsx("div", {
|
|
27204
|
+
className: "flex flex-wrap items-center justify-between gap-2 border-t border-border bg-surface-sunken px-4 py-2 type-caption",
|
|
27205
|
+
children: activeDetail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27206
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27207
|
+
className: "flex flex-wrap items-center gap-2",
|
|
27208
|
+
children: [
|
|
27209
|
+
/* @__PURE__ */ jsx("span", {
|
|
27210
|
+
className: "font-medium text-foreground",
|
|
27211
|
+
children: activeDetail.point.label
|
|
27212
|
+
}),
|
|
27213
|
+
activeDetail.point.group && /* @__PURE__ */ jsxs("span", {
|
|
27214
|
+
className: "text-muted-foreground",
|
|
27215
|
+
children: [
|
|
27216
|
+
"(",
|
|
27217
|
+
activeDetail.point.group,
|
|
27218
|
+
")"
|
|
27219
|
+
]
|
|
27220
|
+
}),
|
|
27221
|
+
frontier.ids.has(activeDetail.id) && /* @__PURE__ */ jsx(Status, {
|
|
27222
|
+
tone: "info",
|
|
27223
|
+
children: "Frontier"
|
|
27224
|
+
}),
|
|
27225
|
+
activeDetail.point.status && /* @__PURE__ */ jsx(Status, {
|
|
27226
|
+
tone: activeDetail.point.status.tone,
|
|
27227
|
+
children: activeDetail.point.status.label
|
|
27228
|
+
})
|
|
27229
|
+
]
|
|
27230
|
+
}),
|
|
27231
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27232
|
+
className: "flex flex-wrap items-center gap-3 font-mono tabular-nums text-foreground",
|
|
27233
|
+
children: [
|
|
27234
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
27235
|
+
activeX.label,
|
|
27236
|
+
": ",
|
|
27237
|
+
/* @__PURE__ */ jsx("strong", { children: activeX.format(activeDetail.x) })
|
|
27238
|
+
] }),
|
|
27239
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
27240
|
+
activeY.label,
|
|
27241
|
+
": ",
|
|
27242
|
+
/* @__PURE__ */ jsx("strong", { children: activeY.format(activeDetail.y) })
|
|
27243
|
+
] }),
|
|
27244
|
+
activeDetail.point.n !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
27245
|
+
className: "text-muted-foreground",
|
|
27246
|
+
children: ["N=", activeDetail.point.n]
|
|
27247
|
+
})
|
|
27248
|
+
]
|
|
27249
|
+
}),
|
|
27250
|
+
activeDetail.point.note && /* @__PURE__ */ jsx("div", {
|
|
27251
|
+
className: "w-full text-muted-foreground",
|
|
27252
|
+
children: activeDetail.point.note
|
|
27253
|
+
})
|
|
27254
|
+
] }) : /* @__PURE__ */ jsx("span", {
|
|
27255
|
+
className: "text-muted-foreground",
|
|
27256
|
+
children: caveat ?? "Select or hover a candidate to inspect its metrics and configuration."
|
|
27257
|
+
})
|
|
27258
|
+
}),
|
|
27259
|
+
caveat && activeDetail && /* @__PURE__ */ jsx("div", {
|
|
27260
|
+
className: "border-t border-border px-4 py-1.5 type-caption text-muted-foreground",
|
|
27261
|
+
children: caveat
|
|
27262
|
+
}),
|
|
27263
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsxs("table", { children: [
|
|
27264
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
27265
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
27266
|
+
/* @__PURE__ */ jsx("th", { children: "Candidate" }),
|
|
27267
|
+
/* @__PURE__ */ jsx("th", { children: "Group" }),
|
|
27268
|
+
/* @__PURE__ */ jsx("th", { children: activeX.label }),
|
|
27269
|
+
/* @__PURE__ */ jsx("th", { children: activeY.label }),
|
|
27270
|
+
/* @__PURE__ */ jsx("th", { children: "Pareto frontier" })
|
|
27271
|
+
] }) }),
|
|
27272
|
+
/* @__PURE__ */ jsx("tbody", { children: resolved.map(({ point, id, x, y }) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
27273
|
+
/* @__PURE__ */ jsx("td", { children: point.label }),
|
|
27274
|
+
/* @__PURE__ */ jsx("td", { children: point.group ?? "" }),
|
|
27275
|
+
/* @__PURE__ */ jsx("td", { children: activeX.format(x) }),
|
|
27276
|
+
/* @__PURE__ */ jsx("td", { children: activeY.format(y) }),
|
|
27277
|
+
/* @__PURE__ */ jsx("td", { children: frontier.ids.has(id) ? "Yes" : "No" })
|
|
27278
|
+
] }, id)) })
|
|
27279
|
+
] }) })
|
|
27280
|
+
]
|
|
27281
|
+
});
|
|
27282
|
+
}
|
|
27283
|
+
|
|
27284
|
+
// src/components/specimen-deck.tsx
|
|
27285
|
+
/** Interactive specimen / A/B showcase deck with pill tabs, prev/next controls and optional auto-advance. */
|
|
27286
|
+
function SpecimenDeck({ label, title, slides, activeId: controlledId, defaultActiveId, onActiveChange, autoAdvanceMs, defaultPlaying = false, className }) {
|
|
27287
|
+
const [internalId, setInternalId] = React.useState(defaultActiveId ?? slides[0]?.id ?? "");
|
|
27288
|
+
const playBtnRef = React.useRef(null);
|
|
27289
|
+
const [playing, setPlaying] = React.useState(() => {
|
|
27290
|
+
if (!defaultPlaying || !autoAdvanceMs) return false;
|
|
27291
|
+
if (typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return false;
|
|
27292
|
+
return true;
|
|
27293
|
+
});
|
|
27294
|
+
const activeId = controlledId ?? internalId;
|
|
27295
|
+
const currentIdx = Math.max(0, slides.findIndex((s) => s.id === activeId));
|
|
27296
|
+
const current = slides[currentIdx] ?? slides[0];
|
|
27297
|
+
const selectByIndex = React.useCallback((nextIdx) => {
|
|
27298
|
+
if (slides.length === 0) return;
|
|
27299
|
+
const nextId = slides[(nextIdx % slides.length + slides.length) % slides.length].id;
|
|
27300
|
+
if (controlledId === void 0) setInternalId(nextId);
|
|
27301
|
+
onActiveChange?.(nextId);
|
|
27302
|
+
}, [
|
|
27303
|
+
slides,
|
|
27304
|
+
controlledId,
|
|
27305
|
+
onActiveChange
|
|
27306
|
+
]);
|
|
27307
|
+
React.useEffect(() => {
|
|
27308
|
+
if (!playing || !autoAdvanceMs || slides.length <= 1) return;
|
|
27309
|
+
const timer = window.setInterval(() => {
|
|
27310
|
+
selectByIndex(currentIdx + 1);
|
|
27311
|
+
}, autoAdvanceMs);
|
|
27312
|
+
return () => window.clearInterval(timer);
|
|
27313
|
+
}, [
|
|
27314
|
+
playing,
|
|
27315
|
+
autoAdvanceMs,
|
|
27316
|
+
slides.length,
|
|
27317
|
+
currentIdx,
|
|
27318
|
+
selectByIndex
|
|
27319
|
+
]);
|
|
27320
|
+
if (!current) return null;
|
|
27321
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
27322
|
+
"aria-roledescription": "carousel",
|
|
27323
|
+
"aria-label": label,
|
|
27324
|
+
onFocusCapture: (e) => {
|
|
27325
|
+
if (playing && e.target !== playBtnRef.current) setPlaying(false);
|
|
27326
|
+
},
|
|
27327
|
+
className: cn("overflow-hidden rounded-surface border border-border bg-card text-card-foreground", className),
|
|
27328
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
27329
|
+
className: "flex flex-wrap items-center justify-between gap-2 border-b border-border bg-surface-sunken px-4 py-2.5",
|
|
27330
|
+
children: [
|
|
27331
|
+
/* @__PURE__ */ jsx("span", {
|
|
27332
|
+
className: "type-label text-foreground",
|
|
27333
|
+
children: title ?? label
|
|
27334
|
+
}),
|
|
27335
|
+
/* @__PURE__ */ jsx("div", {
|
|
27336
|
+
role: "group",
|
|
27337
|
+
"aria-label": `${label} slides`,
|
|
27338
|
+
className: "flex flex-wrap items-center gap-1",
|
|
27339
|
+
children: slides.map((s, i) => {
|
|
27340
|
+
const isSelected = i === currentIdx;
|
|
27341
|
+
return /* @__PURE__ */ jsx(Button$1, {
|
|
27342
|
+
"aria-pressed": isSelected,
|
|
27343
|
+
onPress: () => {
|
|
27344
|
+
setPlaying(false);
|
|
27345
|
+
selectByIndex(i);
|
|
27346
|
+
},
|
|
27347
|
+
className: cn("cursor-pointer rounded-pill px-2.5 py-1 type-caption transition-state focus-visible:outline-2 focus-visible:outline-ring", isSelected ? "bg-primary font-medium text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"),
|
|
27348
|
+
children: s.label
|
|
27349
|
+
}, s.id);
|
|
27350
|
+
})
|
|
27351
|
+
}),
|
|
27352
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27353
|
+
className: "flex items-center gap-1",
|
|
27354
|
+
children: [
|
|
27355
|
+
autoAdvanceMs && slides.length > 1 && /* @__PURE__ */ jsx(Button$1, {
|
|
27356
|
+
ref: playBtnRef,
|
|
27357
|
+
"aria-label": playing ? "Pause slideshow" : "Play slideshow",
|
|
27358
|
+
"aria-pressed": playing,
|
|
27359
|
+
onPress: () => setPlaying((p) => !p),
|
|
27360
|
+
className: "cursor-pointer rounded-control border border-border bg-card p-1 text-muted-foreground transition-state hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
|
|
27361
|
+
children: playing ? /* @__PURE__ */ jsx(Pause, {
|
|
27362
|
+
"aria-hidden": true,
|
|
27363
|
+
className: "size-3.5"
|
|
27364
|
+
}) : /* @__PURE__ */ jsx(Play, {
|
|
27365
|
+
"aria-hidden": true,
|
|
27366
|
+
className: "size-3.5"
|
|
27367
|
+
})
|
|
27368
|
+
}),
|
|
27369
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
27370
|
+
"aria-label": "Previous slide",
|
|
27371
|
+
onPress: () => {
|
|
27372
|
+
setPlaying(false);
|
|
27373
|
+
selectByIndex(currentIdx - 1);
|
|
27374
|
+
},
|
|
27375
|
+
className: "cursor-pointer rounded-control border border-border bg-card p-1 text-muted-foreground transition-state hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
|
|
27376
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, {
|
|
27377
|
+
"aria-hidden": true,
|
|
27378
|
+
className: "size-4"
|
|
27379
|
+
})
|
|
27380
|
+
}),
|
|
27381
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
27382
|
+
"aria-label": "Next slide",
|
|
27383
|
+
onPress: () => {
|
|
27384
|
+
setPlaying(false);
|
|
27385
|
+
selectByIndex(currentIdx + 1);
|
|
27386
|
+
},
|
|
27387
|
+
className: "cursor-pointer rounded-control border border-border bg-card p-1 text-muted-foreground transition-state hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
|
|
27388
|
+
children: /* @__PURE__ */ jsx(ChevronRight, {
|
|
27389
|
+
"aria-hidden": true,
|
|
27390
|
+
className: "size-4"
|
|
27391
|
+
})
|
|
27392
|
+
})
|
|
27393
|
+
]
|
|
27394
|
+
})
|
|
27395
|
+
]
|
|
27396
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
27397
|
+
role: "tabpanel",
|
|
27398
|
+
"aria-label": current.label,
|
|
27399
|
+
className: "p-5",
|
|
27400
|
+
children: current.content
|
|
27401
|
+
}, current.id)]
|
|
27402
|
+
});
|
|
27403
|
+
}
|
|
27404
|
+
|
|
27405
|
+
// src/components/metric-distribution.tsx
|
|
27406
|
+
const PAD_X = 14;
|
|
27407
|
+
const ROW_H = 44;
|
|
27408
|
+
const ECDF_H = 240;
|
|
27409
|
+
const ECDF_PAD = {
|
|
27410
|
+
top: 16,
|
|
27411
|
+
right: 20,
|
|
27412
|
+
bottom: 38,
|
|
27413
|
+
left: 48
|
|
27414
|
+
};
|
|
27415
|
+
/** Per-item outcome distribution (Strip + IQR box plot and ECDF toggle) with explicit missing counts. */
|
|
27416
|
+
function MetricDistribution({ label, series, formatValue, metricLabel, defaultMode = "strip", allowModeSwitch = true, onItemSelect, className }) {
|
|
27417
|
+
const [mode, setMode] = React.useState(defaultMode);
|
|
27418
|
+
const [hoveredItem, setHoveredItem] = React.useState(null);
|
|
27419
|
+
const [trackRef, trackWidth] = useContainerWidth(360);
|
|
27420
|
+
const [ecdfRef, ecdfWidth] = useContainerWidth(560);
|
|
27421
|
+
const summaries = React.useMemo(() => series.map((s) => ({
|
|
27422
|
+
series: s,
|
|
27423
|
+
summary: summarizeDistribution(s.items.map((i) => i.value))
|
|
27424
|
+
})), [series]);
|
|
27425
|
+
const scale = React.useMemo(() => {
|
|
27426
|
+
const vals = [];
|
|
27427
|
+
for (const s of series) for (const item of s.items) if (Number.isFinite(item.value)) vals.push(item.value);
|
|
27428
|
+
return vals.length ? niceScale(Math.min(...vals), Math.max(...vals), 5) : niceScale(0, 1, 5);
|
|
27429
|
+
}, [series]);
|
|
27430
|
+
const span = scale.max - scale.min || 1;
|
|
27431
|
+
const innerStripW = Math.max(120, trackWidth - 28);
|
|
27432
|
+
const xStrip = (v) => PAD_X + (v - scale.min) / span * innerStripW;
|
|
27433
|
+
const innerEcdfW = Math.max(160, ecdfWidth - ECDF_PAD.left - ECDF_PAD.right);
|
|
27434
|
+
const innerEcdfH = ECDF_H - ECDF_PAD.top - ECDF_PAD.bottom;
|
|
27435
|
+
const xEcdf = (v) => ECDF_PAD.left + (v - scale.min) / span * innerEcdfW;
|
|
27436
|
+
const yEcdf = (p) => ECDF_PAD.top + (1 - p) * innerEcdfH;
|
|
27437
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
27438
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
27439
|
+
children: [
|
|
27440
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
27441
|
+
className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-2.5",
|
|
27442
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
27443
|
+
className: "flex flex-wrap items-baseline gap-2",
|
|
27444
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27445
|
+
className: "type-label text-foreground",
|
|
27446
|
+
children: label
|
|
27447
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
27448
|
+
className: "type-caption text-muted-foreground",
|
|
27449
|
+
children: metricLabel
|
|
27450
|
+
})]
|
|
27451
|
+
}), allowModeSwitch && /* @__PURE__ */ jsxs("div", {
|
|
27452
|
+
role: "group",
|
|
27453
|
+
"aria-label": "Distribution view",
|
|
27454
|
+
className: "inline-flex rounded-control border border-border bg-surface-sunken p-0.5",
|
|
27455
|
+
children: [/* @__PURE__ */ jsx(Button$1, {
|
|
27456
|
+
"aria-pressed": mode === "strip",
|
|
27457
|
+
onPress: () => setMode("strip"),
|
|
27458
|
+
className: cn("cursor-pointer rounded-control px-2 py-0.5 type-caption transition-state focus-visible:outline-2 focus-visible:outline-ring", mode === "strip" ? "bg-card font-medium text-foreground" : "text-muted-foreground hover:text-foreground"),
|
|
27459
|
+
children: "Strip + IQR"
|
|
27460
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
27461
|
+
"aria-pressed": mode === "ecdf",
|
|
27462
|
+
onPress: () => setMode("ecdf"),
|
|
27463
|
+
className: cn("cursor-pointer rounded-control px-2 py-0.5 type-caption transition-state focus-visible:outline-2 focus-visible:outline-ring", mode === "ecdf" ? "bg-card font-medium text-foreground" : "text-muted-foreground hover:text-foreground"),
|
|
27464
|
+
children: "ECDF"
|
|
27465
|
+
})]
|
|
27466
|
+
})]
|
|
27467
|
+
}),
|
|
27468
|
+
mode === "strip" ? /* @__PURE__ */ jsx("div", {
|
|
27469
|
+
className: "overflow-x-auto",
|
|
27470
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
27471
|
+
className: "min-w-145",
|
|
27472
|
+
children: [
|
|
27473
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27474
|
+
className: "grid items-center gap-3 border-b border-border bg-surface-sunken px-4 py-1.5 type-caption text-muted-foreground",
|
|
27475
|
+
style: { gridTemplateColumns: "minmax(140px, 1.2fr) minmax(220px, 2.2fr) minmax(130px, 1fr) 72px" },
|
|
27476
|
+
children: [
|
|
27477
|
+
/* @__PURE__ */ jsx("div", { children: "Candidate" }),
|
|
27478
|
+
/* @__PURE__ */ jsx("div", {
|
|
27479
|
+
ref: trackRef,
|
|
27480
|
+
children: metricLabel
|
|
27481
|
+
}),
|
|
27482
|
+
/* @__PURE__ */ jsx("div", {
|
|
27483
|
+
className: "text-right",
|
|
27484
|
+
children: "Median (IQR)"
|
|
27485
|
+
}),
|
|
27486
|
+
/* @__PURE__ */ jsx("div", {
|
|
27487
|
+
className: "text-right",
|
|
27488
|
+
children: "N"
|
|
27489
|
+
})
|
|
27490
|
+
]
|
|
27491
|
+
}),
|
|
27492
|
+
/* @__PURE__ */ jsx("div", {
|
|
27493
|
+
className: "divide-y divide-border",
|
|
27494
|
+
children: summaries.map(({ series: s, summary }, idx) => {
|
|
27495
|
+
const colour = s.baseline ? "var(--muted-foreground)" : chartColour(idx);
|
|
27496
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
27497
|
+
style: { gridTemplateColumns: "minmax(140px, 1.2fr) minmax(220px, 2.2fr) minmax(130px, 1fr) 72px" },
|
|
27498
|
+
className: "grid items-center gap-3 px-4 py-1",
|
|
27499
|
+
children: [
|
|
27500
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27501
|
+
className: "min-w-0",
|
|
27502
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
27503
|
+
className: "truncate type-label text-foreground",
|
|
27504
|
+
children: s.label
|
|
27505
|
+
}), s.subtitle && /* @__PURE__ */ jsx("div", {
|
|
27506
|
+
className: "truncate type-caption text-muted-foreground",
|
|
27507
|
+
children: s.subtitle
|
|
27508
|
+
})]
|
|
27509
|
+
}),
|
|
27510
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27511
|
+
className: "relative h-11 w-full",
|
|
27512
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
27513
|
+
width: trackWidth,
|
|
27514
|
+
height: ROW_H,
|
|
27515
|
+
className: "block h-full w-full overflow-visible",
|
|
27516
|
+
"aria-hidden": "true",
|
|
27517
|
+
children: [
|
|
27518
|
+
scale.ticks.map((t) => /* @__PURE__ */ jsx("line", {
|
|
27519
|
+
x1: xStrip(t),
|
|
27520
|
+
x2: xStrip(t),
|
|
27521
|
+
y1: 0,
|
|
27522
|
+
y2: ROW_H,
|
|
27523
|
+
stroke: "var(--border)",
|
|
27524
|
+
strokeOpacity: .5
|
|
27525
|
+
}, t)),
|
|
27526
|
+
summary && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27527
|
+
/* @__PURE__ */ jsx("line", {
|
|
27528
|
+
x1: xStrip(summary.min),
|
|
27529
|
+
x2: xStrip(summary.max),
|
|
27530
|
+
y1: ROW_H / 2,
|
|
27531
|
+
y2: ROW_H / 2,
|
|
27532
|
+
stroke: colour,
|
|
27533
|
+
strokeOpacity: .45,
|
|
27534
|
+
strokeWidth: 1.5
|
|
27535
|
+
}),
|
|
27536
|
+
/* @__PURE__ */ jsx("rect", {
|
|
27537
|
+
x: xStrip(summary.p25),
|
|
27538
|
+
y: ROW_H / 2 - 9,
|
|
27539
|
+
width: Math.max(2, xStrip(summary.p75) - xStrip(summary.p25)),
|
|
27540
|
+
height: 18,
|
|
27541
|
+
rx: 2,
|
|
27542
|
+
fill: colour,
|
|
27543
|
+
fillOpacity: .18,
|
|
27544
|
+
stroke: colour,
|
|
27545
|
+
strokeWidth: 1.25
|
|
27546
|
+
}),
|
|
27547
|
+
/* @__PURE__ */ jsx("line", {
|
|
27548
|
+
x1: xStrip(summary.median),
|
|
27549
|
+
x2: xStrip(summary.median),
|
|
27550
|
+
y1: ROW_H / 2 - 11,
|
|
27551
|
+
y2: 33,
|
|
27552
|
+
stroke: colour,
|
|
27553
|
+
strokeWidth: 2.5,
|
|
27554
|
+
strokeLinecap: "round"
|
|
27555
|
+
})
|
|
27556
|
+
] }),
|
|
27557
|
+
s.items.map((item) => {
|
|
27558
|
+
if (!Number.isFinite(item.value)) return null;
|
|
27559
|
+
const cx = xStrip(item.value);
|
|
27560
|
+
const cy = ROW_H / 2 + deterministicJitter(`${s.id}:${item.id}`) * 11;
|
|
27561
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
27562
|
+
cx,
|
|
27563
|
+
cy,
|
|
27564
|
+
r: 3,
|
|
27565
|
+
fill: colour,
|
|
27566
|
+
fillOpacity: .78,
|
|
27567
|
+
stroke: "var(--card)",
|
|
27568
|
+
strokeWidth: .75,
|
|
27569
|
+
onMouseEnter: !onItemSelect ? () => setHoveredItem({
|
|
27570
|
+
seriesLabel: s.label,
|
|
27571
|
+
item
|
|
27572
|
+
}) : void 0,
|
|
27573
|
+
onMouseLeave: !onItemSelect ? () => setHoveredItem(null) : void 0
|
|
27574
|
+
}, item.id);
|
|
27575
|
+
})
|
|
27576
|
+
]
|
|
27577
|
+
}), onItemSelect && s.items.map((item) => {
|
|
27578
|
+
if (!Number.isFinite(item.value)) return null;
|
|
27579
|
+
const cx = xStrip(item.value);
|
|
27580
|
+
const cy = ROW_H / 2 + deterministicJitter(`${s.id}:${item.id}`) * 11;
|
|
27581
|
+
const leftPct = cx / Math.max(1, trackWidth) * 100;
|
|
27582
|
+
const topPct = cy / ROW_H * 100;
|
|
27583
|
+
const itemName = item.label ?? item.id;
|
|
27584
|
+
return /* @__PURE__ */ jsx(Button$1, {
|
|
27585
|
+
"aria-label": `${s.label}, ${itemName}: ${formatValue(item.value)}`,
|
|
27586
|
+
onPress: () => onItemSelect(s, item),
|
|
27587
|
+
onHoverStart: () => setHoveredItem({
|
|
27588
|
+
seriesLabel: s.label,
|
|
27589
|
+
item
|
|
27590
|
+
}),
|
|
27591
|
+
onHoverEnd: () => setHoveredItem((prev) => prev?.item.id === item.id ? null : prev),
|
|
27592
|
+
onFocus: () => setHoveredItem({
|
|
27593
|
+
seriesLabel: s.label,
|
|
27594
|
+
item
|
|
27595
|
+
}),
|
|
27596
|
+
onBlur: () => setHoveredItem((prev) => prev?.item.id === item.id ? null : prev),
|
|
27597
|
+
style: {
|
|
27598
|
+
left: `${leftPct}%`,
|
|
27599
|
+
top: `${topPct}%`
|
|
27600
|
+
},
|
|
27601
|
+
className: "absolute size-3 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-pill bg-transparent p-0 focus-visible:outline-2 focus-visible:outline-ring"
|
|
27602
|
+
}, item.id);
|
|
27603
|
+
})]
|
|
27604
|
+
}),
|
|
27605
|
+
/* @__PURE__ */ jsx("div", {
|
|
27606
|
+
className: "text-right font-mono type-caption tabular-nums",
|
|
27607
|
+
children: summary ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
27608
|
+
className: "font-medium text-foreground",
|
|
27609
|
+
children: formatValue(summary.median)
|
|
27610
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
27611
|
+
className: "text-muted-foreground",
|
|
27612
|
+
children: [
|
|
27613
|
+
formatValue(summary.p25),
|
|
27614
|
+
"–",
|
|
27615
|
+
formatValue(summary.p75)
|
|
27616
|
+
]
|
|
27617
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
27618
|
+
className: "text-muted-foreground",
|
|
27619
|
+
children: "—"
|
|
27620
|
+
})
|
|
27621
|
+
}),
|
|
27622
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27623
|
+
className: "flex flex-col items-end gap-0.5 font-mono type-caption tabular-nums",
|
|
27624
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27625
|
+
className: "text-foreground",
|
|
27626
|
+
children: summary?.n ?? 0
|
|
27627
|
+
}), s.missing !== void 0 && s.missing > 0 && /* @__PURE__ */ jsx(Status, {
|
|
27628
|
+
tone: "danger",
|
|
27629
|
+
children: `${s.missing} miss`
|
|
27630
|
+
})]
|
|
27631
|
+
})
|
|
27632
|
+
]
|
|
27633
|
+
}, s.id);
|
|
27634
|
+
})
|
|
27635
|
+
}),
|
|
27636
|
+
/* @__PURE__ */ jsxs("div", {
|
|
27637
|
+
className: "grid items-center gap-3 border-t border-border bg-surface-sunken px-4 py-1",
|
|
27638
|
+
style: { gridTemplateColumns: "minmax(140px, 1.2fr) minmax(220px, 2.2fr) minmax(130px, 1fr) 72px" },
|
|
27639
|
+
children: [
|
|
27640
|
+
/* @__PURE__ */ jsx("div", {
|
|
27641
|
+
className: "truncate type-caption text-muted-foreground",
|
|
27642
|
+
children: hoveredItem ? `${hoveredItem.seriesLabel} · ${hoveredItem.item.label ?? hoveredItem.item.id}: ${formatValue(hoveredItem.item.value)}` : "Box = IQR · line = median"
|
|
27643
|
+
}),
|
|
27644
|
+
/* @__PURE__ */ jsx("svg", {
|
|
27645
|
+
width: trackWidth,
|
|
27646
|
+
height: 24,
|
|
27647
|
+
className: "block w-full overflow-visible",
|
|
27648
|
+
"aria-hidden": "true",
|
|
27649
|
+
children: scale.ticks.map((t) => /* @__PURE__ */ jsxs("g", {
|
|
27650
|
+
transform: `translate(${xStrip(t)}, 0)`,
|
|
27651
|
+
children: [/* @__PURE__ */ jsx("line", {
|
|
27652
|
+
y1: 0,
|
|
27653
|
+
y2: 4,
|
|
27654
|
+
stroke: "var(--border)"
|
|
27655
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
27656
|
+
y: 16,
|
|
27657
|
+
textAnchor: "middle",
|
|
27658
|
+
fill: "var(--muted-foreground)",
|
|
27659
|
+
fontSize: 11,
|
|
27660
|
+
fontFamily: "var(--font-mono)",
|
|
27661
|
+
children: formatValue(t)
|
|
27662
|
+
})]
|
|
27663
|
+
}, t))
|
|
27664
|
+
}),
|
|
27665
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
27666
|
+
/* @__PURE__ */ jsx("div", {})
|
|
27667
|
+
]
|
|
27668
|
+
})
|
|
27669
|
+
]
|
|
27670
|
+
})
|
|
27671
|
+
}) : /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
27672
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-border bg-surface-sunken px-4 py-1.5 type-caption text-muted-foreground",
|
|
27673
|
+
children: series.map((s, idx) => /* @__PURE__ */ jsxs("span", {
|
|
27674
|
+
className: "inline-flex items-center gap-1.5",
|
|
27675
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27676
|
+
"aria-hidden": true,
|
|
27677
|
+
className: "inline-block h-0.5 w-4",
|
|
27678
|
+
style: { backgroundColor: s.baseline ? "var(--muted-foreground)" : chartColour(idx) }
|
|
27679
|
+
}), /* @__PURE__ */ jsx("span", { children: s.label })]
|
|
27680
|
+
}, s.id))
|
|
27681
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
27682
|
+
ref: ecdfRef,
|
|
27683
|
+
className: "px-2 py-2",
|
|
27684
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
27685
|
+
width: ecdfWidth,
|
|
27686
|
+
height: ECDF_H,
|
|
27687
|
+
className: "block w-full overflow-visible",
|
|
27688
|
+
role: "img",
|
|
27689
|
+
"aria-label": `${label} ECDF`,
|
|
27690
|
+
children: [
|
|
27691
|
+
[
|
|
27692
|
+
0,
|
|
27693
|
+
.25,
|
|
27694
|
+
.5,
|
|
27695
|
+
.75,
|
|
27696
|
+
1
|
|
27697
|
+
].map((p) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
27698
|
+
x1: ECDF_PAD.left,
|
|
27699
|
+
x2: ECDF_PAD.left + innerEcdfW,
|
|
27700
|
+
y1: yEcdf(p),
|
|
27701
|
+
y2: yEcdf(p),
|
|
27702
|
+
stroke: "var(--border)",
|
|
27703
|
+
strokeOpacity: .55
|
|
27704
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
27705
|
+
x: ECDF_PAD.left - 8,
|
|
27706
|
+
y: yEcdf(p) + 3.5,
|
|
27707
|
+
textAnchor: "end",
|
|
27708
|
+
fill: "var(--muted-foreground)",
|
|
27709
|
+
fontSize: 11,
|
|
27710
|
+
fontFamily: "var(--font-mono)",
|
|
27711
|
+
children: `${Math.round(p * 100)}%`
|
|
27712
|
+
})] }, p)),
|
|
27713
|
+
scale.ticks.map((t) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
27714
|
+
x1: xEcdf(t),
|
|
27715
|
+
x2: xEcdf(t),
|
|
27716
|
+
y1: ECDF_PAD.top,
|
|
27717
|
+
y2: ECDF_PAD.top + innerEcdfH,
|
|
27718
|
+
stroke: "var(--border)",
|
|
27719
|
+
strokeOpacity: .4
|
|
27720
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
27721
|
+
x: xEcdf(t),
|
|
27722
|
+
y: ECDF_PAD.top + innerEcdfH + 16,
|
|
27723
|
+
textAnchor: "middle",
|
|
27724
|
+
fill: "var(--muted-foreground)",
|
|
27725
|
+
fontSize: 11,
|
|
27726
|
+
fontFamily: "var(--font-mono)",
|
|
27727
|
+
children: formatValue(t)
|
|
27728
|
+
})] }, t)),
|
|
27729
|
+
/* @__PURE__ */ jsx("text", {
|
|
27730
|
+
x: ECDF_PAD.left + innerEcdfW / 2,
|
|
27731
|
+
y: 236,
|
|
27732
|
+
textAnchor: "middle",
|
|
27733
|
+
fill: "var(--muted-foreground)",
|
|
27734
|
+
fontSize: 12,
|
|
27735
|
+
children: metricLabel
|
|
27736
|
+
}),
|
|
27737
|
+
series.map((s, idx) => {
|
|
27738
|
+
const pts = ecdfPoints(s.items.map((i) => i.value));
|
|
27739
|
+
if (pts.length === 0) return null;
|
|
27740
|
+
const colour = s.baseline ? "var(--muted-foreground)" : chartColour(idx);
|
|
27741
|
+
const segs = [`M${xEcdf(pts[0].x).toFixed(1)},${yEcdf(0).toFixed(1)}`];
|
|
27742
|
+
for (let i = 0; i < pts.length; i++) {
|
|
27743
|
+
const pt = pts[i];
|
|
27744
|
+
const x = xEcdf(pt.x).toFixed(1);
|
|
27745
|
+
const y = yEcdf(pt.y).toFixed(1);
|
|
27746
|
+
if (i > 0) segs.push(`H${x}`);
|
|
27747
|
+
segs.push(`V${y}`);
|
|
27748
|
+
}
|
|
27749
|
+
segs.push(`H${xEcdf(scale.max).toFixed(1)}`);
|
|
27750
|
+
return /* @__PURE__ */ jsx("path", {
|
|
27751
|
+
d: segs.join(" "),
|
|
27752
|
+
fill: "none",
|
|
27753
|
+
stroke: colour,
|
|
27754
|
+
strokeWidth: s.baseline ? 1.75 : 2,
|
|
27755
|
+
strokeDasharray: s.baseline ? "4 3" : void 0
|
|
27756
|
+
}, s.id);
|
|
27757
|
+
})
|
|
27758
|
+
]
|
|
27759
|
+
})
|
|
27760
|
+
})] }),
|
|
27761
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsxs("table", { children: [
|
|
27762
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
27763
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
27764
|
+
/* @__PURE__ */ jsx("th", { children: "Candidate" }),
|
|
27765
|
+
/* @__PURE__ */ jsx("th", { children: "N" }),
|
|
27766
|
+
/* @__PURE__ */ jsx("th", { children: "Missing" }),
|
|
27767
|
+
/* @__PURE__ */ jsx("th", { children: "Min" }),
|
|
27768
|
+
/* @__PURE__ */ jsx("th", { children: "P25" }),
|
|
27769
|
+
/* @__PURE__ */ jsx("th", { children: "Median" }),
|
|
27770
|
+
/* @__PURE__ */ jsx("th", { children: "P75" }),
|
|
27771
|
+
/* @__PURE__ */ jsx("th", { children: "Max" })
|
|
27772
|
+
] }) }),
|
|
27773
|
+
/* @__PURE__ */ jsx("tbody", { children: summaries.map(({ series: s, summary }) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
27774
|
+
/* @__PURE__ */ jsx("td", { children: s.label }),
|
|
27775
|
+
/* @__PURE__ */ jsx("td", { children: summary?.n ?? 0 }),
|
|
27776
|
+
/* @__PURE__ */ jsx("td", { children: s.missing ?? 0 }),
|
|
27777
|
+
/* @__PURE__ */ jsx("td", { children: summary ? formatValue(summary.min) : "—" }),
|
|
27778
|
+
/* @__PURE__ */ jsx("td", { children: summary ? formatValue(summary.p25) : "—" }),
|
|
27779
|
+
/* @__PURE__ */ jsx("td", { children: summary ? formatValue(summary.median) : "—" }),
|
|
27780
|
+
/* @__PURE__ */ jsx("td", { children: summary ? formatValue(summary.p75) : "—" }),
|
|
27781
|
+
/* @__PURE__ */ jsx("td", { children: summary ? formatValue(summary.max) : "—" })
|
|
27782
|
+
] }, s.id)) })
|
|
27783
|
+
] }) })
|
|
27784
|
+
]
|
|
27785
|
+
});
|
|
27786
|
+
}
|
|
27787
|
+
|
|
27788
|
+
// src/components/slice-matrix.tsx
|
|
27789
|
+
/** Candidate × dataset-slice matrix with subtle performance tinting, deltas vs baseline and low-N flagging. */
|
|
27790
|
+
function SliceMatrix({ label, columns, rows, formatValue, formatDelta, direction, lowNThreshold = 5, note, selectedCell, onCellSelect, className }) {
|
|
27791
|
+
const { minVal, maxVal } = React.useMemo(() => {
|
|
27792
|
+
const vals = [];
|
|
27793
|
+
for (const r of rows) for (const c of columns) {
|
|
27794
|
+
const v = r.cells[c.id]?.value;
|
|
27795
|
+
if (typeof v === "number" && Number.isFinite(v)) vals.push(v);
|
|
27796
|
+
}
|
|
27797
|
+
return vals.length ? {
|
|
27798
|
+
minVal: Math.min(...vals),
|
|
27799
|
+
maxVal: Math.max(...vals)
|
|
27800
|
+
} : {
|
|
27801
|
+
minVal: 0,
|
|
27802
|
+
maxVal: 1
|
|
27803
|
+
};
|
|
27804
|
+
}, [rows, columns]);
|
|
27805
|
+
const span = maxVal - minVal || 1;
|
|
27806
|
+
const cellTint = (value, lowN) => {
|
|
27807
|
+
if (value === null || value === void 0 || !Number.isFinite(value) || lowN) return void 0;
|
|
27808
|
+
const norm = (value - minVal) / span;
|
|
27809
|
+
const goodness = direction === "higher" ? norm : 1 - norm;
|
|
27810
|
+
const pct = Math.round(goodness * 18);
|
|
27811
|
+
if (pct <= 1) return void 0;
|
|
27812
|
+
return { backgroundColor: `color-mix(in oklch, var(--primary) ${pct}%, transparent)` };
|
|
27813
|
+
};
|
|
27814
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
27815
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
27816
|
+
children: [/* @__PURE__ */ jsxs("figcaption", {
|
|
27817
|
+
className: "flex flex-wrap items-baseline justify-between gap-2 border-b border-border px-4 py-2.5",
|
|
27818
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27819
|
+
className: "type-label text-foreground",
|
|
27820
|
+
children: label
|
|
27821
|
+
}), note && /* @__PURE__ */ jsx("span", {
|
|
27822
|
+
className: "type-caption text-muted-foreground",
|
|
27823
|
+
children: note
|
|
27824
|
+
})]
|
|
27825
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
27826
|
+
className: "overflow-x-auto",
|
|
27827
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
27828
|
+
className: "w-full border-collapse text-left",
|
|
27829
|
+
children: [
|
|
27830
|
+
/* @__PURE__ */ jsx("caption", {
|
|
27831
|
+
className: "sr-only",
|
|
27832
|
+
children: label
|
|
27833
|
+
}),
|
|
27834
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
27835
|
+
className: "border-b border-border bg-surface-sunken type-caption text-muted-foreground",
|
|
27836
|
+
children: [/* @__PURE__ */ jsx("th", {
|
|
27837
|
+
scope: "col",
|
|
27838
|
+
className: "px-4 py-2 font-medium",
|
|
27839
|
+
children: "Candidate"
|
|
27840
|
+
}), columns.map((col) => /* @__PURE__ */ jsxs("th", {
|
|
27841
|
+
scope: "col",
|
|
27842
|
+
className: "px-3 py-2 text-right font-medium",
|
|
27843
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
27844
|
+
className: "text-foreground",
|
|
27845
|
+
children: col.label
|
|
27846
|
+
}), col.n !== void 0 && /* @__PURE__ */ jsxs("div", {
|
|
27847
|
+
className: "font-mono tabular-nums text-muted-foreground",
|
|
27848
|
+
children: ["n=", col.n]
|
|
27849
|
+
})]
|
|
27850
|
+
}, col.id))]
|
|
27851
|
+
}) }),
|
|
27852
|
+
/* @__PURE__ */ jsx("tbody", {
|
|
27853
|
+
className: "divide-y divide-border",
|
|
27854
|
+
children: rows.map((row) => /* @__PURE__ */ jsxs("tr", {
|
|
27855
|
+
className: row.baseline ? "bg-surface-sunken/40" : void 0,
|
|
27856
|
+
children: [/* @__PURE__ */ jsxs("th", {
|
|
27857
|
+
scope: "row",
|
|
27858
|
+
className: "px-4 py-2 font-normal",
|
|
27859
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
27860
|
+
className: cn("type-label", row.baseline ? "text-muted-foreground" : "text-foreground"),
|
|
27861
|
+
children: row.label
|
|
27862
|
+
}), row.subtitle && /* @__PURE__ */ jsx("div", {
|
|
27863
|
+
className: "type-caption text-muted-foreground",
|
|
27864
|
+
children: row.subtitle
|
|
27865
|
+
})]
|
|
27866
|
+
}), columns.map((col) => {
|
|
27867
|
+
const cell = row.cells[col.id];
|
|
27868
|
+
const effectiveN = cell?.n ?? col.n;
|
|
27869
|
+
const isLowN = effectiveN !== void 0 && effectiveN < lowNThreshold;
|
|
27870
|
+
const isSelected = selectedCell?.rowId === row.id && selectedCell?.columnId === col.id;
|
|
27871
|
+
const hasValue = cell !== void 0 && cell.value !== null && Number.isFinite(cell.value);
|
|
27872
|
+
const hasDelta = !row.baseline && formatDelta !== void 0 && cell?.delta !== void 0 && cell.delta !== null && Number.isFinite(cell.delta);
|
|
27873
|
+
const inner = /* @__PURE__ */ jsxs("div", {
|
|
27874
|
+
className: "flex flex-col items-end font-mono tabular-nums",
|
|
27875
|
+
children: [
|
|
27876
|
+
/* @__PURE__ */ jsx("span", {
|
|
27877
|
+
className: cn("type-body-sm font-medium", !hasValue || isLowN ? "text-muted-foreground" : "text-foreground"),
|
|
27878
|
+
children: hasValue ? formatValue(cell.value) : "—"
|
|
27879
|
+
}),
|
|
27880
|
+
hasDelta && /* @__PURE__ */ jsx("span", {
|
|
27881
|
+
className: "type-caption text-muted-foreground",
|
|
27882
|
+
children: formatDelta(cell.delta)
|
|
27883
|
+
}),
|
|
27884
|
+
cell?.n !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
27885
|
+
className: "type-caption text-muted-foreground",
|
|
27886
|
+
children: [
|
|
27887
|
+
"n=",
|
|
27888
|
+
cell.n,
|
|
27889
|
+
isLowN ? " (low N)" : ""
|
|
27890
|
+
]
|
|
27891
|
+
}),
|
|
27892
|
+
cell?.n === void 0 && isLowN && /* @__PURE__ */ jsx("span", {
|
|
27893
|
+
className: "type-caption text-muted-foreground",
|
|
27894
|
+
children: "low N"
|
|
27895
|
+
})
|
|
27896
|
+
]
|
|
27897
|
+
});
|
|
27898
|
+
return /* @__PURE__ */ jsx("td", {
|
|
27899
|
+
style: cellTint(cell?.value, isLowN),
|
|
27900
|
+
className: cn("border-l border-border/60 p-0 text-right align-middle", isSelected && "ring-2 ring-inset ring-ring"),
|
|
27901
|
+
children: onCellSelect ? /* @__PURE__ */ jsx(Button$1, {
|
|
27902
|
+
onPress: () => onCellSelect(row, col, cell),
|
|
27903
|
+
"aria-pressed": isSelected,
|
|
27904
|
+
className: "block h-full w-full cursor-pointer px-3 py-2 text-right transition-state hover:bg-accent/50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
|
|
27905
|
+
children: inner
|
|
27906
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
27907
|
+
className: "px-3 py-2",
|
|
27908
|
+
children: inner
|
|
27909
|
+
})
|
|
27910
|
+
}, col.id);
|
|
27911
|
+
})]
|
|
27912
|
+
}, row.id))
|
|
27913
|
+
})
|
|
27914
|
+
]
|
|
27915
|
+
})
|
|
27916
|
+
})]
|
|
27917
|
+
});
|
|
27918
|
+
}
|
|
27919
|
+
|
|
27920
|
+
// src/components/confusion-matrix.tsx
|
|
27921
|
+
/** Interactive confusion or judge-agreement matrix with row-normalised percentages and clickable cells. */
|
|
27922
|
+
function ConfusionMatrix({ label, rowLabels, colLabels = rowLabels, counts, rowAxisLabel = "Reference", colAxisLabel = "Predicted", showPercent = true, summary, selectedCell, onCellSelect, className }) {
|
|
27923
|
+
const rowTotals = React.useMemo(() => rowLabels.map((_, r) => (counts[r] ?? []).reduce((acc, v) => acc + (Number.isFinite(v) ? v : 0), 0)), [rowLabels, counts]);
|
|
27924
|
+
const grandTotal = React.useMemo(() => rowTotals.reduce((a, b) => a + b, 0), [rowTotals]);
|
|
27925
|
+
const cellStyle = (rowIdx, colIdx, count, rowTotal) => {
|
|
27926
|
+
if (count <= 0 || rowTotal <= 0) return void 0;
|
|
27927
|
+
const share = count / rowTotal;
|
|
27928
|
+
const isDiagonal = rowLabels[rowIdx] === colLabels[colIdx];
|
|
27929
|
+
const pct = Math.max(4, Math.round(share * 22));
|
|
27930
|
+
return { backgroundColor: `color-mix(in oklch, ${isDiagonal ? "var(--primary)" : "var(--danger)"} ${pct}%, transparent)` };
|
|
27931
|
+
};
|
|
27932
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
27933
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
27934
|
+
children: [
|
|
27935
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
27936
|
+
className: "flex flex-wrap items-baseline justify-between gap-2 border-b border-border px-4 py-2.5",
|
|
27937
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27938
|
+
className: "type-label text-foreground",
|
|
27939
|
+
children: label
|
|
27940
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
27941
|
+
className: "font-mono type-caption tabular-nums text-muted-foreground",
|
|
27942
|
+
children: ["N=", grandTotal]
|
|
27943
|
+
})]
|
|
27944
|
+
}),
|
|
27945
|
+
/* @__PURE__ */ jsx("div", {
|
|
27946
|
+
className: "overflow-x-auto",
|
|
27947
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
27948
|
+
className: "w-full border-collapse text-left",
|
|
27949
|
+
children: [
|
|
27950
|
+
/* @__PURE__ */ jsx("caption", {
|
|
27951
|
+
className: "sr-only",
|
|
27952
|
+
children: label
|
|
27953
|
+
}),
|
|
27954
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
27955
|
+
className: "border-b border-border bg-surface-sunken type-caption text-muted-foreground",
|
|
27956
|
+
children: [
|
|
27957
|
+
/* @__PURE__ */ jsxs("th", {
|
|
27958
|
+
scope: "col",
|
|
27959
|
+
className: "px-3 py-2 font-medium",
|
|
27960
|
+
children: [
|
|
27961
|
+
rowAxisLabel,
|
|
27962
|
+
" \\ ",
|
|
27963
|
+
colAxisLabel
|
|
27964
|
+
]
|
|
27965
|
+
}),
|
|
27966
|
+
colLabels.map((c) => /* @__PURE__ */ jsx("th", {
|
|
27967
|
+
scope: "col",
|
|
27968
|
+
className: "px-3 py-2 text-right font-medium text-foreground",
|
|
27969
|
+
children: c
|
|
27970
|
+
}, c)),
|
|
27971
|
+
/* @__PURE__ */ jsx("th", {
|
|
27972
|
+
scope: "col",
|
|
27973
|
+
className: "border-l border-border px-3 py-2 text-right font-medium",
|
|
27974
|
+
children: "Total"
|
|
27975
|
+
})
|
|
27976
|
+
]
|
|
27977
|
+
}) }),
|
|
27978
|
+
/* @__PURE__ */ jsx("tbody", {
|
|
27979
|
+
className: "divide-y divide-border",
|
|
27980
|
+
children: rowLabels.map((rLabel, rIdx) => {
|
|
27981
|
+
const rTotal = rowTotals[rIdx] ?? 0;
|
|
27982
|
+
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
27983
|
+
/* @__PURE__ */ jsx("th", {
|
|
27984
|
+
scope: "row",
|
|
27985
|
+
className: "px-3 py-2 type-label font-medium text-foreground",
|
|
27986
|
+
children: rLabel
|
|
27987
|
+
}),
|
|
27988
|
+
colLabels.map((cLabel, cIdx) => {
|
|
27989
|
+
const count = counts[rIdx]?.[cIdx] ?? 0;
|
|
27990
|
+
const share = rTotal > 0 ? count / rTotal : 0;
|
|
27991
|
+
const isSelected = selectedCell?.row === rIdx && selectedCell?.col === cIdx;
|
|
27992
|
+
const inner = /* @__PURE__ */ jsxs("div", {
|
|
27993
|
+
className: "flex flex-col items-end font-mono tabular-nums",
|
|
27994
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27995
|
+
className: cn("type-body-sm", count === 0 ? "text-muted-foreground/50" : rLabel === cLabel ? "font-semibold text-foreground" : "font-medium text-foreground"),
|
|
27996
|
+
children: count
|
|
27997
|
+
}), showPercent && /* @__PURE__ */ jsx("span", {
|
|
27998
|
+
className: "type-caption text-muted-foreground",
|
|
27999
|
+
children: count === 0 ? "0%" : format.share(share)
|
|
28000
|
+
})]
|
|
28001
|
+
});
|
|
28002
|
+
return /* @__PURE__ */ jsx("td", {
|
|
28003
|
+
style: cellStyle(rIdx, cIdx, count, rTotal),
|
|
28004
|
+
className: cn("border-l border-border/60 p-0 text-right align-middle", isSelected && "ring-2 ring-inset ring-ring"),
|
|
28005
|
+
children: onCellSelect ? /* @__PURE__ */ jsx(Button$1, {
|
|
28006
|
+
onPress: () => onCellSelect({
|
|
28007
|
+
row: rIdx,
|
|
28008
|
+
col: cIdx,
|
|
28009
|
+
rowLabel: rLabel,
|
|
28010
|
+
colLabel: cLabel,
|
|
28011
|
+
count
|
|
28012
|
+
}),
|
|
28013
|
+
"aria-pressed": isSelected,
|
|
28014
|
+
"aria-label": `${rowAxisLabel} ${rLabel}, ${colAxisLabel} ${cLabel}: ${count}`,
|
|
28015
|
+
className: "block h-full w-full cursor-pointer px-3 py-2 text-right transition-state hover:bg-accent/50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
|
|
28016
|
+
children: inner
|
|
28017
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
28018
|
+
className: "px-3 py-2",
|
|
28019
|
+
children: inner
|
|
28020
|
+
})
|
|
28021
|
+
}, cLabel);
|
|
28022
|
+
}),
|
|
28023
|
+
/* @__PURE__ */ jsx("td", {
|
|
28024
|
+
className: "border-l border-border bg-surface-sunken/50 px-3 py-2 text-right font-mono type-caption tabular-nums text-muted-foreground",
|
|
28025
|
+
children: rTotal
|
|
28026
|
+
})
|
|
28027
|
+
] }, rLabel);
|
|
28028
|
+
})
|
|
28029
|
+
})
|
|
28030
|
+
]
|
|
28031
|
+
})
|
|
28032
|
+
}),
|
|
28033
|
+
summary && summary.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
28034
|
+
className: "flex flex-wrap items-center gap-x-5 gap-y-1 border-t border-border bg-surface-sunken px-4 py-2 type-caption",
|
|
28035
|
+
children: summary.map((s) => /* @__PURE__ */ jsxs("div", {
|
|
28036
|
+
className: "inline-flex items-baseline gap-1.5",
|
|
28037
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
28038
|
+
className: "text-muted-foreground",
|
|
28039
|
+
children: [s.label, ":"]
|
|
28040
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
28041
|
+
className: "font-mono font-medium tabular-nums text-foreground",
|
|
28042
|
+
children: s.value
|
|
28043
|
+
})]
|
|
28044
|
+
}, s.label))
|
|
28045
|
+
})
|
|
28046
|
+
]
|
|
28047
|
+
});
|
|
28048
|
+
}
|
|
28049
|
+
|
|
28050
|
+
// src/components/pipeline-diagram.tsx
|
|
28051
|
+
function isParallelStep(step) {
|
|
28052
|
+
return "parallel" in step;
|
|
28053
|
+
}
|
|
28054
|
+
function StageCard({ stage, selected, onSelect }) {
|
|
28055
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
28056
|
+
/* @__PURE__ */ jsxs("div", {
|
|
28057
|
+
className: "flex items-start justify-between gap-2",
|
|
28058
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
28059
|
+
className: "min-w-0",
|
|
28060
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
28061
|
+
className: "truncate type-label text-foreground",
|
|
28062
|
+
children: stage.label
|
|
28063
|
+
}), stage.subtitle && /* @__PURE__ */ jsx("div", {
|
|
28064
|
+
className: "truncate font-mono type-caption text-muted-foreground",
|
|
28065
|
+
children: stage.subtitle
|
|
28066
|
+
})]
|
|
28067
|
+
}), stage.status && /* @__PURE__ */ jsx(Status, {
|
|
28068
|
+
tone: stage.status.tone,
|
|
28069
|
+
children: stage.status.label
|
|
28070
|
+
})]
|
|
28071
|
+
}),
|
|
28072
|
+
stage.metrics && stage.metrics.length > 0 && /* @__PURE__ */ jsx("dl", {
|
|
28073
|
+
className: "mt-2 flex flex-wrap gap-x-3 gap-y-1 border-t border-border/70 pt-2 type-caption",
|
|
28074
|
+
children: stage.metrics.map((m) => /* @__PURE__ */ jsxs("div", {
|
|
28075
|
+
className: "inline-flex items-baseline gap-1",
|
|
28076
|
+
children: [/* @__PURE__ */ jsxs("dt", {
|
|
28077
|
+
className: "text-muted-foreground",
|
|
28078
|
+
children: [m.label, ":"]
|
|
28079
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
28080
|
+
className: "font-mono font-medium tabular-nums text-foreground",
|
|
28081
|
+
children: m.value
|
|
28082
|
+
})]
|
|
28083
|
+
}, m.label))
|
|
28084
|
+
}),
|
|
28085
|
+
stage.detail && /* @__PURE__ */ jsx("div", {
|
|
28086
|
+
className: "mt-2 rounded-control bg-surface-sunken px-2 py-1.5 type-caption text-muted-foreground",
|
|
28087
|
+
children: stage.detail
|
|
28088
|
+
})
|
|
28089
|
+
] });
|
|
28090
|
+
const baseClass = cn("w-full rounded-surface border bg-card p-3 text-left transition-state", selected ? "border-primary bg-accent ring-1 ring-ring" : "border-border");
|
|
28091
|
+
if (onSelect) return /* @__PURE__ */ jsx(Button$1, {
|
|
28092
|
+
onPress: () => onSelect(stage),
|
|
28093
|
+
"aria-pressed": selected,
|
|
28094
|
+
className: cn(baseClass, "cursor-pointer hover:border-primary/60 hover:bg-muted/40 focus-visible:outline-2 focus-visible:outline-ring"),
|
|
28095
|
+
children: inner
|
|
28096
|
+
});
|
|
28097
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28098
|
+
className: baseClass,
|
|
28099
|
+
children: inner
|
|
28100
|
+
});
|
|
28101
|
+
}
|
|
28102
|
+
/** Multi-stage pipeline and architecture flow diagram with parallel lane support and timing/cost summary. */
|
|
28103
|
+
function PipelineDiagram({ label, steps, note, summary, selectedId, onSelect, className }) {
|
|
28104
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
28105
|
+
className: cn("rounded-surface border border-border bg-card text-card-foreground", className),
|
|
28106
|
+
children: [
|
|
28107
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
28108
|
+
className: "flex flex-wrap items-baseline justify-between gap-2 border-b border-border px-4 py-2.5",
|
|
28109
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
28110
|
+
className: "type-label text-foreground",
|
|
28111
|
+
children: label
|
|
28112
|
+
}), note && /* @__PURE__ */ jsx("span", {
|
|
28113
|
+
className: "type-caption text-muted-foreground",
|
|
28114
|
+
children: note
|
|
28115
|
+
})]
|
|
28116
|
+
}),
|
|
28117
|
+
/* @__PURE__ */ jsx("div", {
|
|
28118
|
+
className: "overflow-x-auto p-4",
|
|
28119
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
28120
|
+
"aria-label": label,
|
|
28121
|
+
className: "flex flex-col items-stretch gap-3 md:flex-row md:items-center",
|
|
28122
|
+
children: steps.map((step, idx) => {
|
|
28123
|
+
const isLast = idx === steps.length - 1;
|
|
28124
|
+
const edgeLabel = step.edgeLabel;
|
|
28125
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx("li", {
|
|
28126
|
+
className: "min-w-48 flex-1",
|
|
28127
|
+
children: isParallelStep(step) ? /* @__PURE__ */ jsxs("div", {
|
|
28128
|
+
className: "rounded-surface border border-dashed border-border bg-surface-sunken/60 p-2.5",
|
|
28129
|
+
children: [step.groupLabel && /* @__PURE__ */ jsx("div", {
|
|
28130
|
+
className: "mb-2 type-caption font-medium text-muted-foreground",
|
|
28131
|
+
children: step.groupLabel
|
|
28132
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
28133
|
+
className: "flex flex-col gap-2",
|
|
28134
|
+
children: step.parallel.map((stage) => /* @__PURE__ */ jsx(StageCard, {
|
|
28135
|
+
stage,
|
|
28136
|
+
selected: selectedId === stage.id,
|
|
28137
|
+
onSelect
|
|
28138
|
+
}, stage.id))
|
|
28139
|
+
})]
|
|
28140
|
+
}) : /* @__PURE__ */ jsx(StageCard, {
|
|
28141
|
+
stage: step,
|
|
28142
|
+
selected: selectedId === step.id,
|
|
28143
|
+
onSelect
|
|
28144
|
+
})
|
|
28145
|
+
}), !isLast && /* @__PURE__ */ jsxs("li", {
|
|
28146
|
+
"aria-hidden": "true",
|
|
28147
|
+
className: "flex shrink-0 flex-col items-center justify-center gap-0.5 text-muted-foreground",
|
|
28148
|
+
children: [
|
|
28149
|
+
/* @__PURE__ */ jsx(ArrowRight, { className: "hidden size-4 md:block" }),
|
|
28150
|
+
/* @__PURE__ */ jsx(ArrowDown, { className: "block size-4 md:hidden" }),
|
|
28151
|
+
edgeLabel && /* @__PURE__ */ jsx("span", {
|
|
28152
|
+
className: "max-w-24 text-center font-mono type-caption",
|
|
28153
|
+
children: edgeLabel
|
|
28154
|
+
})
|
|
28155
|
+
]
|
|
28156
|
+
})] }, step.id);
|
|
28157
|
+
})
|
|
28158
|
+
})
|
|
28159
|
+
}),
|
|
28160
|
+
summary && summary.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
28161
|
+
className: "flex flex-wrap items-center gap-x-5 gap-y-1 border-t border-border bg-surface-sunken px-4 py-2 type-caption",
|
|
28162
|
+
children: summary.map((item) => /* @__PURE__ */ jsxs("div", {
|
|
28163
|
+
className: "inline-flex items-baseline gap-1.5",
|
|
28164
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
28165
|
+
className: "text-muted-foreground",
|
|
28166
|
+
children: [item.label, ":"]
|
|
28167
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
28168
|
+
className: "font-mono font-medium tabular-nums text-foreground",
|
|
28169
|
+
children: item.value
|
|
28170
|
+
})]
|
|
28171
|
+
}, item.label))
|
|
28172
|
+
})
|
|
28173
|
+
]
|
|
28174
|
+
});
|
|
28175
|
+
}
|
|
28176
|
+
|
|
28177
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, Balance, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CHART_COLOURS, CLOCK_FACE_STYLES, CLOCK_STYLES, COINS, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, ConfusionMatrix, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FACINGS, FIT, FRACTION_OUTLINES, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FillLevel, FilmStrip, FolderPicker, ForestPlot, FractionShape, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, JsonView, KeysLegend, LEVEL_FLOOR_DB, LengthBar, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricDistribution, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, Money, NBSP, NOTES, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PartialDateField, PauseButton, PipelineDiagram, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SOLID_SHAPES, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScatterFrontier, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, SliceMatrix, Slider, Solid, SortableList, SpanActions, SpanStrip, SpeakerTimeline, SpecimenDeck, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, TurnArrow, UNCLEAR, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, assignTurns, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, chartColour, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, coinOutline, colorSchemeScript, commandShortcut, continues, copyTurns, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, deterministicJitter, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, ecdfPoints, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, fillWords, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, formatPartialDate, fractionParts, fractionWords, frameAt, freshId, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, jsonBranchPaths, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, mergeWithNext, minutesAt, moneyWords, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, newVoiceName, nextBreak, niceScale, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, paretoFrontier, parseChord, parseInline, parsePartialDate, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, removeTurns, renameVoice, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, setEdge, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, solidWords, sortRows, speak, speechLevel, splitRect, splitTurn, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, summarizeDistribution, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnWords, turned, turnedSize, turnsAt, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, voicesOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
26253
28178
|
//# sourceMappingURL=index.js.map
|