@vitavision/workbench 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/components/splitSize.ts","../src/components/SplitPane.tsx","../src/components/AppShell.tsx","../src/components/StatusBar.tsx","../src/components/NavRail.tsx","../src/components/treeModel.ts","../src/components/TreeView.tsx","../src/components/playhead.ts","../src/components/usePlayback.ts","../src/components/PlaybackBar.tsx","../src/components/dropFiles.ts","../src/components/FileDrop.tsx","../src/components/sequence.ts","../src/components/SequenceNavigator.tsx","../src/components/stepperModel.ts","../src/components/Stepper.tsx"],"sourcesContent":["/*\n * The arithmetic behind `SplitPane`: resolving sizes given in pixels or percent, clamping a\n * drag or a key press to the pane's limits, and remembering a size across reloads.\n *\n * Kept out of the component so every rule — which key moves the divider which way, where a\n * collapsible pane snaps shut — is tested without a DOM.\n */\n\n/**\n * A pane size: CSS pixels as a number, or a share of the split's length as a percentage\n * string (`\"30%\"`).\n */\nexport type PaneSize = number | `${number}%`;\n\n/** The limits a `SplitPane`'s sized pane is held to, resolved to pixels. */\nexport interface SplitLimits {\n /** The smallest open size, in pixels. */\n min: number;\n /** The largest size, in pixels. */\n max: number;\n /** Whether the pane may close to 0 below `min`. */\n collapsible: boolean;\n}\n\n/**\n * A size in pixels.\n *\n * @param size - Pixels, or a percentage of `length`.\n * @param length - The split's length along its axis, in pixels.\n * @returns The size in pixels (never negative).\n */\nexport function resolveSize(size: PaneSize, length: number): number {\n const px = typeof size === \"number\" ? size : (Number.parseFloat(size) / 100) * length;\n return Number.isFinite(px) ? Math.max(0, px) : 0;\n}\n\n/**\n * The limits in pixels for a split of `length`. `max` never exceeds `length`, and `min`\n * never exceeds `max`.\n *\n * @param length - The split's length along its axis, in pixels.\n * @param minSize - The smallest open size. Defaults to 0.\n * @param maxSize - The largest size. Defaults to the whole length.\n * @param collapsible - Whether the pane may close below `minSize`.\n * @returns The resolved limits.\n */\nexport function resolveLimits(length: number, minSize: PaneSize = 0, maxSize: PaneSize = \"100%\", collapsible = false): SplitLimits {\n const max = Math.min(resolveSize(maxSize, length), Math.max(0, length));\n const min = Math.min(resolveSize(minSize, length), max);\n return { min, max, collapsible };\n}\n\n/**\n * Hold a proposed size to the limits. A collapsible pane dragged below half its minimum\n * snaps shut (0); between half the minimum and the minimum it stays at the minimum.\n *\n * @param size - The proposed size, in pixels.\n * @param limits - The resolved limits.\n * @returns The size to apply, in pixels, rounded to whole pixels.\n */\nexport function clampSize(size: number, limits: SplitLimits): number {\n if (limits.collapsible && size < limits.min / 2) return 0;\n return Math.round(Math.min(limits.max, Math.max(limits.min, size)));\n}\n\n/** Which way a `SplitPane` lays out its two panes. */\nexport type SplitOrientation = \"horizontal\" | \"vertical\";\n\n/** Which of the two panes carries the explicit size; the other takes the rest. */\nexport type SizedPane = \"start\" | \"end\";\n\n/** What a key press on the divider asks for. */\nexport type SplitKeyAction = { type: \"resize\"; size: number } | { type: \"toggle-collapse\" };\n\n/**\n * The divider's keyboard (the WAI-ARIA window-splitter pattern).\n *\n * The arrow keys along the split's axis move the divider the way they point — so the sized\n * pane grows or shrinks depending on which side it is on — by `step`, or four steps with\n * Shift. Home gives the sized pane its minimum, End its maximum, and Enter collapses or\n * restores a collapsible pane.\n *\n * @param key - `KeyboardEvent.key`.\n * @param shift - Whether Shift is held.\n * @param size - The sized pane's current size, in pixels.\n * @param options - The layout, the step in pixels and the resolved limits.\n * @returns The action, or `null` when the key is not the divider's.\n */\nexport function splitKeyAction(\n key: string,\n shift: boolean,\n size: number,\n options: { orientation: SplitOrientation; sizedPane: SizedPane; step: number; limits: SplitLimits },\n): SplitKeyAction | null {\n const { orientation, sizedPane, step, limits } = options;\n const [back, forward] = orientation === \"horizontal\" ? [\"ArrowLeft\", \"ArrowRight\"] : [\"ArrowUp\", \"ArrowDown\"];\n const grow = sizedPane === \"start\" ? 1 : -1;\n const delta = shift ? step * 4 : step;\n\n switch (key) {\n case forward:\n return { type: \"resize\", size: clampOpen(size + grow * delta, limits) };\n case back:\n return { type: \"resize\", size: clampOpen(size - grow * delta, limits) };\n case \"Home\":\n return { type: \"resize\", size: Math.round(limits.min) };\n case \"End\":\n return { type: \"resize\", size: Math.round(limits.max) };\n case \"Enter\":\n return limits.collapsible ? { type: \"toggle-collapse\" } : null;\n default:\n return null;\n }\n}\n\n/** A key step never snaps a pane shut (that is Enter's job): clamp to the open range. */\nfunction clampOpen(size: number, limits: SplitLimits): number {\n return Math.round(Math.min(limits.max, Math.max(limits.min, size)));\n}\n\n/**\n * The size stored under `key`, if any.\n *\n * @param key - The `localStorage` key.\n * @returns The stored size in pixels, or `null` when nothing valid is stored or storage\n * cannot be read (private browsing, the server).\n */\nexport function readStoredSize(key: string): number | null {\n try {\n const raw = window.localStorage.getItem(key);\n if (raw === null) return null;\n const value = Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Remember a size under `key`. Failures (storage full, disabled, the server) are ignored: a\n * size that is not remembered is not worth an error.\n *\n * @param key - The `localStorage` key.\n * @param size - The size in pixels.\n */\nexport function writeStoredSize(key: string, size: number): void {\n try {\n window.localStorage.setItem(key, String(Math.round(size)));\n } catch {\n // Nothing to do: the size simply is not remembered.\n }\n}\n","/*\n * Two panes and the divider between them.\n *\n * A studio screen is a handful of permanent surfaces — a tree, a viewport, an inspector, a\n * timeline — whose relative size is the user's decision, not the layout's. The divider is\n * therefore a real control: draggable, operable from the keyboard (the WAI-ARIA\n * window-splitter pattern), announced with its position, and remembered across reloads\n * when asked to be.\n *\n * One pane carries the size and the other takes the rest, so nesting composes: the rest of\n * one split is simply another split. `AppShell` builds its side panels exactly that way.\n */\n\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\n\nimport { cn, focusRing } from \"@vitavision/ui\";\n\nimport {\n type PaneSize,\n type SizedPane,\n type SplitOrientation,\n clampSize,\n readStoredSize,\n resolveLimits,\n resolveSize,\n splitKeyAction,\n writeStoredSize,\n} from \"./splitSize\";\n\n/** Props of `SplitPane`. */\nexport interface SplitPaneProps {\n /**\n * The two panes, in reading order (left then right, or top then bottom). Exactly two;\n * nest another `SplitPane` in either for more.\n */\n children: readonly [ReactNode, ReactNode];\n /**\n * `horizontal` (the default) lays the panes side by side with a vertical divider;\n * `vertical` stacks them with a horizontal one.\n */\n orientation?: SplitOrientation | undefined;\n /** Which pane carries the size; the other takes the rest. Defaults to `start`. */\n sizedPane?: SizedPane | undefined;\n /** The sized pane's size in pixels, controlled. Pair with `onSizeChange`. */\n size?: number | undefined;\n /** The initial size when uncontrolled: pixels or a percentage. Defaults to `\"50%\"`. */\n defaultSize?: PaneSize | undefined;\n /** Called with the new size in pixels on every drag move and key press (0 when collapsed). */\n onSizeChange?: ((size: number) => void) | undefined;\n /** The sized pane's smallest open size: pixels or a percentage. Defaults to 0. */\n minSize?: PaneSize | undefined;\n /** The sized pane's largest size: pixels or a percentage. Defaults to `\"100%\"`. */\n maxSize?: PaneSize | undefined;\n /**\n * Lets the sized pane close: dragging it below half its minimum snaps it shut, and Enter\n * on the divider collapses it or restores the last open size.\n */\n collapsible?: boolean | undefined;\n /** How far one arrow-key press moves the divider, in pixels (four times with Shift). Defaults to 16. */\n step?: number | undefined;\n /**\n * Remember the size under this `localStorage` key, and start from it. Uncontrolled only:\n * a controlled split's size is the caller's to keep.\n */\n storageKey?: string | undefined;\n /** Names the divider for assistive technology. Defaults to \"Resize panes\". */\n \"aria-label\"?: string | undefined;\n /** Merged with the split's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Two panes with a draggable, keyboard-operable divider between them.\n *\n * The divider is a `role=\"separator\"` focusable control carrying `aria-valuenow` (the sized\n * pane's size in pixels), `aria-valuemin`/`aria-valuemax` and `aria-controls` (the sized\n * pane). Arrow keys along the axis move it by `step` (Shift: four steps), Home/End give the\n * sized pane its minimum/maximum, Enter collapses or restores a `collapsible` pane. Dragging\n * uses pointer capture, so the drag survives the pointer leaving the divider.\n *\n * Fills its container (`h-full w-full`), so it nests. State is exposed as `data-orientation`\n * on the root, `data-dragging` on the root and the divider while a drag is in progress, and\n * `data-collapsed` on the root and the sized pane while it is closed.\n */\nexport function SplitPane({\n children,\n orientation = \"horizontal\",\n sizedPane = \"start\",\n size: controlledSize,\n defaultSize = \"50%\",\n onSizeChange,\n minSize = 0,\n maxSize = \"100%\",\n collapsible = false,\n step = 16,\n storageKey,\n \"aria-label\": ariaLabel = \"Resize panes\",\n className,\n}: SplitPaneProps) {\n const paneId = useId();\n const horizontal = orientation === \"horizontal\";\n const [length, setLength] = useState<number | null>(null);\n const [internalSize, setInternalSize] = useState<number | null>(null);\n const [dragging, setDragging] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n // The drag in progress: where it started, and the size it has reached. The reached size is\n // kept here, not read back from state, because a pointer move's update is rendered at\n // continuous priority and may not have landed when the pointer is released.\n const dragRef = useRef<{ origin: number; start: number; length: number; reached: number } | null>(null);\n const lastOpenRef = useRef<number | null>(null);\n\n const limits = length === null ? null : resolveLimits(length, minSize, maxSize, collapsible);\n const size =\n controlledSize ?? internalSize ?? (length === null || limits === null ? null : clampSize(resolveSize(defaultSize, length), limits));\n const collapsed = size === 0;\n const controlled = controlledSize !== undefined;\n\n /*\n * Measure the split along its axis — synchronously on attach, so the first paint has the\n * limits, then on every resize — and pick up a remembered size. A callback ref rather than\n * an effect: the subscription lives exactly as long as the element.\n */\n const attach = useCallback(\n (element: HTMLDivElement | null) => {\n rootRef.current = element;\n if (!element) return;\n const measure = () => {\n const rect = element.getBoundingClientRect();\n setLength(horizontal ? rect.width : rect.height);\n };\n measure();\n if (storageKey !== undefined && !controlled) {\n const stored = readStoredSize(storageKey);\n if (stored !== null) setInternalSize(stored);\n }\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n },\n [horizontal, storageKey, controlled],\n );\n\n /** The live length and limits, measured now (a drag or a key press must not use stale ones). */\n const measureNow = () => {\n const element = rootRef.current;\n const rect = element?.getBoundingClientRect();\n const now = rect ? (horizontal ? rect.width : rect.height) : (length ?? 0);\n return { length: now, limits: resolveLimits(now, minSize, maxSize, collapsible) };\n };\n\n /** Take a new size: state, the caller, and (on `commit`) storage. `changed` defaults to a comparison with the rendered size. */\n const apply = (next: number, commit: boolean, changed = next !== size) => {\n if (next > 0) lastOpenRef.current = next;\n if (!controlled) setInternalSize(next);\n if (changed) onSizeChange?.(next);\n if (commit && storageKey !== undefined && !controlled) {\n writeStoredSize(storageKey, next);\n }\n };\n\n const coordinate = (event: ReactPointerEvent) => (horizontal ? event.clientX : event.clientY);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.preventDefault();\n const { length: now } = measureNow();\n const current = size ?? 0;\n dragRef.current = { origin: coordinate(event), start: current, length: now, reached: current };\n event.currentTarget.setPointerCapture(event.pointerId);\n event.currentTarget.focus();\n setDragging(true);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (drag === null) return;\n const delta = (coordinate(event) - drag.origin) * (sizedPane === \"start\" ? 1 : -1);\n const next = clampSize(drag.start + delta, resolveLimits(drag.length, minSize, maxSize, collapsible));\n if (next === drag.reached) return;\n drag.reached = next;\n // Compared with the drag's own last size above: the rendered one may lag behind.\n apply(next, false, true);\n };\n\n const endDrag = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (drag === null) return;\n dragRef.current = null;\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n setDragging(false);\n if (drag.reached > 0) lastOpenRef.current = drag.reached;\n if (storageKey !== undefined && !controlled) writeStoredSize(storageKey, drag.reached);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const { limits: now } = measureNow();\n const current = size ?? 0;\n const action = splitKeyAction(event.key, event.shiftKey, current, {\n orientation,\n sizedPane,\n step,\n limits: now,\n });\n if (action === null) return;\n event.preventDefault();\n if (action.type === \"resize\") {\n apply(action.size, true);\n } else if (current > 0) {\n lastOpenRef.current = current;\n apply(0, true);\n } else {\n apply(clampSize(lastOpenRef.current ?? now.min, { ...now, collapsible: false }), true);\n }\n };\n\n // Before the first measurement (and on the server) the pane is sized by CSS alone, from\n // the default; afterwards by the measured size. The limits stay in CSS too, so a window\n // resize never pushes the pane outside them between two measurements.\n const basis = size !== null ? `${size}px` : typeof defaultSize === \"number\" ? `${defaultSize}px` : defaultSize;\n const cssSize = (value: PaneSize) => (typeof value === \"number\" ? `${value}px` : value);\n const sizedStyle: CSSProperties = {\n flex: `0 0 ${basis}`,\n ...(collapsed\n ? {}\n : horizontal\n ? { minWidth: cssSize(minSize), maxWidth: cssSize(maxSize) }\n : { minHeight: cssSize(minSize), maxHeight: cssSize(maxSize) }),\n };\n\n const [first, second] = children;\n const paneClasses = \"relative min-h-0 min-w-0 overflow-hidden\";\n const sized = (\n <div\n id={paneId}\n style={sizedStyle}\n className={paneClasses}\n data-collapsed={collapsed ? \"\" : undefined}\n // A closed pane keeps its content mounted (a tree keeps its expansion), but nothing in\n // it may take focus or be read out.\n inert={collapsed}\n >\n {sizedPane === \"start\" ? first : second}\n </div>\n );\n const rest = <div className={cn(paneClasses, \"flex-1 basis-0\")}>{sizedPane === \"start\" ? second : first}</div>;\n\n return (\n <div\n ref={attach}\n data-orientation={orientation}\n data-dragging={dragging ? \"\" : undefined}\n data-collapsed={collapsed ? \"\" : undefined}\n className={cn(\n \"flex h-full min-h-0 w-full min-w-0\",\n horizontal ? \"flex-row\" : \"flex-col\",\n dragging && (horizontal ? \"cursor-col-resize select-none\" : \"cursor-row-resize select-none\"),\n className,\n )}\n >\n {sizedPane === \"start\" ? sized : rest}\n <div\n role=\"separator\"\n tabIndex={0}\n aria-label={ariaLabel}\n // The separator's own orientation is across the split: side-by-side panes are divided\n // by a vertical line.\n aria-orientation={horizontal ? \"vertical\" : \"horizontal\"}\n aria-controls={paneId}\n aria-valuenow={size === null ? undefined : Math.round(size)}\n aria-valuemin={limits === null ? undefined : collapsible ? 0 : Math.round(limits.min)}\n aria-valuemax={limits === null ? undefined : Math.round(limits.max)}\n data-dragging={dragging ? \"\" : undefined}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={onKeyDown}\n className={cn(\n // A 1px rule with a wider invisible hit area on either side of it.\n \"relative z-10 shrink-0 touch-none bg-line transition-colors\",\n \"before:absolute before:content-['']\",\n horizontal\n ? \"w-px cursor-col-resize before:inset-y-0 before:-right-1 before:-left-1\"\n : \"h-px cursor-row-resize before:inset-x-0 before:-top-1 before:-bottom-1\",\n \"hover:bg-signal data-dragging:bg-signal\",\n focusRing,\n )}\n />\n {sizedPane === \"start\" ? rest : sized}\n </div>\n );\n}\n","/*\n * The frame of a studio app: a header across the top, a main surface, optional side panels\n * either side of it, and an optional strip along the bottom.\n *\n * `@vitavision/ui` deliberately has no opinion on how an app fills the viewport — a page\n * scrolls. A studio is the other kind of screen: every surface is permanent, nothing scrolls\n * but the insides of panels, and the side panels are resized by hand. This is that frame,\n * built from `SplitPane`, and nothing more: no routing, no menus, no state of its own beyond\n * the panel sizes it is asked to remember.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { cn } from \"@vitavision/ui\";\n\nimport { SplitPane } from \"./SplitPane\";\nimport type { PaneSize } from \"./splitSize\";\n\n/** How one side panel of an `AppShell` is sized. */\nexport interface SidePanelSize {\n /** The initial width: pixels or a percentage. */\n defaultSize?: PaneSize | undefined;\n /** The narrowest the panel may be dragged. */\n minSize?: PaneSize | undefined;\n /** The widest the panel may be dragged. */\n maxSize?: PaneSize | undefined;\n /** Lets the panel close (drag it under half its minimum, or Enter on its divider). */\n collapsible?: boolean | undefined;\n}\n\n/** Props of `AppShell`. */\nexport interface AppShellProps {\n /** The top bar: the app's name, the file actions, the theme toggle. */\n header?: ReactNode;\n /**\n * A fixed-width column at the far left, outside the resizable panels: an icon rail of\n * workspaces, such as a `NavRail`. It takes its content's width and is a `<nav>` named by\n * `railLabel`.\n */\n rail?: ReactNode;\n /** Names the rail's landmark (`<nav>`). Defaults to \"Workspaces\". */\n railLabel?: string | undefined;\n /** The panel left of the main surface — a navigator such as a `TreeView`. */\n left?: ReactNode;\n /** The main surface — the viewport. Always present. */\n main: ReactNode;\n /** The panel right of the main surface — an inspector. */\n right?: ReactNode;\n /** The strip along the bottom, across the whole width — a `PlaybackBar`, a `StatusBar`. */\n bottom?: ReactNode;\n /** Names the left panel's landmark (`<aside>`). Defaults to \"Navigator\". */\n leftLabel?: string | undefined;\n /** Names the right panel's landmark (`<aside>`). Defaults to \"Inspector\". */\n rightLabel?: string | undefined;\n /** The left panel's sizing. Defaults to 280 px, 180 px to 50%. */\n leftSize?: SidePanelSize | undefined;\n /** The right panel's sizing. Defaults to 320 px, 220 px to 50%. */\n rightSize?: SidePanelSize | undefined;\n /**\n * Remember the side panels' widths in `localStorage`, under `<storageKey>:left` and\n * `<storageKey>:right`.\n */\n storageKey?: string | undefined;\n /** Merged with the shell's own classes through `cn` — override `h-dvh` to embed it. */\n className?: string | undefined;\n}\n\nconst LEFT_DEFAULTS = { defaultSize: 280, minSize: 180, maxSize: \"50%\" } as const;\nconst RIGHT_DEFAULTS = { defaultSize: 320, minSize: 220, maxSize: \"50%\" } as const;\n\n/**\n * The full-viewport frame of a studio app: `header` across the top, then `rail` | `left` |\n * `main` | `right` with resizable side panels and a fixed-width rail, and `bottom` across the\n * foot. Every slot but `main` is optional, and an absent slot takes no space.\n *\n * Landmarks: the header is a `<header>`, the rail a `<nav>` named by `railLabel`, the main\n * surface a `<main>`, the side panels `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main\n * surface by a `SplitPane` divider (drag, or focus it and use the arrow keys). Only the\n * insides of the panels scroll; the shell itself is fixed to the viewport (`h-dvh`).\n */\nexport function AppShell({\n header,\n rail,\n railLabel = \"Workspaces\",\n left,\n main,\n right,\n bottom,\n leftLabel = \"Navigator\",\n rightLabel = \"Inspector\",\n leftSize,\n rightSize,\n storageKey,\n className,\n}: AppShellProps) {\n const leftSizing = { ...LEFT_DEFAULTS, ...leftSize };\n const rightSizing = { ...RIGHT_DEFAULTS, ...rightSize };\n const hasLeft = left !== undefined && left !== null && left !== false;\n const hasRight = right !== undefined && right !== null && right !== false;\n const hasRail = rail !== undefined && rail !== null && rail !== false;\n\n const mainSurface = <main className=\"relative h-full min-h-0 min-w-0 overflow-hidden\">{main}</main>;\n\n const withRight = hasRight ? (\n <SplitPane\n sizedPane=\"end\"\n {...rightSizing}\n storageKey={storageKey === undefined ? undefined : `${storageKey}:right`}\n aria-label={`Resize ${rightLabel.toLowerCase()}`}\n >\n {mainSurface}\n <aside aria-label={rightLabel} className=\"h-full overflow-auto bg-surface\">\n {right}\n </aside>\n </SplitPane>\n ) : (\n mainSurface\n );\n\n const middle = hasLeft ? (\n <SplitPane\n sizedPane=\"start\"\n {...leftSizing}\n storageKey={storageKey === undefined ? undefined : `${storageKey}:left`}\n aria-label={`Resize ${leftLabel.toLowerCase()}`}\n >\n <aside aria-label={leftLabel} className=\"h-full overflow-auto bg-surface\">\n {left}\n </aside>\n {withRight}\n </SplitPane>\n ) : (\n withRight\n );\n\n return (\n <div className={cn(\"grid h-dvh w-full grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden bg-ground text-fg\", className)}>\n {header ? <header className=\"min-w-0 border-b border-line bg-surface\">{header}</header> : <div aria-hidden />}\n {hasRail ? (\n <div className=\"flex min-h-0 min-w-0\">\n <nav aria-label={railLabel} className=\"h-full shrink-0 overflow-y-auto border-r border-line bg-surface\">\n {rail}\n </nav>\n <div className=\"min-h-0 min-w-0 flex-1\">{middle}</div>\n </div>\n ) : (\n <div className=\"min-h-0 min-w-0\">{middle}</div>\n )}\n {bottom ? <div className=\"min-w-0 border-t border-line bg-surface\">{bottom}</div> : <div aria-hidden />}\n </div>\n );\n}\n","/*\n * The status line along the foot of a studio app: what the app is doing and what it is\n * showing — the duration of the last operation, the current frame, the model in use.\n *\n * Studio apps each grew one, and each placed, sized and spaced its facts differently. This is\n * the one line, built from `ReadoutStrip`, so the facts read like the readouts everywhere else:\n * mono, quiet labels, separated by a dot.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { ReadoutStrip, cn, type ReadoutItem } from \"@vitavision/ui\";\n\n/** Props of `StatusBar`. */\nexport interface StatusBarProps {\n /** The facts at the left end, in order. Items whose `value` is `null` or `undefined` are skipped. */\n start?: ReadoutItem[] | undefined;\n /** The facts at the right end, in order. Items whose `value` is `null` or `undefined` are skipped. */\n end?: ReadoutItem[] | undefined;\n /** Drawn between the two ends, e.g. a `ProgressBar` while an operation runs. */\n children?: ReactNode;\n /** Names the bar. Defaults to \"Status\". */\n \"aria-label\"?: string | undefined;\n /**\n * Announce changes to the bar's content politely (`role=\"status\"`) instead of leaving it a\n * plain named group. Defaults to false.\n */\n live?: boolean | undefined;\n /** Merged with the bar's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * One 24 px line of facts for `AppShell`'s `bottom` slot: a `ReadoutStrip` of `start` items at\n * the left end, one of `end` items at the right end, and `children` between them.\n *\n * It is a `role=\"group\"` named by `aria-label` (\"Status\"). With `live` it is a\n * `role=\"status\"` instead (a polite live region, and `data-live`), so a screen reader\n * announces what changes in it: use that for facts worth hearing when they change (an\n * operation finished), not for ones that change many times a second. The line does not wrap;\n * keep it to a few short facts.\n */\nexport function StatusBar({ start, end, children, \"aria-label\": ariaLabel = \"Status\", live = false, className }: StatusBarProps) {\n const hasChildren = children !== undefined && children !== null && children !== false;\n return (\n <div\n role={live ? \"status\" : \"group\"}\n aria-label={ariaLabel}\n aria-live={live ? \"polite\" : undefined}\n data-live={live ? \"\" : undefined}\n className={cn(\"flex h-6 min-w-0 items-center gap-3 overflow-hidden px-3\", className)}\n >\n {start && <ReadoutStrip items={start} className={STRIP} />}\n {hasChildren && <div className=\"flex min-w-0 flex-1 items-center gap-2\">{children}</div>}\n {end && <ReadoutStrip items={end} className={cn(STRIP, \"ml-auto\")} />}\n </div>\n );\n}\n\n/** One line: the strip's own wrapping would push the second line out of a 24 px bar. */\nconst STRIP = \"shrink-0 flex-nowrap whitespace-nowrap\";\n","/*\n * The workspaces of a studio app as a column of icons down its left edge: Library, Teach,\n * Inspect. One is current; choosing another swaps the screen.\n *\n * Each item is a button, or — through `asChild` — the app's own link element, so a router's\n * `<Link>` keeps client-side navigation and this package never imports a router.\n */\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useId,\n useState,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Tooltip, cn, focusRing } from \"@vitavision/ui\";\n\n/** How a `NavRail` shows its items' labels. */\nexport type NavRailLabels = \"visible\" | \"tooltip\";\n\n/** Props of `NavRail`. */\nexport interface NavRailProps {\n /** The current item's `value`, or `null` for none. Leave undefined to let the rail keep it. */\n value?: string | null | undefined;\n /** The current item at first, when the rail keeps it (`value` undefined). */\n defaultValue?: string | undefined;\n /** Called with an item's `value` when a person chooses an item other than the current one. */\n onValueChange?: ((value: string) => void) | undefined;\n /**\n * `\"visible\"` (the default) sets each label under its icon; `\"tooltip\"` draws icon-only\n * buttons and shows the label in a tooltip on hover or focus.\n */\n labels?: NavRailLabels | undefined;\n /** The `NavRailItem`s, in order. */\n children: ReactNode;\n /** Merged with the list's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/** Props of `NavRailItem`. */\nexport interface NavRailItemProps {\n /** Identifies the item to the rail's `value`. Unique within the rail. */\n value: string;\n /** The item's name: its text under the icon, or its tooltip and accessible name. */\n label: string;\n /** The item's icon, decorative (`aria-hidden`): the label carries the meaning. */\n icon: ReactNode;\n /**\n * A mark on the icon's corner: a number is drawn as a count (over 99 as \"99+\"), anything\n * else as given. It describes the item (`aria-describedby`); it is not part of its name.\n */\n badge?: ReactNode | number;\n /** Shown but not choosable. A link item gets `aria-disabled` and its clicks are cancelled. */\n disabled?: boolean | undefined;\n /**\n * Render onto the one child element — a router's `<Link to=\"…\" />` or an `<a href>` —\n * instead of a `<button>`. Give the child without content: the icon and label become its\n * children. Its own `className` is kept beside the item's, and its own `onClick` runs first;\n * calling `event.preventDefault()` there keeps the item from being chosen.\n */\n asChild?: boolean | undefined;\n /** With `asChild`, the one element to render as. */\n children?: ReactElement | undefined;\n /** Merged with the item's own classes through `cn`. */\n className?: string | undefined;\n}\n\ninterface NavRailState {\n value: string | null;\n labels: NavRailLabels;\n choose: (value: string) => void;\n}\n\nconst NavRailContext = createContext<NavRailState | null>(null);\n\n/**\n * A vertical rail of workspaces: `NavRailItem`s as a list of buttons (or the app's links, via\n * `asChild`), one of them current. Controlled with `value` and `onValueChange`, or kept by the\n * rail from `defaultValue`.\n *\n * The current item carries `aria-current=\"page\"` and `data-state=\"active\"` (the others\n * `\"inactive\"`). Every item is its own Tab stop. The rail is a plain list with no landmark of\n * its own: `AppShell`'s `rail` slot is already a named `<nav>`, so elsewhere wrap it in a\n * `<nav aria-label=\"…\">`.\n */\nexport function NavRail({ value, defaultValue, onValueChange, labels = \"visible\", children, className }: NavRailProps) {\n const [kept, setKept] = useState<string | null>(defaultValue ?? null);\n const current = value === undefined ? kept : value;\n const choose = (next: string) => {\n if (next === current) return;\n if (value === undefined) setKept(next);\n onValueChange?.(next);\n };\n\n return (\n <NavRailContext value={{ value: current, labels, choose }}>\n <ul data-labels={labels} className={cn(\"flex flex-col items-center gap-1 p-1.5\", className)}>\n {children}\n </ul>\n </NavRailContext>\n );\n}\n\n/**\n * One workspace of a `NavRail`: an icon over its label, or an icon-only button with the label\n * in a tooltip (the rail's `labels`). A `<button>` by default; with `asChild`, the one child\n * element (the app's link) takes the item's look, `aria-current` and click.\n */\nexport function NavRailItem({ value, label, icon, badge, disabled = false, asChild = false, children, className }: NavRailItemProps) {\n const rail = use(NavRailContext);\n if (rail === null) throw new Error(\"NavRailItem must be rendered inside a NavRail.\");\n const badgeId = useId();\n\n const active = rail.value === value;\n const iconOnly = rail.labels === \"tooltip\";\n const hasBadge = badge !== undefined && badge !== null && badge !== false;\n\n const content = (\n <>\n <span aria-hidden className=\"relative grid place-items-center [&>svg]:size-4.5\">\n {icon}\n {hasBadge && (\n <span\n id={badgeId}\n data-badge=\"\"\n className={cn(\n \"absolute -top-1.5 left-[calc(100%-0.375rem)]\",\n typeof badge === \"number\" &&\n \"min-w-4 rounded-full bg-signal px-1 text-center font-mono text-[10px] leading-4 text-signal-fg tabular-nums\",\n )}\n >\n {typeof badge === \"number\" ? formatCount(badge) : badge}\n </span>\n )}\n </span>\n {!iconOnly && <span className=\"max-w-full truncate text-[10px] leading-tight\">{label}</span>}\n </>\n );\n\n const shared = {\n \"aria-current\": active ? (\"page\" as const) : undefined,\n \"aria-label\": iconOnly ? label : undefined,\n \"aria-describedby\": hasBadge ? badgeId : undefined,\n \"data-state\": active ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : undefined,\n };\n const classes = cn(\n \"relative flex flex-col items-center justify-center gap-0.5 rounded-control text-fg-muted transition-colors\",\n iconOnly ? \"size-9\" : \"w-14 px-1 py-1.5\",\n active ? \"bg-signal/12 text-fg [&_svg]:text-signal\" : \"hover:bg-raised hover:text-fg\",\n disabled && \"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-fg-muted\",\n focusRing,\n );\n\n let item: ReactElement;\n if (asChild && isValidElement<ChildProps>(children)) {\n const own = children.props;\n // `@vitavision/ui` keeps its Slot to itself, and this package takes no Radix dependency of\n // its own: the one child element is cloned with the item's props merged in.\n // oxlint-disable-next-line react/no-clone-element -- the asChild merge, see above\n item = cloneElement(children, {\n ...shared,\n \"aria-disabled\": disabled ? true : undefined,\n className: cn(classes, className, own.className),\n onClick: (event: MouseEvent<HTMLElement>) => {\n own.onClick?.(event);\n if (disabled) {\n event.preventDefault();\n return;\n }\n if (!event.defaultPrevented) rail.choose(value);\n },\n children: content,\n });\n } else {\n item = (\n <button type=\"button\" {...shared} disabled={disabled} onClick={() => rail.choose(value)} className={cn(classes, className)}>\n {content}\n </button>\n );\n }\n\n return <li>{iconOnly ? <Tooltip content={label}>{item}</Tooltip> : item}</li>;\n}\n\n/** The props `asChild` reads from, and merges into, the child element. */\ntype ChildProps = HTMLAttributes<HTMLElement> & Partial<Record<`data-${string}`, string>>;\n\n/** A badge count: up to 99 as is, more as \"99+\". */\nfunction formatCount(count: number): string {\n return count > 99 ? \"99+\" : String(count);\n}\n","/*\n * The model behind `TreeView`: which rows are visible, where each sits in its set, and what\n * each key does (the WAI-ARIA tree pattern).\n *\n * Kept out of the component so the keyboard contract — the part a tree most often gets\n * subtly wrong — is tested as a function from (rows, focus, key) to an action.\n */\n\nimport type { ReactNode } from \"react\";\n\n/** One node of a `TreeView`. */\nexport interface TreeNode {\n /** Identifies the node to `selectedId`, `onSelect` and `expanded`. Unique in the tree. */\n id: string;\n /** The node's name: shown, read out, and matched by type-ahead. */\n label: string;\n /** A leading icon (decorative) — typically a lucide icon at `size-3.5`. */\n icon?: ReactNode;\n /** Child nodes. A node with a (possibly empty) array is a parent; without, a leaf. */\n children?: readonly TreeNode[] | undefined;\n /** A quiet trailing annotation — a type, a count, a frame name. Shown in mono. */\n meta?: ReactNode;\n /** Shown and focusable, but not selectable. */\n disabled?: boolean | undefined;\n}\n\n/** A node as it is laid out: one visible row of the tree. */\nexport interface TreeRow {\n /** The node. */\n node: TreeNode;\n /** Depth, from 1 at the root (`aria-level`). */\n level: number;\n /** The parent's id, or `null` at the root. */\n parentId: string | null;\n /** 1-based position among its siblings (`aria-posinset`). */\n posInSet: number;\n /** How many siblings, itself included (`aria-setsize`). */\n setSize: number;\n /** Whether the node has a children array. */\n isParent: boolean;\n /** Whether the node is a parent and expanded. */\n isExpanded: boolean;\n}\n\n/**\n * The rows a reader can see: every root, and the children of every expanded parent, in\n * document order.\n *\n * @param nodes - The roots.\n * @param expanded - The ids of the expanded parents.\n * @returns The visible rows, in order.\n */\nexport function visibleRows(nodes: readonly TreeNode[], expanded: ReadonlySet<string>): TreeRow[] {\n const rows: TreeRow[] = [];\n const walk = (siblings: readonly TreeNode[], level: number, parentId: string | null) => {\n siblings.forEach((node, index) => {\n const isParent = node.children !== undefined;\n const isExpanded = isParent && expanded.has(node.id);\n rows.push({\n node,\n level,\n parentId,\n posInSet: index + 1,\n setSize: siblings.length,\n isParent,\n isExpanded,\n });\n if (isExpanded && node.children) walk(node.children, level + 1, node.id);\n });\n };\n walk(nodes, 1, null);\n return rows;\n}\n\n/**\n * Every parent's id — the expanded set for \"everything open\".\n *\n * @param nodes - The roots.\n * @returns The ids of every node with a children array, at any depth.\n */\nexport function parentIds(nodes: readonly TreeNode[]): string[] {\n const ids: string[] = [];\n const walk = (siblings: readonly TreeNode[]) => {\n for (const node of siblings) {\n if (node.children === undefined) continue;\n ids.push(node.id);\n walk(node.children);\n }\n };\n walk(nodes);\n return ids;\n}\n\n/**\n * The ancestors of a node, root first — what must be expanded for it to be visible.\n *\n * @param nodes - The roots.\n * @param id - The node.\n * @returns The ancestor ids, root first; empty for a root or an id not in the tree.\n */\nexport function ancestorIds(nodes: readonly TreeNode[], id: string): string[] {\n const walk = (siblings: readonly TreeNode[], path: string[]): string[] | null => {\n for (const node of siblings) {\n if (node.id === id) return path;\n if (node.children) {\n const found = walk(node.children, [...path, node.id]);\n if (found) return found;\n }\n }\n return null;\n };\n return walk(nodes, []) ?? [];\n}\n\n/** What a key press on a tree asks for. */\nexport type TreeKeyAction =\n | { type: \"focus\"; id: string }\n | { type: \"expand\"; id: string }\n | { type: \"collapse\"; id: string }\n | { type: \"select\"; id: string }\n | { type: \"expand-siblings\"; ids: string[] };\n\n/**\n * The tree's keyboard (the WAI-ARIA tree pattern), as a pure function.\n *\n * ↓/↑ move to the next/previous visible row; → expands a closed parent, or moves into an\n * open one's first child; ← collapses an open parent, or moves to the parent; Home/End go to\n * the first/last visible row; Enter and Space select; `*` expands every sibling of the\n * focused row; a printable character moves to the next row whose label starts with it\n * (type-ahead, wrapping).\n *\n * @param rows - The visible rows, from `visibleRows`.\n * @param focusedId - The row with focus.\n * @param key - `KeyboardEvent.key`.\n * @returns The action, or `null` when the key does nothing here.\n */\nexport function treeKeyAction(rows: readonly TreeRow[], focusedId: string, key: string): TreeKeyAction | null {\n const index = rows.findIndex((row) => row.node.id === focusedId);\n const row = rows[index];\n if (row === undefined) return null;\n const focus = (target: TreeRow | undefined): TreeKeyAction | null =>\n target === undefined || target === row ? null : { type: \"focus\", id: target.node.id };\n\n switch (key) {\n case \"ArrowDown\":\n return focus(rows[index + 1]);\n case \"ArrowUp\":\n return focus(rows[index - 1]);\n case \"Home\":\n return focus(rows[0]);\n case \"End\":\n return focus(rows[rows.length - 1]);\n case \"ArrowRight\":\n if (!row.isParent) return null;\n if (!row.isExpanded) return { type: \"expand\", id: row.node.id };\n // An open parent's first child is the next row, if it has one.\n return rows[index + 1]?.parentId === row.node.id ? focus(rows[index + 1]) : null;\n case \"ArrowLeft\":\n if (row.isExpanded) return { type: \"collapse\", id: row.node.id };\n return row.parentId === null ? null : focus(rows.find((candidate) => candidate.node.id === row.parentId));\n case \"Enter\":\n case \" \":\n return row.node.disabled ? null : { type: \"select\", id: row.node.id };\n case \"*\": {\n const ids = rows\n .filter((candidate) => candidate.parentId === row.parentId && candidate.isParent && !candidate.isExpanded)\n .map((candidate) => candidate.node.id);\n return ids.length === 0 ? null : { type: \"expand-siblings\", ids };\n }\n default:\n return typeAhead(rows, index, key);\n }\n}\n\n/** The next row after `from` (wrapping) whose label starts with `key`, for a single printable character. */\nfunction typeAhead(rows: readonly TreeRow[], from: number, key: string): TreeKeyAction | null {\n if (key.length !== 1 || key.trim() === \"\") return null;\n const needle = key.toLocaleLowerCase();\n for (let offset = 1; offset <= rows.length; offset += 1) {\n const candidate = rows[(from + offset) % rows.length];\n if (candidate?.node.label.toLocaleLowerCase().startsWith(needle)) {\n return offset === rows.length ? null : { type: \"focus\", id: candidate.node.id };\n }\n }\n return null;\n}\n","/*\n * A hierarchy you can walk with the keyboard.\n *\n * Built for the navigator column of a studio — a robot cell's frame tree, world → robots →\n * links → rigs → cameras — where the tree is data the app already has, the icons are the\n * app's own, and selection is shared with a viewport that can also pick things. So the tree\n * is data-driven, selection is controlled, and selecting something hidden opens the way to it.\n *\n * Rendered flat: one `treeitem` per visible row, carrying its level, position and set size\n * (the WAI-ARIA tree pattern's \"flat\" form). The focus ring then belongs to one row rather\n * than to a subtree, and the keyboard contract is a function over the same list the DOM is\n * — see `treeModel.ts`.\n */\n\nimport { ChevronRight } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent, MouseEvent } from \"react\";\n\nimport { byDensity, cn, useDensity } from \"@vitavision/ui\";\n\nimport { type TreeNode, type TreeRow, ancestorIds, parentIds, treeKeyAction, visibleRows } from \"./treeModel\";\n\n/** Props of `TreeView`. */\nexport interface TreeViewProps {\n /** The roots of the tree. */\n nodes: readonly TreeNode[];\n /** The selected node's id, controlled; `null` or absent for none. */\n selectedId?: string | null | undefined;\n /** Called with the node's id (and the node) on click, Enter or Space. Not called for a disabled node. */\n onSelect?: ((id: string, node: TreeNode) => void) | undefined;\n /** The expanded parents' ids, controlled. Pair with `onExpandedChange`. */\n expanded?: readonly string[] | undefined;\n /** The initially expanded parents' ids, when uncontrolled. */\n defaultExpanded?: readonly string[] | undefined;\n /** Start with every parent expanded, when uncontrolled (overrides `defaultExpanded`). */\n defaultExpandAll?: boolean | undefined;\n /** Called with the new set of expanded ids whenever a parent opens or closes. */\n onExpandedChange?: ((expanded: string[]) => void) | undefined;\n /** Names the tree for assistive technology. */\n \"aria-label\": string;\n /** Merged with the tree's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A data-driven tree (the WAI-ARIA tree pattern) with single selection.\n *\n * Keyboard: the tree is one Tab stop (roving `tabindex`). ↓/↑ move between visible rows, →\n * expands a parent or enters it, ← collapses a parent or goes up to its parent, Home/End jump\n * to the ends, Enter/Space select, `*` expands the focused row's siblings, and a letter jumps\n * to the next row starting with it. Clicking a row selects it; clicking its chevron toggles it.\n *\n * Selection is controlled (`selectedId`/`onSelect`). When `selectedId` changes to a node\n * inside a collapsed parent, its ancestors are expanded (through `onExpandedChange` when\n * `expanded` is controlled) and the row is scrolled into view — so a pick in a viewport can\n * drive the tree.\n *\n * Each row is a `treeitem` with `aria-level`, `aria-posinset`, `aria-setsize`,\n * `aria-selected` and, for parents, `aria-expanded`; also `data-selected` and, for parents,\n * `data-state` (`open`/`closed`). Row height follows the density in force.\n */\nexport function TreeView({\n nodes,\n selectedId = null,\n onSelect,\n expanded: controlledExpanded,\n defaultExpanded,\n defaultExpandAll = false,\n onExpandedChange,\n \"aria-label\": ariaLabel,\n className,\n}: TreeViewProps) {\n const density = useDensity();\n const [internalExpanded, setInternalExpanded] = useState<readonly string[]>(() =>\n defaultExpandAll ? parentIds(nodes) : (defaultExpanded ?? []),\n );\n const expandedIds = controlledExpanded ?? internalExpanded;\n const expandedSet = new Set(expandedIds);\n const rows = visibleRows(nodes, expandedSet);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n const rowElementsRef = useRef(new Map<string, HTMLDivElement>());\n\n const setExpanded = (next: readonly string[]) => {\n if (controlledExpanded === undefined) setInternalExpanded(next);\n onExpandedChange?.([...next]);\n };\n\n const toggle = (id: string, open: boolean) => {\n if (open === expandedSet.has(id)) return;\n setExpanded(open ? [...expandedIds, id] : expandedIds.filter((other) => other !== id));\n };\n\n // Reveal a selection made elsewhere: open its ancestors and bring its row into view.\n const latestRef = useRef({ nodes, expandedIds, setExpanded });\n useEffect(() => {\n latestRef.current = { nodes, expandedIds, setExpanded };\n });\n useEffect(() => {\n if (selectedId === null) return;\n const { nodes: tree, expandedIds: open, setExpanded: update } = latestRef.current;\n const missing = ancestorIds(tree, selectedId).filter((id) => !open.includes(id));\n if (missing.length > 0) update([...open, ...missing]);\n }, [selectedId]);\n useEffect(() => {\n if (selectedId === null) return;\n const element = rowElementsRef.current.get(selectedId);\n // `scrollIntoView` is absent in some test DOMs.\n if (typeof element?.scrollIntoView === \"function\") element.scrollIntoView({ block: \"nearest\" });\n }, [selectedId, rows.length]);\n\n const isVisible = (id: string | null) => id !== null && rows.some((row) => row.node.id === id);\n const tabStop = isVisible(focusedId) ? focusedId : isVisible(selectedId) ? selectedId : (rows[0]?.node.id ?? null);\n\n const focusRow = (id: string) => {\n setFocusedId(id);\n rowElementsRef.current.get(id)?.focus();\n };\n\n const select = (row: TreeRow) => {\n if (!row.node.disabled) onSelect?.(row.node.id, row.node);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const id = (event.target as HTMLElement).dataset[\"treeId\"];\n if (id === undefined) return;\n const action = treeKeyAction(rows, id, event.key);\n if (action === null) return;\n event.preventDefault();\n switch (action.type) {\n case \"focus\":\n focusRow(action.id);\n break;\n case \"expand\":\n toggle(action.id, true);\n break;\n case \"collapse\":\n toggle(action.id, false);\n break;\n case \"select\": {\n const row = rows.find((candidate) => candidate.node.id === action.id);\n if (row) select(row);\n break;\n }\n case \"expand-siblings\":\n setExpanded([...expandedIds, ...action.ids]);\n break;\n }\n };\n\n const onChevron = (event: MouseEvent, row: TreeRow) => {\n event.stopPropagation();\n toggle(row.node.id, !row.isExpanded);\n focusRow(row.node.id);\n };\n\n return (\n <div role=\"tree\" aria-label={ariaLabel} onKeyDown={onKeyDown} className={cn(\"flex flex-col py-1 select-none\", className)}>\n {rows.map((row) => {\n const { node } = row;\n const selected = node.id === selectedId;\n return (\n <div\n key={node.id}\n ref={(element) => {\n if (element) rowElementsRef.current.set(node.id, element);\n else rowElementsRef.current.delete(node.id);\n }}\n role=\"treeitem\"\n aria-level={row.level}\n aria-posinset={row.posInSet}\n aria-setsize={row.setSize}\n aria-selected={selected}\n aria-expanded={row.isParent ? row.isExpanded : undefined}\n aria-disabled={node.disabled || undefined}\n tabIndex={node.id === tabStop ? 0 : -1}\n data-tree-id={node.id}\n data-selected={selected ? \"\" : undefined}\n data-state={row.isParent ? (row.isExpanded ? \"open\" : \"closed\") : undefined}\n onFocus={(event) => {\n if (event.target === event.currentTarget) setFocusedId(node.id);\n }}\n onClick={() => {\n focusRow(node.id);\n select(row);\n }}\n style={{ paddingLeft: `calc(${row.level - 1} * 0.875rem + 0.25rem)` }}\n className={cn(\n \"mx-1 flex shrink-0 cursor-default items-center gap-1.5 rounded-control pr-2 text-fg transition-colors\",\n \"outline-none focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-signal\",\n byDensity(density, \"h-7 text-sm\", \"h-6 text-xs\"),\n selected ? \"bg-signal/12\" : \"hover:bg-raised\",\n node.disabled && \"text-fg-subtle\",\n )}\n >\n {row.isParent ? (\n <span\n aria-hidden\n onClick={(event) => onChevron(event, row)}\n className=\"grid size-4 shrink-0 place-items-center rounded-sm text-fg-subtle hover:text-fg\"\n >\n <ChevronRight className={cn(\"size-3.5 transition-transform\", row.isExpanded && \"rotate-90\")} />\n </span>\n ) : (\n <span aria-hidden className=\"size-4 shrink-0\" />\n )}\n {node.icon !== undefined && (\n <span\n aria-hidden\n className={cn(\"grid shrink-0 place-items-center [&>svg]:size-3.5\", selected ? \"text-signal\" : \"text-fg-muted\")}\n >\n {node.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">{node.label}</span>\n {node.meta !== undefined && (\n // On the selected row's tint both `fg-subtle` and `fg-muted` fall below AA at this size.\n <span className={cn(\"shrink-0 font-mono text-[11px]\", selected ? \"text-fg\" : \"text-fg-subtle\")}>{node.meta}</span>\n )}\n </div>\n );\n })}\n </div>\n );\n}\n","/*\n * Where playback is, as a store outside React.\n *\n * A sampled timeline plays at display rate, and the things that follow it — a robot's joint\n * angles, a camera frustum, a highlighted capture — are drawn by a render loop, not by\n * React. If the current frame lived in React state, every frame of playback would re-render\n * every component that reads it, including the whole scene graph. So it lives here: a tiny\n * store a render loop reads with `get()` at no cost, and that React components subscribe to\n * (through `usePlayhead`) only where they display it — the playback bar, a time readout.\n *\n * The store holds an integer sample index and nothing else that changes per frame. The\n * sub-sample position real-time playback needs is the clock's business (`advance`,\n * `usePlaybackClock`), not the store's, so a reader never sees a fractional frame.\n */\n\n/**\n * A sampled timeline's current position: an external store shared by React and render loops.\n *\n * Every function member may be called detached (`const { get } = playhead`), which is how\n * `useSyncExternalStore` and a render loop hold them.\n */\nexport interface Playhead {\n /** The current sample index, an integer in `0 … count − 1` (0 when `count` is 0). Cheap: call it every frame. */\n readonly get: () => number;\n /**\n * Move to sample `k`. Rounded to an integer and clamped to `0 … count − 1`; listeners are\n * notified only if the index changed.\n */\n readonly set: (k: number) => void;\n /**\n * Be told when the index or the timeline changes.\n *\n * @returns The unsubscribe function.\n */\n readonly subscribe: (listener: () => void) => () => void;\n /** How many samples the timeline has. */\n readonly count: number;\n /** The time between samples, in seconds. Sample `k` is at `t = k · dt`. */\n readonly dt: number;\n /**\n * Swap in a new timeline — a newly loaded or re-baked scenario — keeping the one store\n * every subscriber already holds. The index is clamped into the new range (not reset:\n * call `set(0)` for that). Listeners are notified if anything changed.\n */\n readonly setTimeline: (count: number, dt: number) => void;\n}\n\n/**\n * A playhead over `count` samples spaced `dt` seconds apart, starting at sample 0.\n *\n * Create one per app (not per render — keep it in a `useState` initialiser or module\n * scope), hand it to `PlaybackBar` and to the render loop, and replace its timeline with\n * `setTimeline` when a new scenario loads.\n *\n * @param count - The number of samples (a non-negative integer).\n * @param dt - Seconds between samples (positive).\n * @returns The store.\n */\nexport function createPlayhead(count: number, dt: number): Playhead {\n let index = 0;\n let timeline = checkTimeline(count, dt);\n const listeners = new Set<() => void>();\n const notify = () => {\n for (const listener of [...listeners]) listener();\n };\n\n return {\n get: () => index,\n set: (k) => {\n const next = clampIndex(k, timeline.count);\n if (next === index) return;\n index = next;\n notify();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n get count() {\n return timeline.count;\n },\n get dt() {\n return timeline.dt;\n },\n setTimeline: (nextCount, nextDt) => {\n const next = checkTimeline(nextCount, nextDt);\n const nextIndex = clampIndex(index, next.count);\n if (next.count === timeline.count && next.dt === timeline.dt && nextIndex === index) return;\n timeline = next;\n index = nextIndex;\n notify();\n },\n };\n}\n\nfunction checkTimeline(count: number, dt: number): { count: number; dt: number } {\n if (!Number.isInteger(count) || count < 0) {\n throw new RangeError(`playhead: count must be a non-negative integer, got ${count}`);\n }\n if (!(dt > 0) || !Number.isFinite(dt)) {\n throw new RangeError(`playhead: dt must be a positive number of seconds, got ${dt}`);\n }\n return { count, dt };\n}\n\n/**\n * A sample index made legal: rounded, and clamped to `0 … count − 1`.\n *\n * @param k - Any number (`NaN` reads as 0).\n * @param count - The number of samples.\n * @returns The index; 0 when `count` is 0.\n */\nexport function clampIndex(k: number, count: number): number {\n if (count <= 0 || Number.isNaN(k)) return 0;\n return Math.min(count - 1, Math.max(0, Math.round(k)));\n}\n\n/** The outcome of one clock step: the new fractional position, and whether playback ran off the end. */\nexport interface AdvanceResult {\n /** The new position in samples (fractional); the index to show is its floor. */\n position: number;\n /** True when a non-looping timeline reached its last sample on this step. */\n ended: boolean;\n}\n\n/**\n * One step of real-time playback, in samples.\n *\n * Each sample is shown for `dt`: a looping timeline has period `count · dt` and wraps from\n * the last sample to the first; a non-looping one stops on the last sample and reports\n * `ended`. The position is fractional so that playback slower than one sample per frame\n * still advances.\n *\n * @param position - The current position in samples (fractional).\n * @param delta - How many samples to advance (elapsed seconds × speed ÷ dt); not negative.\n * @param count - The number of samples.\n * @param loop - Whether to wrap at the end.\n * @returns The new position and whether playback ended.\n */\nexport function advance(position: number, delta: number, count: number, loop: boolean): AdvanceResult {\n if (count <= 1) return { position: 0, ended: !loop };\n const next = position + Math.max(0, delta);\n if (loop) return { position: next % count, ended: false };\n const last = count - 1;\n return next >= last ? { position: last, ended: true } : { position: next, ended: false };\n}\n\n/**\n * The default time readout: seconds with millisecond resolution, `\"1.234 s\"`.\n *\n * @param seconds - The time.\n * @returns The formatted time.\n */\nexport function formatSeconds(seconds: number): string {\n return `${seconds.toFixed(3)} s`;\n}\n","/*\n * The React side of the playhead: subscribing to it, and driving it in real time.\n */\n\nimport { useEffect, useEffectEvent, useSyncExternalStore } from \"react\";\n\nimport { advance, type Playhead } from \"./playhead\";\n\n/**\n * The playhead's current sample index, re-rendering the calling component when it changes.\n *\n * Use it only where the index is *displayed* (the playback bar, a readout). A render loop\n * reads `playhead.get()` in its own frame callback instead, and re-renders nothing.\n *\n * @param playhead - The store.\n * @returns The current sample index.\n */\nexport function usePlayhead(playhead: Playhead): number {\n return useSyncExternalStore(playhead.subscribe, playhead.get, playhead.get);\n}\n\n/**\n * The playhead's timeline — `count` and `dt` — re-rendering when `setTimeline` changes it.\n *\n * @param playhead - The store.\n * @returns The number of samples and the seconds between them.\n */\nexport function usePlayheadTimeline(playhead: Playhead): { count: number; dt: number } {\n const count = useSyncExternalStore(\n playhead.subscribe,\n () => playhead.count,\n () => playhead.count,\n );\n const dt = useSyncExternalStore(\n playhead.subscribe,\n () => playhead.dt,\n () => playhead.dt,\n );\n return { count, dt };\n}\n\n/** Options of `usePlaybackClock`. */\nexport interface PlaybackClockOptions {\n /** The store to advance. */\n playhead: Playhead;\n /** Whether the clock runs. */\n playing: boolean;\n /** Playback rate: 1 is real time. Defaults to 1. */\n speed?: number | undefined;\n /** Wrap from the last sample to the first instead of stopping. Defaults to false. */\n loop?: boolean | undefined;\n /** Called once when a non-looping timeline reaches its last sample; set `playing` false here. */\n onEnd?: (() => void) | undefined;\n /**\n * The longest wall-clock gap one frame may advance by, in milliseconds. A tab in the\n * background gets no animation frames, and without this cap the first frame back would\n * jump by the whole time away. Defaults to 100.\n */\n maxFrameMs?: number | undefined;\n}\n\n/**\n * Advance a playhead in real time × `speed` while `playing`, from `requestAnimationFrame`.\n *\n * Position is accumulated fractionally, so slow playback of a finely sampled timeline still\n * moves; the store only ever holds the integer index. A seek from elsewhere (the scrubber, a\n * marker) is picked up on the next frame. Starting a non-looping timeline that sits on its\n * last sample rewinds it to 0 first. `speed`, `loop` and `onEnd` may change while playing\n * without restarting the clock.\n *\n * Renders nothing and re-renders nothing: call it once, in the component that owns the\n * `playing` state.\n *\n * @param options - The playhead and the transport state.\n */\nexport function usePlaybackClock({ playhead, playing, speed = 1, loop = false, onEnd, maxFrameMs = 100 }: PlaybackClockOptions): void {\n const step = useEffectEvent((position: number, elapsedMs: number) => {\n const delta = (Math.min(elapsedMs, maxFrameMs) / 1000) * (speed / playhead.dt);\n return advance(position, delta, playhead.count, loop);\n });\n const end = useEffectEvent(() => onEnd?.());\n const rewindIfAtEnd = useEffectEvent(() => {\n if (!loop && playhead.count > 0 && playhead.get() >= playhead.count - 1) playhead.set(0);\n });\n\n useEffect(() => {\n if (!playing) return;\n rewindIfAtEnd();\n let position = playhead.get();\n let last: number | null = null;\n let frame = requestAnimationFrame(function tick(now: number) {\n // A seek since the last frame (scrubber, marker, step button) wins over the clock.\n if (Math.floor(position) !== playhead.get()) position = playhead.get();\n const result = last === null ? { position, ended: false } : step(position, now - last);\n last = now;\n position = result.position;\n playhead.set(Math.floor(position));\n if (result.ended) {\n end();\n return;\n }\n frame = requestAnimationFrame(tick);\n });\n return () => cancelAnimationFrame(frame);\n }, [playing, playhead]);\n}\n","/*\n * The transport for a sampled timeline.\n *\n * Playback state splits by how often it changes. Whether it is playing, how fast, and\n * whether it loops change when someone clicks — ordinary controlled props. Where it is\n * changes every frame — so that is a `Playhead` store the bar subscribes to itself, and a\n * playing timeline re-renders this bar and nothing else in the app.\n *\n * The bar is chrome over a viewport, like the image stage's toolbar: one row, icon buttons\n * named for what they do, the time in mono so it does not jitter as digits change.\n */\n\nimport { ChevronFirst, ChevronLast, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from \"lucide-react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { type MeasureTone, Select, Slider, byDensity, cn, focusRing, toneColor, useDensity } from \"@vitavision/ui\";\n\nimport { formatSeconds, type Playhead } from \"./playhead\";\nimport { usePlayhead, usePlayheadTimeline } from \"./usePlayback\";\n\n/** A point of interest on the timeline — a capture, an event — drawn as a tick on the scrubber. */\nexport interface PlaybackMarker {\n /** The sample the marker sits on. */\n index: number;\n /** What happens there; names the tick for assistive technology and its tooltip. */\n label?: string | undefined;\n /** The tick's colour. Defaults to `signal`. */\n tone?: MeasureTone | undefined;\n}\n\n/** The speeds offered by default. */\nexport const DEFAULT_SPEEDS: readonly number[] = [0.25, 0.5, 1, 2, 4];\n\n/** Props of `PlaybackBar`. */\nexport interface PlaybackBarProps {\n /** Where playback is. The bar subscribes to it; seeking writes to it. */\n playhead: Playhead;\n /** Whether playback is running, controlled. */\n playing: boolean;\n /** Called with the requested playing state (the play/pause button, Space). */\n onPlayingChange: (playing: boolean) => void;\n /** The playback rate, controlled. Defaults to 1. */\n speed?: number | undefined;\n /** Called with the chosen rate. Without it the speed selector is not shown. */\n onSpeedChange?: ((speed: number) => void) | undefined;\n /** The rates the selector offers. Defaults to 0.25×, 0.5×, 1×, 2×, 4×. */\n speeds?: readonly number[] | undefined;\n /** Whether playback wraps at the end, controlled. */\n loop?: boolean | undefined;\n /** Called with the new loop state. Without it the loop toggle is not shown. */\n onLoopChange?: ((loop: boolean) => void) | undefined;\n /** Ticks on the scrubber, each a click target that seeks to it. */\n markers?: readonly PlaybackMarker[] | undefined;\n /** Called after a marker tick is clicked (the playhead has already moved to it). */\n onMarkerSelect?: ((marker: PlaybackMarker) => void) | undefined;\n /** Formats `t = k · dt` in seconds for the readout. Defaults to `\"1.234 s\"`. */\n formatTime?: ((seconds: number) => string) | undefined;\n /** Names the bar (a `toolbar`). Defaults to \"Playback\". */\n \"aria-label\"?: string | undefined;\n /** Merged with the bar's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * The transport for a sampled timeline: jump to start, previous marker, step back,\n * play/pause, step forward, next marker, jump to end; a scrubber over the samples with the\n * markers as ticks; the time `t = k · dt`; the speed; loop.\n *\n * `playing`, `speed` and `loop` are controlled props. The position is the `playhead` store,\n * which the bar subscribes to itself — so during playback only the bar re-renders. Drive the\n * store with `usePlaybackClock`, and read `playhead.get()` in a render loop.\n *\n * A `role=\"toolbar\"`. Keyboard, while focus is inside it: the scrubber is a slider (←/→ one\n * sample, PageUp/PageDown ten, Home/End); on the buttons, ←/→ step one sample; Space\n * toggles playback anywhere in the bar except on a button, where it presses the button. The\n * root carries `data-playing` while playing and `data-empty` when the timeline has no samples.\n */\nexport function PlaybackBar({\n playhead,\n playing,\n onPlayingChange,\n speed = 1,\n onSpeedChange,\n speeds = DEFAULT_SPEEDS,\n loop = false,\n onLoopChange,\n markers = [],\n onMarkerSelect,\n formatTime = formatSeconds,\n \"aria-label\": ariaLabel = \"Playback\",\n className,\n}: PlaybackBarProps) {\n const density = useDensity();\n const index = usePlayhead(playhead);\n const { count, dt } = usePlayheadTimeline(playhead);\n const last = Math.max(0, count - 1);\n const empty = count === 0;\n\n const sorted = [...markers].filter((m) => m.index >= 0 && m.index <= last).sort((a, b) => a.index - b.index);\n const previousMarker = sorted.filter((m) => m.index < index).at(-1);\n const nextMarker = sorted.find((m) => m.index > index);\n\n const seek = (k: number) => playhead.set(k);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n const onButton = target.tagName === \"BUTTON\";\n if (event.key === \" \" && !onButton && target.getAttribute(\"role\") !== \"combobox\") {\n event.preventDefault();\n if (!empty) onPlayingChange(!playing);\n } else if (onButton && (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\")) {\n event.preventDefault();\n seek(index + (event.key === \"ArrowRight\" ? 1 : -1));\n }\n };\n\n return (\n <div\n role=\"toolbar\"\n aria-label={ariaLabel}\n data-playing={playing ? \"\" : undefined}\n data-empty={empty ? \"\" : undefined}\n onKeyDown={onKeyDown}\n className={cn(\"flex w-full min-w-0 items-center bg-surface\", byDensity(density, \"gap-3 px-3 py-2\", \"gap-2 px-2 py-1\"), className)}\n >\n <div className=\"flex shrink-0 items-center gap-0.5\">\n <BarButton label=\"Jump to start\" onClick={() => seek(0)} disabled={empty || index === 0}>\n <ChevronFirst className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton\n label=\"Previous marker\"\n onClick={() => previousMarker && seek(previousMarker.index)}\n disabled={previousMarker === undefined}\n >\n <SkipBack className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Step back\" onClick={() => seek(index - 1)} disabled={empty || index === 0}>\n <StepBack className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label={playing ? \"Pause\" : \"Play\"} onClick={() => onPlayingChange(!playing)} disabled={empty} className=\"text-fg\">\n {playing ? <Pause className=\"size-4\" aria-hidden /> : <Play className=\"size-4\" aria-hidden />}\n </BarButton>\n <BarButton label=\"Step forward\" onClick={() => seek(index + 1)} disabled={empty || index >= last}>\n <StepForward className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Next marker\" onClick={() => nextMarker && seek(nextMarker.index)} disabled={nextMarker === undefined}>\n <SkipForward className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Jump to end\" onClick={() => seek(last)} disabled={empty || index >= last}>\n <ChevronLast className=\"size-4\" aria-hidden />\n </BarButton>\n </div>\n\n <div className=\"relative flex min-w-24 flex-1 flex-col justify-center\">\n {sorted.length > 0 && (\n // The ticks sit on a rail above the track, positioned as Radix positions the thumb:\n // its centre travels from half a thumb (7 px) in from either end.\n <div className=\"relative h-2.5\">\n {sorted.map((marker) => (\n <MarkerTick\n key={`${marker.index}:${marker.label ?? \"\"}`}\n marker={marker}\n fraction={last === 0 ? 0 : marker.index / last}\n time={formatTime(marker.index * dt)}\n active={marker.index === index}\n onClick={() => {\n seek(marker.index);\n onMarkerSelect?.(marker);\n }}\n />\n ))}\n </div>\n )}\n <Slider value={index} onValueChange={seek} min={0} max={last} step={1} disabled={empty} aria-label=\"Playback position\" />\n </div>\n\n {/* Not an <output>: that is a live region, and this changes every frame. */}\n <span className=\"shrink-0 font-mono text-xs whitespace-nowrap text-fg tabular-nums\">\n <span className=\"text-fg-subtle\">t = </span>\n {formatTime(index * dt)}\n <span className=\"ml-2 text-fg-subtle\">\n {empty ? \"–\" : index}/{last}\n </span>\n </span>\n\n {onSpeedChange && (\n <Select\n value={String(speed)}\n onValueChange={(value) => value !== \"\" && onSpeedChange(Number(value))}\n options={speeds.map((s) => ({ value: String(s), label: `${s}×` }))}\n aria-label=\"Playback speed\"\n className={cn(\"w-20 shrink-0 font-mono\", byDensity(density, \"h-8\", \"h-7\"))}\n />\n )}\n\n {onLoopChange && (\n <BarButton label=\"Loop\" pressed={loop} onClick={() => onLoopChange(!loop)}>\n <Repeat className=\"size-4\" aria-hidden />\n </BarButton>\n )}\n </div>\n );\n}\n\nfunction MarkerTick({\n marker,\n fraction,\n time,\n active,\n onClick,\n}: {\n marker: PlaybackMarker;\n fraction: number;\n time: string;\n active: boolean;\n onClick: () => void;\n}) {\n const name = marker.label ? `${marker.label} (${time})` : `Marker at ${time}`;\n return (\n <button\n type=\"button\"\n // The previous/next-marker buttons are the keyboard's way to the markers; one tab stop\n // per tick would bury the rest of the bar behind a long capture list.\n tabIndex={-1}\n title={name}\n aria-label={name}\n data-active={active ? \"\" : undefined}\n onClick={onClick}\n style={{ left: `calc(7px + ${fraction} * (100% - 14px))` }}\n className=\"group absolute top-0 flex h-full w-2.5 -translate-x-1/2 cursor-pointer justify-center\"\n >\n <span\n aria-hidden\n className=\"h-full w-0.5 rounded-full opacity-70 transition-opacity group-hover:opacity-100 group-data-active:w-1 group-data-active:opacity-100\"\n style={{ backgroundColor: toneColor(marker.tone) }}\n />\n </button>\n );\n}\n\n/** Props of the bar's icon button. */\ninterface BarButtonProps extends Omit<ComponentPropsWithRef<\"button\">, \"type\" | \"title\" | \"aria-label\" | \"aria-pressed\" | \"children\"> {\n label: string;\n pressed?: boolean | undefined;\n children: ReactNode;\n}\n\n/** An icon button in the style of `@vitavision/stage2d`'s `StageButton`, sized by density. */\nfunction BarButton({ label, pressed, className, children, ...props }: BarButtonProps) {\n const density = useDensity();\n return (\n <button\n {...props}\n type=\"button\"\n title={label}\n aria-label={label}\n aria-pressed={pressed}\n data-state={pressed === undefined ? undefined : pressed ? \"on\" : \"off\"}\n className={cn(\n \"grid place-items-center rounded-control text-fg-muted transition-colors\",\n byDensity(density, \"size-8\", \"size-7\"),\n \"hover:bg-raised hover:text-fg disabled:pointer-events-none disabled:opacity-40\",\n pressed && \"bg-signal/15 text-signal\",\n focusRing,\n className,\n )}\n >\n {children}\n </button>\n );\n}\n","/*\n * What `FileDrop` does with a drop: which files match `accept`, and what a dropped folder\n * contains.\n *\n * The browser enforces `accept` only in the file picker, and only as a hint; a drop brings\n * whatever was dragged. So the filter is applied here, to both routes. And a dropped folder\n * arrives as a zero-byte \"file\" unless its entries are walked — which is how a scenario\n * folder (a scene, a scenario, its meshes) is opened in one gesture.\n */\n\n/**\n * Whether a file matches an `accept` string, as `<input type=\"file\" accept>` reads it:\n * comma-separated extensions (`.json`), MIME types (`application/json`) and MIME wildcards\n * (`image/*`). Matching is case-insensitive.\n *\n * @param file - The file's name and MIME type.\n * @param accept - The accept string; empty or absent accepts everything.\n * @returns Whether the file is accepted.\n */\nexport function acceptsFile(file: { name: string; type: string }, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((token) => token.trim().toLowerCase())\n .filter((token) => token !== \"\");\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types by extension, for matching a bare path against `type/*` and MIME tokens. */\nconst MIME_BY_EXTENSION: Readonly<Record<string, string>> = {\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n bmp: \"image/bmp\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n tif: \"image/tiff\",\n tiff: \"image/tiff\",\n pgm: \"image/x-portable-graymap\",\n json: \"application/json\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\n/**\n * Whether a path matches an `accept` string, for desktop shells whose native drops and\n * dialogs yield paths rather than `File`s. Extensions match the path's ending; MIME types and\n * wildcards match through the extension of common image, JSON and text formats.\n *\n * @param path - A file path, with either separator.\n * @param accept - The accept string; empty or absent accepts everything.\n * @returns Whether the path is accepted.\n */\nexport function acceptsPath(path: string, accept: string | undefined): boolean {\n const name = path.split(/[\\\\/]/).pop() ?? path;\n const dot = name.lastIndexOf(\".\");\n const type = dot >= 0 ? (MIME_BY_EXTENSION[name.slice(dot + 1).toLowerCase()] ?? \"\") : \"\";\n return acceptsFile({ name, type }, accept);\n}\n\n/**\n * Split files by `accept`.\n *\n * @param files - The candidates.\n * @param accept - The accept string.\n * @returns The accepted files and the rejected ones, each in their original order.\n */\nexport function partitionFiles(files: readonly File[], accept: string | undefined): { accepted: File[]; rejected: File[] } {\n const accepted: File[] = [];\n const rejected: File[] = [];\n for (const file of files) (acceptsFile(file, accept) ? accepted : rejected).push(file);\n return { accepted, rejected };\n}\n\n/**\n * Whether a drag carries files (rather than text or a link) — the only drags `FileDrop`\n * reacts to.\n *\n * @param dataTransfer - The drag's data, or `null`.\n * @returns Whether `Files` is among its types.\n */\nexport function carriesFiles(dataTransfer: Pick<DataTransfer, \"types\"> | null): boolean {\n return dataTransfer !== null && Array.from(dataTransfer.types).includes(\"Files\");\n}\n\n/** The part of the File and Directory Entries API a drop walk needs (`webkitGetAsEntry`). */\nexport interface DropEntry {\n /** A file (`FileSystemFileEntry`). */\n isFile: boolean;\n /** A folder (`FileSystemDirectoryEntry`). */\n isDirectory: boolean;\n /** The entry's own name. */\n name: string;\n /** The entry's path from the drop root, with a leading `/`. */\n fullPath: string;\n /** A file entry's contents, as a `File`. */\n file?: (success: (file: File) => void, failure?: (error: unknown) => void) => void;\n /** A folder entry's reader; `readEntries` yields the children in batches, then an empty one. */\n createReader?: () => {\n readEntries: (success: (entries: DropEntry[]) => void, failure?: (error: unknown) => void) => void;\n };\n}\n\n/**\n * Every file in a drop, with dropped folders walked recursively.\n *\n * Files found inside a folder carry `webkitRelativePath` (`scene/meshes/base.glb`), as the\n * files of `<input webkitdirectory>` do, so both routes give the same shape. Where the entries\n * API is missing, the drop's plain file list is returned.\n *\n * @param dataTransfer - The drop's data.\n * @returns The files, in the order the browser listed them.\n */\nexport async function collectDroppedFiles(dataTransfer: Pick<DataTransfer, \"files\" | \"items\">): Promise<File[]> {\n // Everything is read before the first `await`: a drop's data is emptied once its event\n // handler returns.\n const plain = Array.from(dataTransfer.files);\n const entries = Array.from(dataTransfer.items ?? [])\n .filter((item) => item.kind === \"file\")\n .map((item) => (typeof item.webkitGetAsEntry === \"function\" ? (item.webkitGetAsEntry() as DropEntry | null) : null));\n // No folder among them (or no entries API): the plain list is already the answer.\n if (!entries.some((entry) => entry?.isDirectory)) return plain;\n const files: File[] = [];\n for (const entry of entries) if (entry) await walkEntry(entry, files);\n return files;\n}\n\nasync function walkEntry(entry: DropEntry, out: File[]): Promise<void> {\n if (entry.isFile && entry.file) {\n const read = entry.file.bind(entry);\n const file = await new Promise<File>((resolve, reject) => read(resolve, reject));\n const path = entry.fullPath.replace(/^\\//, \"\");\n out.push(path.includes(\"/\") ? withRelativePath(file, path) : file);\n } else if (entry.isDirectory && entry.createReader) {\n const reader = entry.createReader();\n // `readEntries` returns a directory in batches (100 in Chromium) until an empty one.\n for (;;) {\n const batch = await new Promise<DropEntry[]>((resolve, reject) => reader.readEntries(resolve, reject));\n if (batch.length === 0) break;\n for (const child of batch) await walkEntry(child, out);\n }\n }\n}\n\n/**\n * The file, carrying `webkitRelativePath` — a read-only accessor on `File.prototype`,\n * shadowed here on the instance.\n */\nfunction withRelativePath(file: File, path: string): File {\n Object.defineProperty(file, \"webkitRelativePath\", { value: path, configurable: true });\n return file;\n}\n","/*\n * Opening local files: by dropping them, or through the picker.\n *\n * Both routes are always offered. A drop target alone is invisible to a keyboard and to\n * anyone who does not know it is there; a picker alone makes a folder of scenario files a\n * dozen clicks. The picker is a real `<button>`, so the component is operable without a\n * pointer.\n */\n\nimport { FolderOpen } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ChangeEvent, DragEvent, ReactNode } from \"react\";\n\nimport { Button, cn } from \"@vitavision/ui\";\n\nimport { acceptsPath, carriesFiles, collectDroppedFiles, partitionFiles } from \"./dropFiles\";\n\n/**\n * Where paths come from in a desktop shell whose native drops and dialogs yield paths, not\n * `File`s (Tauri, Electron). The app implements it over its shell's APIs; the package stays\n * shell-agnostic. See the README for a Tauri implementation.\n */\nexport interface PathSource {\n /** Opens the native picker; resolves with the chosen paths, `[]` if cancelled. */\n pick: (options: { multiple: boolean; directory: boolean; accept?: string | undefined }) => Promise<string[]>;\n /**\n * Subscribes to native drags of files over the window: `onEnter` and `onLeave` while a drag\n * hovers, `onDrop` with its paths. Returns the unsubscribe. Optional: without it, only the\n * picker offers paths.\n */\n subscribe?: (handlers: { onEnter: () => void; onLeave: () => void; onDrop: (paths: string[]) => void }) => () => void;\n}\n\n/** Props of `FileDrop`. */\nexport interface FileDropProps {\n /** Called with the accepted files of a drop or a pick (never with an empty list). */\n onFiles?: ((files: File[]) => void) | undefined;\n /**\n * The desktop route: paths from `pathSource`'s picker and native drops, filtered by\n * `accept` on their extensions. With a `pathSource`, the picker and drops go through it\n * instead of the browser's `File` route.\n */\n pathSource?: PathSource | undefined;\n /** Called with the accepted paths of a native drop or pick (never with an empty list). */\n onPaths?: ((paths: string[]) => void) | undefined;\n /** Called with the paths `accept` turned away. */\n onRejectPaths?: ((paths: string[]) => void) | undefined;\n /** Called with the files a drop or a pick brought that `accept` turned away. */\n onReject?: ((files: File[]) => void) | undefined;\n /**\n * Which files to take, as `<input accept>`: extensions (`.json`), MIME types and MIME\n * wildcards (`image/*`), comma-separated. Applied to drops as well as the picker. Default: all.\n */\n accept?: string | undefined;\n /** Take several files at once. Defaults to true; when false only the first accepted file is passed. */\n multiple?: boolean | undefined;\n /**\n * The picker chooses a folder (`webkitdirectory`) instead of files. Dropped folders are\n * walked either way; files found in a folder carry `webkitRelativePath`.\n */\n directory?: boolean | undefined;\n /**\n * Take drops anywhere in the window, showing a full-window overlay while files are dragged\n * over it; the component itself then renders only the picker button (for a header). Without\n * it, the component is an inline drop zone.\n */\n overlay?: boolean | undefined;\n /** Refuses drops and blocks the picker. */\n disabled?: boolean | undefined;\n /** The picker button's label. Defaults to \"Open files…\" (or \"Open folder…\" with `directory`). */\n buttonLabel?: string | undefined;\n /** The overlay's message. Defaults to \"Drop to open\". */\n overlayMessage?: ReactNode;\n /** The inline zone's message, before the button. Defaults to \"Drop files here, or\". */\n children?: ReactNode;\n /** Merged with the zone's (or, with `overlay`, the button's) own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A drop target plus an \"Open files…\" button over a hidden `<input type=\"file\">`.\n *\n * Inline (the default) it is a dashed zone with a message and the button, carrying\n * `data-dragging` while files are dragged over it. With `overlay` it renders only the button\n * and takes drops anywhere in the window, showing a full-window overlay (`aria-hidden`: the\n * button is the accessible route) while a drag carrying files is over the window. Only drags\n * that carry files are reacted to; text and links pass through.\n *\n * Files are filtered by `accept` on both routes (the browser applies it to neither drops nor,\n * reliably, the picker); the rest go to `onReject`. A dropped folder is walked recursively.\n *\n * In a desktop shell, pass a `pathSource`: the picker and native drops then yield paths to\n * `onPaths`, filtered by `accept` on their extensions, and the browser `File` route is off.\n */\nexport function FileDrop({\n onFiles,\n pathSource,\n onPaths,\n onRejectPaths,\n onReject,\n accept,\n multiple = true,\n directory = false,\n overlay = false,\n disabled = false,\n buttonLabel,\n overlayMessage = \"Drop to open\",\n children = \"Drop files here, or\",\n className,\n}: FileDropProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const depthRef = useRef(0);\n const [dragging, setDragging] = useState(false);\n const label = buttonLabel ?? (directory ? \"Open folder…\" : \"Open files…\");\n\n const deliver = (files: readonly File[]) => {\n const { accepted, rejected } = partitionFiles(files, accept);\n if (accepted.length > 0) onFiles?.(multiple ? accepted : accepted.slice(0, 1));\n if (rejected.length > 0) onReject?.(rejected);\n };\n const deliverPaths = (paths: readonly string[]) => {\n const accepted = paths.filter((path) => acceptsPath(path, accept));\n const rejected = paths.filter((path) => !acceptsPath(path, accept));\n if (accepted.length > 0) onPaths?.(multiple ? accepted : accepted.slice(0, 1));\n if (rejected.length > 0) onRejectPaths?.(rejected);\n };\n const deliverRef = useRef(deliver);\n const deliverPathsRef = useRef(deliverPaths);\n useEffect(() => {\n deliverRef.current = deliver;\n deliverPathsRef.current = deliverPaths;\n });\n\n // The desktop route: native drags report paths through the source, for the overlay and the\n // inline zone alike (a webview with native drag-drop on fires no DOM drop with files).\n useEffect(() => {\n if (!pathSource?.subscribe || disabled) return;\n return pathSource.subscribe({\n onEnter: () => setDragging(true),\n onLeave: () => setDragging(false),\n onDrop: (paths) => {\n setDragging(false);\n deliverPathsRef.current(paths);\n },\n });\n }, [pathSource, disabled]);\n\n // The window-wide target. `dragenter`/`dragleave` fire for every element crossed, so the\n // overlay's visibility is a depth count rather than the last event seen.\n useEffect(() => {\n if (!overlay || disabled || pathSource) return;\n const onEnter = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n depthRef.current += 1;\n setDragging(true);\n };\n const onLeave = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n depthRef.current = Math.max(0, depthRef.current - 1);\n if (depthRef.current === 0) setDragging(false);\n };\n const onOver = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (event.dataTransfer) event.dataTransfer.dropEffect = \"copy\";\n };\n const onDrop = (event: globalThis.DragEvent) => {\n if (!event.dataTransfer || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n depthRef.current = 0;\n setDragging(false);\n void collectDroppedFiles(event.dataTransfer).then((files) => deliverRef.current(files));\n };\n window.addEventListener(\"dragenter\", onEnter);\n window.addEventListener(\"dragleave\", onLeave);\n window.addEventListener(\"dragover\", onOver);\n window.addEventListener(\"drop\", onDrop);\n return () => {\n window.removeEventListener(\"dragenter\", onEnter);\n window.removeEventListener(\"dragleave\", onLeave);\n window.removeEventListener(\"dragover\", onOver);\n window.removeEventListener(\"drop\", onDrop);\n depthRef.current = 0;\n };\n }, [overlay, disabled, pathSource]);\n\n const onPick = (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.currentTarget.files ?? []);\n // Cleared so that choosing the same file again is still a change.\n event.currentTarget.value = \"\";\n if (files.length > 0) deliver(files);\n };\n\n const picker = (\n <>\n <input\n ref={(element) => {\n inputRef.current = element;\n if (element) element.webkitdirectory = directory;\n }}\n type=\"file\"\n hidden\n tabIndex={-1}\n accept={accept}\n multiple={multiple || directory}\n disabled={disabled}\n onChange={onPick}\n />\n <Button\n icon={<FolderOpen />}\n disabled={disabled}\n onClick={() => {\n if (pathSource) {\n void pathSource.pick({ multiple: multiple || directory, directory, accept }).then((paths) => {\n if (paths.length > 0) deliverPathsRef.current(paths);\n });\n return;\n }\n inputRef.current?.click();\n }}\n className={overlay ? className : undefined}\n >\n {label}\n </Button>\n </>\n );\n\n if (overlay) {\n return (\n <>\n {picker}\n {dragging && (\n <div\n aria-hidden\n data-dragging=\"\"\n className=\"pointer-events-none fixed inset-0 z-50 grid place-items-center bg-ground/80 p-8 backdrop-blur-sm\"\n >\n <div className=\"rounded-panel border-2 border-dashed border-signal bg-surface px-10 py-8 text-sm font-medium text-fg shadow-lg\">\n {overlayMessage}\n </div>\n </div>\n )}\n </>\n );\n }\n\n const zoneDrag = (event: DragEvent<HTMLDivElement>, change: 1 | -1 | 0) => {\n if (disabled || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (change === 0) {\n event.dataTransfer.dropEffect = \"copy\";\n return;\n }\n depthRef.current = Math.max(0, depthRef.current + change);\n setDragging(depthRef.current > 0);\n };\n\n return (\n <div\n data-dragging={dragging ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n onDragEnter={(event) => zoneDrag(event, 1)}\n onDragLeave={(event) => zoneDrag(event, -1)}\n onDragOver={(event) => zoneDrag(event, 0)}\n onDrop={(event) => {\n if (disabled || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n depthRef.current = 0;\n setDragging(false);\n void collectDroppedFiles(event.dataTransfer).then(deliver);\n }}\n className={cn(\n \"flex flex-col items-center justify-center gap-3 rounded-panel border-2 border-dashed border-line-strong px-6 py-8 text-center text-sm text-fg-muted transition-colors\",\n \"data-dragging:border-signal data-dragging:bg-signal/8 data-dragging:text-fg\",\n // Not `opacity-50`: the message would fall below AA. The disabled button and the quieter\n // border say it instead.\n \"data-disabled:border-line\",\n className,\n )}\n >\n <p>{children}</p>\n {picker}\n </div>\n );\n}\n","/*\n * Stepping through an ordered set, as a pure function so its edge cases (an empty set, no\n * current item, wrapping) are tested without a DOM.\n */\n\n/**\n * The index one step from `index`.\n *\n * @param length - The number of items.\n * @param index - The current index, or -1 for none.\n * @param delta - +1 for next, -1 for previous.\n * @param wrap - Wrap from the last item to the first and back.\n * @returns The next index; the first (or, stepping back, the last) item when there is no\n * current one; the same index at an end without `wrap`; `null` for an empty set.\n */\nexport function stepIndex(length: number, index: number, delta: 1 | -1, wrap = false): number | null {\n if (length <= 0) return null;\n if (index < 0 || index >= length) return delta > 0 ? 0 : length - 1;\n const next = index + delta;\n if (wrap) return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/*\n * Which item of an ordered set is current — a frame of a capture, a page of a scan — as a\n * strip of thumbnails with previous/next and `[` / `]`.\n *\n * A capture is an ordered set and a person steps through it one item at a time, which a\n * dropdown hides and a library page makes a round trip. The strip keeps the neighbours in\n * view, and the keys work from anywhere on the screen.\n */\n\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { useEffect, useRef, type ReactNode } from \"react\";\n\nimport { Button, Kbd, StatusDot, cn, focusRing, type Tone } from \"@vitavision/ui\";\n\nimport { stepIndex } from \"./sequence\";\n\n/**\n * A per-item status — \"not found\" in a batch run, \"rejected\" by a reviewer — drawn as a dot in\n * the thumbnail's corner and said in words in the item's name.\n */\nexport interface SequenceItemStatus {\n /** The dot's colour, by meaning; also the item's `data-status`. */\n tone: Tone;\n /** The status in words, appended to the item's name and tooltip: `\"frame_0003.bmp, not found\"`. */\n label: string;\n}\n\n/** One item of a `SequenceNavigator`. */\nexport interface SequenceItem {\n /** Its identity, unique in the sequence. */\n id: string;\n /** Its name: the thumbnail's alt text and tooltip. */\n label: string;\n /** A thumbnail URL, loaded lazily. Without it, the default rendering is the label. */\n thumbnail?: string | undefined;\n /** A status, drawn as a dot in the thumbnail's corner over any thumbnail rendering. */\n status?: SequenceItemStatus | undefined;\n}\n\n/** Props of `SequenceNavigator`. */\nexport interface SequenceNavigatorProps {\n /** The items, in order. */\n items: readonly SequenceItem[];\n /** The current item's id, or `null` for none. */\n value: string | null;\n /** Called with the id of the item chosen by click, by previous/next, or by `[` / `]`. */\n onValueChange: (id: string) => void;\n /** Draws an item's thumbnail, e.g. one whose URL must be fetched. Defaults to a lazy `<img>`. */\n renderThumbnail?: ((item: SequenceItem) => ReactNode) | undefined;\n /** Step with `[` and `]` from anywhere outside a text field. Defaults to true. */\n keys?: boolean | undefined;\n /** Wrap from the last item to the first. Defaults to false. */\n wrap?: boolean | undefined;\n /** Names the strip (`aria-label`). */\n \"aria-label\": string;\n /** Merged with the row's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A horizontal strip of thumbnails between previous and next buttons, with the position\n * (\"3 / 50\").\n *\n * The current thumbnail carries `aria-current=\"true\"` and `data-current`, has an outline,\n * and is scrolled into view when it changes. An item with a `status` shows a dot in its\n * corner, carries `data-status` (the tone) and is named `\"label, status\"`. `[` and `]` step\n * from anywhere outside a text field. Thumbnails load lazily, so a capture of thousands of\n * frames opens at once. The strip is as wide as its thumbnails, so previous and next stay\n * beside a short sequence; a long one scrolls.\n */\nexport function SequenceNavigator({\n items,\n value,\n onValueChange,\n renderThumbnail,\n keys = true,\n wrap = false,\n \"aria-label\": ariaLabel,\n className,\n}: SequenceNavigatorProps) {\n const index = items.findIndex((item) => item.id === value);\n const listRef = useRef<HTMLOListElement>(null);\n\n const step = (delta: 1 | -1) => {\n const next = stepIndex(items.length, index, delta, wrap);\n const item = next === null ? undefined : items[next];\n if (item && item.id !== value) onValueChange(item.id);\n };\n const stepRef = useRef(step);\n useEffect(() => {\n stepRef.current = step;\n });\n\n useEffect(() => {\n if (!keys) return;\n const onKey = (event: KeyboardEvent) => {\n if (event.metaKey || event.ctrlKey || event.altKey || isTypingTarget(event.target)) return;\n if (event.key === \"[\") stepRef.current(-1);\n else if (event.key === \"]\") stepRef.current(1);\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [keys]);\n\n useEffect(() => {\n listRef.current?.querySelector(\"[data-current]\")?.scrollIntoView({ block: \"nearest\", inline: \"nearest\" });\n }, [value]);\n\n const atStart = !wrap && index <= 0;\n const atEnd = !wrap && (index < 0 || index >= items.length - 1);\n\n return (\n <div className={cn(\"flex min-w-0 items-center gap-1.5\", className)}>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n icon={<ChevronLeft />}\n aria-label=\"Previous\"\n aria-keyshortcuts={keys ? \"[\" : undefined}\n disabled={items.length < 2 || atStart}\n onClick={() => step(-1)}\n />\n {/* The padding (and the matching scroll padding, for the current item scrolled into view)\n is the room for the current ring and the focus outline: the scroller clips at its edge. */}\n <ol ref={listRef} aria-label={ariaLabel} className=\"flex min-w-0 scroll-px-1 gap-1 overflow-x-auto p-1\">\n {items.map((item) => {\n const current = item.id === value;\n const { status } = item;\n const name = status ? `${item.label}, ${status.label}` : item.label;\n return (\n <li key={item.id} className=\"shrink-0\">\n <button\n type=\"button\"\n title={name}\n aria-label={name}\n aria-current={current ? \"true\" : undefined}\n data-current={current ? \"\" : undefined}\n data-status={status?.tone}\n onClick={() => {\n if (!current) onValueChange(item.id);\n }}\n className={cn(\n \"relative block h-10 w-14 overflow-hidden rounded-control border border-line bg-raised text-fg\",\n \"data-current:ring-2 data-current:ring-signal\",\n focusRing,\n )}\n >\n {renderThumbnail ? (\n renderThumbnail(item)\n ) : item.thumbnail ? (\n <img src={item.thumbnail} alt=\"\" loading=\"lazy\" decoding=\"async\" className=\"h-full w-full object-cover\" />\n ) : (\n <span className={cn(\"block truncate px-1 font-mono text-[10px]\", status && \"pr-3\")}>{item.label}</span>\n )}\n {status && (\n // The surface-coloured backing keeps the dot legible over any thumbnail.\n <StatusDot tone={status.tone} className=\"absolute top-0.5 right-0.5 rounded-full bg-surface p-0.5\" />\n )}\n </button>\n </li>\n );\n })}\n </ol>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n icon={<ChevronRight />}\n aria-label=\"Next\"\n aria-keyshortcuts={keys ? \"]\" : undefined}\n disabled={items.length < 2 || atEnd}\n onClick={() => step(1)}\n />\n <span className=\"shrink-0 font-mono text-xs text-fg-muted tabular-nums\">\n {index >= 0 ? index + 1 : \"–\"} / {items.length}\n </span>\n {keys && (\n <span className=\"hidden shrink-0 items-center gap-0.5 text-xs text-fg-muted sm:flex\" aria-hidden>\n <Kbd>[</Kbd>\n <Kbd>]</Kbd>\n </span>\n )}\n </div>\n );\n}\n\nfunction isTypingTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" || target.isContentEditable;\n}\n","/*\n * What each step of a `Stepper` is, as a pure function, so the rules (a blocked step cannot\n * be entered, the current step outranks every other state) are tested without a DOM.\n */\n\n/**\n * Where a step stands: `current` (the one a person is on), `blocked` (cannot be entered\n * yet; it says why), `complete` (done) or `upcoming` (not done, and open).\n */\nexport type StepState = \"current\" | \"complete\" | \"blocked\" | \"upcoming\";\n\n/** The part of a step its state depends on. */\nexport interface StepGate {\n /** Its identity, unique among the steps. */\n id: string;\n /** Why it cannot be entered yet. A step with a non-empty reason is blocked. */\n blockedBy?: string | undefined;\n /** Whether it is done. */\n complete?: boolean | undefined;\n}\n\n/** One step's state, and whether choosing it would make it current. */\nexport interface StepView {\n /** The step's id. */\n id: string;\n /** Where the step stands. */\n state: StepState;\n /** True when choosing it makes it current: it is neither blocked nor current already. */\n canActivate: boolean;\n}\n\n/**\n * Each step's state, in order.\n *\n * The step whose id is `current` is `current`, whatever else is true of it: the app put the\n * person there. Of the others, one with a `blockedBy` reason is `blocked` (even if `complete`:\n * a step can be done and then fall behind a newer gate), then `complete`, then `upcoming`.\n * Only a step that is neither current nor blocked can be activated.\n *\n * @param steps - The steps, in order.\n * @param current - The current step's id, or `null` for none.\n */\nexport function stepStates(steps: readonly StepGate[], current: string | null): StepView[] {\n return steps.map(({ id, blockedBy, complete }) => {\n const state: StepState = id === current ? \"current\" : blockedBy ? \"blocked\" : complete ? \"complete\" : \"upcoming\";\n return { id, state, canActivate: state === \"complete\" || state === \"upcoming\" };\n });\n}\n","/*\n * A gated sequence of steps — Teach, then Find, then Verify — where a step can be entered\n * only once what it depends on is in place, and says what that is.\n *\n * A disabled button would say nothing: it cannot be focused, so neither the tooltip nor a\n * screen reader can give the reason. A blocked step stays focusable, marked\n * `aria-disabled`, and carries its reason as its description.\n */\n\nimport { Check, Lock } from \"lucide-react\";\nimport { useId, useState, type ReactNode } from \"react\";\n\nimport { Tooltip, cn, focusRing } from \"@vitavision/ui\";\n\nimport { stepStates, type StepState } from \"./stepperModel\";\n\n/** One step of a `Stepper`. */\nexport interface StepperStep {\n /** Its identity, unique among the steps; the stepper's `value`. */\n id: string;\n /** Its name. */\n label: ReactNode;\n /**\n * Why it cannot be entered yet — \"Teach a model first\". A step with a reason is blocked:\n * shown, focusable and described by the reason, but not choosable.\n */\n blockedBy?: string | undefined;\n /** Marks it done (a check instead of its number). */\n complete?: boolean | undefined;\n}\n\n/** Props of `Stepper`. */\nexport interface StepperProps {\n /** The steps, in order. */\n steps: readonly StepperStep[];\n /** The current step's id, or `null` for none. Leave undefined to let the stepper keep it. */\n value?: string | null | undefined;\n /** The current step at first, when the stepper keeps it. Defaults to the first step. */\n defaultValue?: string | undefined;\n /** Called with a step's id when a person chooses a step that is neither current nor blocked. */\n onValueChange?: ((id: string) => void) | undefined;\n /** A row (the default) or a column. */\n orientation?: \"horizontal\" | \"vertical\" | undefined;\n /** Names the list of steps. */\n \"aria-label\": string;\n /** Merged with the list's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * The steps of a gated sequence as an ordered list of buttons, numbered, with the current one\n * marked (`aria-current=\"step\"`) and done ones checked. Controlled with `value` and\n * `onValueChange`, or kept by the stepper from `defaultValue`.\n *\n * A step with `blockedBy` is blocked: it keeps its Tab stop but carries `aria-disabled`, its\n * reason is its description (`aria-describedby`) and its tooltip, and choosing it does nothing.\n * Each step carries `data-state` (`current`, `complete`, `blocked` or `upcoming`), and the\n * list `data-orientation`.\n */\nexport function Stepper({\n steps,\n value,\n defaultValue,\n onValueChange,\n orientation = \"horizontal\",\n \"aria-label\": ariaLabel,\n className,\n}: StepperProps) {\n const [kept, setKept] = useState<string | null>(() => defaultValue ?? steps[0]?.id ?? null);\n const current = value === undefined ? kept : value;\n const views = stepStates(steps, current);\n const baseId = useId();\n const vertical = orientation === \"vertical\";\n\n const choose = (id: string) => {\n if (value === undefined) setKept(id);\n onValueChange?.(id);\n };\n\n return (\n <ol\n aria-label={ariaLabel}\n data-orientation={orientation}\n className={cn(\"flex\", vertical ? \"flex-col items-start\" : \"flex-wrap items-center gap-y-1\", className)}\n >\n {steps.map((step, index) => {\n const view = views[index];\n if (view === undefined) return null;\n const { state, canActivate } = view;\n const blocked = state === \"blocked\";\n const reasonId = `${baseId}-${index}-reason`;\n const button = (\n <button\n type=\"button\"\n aria-current={state === \"current\" ? \"step\" : undefined}\n aria-disabled={blocked ? true : undefined}\n aria-describedby={blocked ? reasonId : undefined}\n data-state={state}\n onClick={() => {\n if (canActivate) choose(step.id);\n }}\n className={cn(\n \"flex items-center gap-2 rounded-control px-1.5 py-1 text-sm transition-colors\",\n state === \"current\" ? \"font-medium text-fg\" : \"text-fg-muted\",\n canActivate && \"hover:text-fg\",\n blocked && \"cursor-not-allowed\",\n focusRing,\n )}\n >\n <StepMarker state={state} number={index + 1} />\n <span>{step.label}</span>\n </button>\n );\n return (\n <li key={step.id} className={cn(\"flex\", vertical ? \"flex-col items-start\" : \"items-center\")}>\n {index > 0 && <span aria-hidden className={cn(\"bg-line-strong\", vertical ? \"ml-4 h-3 w-px\" : \"mx-1 h-px w-6\")} />}\n {blocked ? <Tooltip content={step.blockedBy}>{button}</Tooltip> : button}\n {blocked && (\n <span id={reasonId} className=\"sr-only\">\n {step.blockedBy}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n );\n}\n\n/** The step's number in a circle; a check when done, a lock when blocked. Decorative. */\nfunction StepMarker({ state, number }: { state: StepState; number: number }) {\n return (\n <span\n aria-hidden\n className={cn(\n \"grid size-5 shrink-0 place-items-center rounded-full border font-mono text-[11px] tabular-nums [&>svg]:size-3\",\n state === \"current\" && \"border-signal bg-signal text-signal-fg\",\n state === \"complete\" && \"border-signal text-signal\",\n state === \"blocked\" && \"border-line-strong text-fg-muted\",\n state === \"upcoming\" && \"border-line-strong text-fg-muted\",\n )}\n >\n {state === \"complete\" ? <Check /> : state === \"blocked\" ? <Lock /> : number}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,YAAY,MAAgB,QAAwB;CAClE,MAAM,KAAK,OAAO,SAAS,WAAW,OAAQ,OAAO,WAAW,IAAI,IAAI,MAAO;CAC/E,OAAO,OAAO,SAAS,EAAE,IAAI,KAAK,IAAI,GAAG,EAAE,IAAI;AACjD;;;;;;;;;;;AAYA,SAAgB,cAAc,QAAgB,UAAoB,GAAG,UAAoB,QAAQ,cAAc,OAA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,GAAG,MAAM;GACpC,MAAM,SACJ,qBAAC,UAAD;IACE,MAAK;IACL,gBAAc,UAAU,YAAY,SAAS,KAAA;IAC7C,iBAAe,UAAU,OAAO,KAAA;IAChC,oBAAkB,UAAU,WAAW,KAAA;IACvC,cAAY;IACZ,eAAe;KACb,IAAI,aAAa,OAAO,KAAK,EAAE;IACjC;IACA,WAAW,GACT,iFACA,UAAU,YAAY,wBAAwB,iBAC9C,eAAe,iBACf,WAAW,sBACX,SACF;IAfF,UAAA,CAiBE,oBAAC,YAAD;KAAmB;KAAO,QAAQ,QAAQ;IAAI,CAAA,GAC9C,oBAAC,QAAD,EAAA,UAAO,KAAK,MAAY,CAAA,CAClB;;GAEV,OACE,qBAAC,MAAD;IAAkB,WAAW,GAAG,QAAQ,WAAW,yBAAyB,cAAc;IAA1F,UAAA;KACG,QAAQ,KAAK,oBAAC,QAAD;MAAM,eAAA;MAAY,WAAW,GAAG,kBAAkB,WAAW,kBAAkB,eAAe;KAAI,CAAA;KAC/G,UAAU,oBAAC,SAAD;MAAS,SAAS,KAAK;MAAY,UAAA;KAAgB,CAAA,IAAI;KACjE,WACC,oBAAC,QAAD;MAAM,IAAI;MAAU,WAAU;MAC3B,UAAA,KAAK;KACF,CAAA;IAEN;GARK,GAAA,KAAK,EAQV;EAER,CAAC;CACC,CAAA;AAER;;AAGA,SAAS,WAAW,EAAE,OAAO,UAAgD;CAC3E,OACE,oBAAC,QAAD;EACE,eAAA;EACA,WAAW,GACT,iHACA,UAAU,aAAa,0CACvB,UAAU,cAAc,6BACxB,UAAU,aAAa,oCACvB,UAAU,cAAc,kCAC1B;EAEC,UAAA,UAAU,aAAa,oBAAC,OAAD,CAAQ,CAAA,IAAI,UAAU,YAAY,oBAAC,MAAD,CAAO,CAAA,IAAI;CACjE,CAAA;AAEV"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/components/splitSize.ts","../src/components/SplitPane.tsx","../src/components/AppShell.tsx","../src/components/StatusBar.tsx","../src/components/NavRail.tsx","../src/components/treeModel.ts","../src/components/TreeView.tsx","../src/components/playhead.ts","../src/components/usePlayback.ts","../src/components/PlaybackBar.tsx","../src/components/dropFiles.ts","../src/components/FileDrop.tsx","../src/components/sequence.ts","../src/components/SequenceNavigator.tsx","../src/components/matrixModel.ts","../src/components/SequenceMatrix.tsx","../src/components/stepperModel.ts","../src/components/Stepper.tsx"],"sourcesContent":["/*\n * The arithmetic behind `SplitPane`: resolving sizes given in pixels or percent, clamping a\n * drag or a key press to the pane's limits, and remembering a size across reloads.\n *\n * Kept out of the component so every rule — which key moves the divider which way, where a\n * collapsible pane snaps shut — is tested without a DOM.\n */\n\n/**\n * A pane size: CSS pixels as a number, or a share of the split's length as a percentage\n * string (`\"30%\"`).\n */\nexport type PaneSize = number | `${number}%`;\n\n/** The limits a `SplitPane`'s sized pane is held to, resolved to pixels. */\nexport interface SplitLimits {\n /** The smallest open size, in pixels. */\n min: number;\n /** The largest size, in pixels. */\n max: number;\n /** Whether the pane may close to 0 below `min`. */\n collapsible: boolean;\n}\n\n/**\n * A size in pixels.\n *\n * @param size - Pixels, or a percentage of `length`.\n * @param length - The split's length along its axis, in pixels.\n * @returns The size in pixels (never negative).\n */\nexport function resolveSize(size: PaneSize, length: number): number {\n const px = typeof size === \"number\" ? size : (Number.parseFloat(size) / 100) * length;\n return Number.isFinite(px) ? Math.max(0, px) : 0;\n}\n\n/**\n * The limits in pixels for a split of `length`. `max` never exceeds `length`, and `min`\n * never exceeds `max`.\n *\n * @param length - The split's length along its axis, in pixels.\n * @param minSize - The smallest open size. Defaults to 0.\n * @param maxSize - The largest size. Defaults to the whole length.\n * @param collapsible - Whether the pane may close below `minSize`.\n * @returns The resolved limits.\n */\nexport function resolveLimits(length: number, minSize: PaneSize = 0, maxSize: PaneSize = \"100%\", collapsible = false): SplitLimits {\n const max = Math.min(resolveSize(maxSize, length), Math.max(0, length));\n const min = Math.min(resolveSize(minSize, length), max);\n return { min, max, collapsible };\n}\n\n/**\n * Hold a proposed size to the limits. A collapsible pane dragged below half its minimum\n * snaps shut (0); between half the minimum and the minimum it stays at the minimum.\n *\n * @param size - The proposed size, in pixels.\n * @param limits - The resolved limits.\n * @returns The size to apply, in pixels, rounded to whole pixels.\n */\nexport function clampSize(size: number, limits: SplitLimits): number {\n if (limits.collapsible && size < limits.min / 2) return 0;\n return Math.round(Math.min(limits.max, Math.max(limits.min, size)));\n}\n\n/** Which way a `SplitPane` lays out its two panes. */\nexport type SplitOrientation = \"horizontal\" | \"vertical\";\n\n/** Which of the two panes carries the explicit size; the other takes the rest. */\nexport type SizedPane = \"start\" | \"end\";\n\n/** What a key press on the divider asks for. */\nexport type SplitKeyAction = { type: \"resize\"; size: number } | { type: \"toggle-collapse\" };\n\n/**\n * The divider's keyboard (the WAI-ARIA window-splitter pattern).\n *\n * The arrow keys along the split's axis move the divider the way they point — so the sized\n * pane grows or shrinks depending on which side it is on — by `step`, or four steps with\n * Shift. Home gives the sized pane its minimum, End its maximum, and Enter collapses or\n * restores a collapsible pane.\n *\n * @param key - `KeyboardEvent.key`.\n * @param shift - Whether Shift is held.\n * @param size - The sized pane's current size, in pixels.\n * @param options - The layout, the step in pixels and the resolved limits.\n * @returns The action, or `null` when the key is not the divider's.\n */\nexport function splitKeyAction(\n key: string,\n shift: boolean,\n size: number,\n options: { orientation: SplitOrientation; sizedPane: SizedPane; step: number; limits: SplitLimits },\n): SplitKeyAction | null {\n const { orientation, sizedPane, step, limits } = options;\n const [back, forward] = orientation === \"horizontal\" ? [\"ArrowLeft\", \"ArrowRight\"] : [\"ArrowUp\", \"ArrowDown\"];\n const grow = sizedPane === \"start\" ? 1 : -1;\n const delta = shift ? step * 4 : step;\n\n switch (key) {\n case forward:\n return { type: \"resize\", size: clampOpen(size + grow * delta, limits) };\n case back:\n return { type: \"resize\", size: clampOpen(size - grow * delta, limits) };\n case \"Home\":\n return { type: \"resize\", size: Math.round(limits.min) };\n case \"End\":\n return { type: \"resize\", size: Math.round(limits.max) };\n case \"Enter\":\n return limits.collapsible ? { type: \"toggle-collapse\" } : null;\n default:\n return null;\n }\n}\n\n/** A key step never snaps a pane shut (that is Enter's job): clamp to the open range. */\nfunction clampOpen(size: number, limits: SplitLimits): number {\n return Math.round(Math.min(limits.max, Math.max(limits.min, size)));\n}\n\n/**\n * The size stored under `key`, if any.\n *\n * @param key - The `localStorage` key.\n * @returns The stored size in pixels, or `null` when nothing valid is stored or storage\n * cannot be read (private browsing, the server).\n */\nexport function readStoredSize(key: string): number | null {\n try {\n const raw = window.localStorage.getItem(key);\n if (raw === null) return null;\n const value = Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Remember a size under `key`. Failures (storage full, disabled, the server) are ignored: a\n * size that is not remembered is not worth an error.\n *\n * @param key - The `localStorage` key.\n * @param size - The size in pixels.\n */\nexport function writeStoredSize(key: string, size: number): void {\n try {\n window.localStorage.setItem(key, String(Math.round(size)));\n } catch {\n // Nothing to do: the size simply is not remembered.\n }\n}\n","/*\n * Two panes and the divider between them.\n *\n * A studio screen is a handful of permanent surfaces — a tree, a viewport, an inspector, a\n * timeline — whose relative size is the user's decision, not the layout's. The divider is\n * therefore a real control: draggable, operable from the keyboard (the WAI-ARIA\n * window-splitter pattern), announced with its position, and remembered across reloads\n * when asked to be.\n *\n * One pane carries the size and the other takes the rest, so nesting composes: the rest of\n * one split is simply another split. `AppShell` builds its side panels exactly that way.\n */\n\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\n\nimport { cn, focusRing } from \"@vitavision/ui\";\n\nimport {\n type PaneSize,\n type SizedPane,\n type SplitOrientation,\n clampSize,\n readStoredSize,\n resolveLimits,\n resolveSize,\n splitKeyAction,\n writeStoredSize,\n} from \"./splitSize\";\n\n/** Props of `SplitPane`. */\nexport interface SplitPaneProps {\n /**\n * The two panes, in reading order (left then right, or top then bottom). Exactly two;\n * nest another `SplitPane` in either for more.\n */\n children: readonly [ReactNode, ReactNode];\n /**\n * `horizontal` (the default) lays the panes side by side with a vertical divider;\n * `vertical` stacks them with a horizontal one.\n */\n orientation?: SplitOrientation | undefined;\n /** Which pane carries the size; the other takes the rest. Defaults to `start`. */\n sizedPane?: SizedPane | undefined;\n /** The sized pane's size in pixels, controlled. Pair with `onSizeChange`. */\n size?: number | undefined;\n /** The initial size when uncontrolled: pixels or a percentage. Defaults to `\"50%\"`. */\n defaultSize?: PaneSize | undefined;\n /** Called with the new size in pixels on every drag move and key press (0 when collapsed). */\n onSizeChange?: ((size: number) => void) | undefined;\n /** The sized pane's smallest open size: pixels or a percentage. Defaults to 0. */\n minSize?: PaneSize | undefined;\n /** The sized pane's largest size: pixels or a percentage. Defaults to `\"100%\"`. */\n maxSize?: PaneSize | undefined;\n /**\n * Lets the sized pane close: dragging it below half its minimum snaps it shut, and Enter\n * on the divider collapses it or restores the last open size.\n */\n collapsible?: boolean | undefined;\n /** How far one arrow-key press moves the divider, in pixels (four times with Shift). Defaults to 16. */\n step?: number | undefined;\n /**\n * Remember the size under this `localStorage` key, and start from it. Uncontrolled only:\n * a controlled split's size is the caller's to keep.\n */\n storageKey?: string | undefined;\n /** Names the divider for assistive technology. Defaults to \"Resize panes\". */\n \"aria-label\"?: string | undefined;\n /** Merged with the split's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Two panes with a draggable, keyboard-operable divider between them.\n *\n * The divider is a `role=\"separator\"` focusable control carrying `aria-valuenow` (the sized\n * pane's size in pixels), `aria-valuemin`/`aria-valuemax` and `aria-controls` (the sized\n * pane). Arrow keys along the axis move it by `step` (Shift: four steps), Home/End give the\n * sized pane its minimum/maximum, Enter collapses or restores a `collapsible` pane. Dragging\n * uses pointer capture, so the drag survives the pointer leaving the divider.\n *\n * Fills its container (`h-full w-full`), so it nests. State is exposed as `data-orientation`\n * on the root, `data-dragging` on the root and the divider while a drag is in progress, and\n * `data-collapsed` on the root and the sized pane while it is closed.\n */\nexport function SplitPane({\n children,\n orientation = \"horizontal\",\n sizedPane = \"start\",\n size: controlledSize,\n defaultSize = \"50%\",\n onSizeChange,\n minSize = 0,\n maxSize = \"100%\",\n collapsible = false,\n step = 16,\n storageKey,\n \"aria-label\": ariaLabel = \"Resize panes\",\n className,\n}: SplitPaneProps) {\n const paneId = useId();\n const horizontal = orientation === \"horizontal\";\n const [length, setLength] = useState<number | null>(null);\n const [internalSize, setInternalSize] = useState<number | null>(null);\n const [dragging, setDragging] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n // The drag in progress: where it started, and the size it has reached. The reached size is\n // kept here, not read back from state, because a pointer move's update is rendered at\n // continuous priority and may not have landed when the pointer is released.\n const dragRef = useRef<{ origin: number; start: number; length: number; reached: number } | null>(null);\n const lastOpenRef = useRef<number | null>(null);\n\n const limits = length === null ? null : resolveLimits(length, minSize, maxSize, collapsible);\n const size =\n controlledSize ?? internalSize ?? (length === null || limits === null ? null : clampSize(resolveSize(defaultSize, length), limits));\n const collapsed = size === 0;\n const controlled = controlledSize !== undefined;\n\n /*\n * Measure the split along its axis — synchronously on attach, so the first paint has the\n * limits, then on every resize — and pick up a remembered size. A callback ref rather than\n * an effect: the subscription lives exactly as long as the element.\n */\n const attach = useCallback(\n (element: HTMLDivElement | null) => {\n rootRef.current = element;\n if (!element) return;\n const measure = () => {\n const rect = element.getBoundingClientRect();\n setLength(horizontal ? rect.width : rect.height);\n };\n measure();\n if (storageKey !== undefined && !controlled) {\n const stored = readStoredSize(storageKey);\n if (stored !== null) setInternalSize(stored);\n }\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n },\n [horizontal, storageKey, controlled],\n );\n\n /** The live length and limits, measured now (a drag or a key press must not use stale ones). */\n const measureNow = () => {\n const element = rootRef.current;\n const rect = element?.getBoundingClientRect();\n const now = rect ? (horizontal ? rect.width : rect.height) : (length ?? 0);\n return { length: now, limits: resolveLimits(now, minSize, maxSize, collapsible) };\n };\n\n /** Take a new size: state, the caller, and (on `commit`) storage. `changed` defaults to a comparison with the rendered size. */\n const apply = (next: number, commit: boolean, changed = next !== size) => {\n if (next > 0) lastOpenRef.current = next;\n if (!controlled) setInternalSize(next);\n if (changed) onSizeChange?.(next);\n if (commit && storageKey !== undefined && !controlled) {\n writeStoredSize(storageKey, next);\n }\n };\n\n const coordinate = (event: ReactPointerEvent) => (horizontal ? event.clientX : event.clientY);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.preventDefault();\n const { length: now } = measureNow();\n const current = size ?? 0;\n dragRef.current = { origin: coordinate(event), start: current, length: now, reached: current };\n event.currentTarget.setPointerCapture(event.pointerId);\n event.currentTarget.focus();\n setDragging(true);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (drag === null) return;\n const delta = (coordinate(event) - drag.origin) * (sizedPane === \"start\" ? 1 : -1);\n const next = clampSize(drag.start + delta, resolveLimits(drag.length, minSize, maxSize, collapsible));\n if (next === drag.reached) return;\n drag.reached = next;\n // Compared with the drag's own last size above: the rendered one may lag behind.\n apply(next, false, true);\n };\n\n const endDrag = (event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (drag === null) return;\n dragRef.current = null;\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n setDragging(false);\n if (drag.reached > 0) lastOpenRef.current = drag.reached;\n if (storageKey !== undefined && !controlled) writeStoredSize(storageKey, drag.reached);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const { limits: now } = measureNow();\n const current = size ?? 0;\n const action = splitKeyAction(event.key, event.shiftKey, current, {\n orientation,\n sizedPane,\n step,\n limits: now,\n });\n if (action === null) return;\n event.preventDefault();\n if (action.type === \"resize\") {\n apply(action.size, true);\n } else if (current > 0) {\n lastOpenRef.current = current;\n apply(0, true);\n } else {\n apply(clampSize(lastOpenRef.current ?? now.min, { ...now, collapsible: false }), true);\n }\n };\n\n // Before the first measurement (and on the server) the pane is sized by CSS alone, from\n // the default; afterwards by the measured size. The limits stay in CSS too, so a window\n // resize never pushes the pane outside them between two measurements.\n const basis = size !== null ? `${size}px` : typeof defaultSize === \"number\" ? `${defaultSize}px` : defaultSize;\n const cssSize = (value: PaneSize) => (typeof value === \"number\" ? `${value}px` : value);\n const sizedStyle: CSSProperties = {\n flex: `0 0 ${basis}`,\n ...(collapsed\n ? {}\n : horizontal\n ? { minWidth: cssSize(minSize), maxWidth: cssSize(maxSize) }\n : { minHeight: cssSize(minSize), maxHeight: cssSize(maxSize) }),\n };\n\n const [first, second] = children;\n const paneClasses = \"relative min-h-0 min-w-0 overflow-hidden\";\n const sized = (\n <div\n id={paneId}\n style={sizedStyle}\n className={paneClasses}\n data-collapsed={collapsed ? \"\" : undefined}\n // A closed pane keeps its content mounted (a tree keeps its expansion), but nothing in\n // it may take focus or be read out.\n inert={collapsed}\n >\n {sizedPane === \"start\" ? first : second}\n </div>\n );\n const rest = <div className={cn(paneClasses, \"flex-1 basis-0\")}>{sizedPane === \"start\" ? second : first}</div>;\n\n return (\n <div\n ref={attach}\n data-orientation={orientation}\n data-dragging={dragging ? \"\" : undefined}\n data-collapsed={collapsed ? \"\" : undefined}\n className={cn(\n \"flex h-full min-h-0 w-full min-w-0\",\n horizontal ? \"flex-row\" : \"flex-col\",\n dragging && (horizontal ? \"cursor-col-resize select-none\" : \"cursor-row-resize select-none\"),\n className,\n )}\n >\n {sizedPane === \"start\" ? sized : rest}\n <div\n role=\"separator\"\n tabIndex={0}\n aria-label={ariaLabel}\n // The separator's own orientation is across the split: side-by-side panes are divided\n // by a vertical line.\n aria-orientation={horizontal ? \"vertical\" : \"horizontal\"}\n aria-controls={paneId}\n aria-valuenow={size === null ? undefined : Math.round(size)}\n aria-valuemin={limits === null ? undefined : collapsible ? 0 : Math.round(limits.min)}\n aria-valuemax={limits === null ? undefined : Math.round(limits.max)}\n data-dragging={dragging ? \"\" : undefined}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={onKeyDown}\n className={cn(\n // A 1px rule with a wider invisible hit area on either side of it.\n \"relative z-10 shrink-0 touch-none bg-line transition-colors\",\n \"before:absolute before:content-['']\",\n horizontal\n ? \"w-px cursor-col-resize before:inset-y-0 before:-right-1 before:-left-1\"\n : \"h-px cursor-row-resize before:inset-x-0 before:-top-1 before:-bottom-1\",\n \"hover:bg-signal data-dragging:bg-signal\",\n focusRing,\n )}\n />\n {sizedPane === \"start\" ? rest : sized}\n </div>\n );\n}\n","/*\n * The frame of a studio app: a header across the top, a main surface, optional side panels\n * either side of it, and an optional strip along the bottom.\n *\n * `@vitavision/ui` deliberately has no opinion on how an app fills the viewport — a page\n * scrolls. A studio is the other kind of screen: every surface is permanent, nothing scrolls\n * but the insides of panels, and the side panels are resized by hand. This is that frame,\n * built from `SplitPane`, and nothing more: no routing, no menus, no state of its own beyond\n * the panel sizes it is asked to remember.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { cn } from \"@vitavision/ui\";\n\nimport { SplitPane } from \"./SplitPane\";\nimport type { PaneSize } from \"./splitSize\";\n\n/** How one side panel of an `AppShell` is sized. */\nexport interface SidePanelSize {\n /** The initial width: pixels or a percentage. */\n defaultSize?: PaneSize | undefined;\n /** The narrowest the panel may be dragged. */\n minSize?: PaneSize | undefined;\n /** The widest the panel may be dragged. */\n maxSize?: PaneSize | undefined;\n /** Lets the panel close (drag it under half its minimum, or Enter on its divider). */\n collapsible?: boolean | undefined;\n}\n\n/** Props of `AppShell`. */\nexport interface AppShellProps {\n /** The top bar: the app's name, the file actions, the theme toggle. */\n header?: ReactNode;\n /**\n * A fixed-width column at the far left, outside the resizable panels: an icon rail of\n * workspaces, such as a `NavRail`. It takes its content's width and is a `<nav>` named by\n * `railLabel`.\n */\n rail?: ReactNode;\n /** Names the rail's landmark (`<nav>`). Defaults to \"Workspaces\". */\n railLabel?: string | undefined;\n /** The panel left of the main surface — a navigator such as a `TreeView`. */\n left?: ReactNode;\n /** The main surface — the viewport. Always present. */\n main: ReactNode;\n /** The panel right of the main surface — an inspector. */\n right?: ReactNode;\n /** The strip along the bottom, across the whole width — a `PlaybackBar`, a `StatusBar`. */\n bottom?: ReactNode;\n /** Names the left panel's landmark (`<aside>`). Defaults to \"Navigator\". */\n leftLabel?: string | undefined;\n /** Names the right panel's landmark (`<aside>`). Defaults to \"Inspector\". */\n rightLabel?: string | undefined;\n /** The left panel's sizing. Defaults to 280 px, 180 px to 50%. */\n leftSize?: SidePanelSize | undefined;\n /** The right panel's sizing. Defaults to 320 px, 220 px to 50%. */\n rightSize?: SidePanelSize | undefined;\n /**\n * Remember the side panels' widths in `localStorage`, under `<storageKey>:left` and\n * `<storageKey>:right`.\n */\n storageKey?: string | undefined;\n /** Merged with the shell's own classes through `cn` — override `h-dvh` to embed it. */\n className?: string | undefined;\n}\n\nconst LEFT_DEFAULTS = { defaultSize: 280, minSize: 180, maxSize: \"50%\" } as const;\nconst RIGHT_DEFAULTS = { defaultSize: 320, minSize: 220, maxSize: \"50%\" } as const;\n\n/**\n * The full-viewport frame of a studio app: `header` across the top, then `rail` | `left` |\n * `main` | `right` with resizable side panels and a fixed-width rail, and `bottom` across the\n * foot. Every slot but `main` is optional, and an absent slot takes no space.\n *\n * Landmarks: the header is a `<header>`, the rail a `<nav>` named by `railLabel`, the main\n * surface a `<main>`, the side panels `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main\n * surface by a `SplitPane` divider (drag, or focus it and use the arrow keys). Only the\n * insides of the panels scroll; the shell itself is fixed to the viewport (`h-dvh`).\n */\nexport function AppShell({\n header,\n rail,\n railLabel = \"Workspaces\",\n left,\n main,\n right,\n bottom,\n leftLabel = \"Navigator\",\n rightLabel = \"Inspector\",\n leftSize,\n rightSize,\n storageKey,\n className,\n}: AppShellProps) {\n const leftSizing = { ...LEFT_DEFAULTS, ...leftSize };\n const rightSizing = { ...RIGHT_DEFAULTS, ...rightSize };\n const hasLeft = left !== undefined && left !== null && left !== false;\n const hasRight = right !== undefined && right !== null && right !== false;\n const hasRail = rail !== undefined && rail !== null && rail !== false;\n\n const mainSurface = <main className=\"relative h-full min-h-0 min-w-0 overflow-hidden\">{main}</main>;\n\n const withRight = hasRight ? (\n <SplitPane\n sizedPane=\"end\"\n {...rightSizing}\n storageKey={storageKey === undefined ? undefined : `${storageKey}:right`}\n aria-label={`Resize ${rightLabel.toLowerCase()}`}\n >\n {mainSurface}\n <aside aria-label={rightLabel} className=\"h-full overflow-auto bg-surface\">\n {right}\n </aside>\n </SplitPane>\n ) : (\n mainSurface\n );\n\n const middle = hasLeft ? (\n <SplitPane\n sizedPane=\"start\"\n {...leftSizing}\n storageKey={storageKey === undefined ? undefined : `${storageKey}:left`}\n aria-label={`Resize ${leftLabel.toLowerCase()}`}\n >\n <aside aria-label={leftLabel} className=\"h-full overflow-auto bg-surface\">\n {left}\n </aside>\n {withRight}\n </SplitPane>\n ) : (\n withRight\n );\n\n return (\n <div className={cn(\"grid h-dvh w-full grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden bg-ground text-fg\", className)}>\n {header ? <header className=\"min-w-0 border-b border-line bg-surface\">{header}</header> : <div aria-hidden />}\n {hasRail ? (\n <div className=\"flex min-h-0 min-w-0\">\n <nav aria-label={railLabel} className=\"h-full shrink-0 overflow-y-auto border-r border-line bg-surface\">\n {rail}\n </nav>\n <div className=\"min-h-0 min-w-0 flex-1\">{middle}</div>\n </div>\n ) : (\n <div className=\"min-h-0 min-w-0\">{middle}</div>\n )}\n {bottom ? <div className=\"min-w-0 border-t border-line bg-surface\">{bottom}</div> : <div aria-hidden />}\n </div>\n );\n}\n","/*\n * The status line along the foot of a studio app: what the app is doing and what it is\n * showing — the duration of the last operation, the current frame, the model in use.\n *\n * Studio apps each grew one, and each placed, sized and spaced its facts differently. This is\n * the one line, built from `ReadoutStrip`, so the facts read like the readouts everywhere else:\n * mono, quiet labels, separated by a dot.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { ReadoutStrip, cn, type ReadoutItem } from \"@vitavision/ui\";\n\n/** Props of `StatusBar`. */\nexport interface StatusBarProps {\n /** The facts at the left end, in order. Items whose `value` is `null` or `undefined` are skipped. */\n start?: ReadoutItem[] | undefined;\n /** The facts at the right end, in order. Items whose `value` is `null` or `undefined` are skipped. */\n end?: ReadoutItem[] | undefined;\n /** Drawn between the two ends, e.g. a `ProgressBar` while an operation runs. */\n children?: ReactNode;\n /** Names the bar. Defaults to \"Status\". */\n \"aria-label\"?: string | undefined;\n /**\n * Announce changes to the bar's content politely (`role=\"status\"`) instead of leaving it a\n * plain named group. Defaults to false.\n */\n live?: boolean | undefined;\n /** Merged with the bar's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * One 24 px line of facts for `AppShell`'s `bottom` slot: a `ReadoutStrip` of `start` items at\n * the left end, one of `end` items at the right end, and `children` between them.\n *\n * It is a `role=\"group\"` named by `aria-label` (\"Status\"). With `live` it is a\n * `role=\"status\"` instead (a polite live region, and `data-live`), so a screen reader\n * announces what changes in it: use that for facts worth hearing when they change (an\n * operation finished), not for ones that change many times a second. The line does not wrap;\n * keep it to a few short facts.\n */\nexport function StatusBar({ start, end, children, \"aria-label\": ariaLabel = \"Status\", live = false, className }: StatusBarProps) {\n const hasChildren = children !== undefined && children !== null && children !== false;\n return (\n <div\n role={live ? \"status\" : \"group\"}\n aria-label={ariaLabel}\n aria-live={live ? \"polite\" : undefined}\n data-live={live ? \"\" : undefined}\n className={cn(\"flex h-6 min-w-0 items-center gap-3 overflow-hidden px-3\", className)}\n >\n {start && <ReadoutStrip items={start} className={STRIP} />}\n {hasChildren && <div className=\"flex min-w-0 flex-1 items-center gap-2\">{children}</div>}\n {end && <ReadoutStrip items={end} className={cn(STRIP, \"ml-auto\")} />}\n </div>\n );\n}\n\n/** One line: the strip's own wrapping would push the second line out of a 24 px bar. */\nconst STRIP = \"shrink-0 flex-nowrap whitespace-nowrap\";\n","/*\n * The workspaces of a studio app as a column of icons down its left edge: Library, Teach,\n * Inspect. One is current; choosing another swaps the screen.\n *\n * Each item is a button, or — through `asChild` — the app's own link element, so a router's\n * `<Link>` keeps client-side navigation and this package never imports a router.\n */\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useId,\n useState,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Tooltip, cn, focusRing } from \"@vitavision/ui\";\n\n/** How a `NavRail` shows its items' labels. */\nexport type NavRailLabels = \"visible\" | \"tooltip\";\n\n/** Props of `NavRail`. */\nexport interface NavRailProps {\n /** The current item's `value`, or `null` for none. Leave undefined to let the rail keep it. */\n value?: string | null | undefined;\n /** The current item at first, when the rail keeps it (`value` undefined). */\n defaultValue?: string | undefined;\n /** Called with an item's `value` when a person chooses an item other than the current one. */\n onValueChange?: ((value: string) => void) | undefined;\n /**\n * `\"visible\"` (the default) sets each label under its icon; `\"tooltip\"` draws icon-only\n * buttons and shows the label in a tooltip on hover or focus.\n */\n labels?: NavRailLabels | undefined;\n /** The `NavRailItem`s, in order. */\n children: ReactNode;\n /** Merged with the list's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/** Props of `NavRailItem`. */\nexport interface NavRailItemProps {\n /** Identifies the item to the rail's `value`. Unique within the rail. */\n value: string;\n /** The item's name: its text under the icon, or its tooltip and accessible name. */\n label: string;\n /** The item's icon, decorative (`aria-hidden`): the label carries the meaning. */\n icon: ReactNode;\n /**\n * A mark on the icon's corner: a number is drawn as a count (over 99 as \"99+\"), anything\n * else as given. It describes the item (`aria-describedby`); it is not part of its name.\n */\n badge?: ReactNode | number;\n /** Shown but not choosable. A link item gets `aria-disabled` and its clicks are cancelled. */\n disabled?: boolean | undefined;\n /**\n * Render onto the one child element — a router's `<Link to=\"…\" />` or an `<a href>` —\n * instead of a `<button>`. Give the child without content: the icon and label become its\n * children. Its own `className` is kept beside the item's, and its own `onClick` runs first;\n * calling `event.preventDefault()` there keeps the item from being chosen.\n */\n asChild?: boolean | undefined;\n /** With `asChild`, the one element to render as. */\n children?: ReactElement | undefined;\n /** Merged with the item's own classes through `cn`. */\n className?: string | undefined;\n}\n\ninterface NavRailState {\n value: string | null;\n labels: NavRailLabels;\n choose: (value: string) => void;\n}\n\nconst NavRailContext = createContext<NavRailState | null>(null);\n\n/**\n * A vertical rail of workspaces: `NavRailItem`s as a list of buttons (or the app's links, via\n * `asChild`), one of them current. Controlled with `value` and `onValueChange`, or kept by the\n * rail from `defaultValue`.\n *\n * The current item carries `aria-current=\"page\"` and `data-state=\"active\"` (the others\n * `\"inactive\"`). Every item is its own Tab stop. The rail is a plain list with no landmark of\n * its own: `AppShell`'s `rail` slot is already a named `<nav>`, so elsewhere wrap it in a\n * `<nav aria-label=\"…\">`.\n */\nexport function NavRail({ value, defaultValue, onValueChange, labels = \"visible\", children, className }: NavRailProps) {\n const [kept, setKept] = useState<string | null>(defaultValue ?? null);\n const current = value === undefined ? kept : value;\n const choose = (next: string) => {\n if (next === current) return;\n if (value === undefined) setKept(next);\n onValueChange?.(next);\n };\n\n return (\n <NavRailContext value={{ value: current, labels, choose }}>\n <ul data-labels={labels} className={cn(\"flex flex-col items-center gap-1 p-1.5\", className)}>\n {children}\n </ul>\n </NavRailContext>\n );\n}\n\n/**\n * One workspace of a `NavRail`: an icon over its label, or an icon-only button with the label\n * in a tooltip (the rail's `labels`). A `<button>` by default; with `asChild`, the one child\n * element (the app's link) takes the item's look, `aria-current` and click.\n */\nexport function NavRailItem({ value, label, icon, badge, disabled = false, asChild = false, children, className }: NavRailItemProps) {\n const rail = use(NavRailContext);\n if (rail === null) throw new Error(\"NavRailItem must be rendered inside a NavRail.\");\n const badgeId = useId();\n\n const active = rail.value === value;\n const iconOnly = rail.labels === \"tooltip\";\n const hasBadge = badge !== undefined && badge !== null && badge !== false;\n\n const content = (\n <>\n <span aria-hidden className=\"relative grid place-items-center [&>svg]:size-4.5\">\n {icon}\n {hasBadge && (\n <span\n id={badgeId}\n data-badge=\"\"\n className={cn(\n \"absolute -top-1.5 left-[calc(100%-0.375rem)]\",\n typeof badge === \"number\" &&\n \"min-w-4 rounded-full bg-signal px-1 text-center font-mono text-[10px] leading-4 text-signal-fg tabular-nums\",\n )}\n >\n {typeof badge === \"number\" ? formatCount(badge) : badge}\n </span>\n )}\n </span>\n {!iconOnly && <span className=\"max-w-full truncate text-[10px] leading-tight\">{label}</span>}\n </>\n );\n\n const shared = {\n \"aria-current\": active ? (\"page\" as const) : undefined,\n \"aria-label\": iconOnly ? label : undefined,\n \"aria-describedby\": hasBadge ? badgeId : undefined,\n \"data-state\": active ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : undefined,\n };\n const classes = cn(\n \"relative flex flex-col items-center justify-center gap-0.5 rounded-control text-fg-muted transition-colors\",\n iconOnly ? \"size-9\" : \"w-14 px-1 py-1.5\",\n active ? \"bg-signal/12 text-fg [&_svg]:text-signal\" : \"hover:bg-raised hover:text-fg\",\n disabled && \"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-fg-muted\",\n focusRing,\n );\n\n let item: ReactElement;\n if (asChild && isValidElement<ChildProps>(children)) {\n const own = children.props;\n // `@vitavision/ui` keeps its Slot to itself, and this package takes no Radix dependency of\n // its own: the one child element is cloned with the item's props merged in.\n // oxlint-disable-next-line react/no-clone-element -- the asChild merge, see above\n item = cloneElement(children, {\n ...shared,\n \"aria-disabled\": disabled ? true : undefined,\n className: cn(classes, className, own.className),\n onClick: (event: MouseEvent<HTMLElement>) => {\n own.onClick?.(event);\n if (disabled) {\n event.preventDefault();\n return;\n }\n if (!event.defaultPrevented) rail.choose(value);\n },\n children: content,\n });\n } else {\n item = (\n <button type=\"button\" {...shared} disabled={disabled} onClick={() => rail.choose(value)} className={cn(classes, className)}>\n {content}\n </button>\n );\n }\n\n return <li>{iconOnly ? <Tooltip content={label}>{item}</Tooltip> : item}</li>;\n}\n\n/** The props `asChild` reads from, and merges into, the child element. */\ntype ChildProps = HTMLAttributes<HTMLElement> & Partial<Record<`data-${string}`, string>>;\n\n/** A badge count: up to 99 as is, more as \"99+\". */\nfunction formatCount(count: number): string {\n return count > 99 ? \"99+\" : String(count);\n}\n","/*\n * The model behind `TreeView`: which rows are visible, where each sits in its set, and what\n * each key does (the WAI-ARIA tree pattern).\n *\n * Kept out of the component so the keyboard contract — the part a tree most often gets\n * subtly wrong — is tested as a function from (rows, focus, key) to an action.\n */\n\nimport type { ReactNode } from \"react\";\n\n/** One node of a `TreeView`. */\nexport interface TreeNode {\n /** Identifies the node to `selectedId`, `onSelect` and `expanded`. Unique in the tree. */\n id: string;\n /** The node's name: shown, read out, and matched by type-ahead. */\n label: string;\n /** A leading icon (decorative) — typically a lucide icon at `size-3.5`. */\n icon?: ReactNode;\n /** Child nodes. A node with a (possibly empty) array is a parent; without, a leaf. */\n children?: readonly TreeNode[] | undefined;\n /** A quiet trailing annotation — a type, a count, a frame name. Shown in mono. */\n meta?: ReactNode;\n /** Shown and focusable, but not selectable. */\n disabled?: boolean | undefined;\n}\n\n/** A node as it is laid out: one visible row of the tree. */\nexport interface TreeRow {\n /** The node. */\n node: TreeNode;\n /** Depth, from 1 at the root (`aria-level`). */\n level: number;\n /** The parent's id, or `null` at the root. */\n parentId: string | null;\n /** 1-based position among its siblings (`aria-posinset`). */\n posInSet: number;\n /** How many siblings, itself included (`aria-setsize`). */\n setSize: number;\n /** Whether the node has a children array. */\n isParent: boolean;\n /** Whether the node is a parent and expanded. */\n isExpanded: boolean;\n}\n\n/**\n * The rows a reader can see: every root, and the children of every expanded parent, in\n * document order.\n *\n * @param nodes - The roots.\n * @param expanded - The ids of the expanded parents.\n * @returns The visible rows, in order.\n */\nexport function visibleRows(nodes: readonly TreeNode[], expanded: ReadonlySet<string>): TreeRow[] {\n const rows: TreeRow[] = [];\n const walk = (siblings: readonly TreeNode[], level: number, parentId: string | null) => {\n siblings.forEach((node, index) => {\n const isParent = node.children !== undefined;\n const isExpanded = isParent && expanded.has(node.id);\n rows.push({\n node,\n level,\n parentId,\n posInSet: index + 1,\n setSize: siblings.length,\n isParent,\n isExpanded,\n });\n if (isExpanded && node.children) walk(node.children, level + 1, node.id);\n });\n };\n walk(nodes, 1, null);\n return rows;\n}\n\n/**\n * Every parent's id — the expanded set for \"everything open\".\n *\n * @param nodes - The roots.\n * @returns The ids of every node with a children array, at any depth.\n */\nexport function parentIds(nodes: readonly TreeNode[]): string[] {\n const ids: string[] = [];\n const walk = (siblings: readonly TreeNode[]) => {\n for (const node of siblings) {\n if (node.children === undefined) continue;\n ids.push(node.id);\n walk(node.children);\n }\n };\n walk(nodes);\n return ids;\n}\n\n/**\n * The ancestors of a node, root first — what must be expanded for it to be visible.\n *\n * @param nodes - The roots.\n * @param id - The node.\n * @returns The ancestor ids, root first; empty for a root or an id not in the tree.\n */\nexport function ancestorIds(nodes: readonly TreeNode[], id: string): string[] {\n const walk = (siblings: readonly TreeNode[], path: string[]): string[] | null => {\n for (const node of siblings) {\n if (node.id === id) return path;\n if (node.children) {\n const found = walk(node.children, [...path, node.id]);\n if (found) return found;\n }\n }\n return null;\n };\n return walk(nodes, []) ?? [];\n}\n\n/** What a key press on a tree asks for. */\nexport type TreeKeyAction =\n | { type: \"focus\"; id: string }\n | { type: \"expand\"; id: string }\n | { type: \"collapse\"; id: string }\n | { type: \"select\"; id: string }\n | { type: \"expand-siblings\"; ids: string[] };\n\n/**\n * The tree's keyboard (the WAI-ARIA tree pattern), as a pure function.\n *\n * ↓/↑ move to the next/previous visible row; → expands a closed parent, or moves into an\n * open one's first child; ← collapses an open parent, or moves to the parent; Home/End go to\n * the first/last visible row; Enter and Space select; `*` expands every sibling of the\n * focused row; a printable character moves to the next row whose label starts with it\n * (type-ahead, wrapping).\n *\n * @param rows - The visible rows, from `visibleRows`.\n * @param focusedId - The row with focus.\n * @param key - `KeyboardEvent.key`.\n * @returns The action, or `null` when the key does nothing here.\n */\nexport function treeKeyAction(rows: readonly TreeRow[], focusedId: string, key: string): TreeKeyAction | null {\n const index = rows.findIndex((row) => row.node.id === focusedId);\n const row = rows[index];\n if (row === undefined) return null;\n const focus = (target: TreeRow | undefined): TreeKeyAction | null =>\n target === undefined || target === row ? null : { type: \"focus\", id: target.node.id };\n\n switch (key) {\n case \"ArrowDown\":\n return focus(rows[index + 1]);\n case \"ArrowUp\":\n return focus(rows[index - 1]);\n case \"Home\":\n return focus(rows[0]);\n case \"End\":\n return focus(rows[rows.length - 1]);\n case \"ArrowRight\":\n if (!row.isParent) return null;\n if (!row.isExpanded) return { type: \"expand\", id: row.node.id };\n // An open parent's first child is the next row, if it has one.\n return rows[index + 1]?.parentId === row.node.id ? focus(rows[index + 1]) : null;\n case \"ArrowLeft\":\n if (row.isExpanded) return { type: \"collapse\", id: row.node.id };\n return row.parentId === null ? null : focus(rows.find((candidate) => candidate.node.id === row.parentId));\n case \"Enter\":\n case \" \":\n return row.node.disabled ? null : { type: \"select\", id: row.node.id };\n case \"*\": {\n const ids = rows\n .filter((candidate) => candidate.parentId === row.parentId && candidate.isParent && !candidate.isExpanded)\n .map((candidate) => candidate.node.id);\n return ids.length === 0 ? null : { type: \"expand-siblings\", ids };\n }\n default:\n return typeAhead(rows, index, key);\n }\n}\n\n/** The next row after `from` (wrapping) whose label starts with `key`, for a single printable character. */\nfunction typeAhead(rows: readonly TreeRow[], from: number, key: string): TreeKeyAction | null {\n if (key.length !== 1 || key.trim() === \"\") return null;\n const needle = key.toLocaleLowerCase();\n for (let offset = 1; offset <= rows.length; offset += 1) {\n const candidate = rows[(from + offset) % rows.length];\n if (candidate?.node.label.toLocaleLowerCase().startsWith(needle)) {\n return offset === rows.length ? null : { type: \"focus\", id: candidate.node.id };\n }\n }\n return null;\n}\n","/*\n * A hierarchy you can walk with the keyboard.\n *\n * Built for the navigator column of a studio — a robot cell's frame tree, world → robots →\n * links → rigs → cameras — where the tree is data the app already has, the icons are the\n * app's own, and selection is shared with a viewport that can also pick things. So the tree\n * is data-driven, selection is controlled, and selecting something hidden opens the way to it.\n *\n * Rendered flat: one `treeitem` per visible row, carrying its level, position and set size\n * (the WAI-ARIA tree pattern's \"flat\" form). The focus ring then belongs to one row rather\n * than to a subtree, and the keyboard contract is a function over the same list the DOM is\n * — see `treeModel.ts`.\n */\n\nimport { ChevronRight } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent, MouseEvent } from \"react\";\n\nimport { byDensity, cn, useDensity } from \"@vitavision/ui\";\n\nimport { type TreeNode, type TreeRow, ancestorIds, parentIds, treeKeyAction, visibleRows } from \"./treeModel\";\n\n/** Props of `TreeView`. */\nexport interface TreeViewProps {\n /** The roots of the tree. */\n nodes: readonly TreeNode[];\n /** The selected node's id, controlled; `null` or absent for none. */\n selectedId?: string | null | undefined;\n /** Called with the node's id (and the node) on click, Enter or Space. Not called for a disabled node. */\n onSelect?: ((id: string, node: TreeNode) => void) | undefined;\n /** The expanded parents' ids, controlled. Pair with `onExpandedChange`. */\n expanded?: readonly string[] | undefined;\n /** The initially expanded parents' ids, when uncontrolled. */\n defaultExpanded?: readonly string[] | undefined;\n /** Start with every parent expanded, when uncontrolled (overrides `defaultExpanded`). */\n defaultExpandAll?: boolean | undefined;\n /** Called with the new set of expanded ids whenever a parent opens or closes. */\n onExpandedChange?: ((expanded: string[]) => void) | undefined;\n /** Names the tree for assistive technology. */\n \"aria-label\": string;\n /** Merged with the tree's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A data-driven tree (the WAI-ARIA tree pattern) with single selection.\n *\n * Keyboard: the tree is one Tab stop (roving `tabindex`). ↓/↑ move between visible rows, →\n * expands a parent or enters it, ← collapses a parent or goes up to its parent, Home/End jump\n * to the ends, Enter/Space select, `*` expands the focused row's siblings, and a letter jumps\n * to the next row starting with it. Clicking a row selects it; clicking its chevron toggles it.\n *\n * Selection is controlled (`selectedId`/`onSelect`). When `selectedId` changes to a node\n * inside a collapsed parent, its ancestors are expanded (through `onExpandedChange` when\n * `expanded` is controlled) and the row is scrolled into view — so a pick in a viewport can\n * drive the tree.\n *\n * Each row is a `treeitem` with `aria-level`, `aria-posinset`, `aria-setsize`,\n * `aria-selected` and, for parents, `aria-expanded`; also `data-selected` and, for parents,\n * `data-state` (`open`/`closed`). Row height follows the density in force.\n */\nexport function TreeView({\n nodes,\n selectedId = null,\n onSelect,\n expanded: controlledExpanded,\n defaultExpanded,\n defaultExpandAll = false,\n onExpandedChange,\n \"aria-label\": ariaLabel,\n className,\n}: TreeViewProps) {\n const density = useDensity();\n const [internalExpanded, setInternalExpanded] = useState<readonly string[]>(() =>\n defaultExpandAll ? parentIds(nodes) : (defaultExpanded ?? []),\n );\n const expandedIds = controlledExpanded ?? internalExpanded;\n const expandedSet = new Set(expandedIds);\n const rows = visibleRows(nodes, expandedSet);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n const rowElementsRef = useRef(new Map<string, HTMLDivElement>());\n\n const setExpanded = (next: readonly string[]) => {\n if (controlledExpanded === undefined) setInternalExpanded(next);\n onExpandedChange?.([...next]);\n };\n\n const toggle = (id: string, open: boolean) => {\n if (open === expandedSet.has(id)) return;\n setExpanded(open ? [...expandedIds, id] : expandedIds.filter((other) => other !== id));\n };\n\n // Reveal a selection made elsewhere: open its ancestors and bring its row into view.\n const latestRef = useRef({ nodes, expandedIds, setExpanded });\n useEffect(() => {\n latestRef.current = { nodes, expandedIds, setExpanded };\n });\n useEffect(() => {\n if (selectedId === null) return;\n const { nodes: tree, expandedIds: open, setExpanded: update } = latestRef.current;\n const missing = ancestorIds(tree, selectedId).filter((id) => !open.includes(id));\n if (missing.length > 0) update([...open, ...missing]);\n }, [selectedId]);\n useEffect(() => {\n if (selectedId === null) return;\n const element = rowElementsRef.current.get(selectedId);\n // `scrollIntoView` is absent in some test DOMs.\n if (typeof element?.scrollIntoView === \"function\") element.scrollIntoView({ block: \"nearest\" });\n }, [selectedId, rows.length]);\n\n const isVisible = (id: string | null) => id !== null && rows.some((row) => row.node.id === id);\n const tabStop = isVisible(focusedId) ? focusedId : isVisible(selectedId) ? selectedId : (rows[0]?.node.id ?? null);\n\n const focusRow = (id: string) => {\n setFocusedId(id);\n rowElementsRef.current.get(id)?.focus();\n };\n\n const select = (row: TreeRow) => {\n if (!row.node.disabled) onSelect?.(row.node.id, row.node);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const id = (event.target as HTMLElement).dataset[\"treeId\"];\n if (id === undefined) return;\n const action = treeKeyAction(rows, id, event.key);\n if (action === null) return;\n event.preventDefault();\n switch (action.type) {\n case \"focus\":\n focusRow(action.id);\n break;\n case \"expand\":\n toggle(action.id, true);\n break;\n case \"collapse\":\n toggle(action.id, false);\n break;\n case \"select\": {\n const row = rows.find((candidate) => candidate.node.id === action.id);\n if (row) select(row);\n break;\n }\n case \"expand-siblings\":\n setExpanded([...expandedIds, ...action.ids]);\n break;\n }\n };\n\n const onChevron = (event: MouseEvent, row: TreeRow) => {\n event.stopPropagation();\n toggle(row.node.id, !row.isExpanded);\n focusRow(row.node.id);\n };\n\n return (\n <div role=\"tree\" aria-label={ariaLabel} onKeyDown={onKeyDown} className={cn(\"flex flex-col py-1 select-none\", className)}>\n {rows.map((row) => {\n const { node } = row;\n const selected = node.id === selectedId;\n return (\n <div\n key={node.id}\n ref={(element) => {\n if (element) rowElementsRef.current.set(node.id, element);\n else rowElementsRef.current.delete(node.id);\n }}\n role=\"treeitem\"\n aria-level={row.level}\n aria-posinset={row.posInSet}\n aria-setsize={row.setSize}\n aria-selected={selected}\n aria-expanded={row.isParent ? row.isExpanded : undefined}\n aria-disabled={node.disabled || undefined}\n tabIndex={node.id === tabStop ? 0 : -1}\n data-tree-id={node.id}\n data-selected={selected ? \"\" : undefined}\n data-state={row.isParent ? (row.isExpanded ? \"open\" : \"closed\") : undefined}\n onFocus={(event) => {\n if (event.target === event.currentTarget) setFocusedId(node.id);\n }}\n onClick={() => {\n focusRow(node.id);\n select(row);\n }}\n style={{ paddingLeft: `calc(${row.level - 1} * 0.875rem + 0.25rem)` }}\n className={cn(\n \"mx-1 flex shrink-0 cursor-default items-center gap-1.5 rounded-control pr-2 text-fg transition-colors\",\n \"outline-none focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-signal\",\n byDensity(density, \"h-7 text-sm\", \"h-6 text-xs\"),\n selected ? \"bg-signal/12\" : \"hover:bg-raised\",\n node.disabled && \"text-fg-subtle\",\n )}\n >\n {row.isParent ? (\n <span\n aria-hidden\n onClick={(event) => onChevron(event, row)}\n className=\"grid size-4 shrink-0 place-items-center rounded-sm text-fg-subtle hover:text-fg\"\n >\n <ChevronRight className={cn(\"size-3.5 transition-transform\", row.isExpanded && \"rotate-90\")} />\n </span>\n ) : (\n <span aria-hidden className=\"size-4 shrink-0\" />\n )}\n {node.icon !== undefined && (\n <span\n aria-hidden\n className={cn(\"grid shrink-0 place-items-center [&>svg]:size-3.5\", selected ? \"text-signal\" : \"text-fg-muted\")}\n >\n {node.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">{node.label}</span>\n {node.meta !== undefined && (\n // On the selected row's tint both `fg-subtle` and `fg-muted` fall below AA at this size.\n <span className={cn(\"shrink-0 font-mono text-[11px]\", selected ? \"text-fg\" : \"text-fg-subtle\")}>{node.meta}</span>\n )}\n </div>\n );\n })}\n </div>\n );\n}\n","/*\n * Where playback is, as a store outside React.\n *\n * A sampled timeline plays at display rate, and the things that follow it — a robot's joint\n * angles, a camera frustum, a highlighted capture — are drawn by a render loop, not by\n * React. If the current frame lived in React state, every frame of playback would re-render\n * every component that reads it, including the whole scene graph. So it lives here: a tiny\n * store a render loop reads with `get()` at no cost, and that React components subscribe to\n * (through `usePlayhead`) only where they display it — the playback bar, a time readout.\n *\n * The store holds an integer sample index and nothing else that changes per frame. The\n * sub-sample position real-time playback needs is the clock's business (`advance`,\n * `usePlaybackClock`), not the store's, so a reader never sees a fractional frame.\n */\n\n/**\n * A sampled timeline's current position: an external store shared by React and render loops.\n *\n * Every function member may be called detached (`const { get } = playhead`), which is how\n * `useSyncExternalStore` and a render loop hold them.\n */\nexport interface Playhead {\n /** The current sample index, an integer in `0 … count − 1` (0 when `count` is 0). Cheap: call it every frame. */\n readonly get: () => number;\n /**\n * Move to sample `k`. Rounded to an integer and clamped to `0 … count − 1`; listeners are\n * notified only if the index changed.\n */\n readonly set: (k: number) => void;\n /**\n * Be told when the index or the timeline changes.\n *\n * @returns The unsubscribe function.\n */\n readonly subscribe: (listener: () => void) => () => void;\n /** How many samples the timeline has. */\n readonly count: number;\n /** The time between samples, in seconds. Sample `k` is at `t = k · dt`. */\n readonly dt: number;\n /**\n * Swap in a new timeline — a newly loaded or re-baked scenario — keeping the one store\n * every subscriber already holds. The index is clamped into the new range (not reset:\n * call `set(0)` for that). Listeners are notified if anything changed.\n */\n readonly setTimeline: (count: number, dt: number) => void;\n}\n\n/**\n * A playhead over `count` samples spaced `dt` seconds apart, starting at sample 0.\n *\n * Create one per app (not per render — keep it in a `useState` initialiser or module\n * scope), hand it to `PlaybackBar` and to the render loop, and replace its timeline with\n * `setTimeline` when a new scenario loads.\n *\n * @param count - The number of samples (a non-negative integer).\n * @param dt - Seconds between samples (positive).\n * @returns The store.\n */\nexport function createPlayhead(count: number, dt: number): Playhead {\n let index = 0;\n let timeline = checkTimeline(count, dt);\n const listeners = new Set<() => void>();\n const notify = () => {\n for (const listener of [...listeners]) listener();\n };\n\n return {\n get: () => index,\n set: (k) => {\n const next = clampIndex(k, timeline.count);\n if (next === index) return;\n index = next;\n notify();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n get count() {\n return timeline.count;\n },\n get dt() {\n return timeline.dt;\n },\n setTimeline: (nextCount, nextDt) => {\n const next = checkTimeline(nextCount, nextDt);\n const nextIndex = clampIndex(index, next.count);\n if (next.count === timeline.count && next.dt === timeline.dt && nextIndex === index) return;\n timeline = next;\n index = nextIndex;\n notify();\n },\n };\n}\n\nfunction checkTimeline(count: number, dt: number): { count: number; dt: number } {\n if (!Number.isInteger(count) || count < 0) {\n throw new RangeError(`playhead: count must be a non-negative integer, got ${count}`);\n }\n if (!(dt > 0) || !Number.isFinite(dt)) {\n throw new RangeError(`playhead: dt must be a positive number of seconds, got ${dt}`);\n }\n return { count, dt };\n}\n\n/**\n * A sample index made legal: rounded, and clamped to `0 … count − 1`.\n *\n * @param k - Any number (`NaN` reads as 0).\n * @param count - The number of samples.\n * @returns The index; 0 when `count` is 0.\n */\nexport function clampIndex(k: number, count: number): number {\n if (count <= 0 || Number.isNaN(k)) return 0;\n return Math.min(count - 1, Math.max(0, Math.round(k)));\n}\n\n/** The outcome of one clock step: the new fractional position, and whether playback ran off the end. */\nexport interface AdvanceResult {\n /** The new position in samples (fractional); the index to show is its floor. */\n position: number;\n /** True when a non-looping timeline reached its last sample on this step. */\n ended: boolean;\n}\n\n/**\n * One step of real-time playback, in samples.\n *\n * Each sample is shown for `dt`: a looping timeline has period `count · dt` and wraps from\n * the last sample to the first; a non-looping one stops on the last sample and reports\n * `ended`. The position is fractional so that playback slower than one sample per frame\n * still advances.\n *\n * @param position - The current position in samples (fractional).\n * @param delta - How many samples to advance (elapsed seconds × speed ÷ dt); not negative.\n * @param count - The number of samples.\n * @param loop - Whether to wrap at the end.\n * @returns The new position and whether playback ended.\n */\nexport function advance(position: number, delta: number, count: number, loop: boolean): AdvanceResult {\n if (count <= 1) return { position: 0, ended: !loop };\n const next = position + Math.max(0, delta);\n if (loop) return { position: next % count, ended: false };\n const last = count - 1;\n return next >= last ? { position: last, ended: true } : { position: next, ended: false };\n}\n\n/**\n * The default time readout: seconds with millisecond resolution, `\"1.234 s\"`.\n *\n * @param seconds - The time.\n * @returns The formatted time.\n */\nexport function formatSeconds(seconds: number): string {\n return `${seconds.toFixed(3)} s`;\n}\n","/*\n * The React side of the playhead: subscribing to it, and driving it in real time.\n */\n\nimport { useEffect, useEffectEvent, useSyncExternalStore } from \"react\";\n\nimport { advance, type Playhead } from \"./playhead\";\n\n/**\n * The playhead's current sample index, re-rendering the calling component when it changes.\n *\n * Use it only where the index is *displayed* (the playback bar, a readout). A render loop\n * reads `playhead.get()` in its own frame callback instead, and re-renders nothing.\n *\n * @param playhead - The store.\n * @returns The current sample index.\n */\nexport function usePlayhead(playhead: Playhead): number {\n return useSyncExternalStore(playhead.subscribe, playhead.get, playhead.get);\n}\n\n/**\n * The playhead's timeline — `count` and `dt` — re-rendering when `setTimeline` changes it.\n *\n * @param playhead - The store.\n * @returns The number of samples and the seconds between them.\n */\nexport function usePlayheadTimeline(playhead: Playhead): { count: number; dt: number } {\n const count = useSyncExternalStore(\n playhead.subscribe,\n () => playhead.count,\n () => playhead.count,\n );\n const dt = useSyncExternalStore(\n playhead.subscribe,\n () => playhead.dt,\n () => playhead.dt,\n );\n return { count, dt };\n}\n\n/** Options of `usePlaybackClock`. */\nexport interface PlaybackClockOptions {\n /** The store to advance. */\n playhead: Playhead;\n /** Whether the clock runs. */\n playing: boolean;\n /** Playback rate: 1 is real time. Defaults to 1. */\n speed?: number | undefined;\n /** Wrap from the last sample to the first instead of stopping. Defaults to false. */\n loop?: boolean | undefined;\n /** Called once when a non-looping timeline reaches its last sample; set `playing` false here. */\n onEnd?: (() => void) | undefined;\n /**\n * The longest wall-clock gap one frame may advance by, in milliseconds. A tab in the\n * background gets no animation frames, and without this cap the first frame back would\n * jump by the whole time away. Defaults to 100.\n */\n maxFrameMs?: number | undefined;\n}\n\n/**\n * Advance a playhead in real time × `speed` while `playing`, from `requestAnimationFrame`.\n *\n * Position is accumulated fractionally, so slow playback of a finely sampled timeline still\n * moves; the store only ever holds the integer index. A seek from elsewhere (the scrubber, a\n * marker) is picked up on the next frame. Starting a non-looping timeline that sits on its\n * last sample rewinds it to 0 first. `speed`, `loop` and `onEnd` may change while playing\n * without restarting the clock.\n *\n * Renders nothing and re-renders nothing: call it once, in the component that owns the\n * `playing` state.\n *\n * @param options - The playhead and the transport state.\n */\nexport function usePlaybackClock({ playhead, playing, speed = 1, loop = false, onEnd, maxFrameMs = 100 }: PlaybackClockOptions): void {\n const step = useEffectEvent((position: number, elapsedMs: number) => {\n const delta = (Math.min(elapsedMs, maxFrameMs) / 1000) * (speed / playhead.dt);\n return advance(position, delta, playhead.count, loop);\n });\n const end = useEffectEvent(() => onEnd?.());\n const rewindIfAtEnd = useEffectEvent(() => {\n if (!loop && playhead.count > 0 && playhead.get() >= playhead.count - 1) playhead.set(0);\n });\n\n useEffect(() => {\n if (!playing) return;\n rewindIfAtEnd();\n let position = playhead.get();\n let last: number | null = null;\n let frame = requestAnimationFrame(function tick(now: number) {\n // A seek since the last frame (scrubber, marker, step button) wins over the clock.\n if (Math.floor(position) !== playhead.get()) position = playhead.get();\n const result = last === null ? { position, ended: false } : step(position, now - last);\n last = now;\n position = result.position;\n playhead.set(Math.floor(position));\n if (result.ended) {\n end();\n return;\n }\n frame = requestAnimationFrame(tick);\n });\n return () => cancelAnimationFrame(frame);\n }, [playing, playhead]);\n}\n","/*\n * The transport for a sampled timeline.\n *\n * Playback state splits by how often it changes. Whether it is playing, how fast, and\n * whether it loops change when someone clicks — ordinary controlled props. Where it is\n * changes every frame — so that is a `Playhead` store the bar subscribes to itself, and a\n * playing timeline re-renders this bar and nothing else in the app.\n *\n * The bar is chrome over a viewport, like the image stage's toolbar: one row, icon buttons\n * named for what they do, the time in mono so it does not jitter as digits change.\n */\n\nimport { ChevronFirst, ChevronLast, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from \"lucide-react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { type MeasureTone, Select, Slider, byDensity, cn, focusRing, toneColor, useDensity } from \"@vitavision/ui\";\n\nimport { formatSeconds, type Playhead } from \"./playhead\";\nimport { usePlayhead, usePlayheadTimeline } from \"./usePlayback\";\n\n/** A point of interest on the timeline — a capture, an event — drawn as a tick on the scrubber. */\nexport interface PlaybackMarker {\n /** The sample the marker sits on. */\n index: number;\n /** What happens there; names the tick for assistive technology and its tooltip. */\n label?: string | undefined;\n /** The tick's colour. Defaults to `signal`. */\n tone?: MeasureTone | undefined;\n}\n\n/** The speeds offered by default. */\nexport const DEFAULT_SPEEDS: readonly number[] = [0.25, 0.5, 1, 2, 4];\n\n/** Props of `PlaybackBar`. */\nexport interface PlaybackBarProps {\n /** Where playback is. The bar subscribes to it; seeking writes to it. */\n playhead: Playhead;\n /** Whether playback is running, controlled. */\n playing: boolean;\n /** Called with the requested playing state (the play/pause button, Space). */\n onPlayingChange: (playing: boolean) => void;\n /** The playback rate, controlled. Defaults to 1. */\n speed?: number | undefined;\n /** Called with the chosen rate. Without it the speed selector is not shown. */\n onSpeedChange?: ((speed: number) => void) | undefined;\n /** The rates the selector offers. Defaults to 0.25×, 0.5×, 1×, 2×, 4×. */\n speeds?: readonly number[] | undefined;\n /** Whether playback wraps at the end, controlled. */\n loop?: boolean | undefined;\n /** Called with the new loop state. Without it the loop toggle is not shown. */\n onLoopChange?: ((loop: boolean) => void) | undefined;\n /** Ticks on the scrubber, each a click target that seeks to it. */\n markers?: readonly PlaybackMarker[] | undefined;\n /** Called after a marker tick is clicked (the playhead has already moved to it). */\n onMarkerSelect?: ((marker: PlaybackMarker) => void) | undefined;\n /** Formats `t = k · dt` in seconds for the readout. Defaults to `\"1.234 s\"`. */\n formatTime?: ((seconds: number) => string) | undefined;\n /** Names the bar (a `toolbar`). Defaults to \"Playback\". */\n \"aria-label\"?: string | undefined;\n /** Merged with the bar's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * The transport for a sampled timeline: jump to start, previous marker, step back,\n * play/pause, step forward, next marker, jump to end; a scrubber over the samples with the\n * markers as ticks; the time `t = k · dt`; the speed; loop.\n *\n * `playing`, `speed` and `loop` are controlled props. The position is the `playhead` store,\n * which the bar subscribes to itself — so during playback only the bar re-renders. Drive the\n * store with `usePlaybackClock`, and read `playhead.get()` in a render loop.\n *\n * A `role=\"toolbar\"`. Keyboard, while focus is inside it: the scrubber is a slider (←/→ one\n * sample, PageUp/PageDown ten, Home/End); on the buttons, ←/→ step one sample; Space\n * toggles playback anywhere in the bar except on a button, where it presses the button. The\n * root carries `data-playing` while playing and `data-empty` when the timeline has no samples.\n */\nexport function PlaybackBar({\n playhead,\n playing,\n onPlayingChange,\n speed = 1,\n onSpeedChange,\n speeds = DEFAULT_SPEEDS,\n loop = false,\n onLoopChange,\n markers = [],\n onMarkerSelect,\n formatTime = formatSeconds,\n \"aria-label\": ariaLabel = \"Playback\",\n className,\n}: PlaybackBarProps) {\n const density = useDensity();\n const index = usePlayhead(playhead);\n const { count, dt } = usePlayheadTimeline(playhead);\n const last = Math.max(0, count - 1);\n const empty = count === 0;\n\n const sorted = [...markers].filter((m) => m.index >= 0 && m.index <= last).sort((a, b) => a.index - b.index);\n const previousMarker = sorted.filter((m) => m.index < index).at(-1);\n const nextMarker = sorted.find((m) => m.index > index);\n\n const seek = (k: number) => playhead.set(k);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n const onButton = target.tagName === \"BUTTON\";\n if (event.key === \" \" && !onButton && target.getAttribute(\"role\") !== \"combobox\") {\n event.preventDefault();\n if (!empty) onPlayingChange(!playing);\n } else if (onButton && (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\")) {\n event.preventDefault();\n seek(index + (event.key === \"ArrowRight\" ? 1 : -1));\n }\n };\n\n return (\n <div\n role=\"toolbar\"\n aria-label={ariaLabel}\n data-playing={playing ? \"\" : undefined}\n data-empty={empty ? \"\" : undefined}\n onKeyDown={onKeyDown}\n className={cn(\"flex w-full min-w-0 items-center bg-surface\", byDensity(density, \"gap-3 px-3 py-2\", \"gap-2 px-2 py-1\"), className)}\n >\n <div className=\"flex shrink-0 items-center gap-0.5\">\n <BarButton label=\"Jump to start\" onClick={() => seek(0)} disabled={empty || index === 0}>\n <ChevronFirst className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton\n label=\"Previous marker\"\n onClick={() => previousMarker && seek(previousMarker.index)}\n disabled={previousMarker === undefined}\n >\n <SkipBack className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Step back\" onClick={() => seek(index - 1)} disabled={empty || index === 0}>\n <StepBack className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label={playing ? \"Pause\" : \"Play\"} onClick={() => onPlayingChange(!playing)} disabled={empty} className=\"text-fg\">\n {playing ? <Pause className=\"size-4\" aria-hidden /> : <Play className=\"size-4\" aria-hidden />}\n </BarButton>\n <BarButton label=\"Step forward\" onClick={() => seek(index + 1)} disabled={empty || index >= last}>\n <StepForward className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Next marker\" onClick={() => nextMarker && seek(nextMarker.index)} disabled={nextMarker === undefined}>\n <SkipForward className=\"size-4\" aria-hidden />\n </BarButton>\n <BarButton label=\"Jump to end\" onClick={() => seek(last)} disabled={empty || index >= last}>\n <ChevronLast className=\"size-4\" aria-hidden />\n </BarButton>\n </div>\n\n <div className=\"relative flex min-w-24 flex-1 flex-col justify-center\">\n {sorted.length > 0 && (\n // The ticks sit on a rail above the track, positioned as Radix positions the thumb:\n // its centre travels from half a thumb (7 px) in from either end.\n <div className=\"relative h-2.5\">\n {sorted.map((marker) => (\n <MarkerTick\n key={`${marker.index}:${marker.label ?? \"\"}`}\n marker={marker}\n fraction={last === 0 ? 0 : marker.index / last}\n time={formatTime(marker.index * dt)}\n active={marker.index === index}\n onClick={() => {\n seek(marker.index);\n onMarkerSelect?.(marker);\n }}\n />\n ))}\n </div>\n )}\n <Slider value={index} onValueChange={seek} min={0} max={last} step={1} disabled={empty} aria-label=\"Playback position\" />\n </div>\n\n {/* Not an <output>: that is a live region, and this changes every frame. */}\n <span className=\"shrink-0 font-mono text-xs whitespace-nowrap text-fg tabular-nums\">\n <span className=\"text-fg-subtle\">t = </span>\n {formatTime(index * dt)}\n <span className=\"ml-2 text-fg-subtle\">\n {empty ? \"–\" : index}/{last}\n </span>\n </span>\n\n {onSpeedChange && (\n <Select\n value={String(speed)}\n onValueChange={(value) => value !== \"\" && onSpeedChange(Number(value))}\n options={speeds.map((s) => ({ value: String(s), label: `${s}×` }))}\n aria-label=\"Playback speed\"\n className={cn(\"w-20 shrink-0 font-mono\", byDensity(density, \"h-8\", \"h-7\"))}\n />\n )}\n\n {onLoopChange && (\n <BarButton label=\"Loop\" pressed={loop} onClick={() => onLoopChange(!loop)}>\n <Repeat className=\"size-4\" aria-hidden />\n </BarButton>\n )}\n </div>\n );\n}\n\nfunction MarkerTick({\n marker,\n fraction,\n time,\n active,\n onClick,\n}: {\n marker: PlaybackMarker;\n fraction: number;\n time: string;\n active: boolean;\n onClick: () => void;\n}) {\n const name = marker.label ? `${marker.label} (${time})` : `Marker at ${time}`;\n return (\n <button\n type=\"button\"\n // The previous/next-marker buttons are the keyboard's way to the markers; one tab stop\n // per tick would bury the rest of the bar behind a long capture list.\n tabIndex={-1}\n title={name}\n aria-label={name}\n data-active={active ? \"\" : undefined}\n onClick={onClick}\n style={{ left: `calc(7px + ${fraction} * (100% - 14px))` }}\n className=\"group absolute top-0 flex h-full w-2.5 -translate-x-1/2 cursor-pointer justify-center\"\n >\n <span\n aria-hidden\n className=\"h-full w-0.5 rounded-full opacity-70 transition-opacity group-hover:opacity-100 group-data-active:w-1 group-data-active:opacity-100\"\n style={{ backgroundColor: toneColor(marker.tone) }}\n />\n </button>\n );\n}\n\n/** Props of the bar's icon button. */\ninterface BarButtonProps extends Omit<ComponentPropsWithRef<\"button\">, \"type\" | \"title\" | \"aria-label\" | \"aria-pressed\" | \"children\"> {\n label: string;\n pressed?: boolean | undefined;\n children: ReactNode;\n}\n\n/** An icon button in the style of `@vitavision/stage2d`'s `StageButton`, sized by density. */\nfunction BarButton({ label, pressed, className, children, ...props }: BarButtonProps) {\n const density = useDensity();\n return (\n <button\n {...props}\n type=\"button\"\n title={label}\n aria-label={label}\n aria-pressed={pressed}\n data-state={pressed === undefined ? undefined : pressed ? \"on\" : \"off\"}\n className={cn(\n \"grid place-items-center rounded-control text-fg-muted transition-colors\",\n byDensity(density, \"size-8\", \"size-7\"),\n \"hover:bg-raised hover:text-fg disabled:pointer-events-none disabled:opacity-40\",\n pressed && \"bg-signal/15 text-signal\",\n focusRing,\n className,\n )}\n >\n {children}\n </button>\n );\n}\n","/*\n * What `FileDrop` does with a drop: which files match `accept`, and what a dropped folder\n * contains.\n *\n * The browser enforces `accept` only in the file picker, and only as a hint; a drop brings\n * whatever was dragged. So the filter is applied here, to both routes. And a dropped folder\n * arrives as a zero-byte \"file\" unless its entries are walked — which is how a scenario\n * folder (a scene, a scenario, its meshes) is opened in one gesture.\n */\n\n/**\n * Whether a file matches an `accept` string, as `<input type=\"file\" accept>` reads it:\n * comma-separated extensions (`.json`), MIME types (`application/json`) and MIME wildcards\n * (`image/*`). Matching is case-insensitive.\n *\n * @param file - The file's name and MIME type.\n * @param accept - The accept string; empty or absent accepts everything.\n * @returns Whether the file is accepted.\n */\nexport function acceptsFile(file: { name: string; type: string }, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((token) => token.trim().toLowerCase())\n .filter((token) => token !== \"\");\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types by extension, for matching a bare path against `type/*` and MIME tokens. */\nconst MIME_BY_EXTENSION: Readonly<Record<string, string>> = {\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n bmp: \"image/bmp\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n tif: \"image/tiff\",\n tiff: \"image/tiff\",\n pgm: \"image/x-portable-graymap\",\n json: \"application/json\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\n/**\n * Whether a path matches an `accept` string, for desktop shells whose native drops and\n * dialogs yield paths rather than `File`s. Extensions match the path's ending; MIME types and\n * wildcards match through the extension of common image, JSON and text formats.\n *\n * @param path - A file path, with either separator.\n * @param accept - The accept string; empty or absent accepts everything.\n * @returns Whether the path is accepted.\n */\nexport function acceptsPath(path: string, accept: string | undefined): boolean {\n const name = path.split(/[\\\\/]/).pop() ?? path;\n const dot = name.lastIndexOf(\".\");\n const type = dot >= 0 ? (MIME_BY_EXTENSION[name.slice(dot + 1).toLowerCase()] ?? \"\") : \"\";\n return acceptsFile({ name, type }, accept);\n}\n\n/**\n * Split files by `accept`.\n *\n * @param files - The candidates.\n * @param accept - The accept string.\n * @returns The accepted files and the rejected ones, each in their original order.\n */\nexport function partitionFiles(files: readonly File[], accept: string | undefined): { accepted: File[]; rejected: File[] } {\n const accepted: File[] = [];\n const rejected: File[] = [];\n for (const file of files) (acceptsFile(file, accept) ? accepted : rejected).push(file);\n return { accepted, rejected };\n}\n\n/**\n * Whether a drag carries files (rather than text or a link) — the only drags `FileDrop`\n * reacts to.\n *\n * @param dataTransfer - The drag's data, or `null`.\n * @returns Whether `Files` is among its types.\n */\nexport function carriesFiles(dataTransfer: Pick<DataTransfer, \"types\"> | null): boolean {\n return dataTransfer !== null && Array.from(dataTransfer.types).includes(\"Files\");\n}\n\n/** The part of the File and Directory Entries API a drop walk needs (`webkitGetAsEntry`). */\nexport interface DropEntry {\n /** A file (`FileSystemFileEntry`). */\n isFile: boolean;\n /** A folder (`FileSystemDirectoryEntry`). */\n isDirectory: boolean;\n /** The entry's own name. */\n name: string;\n /** The entry's path from the drop root, with a leading `/`. */\n fullPath: string;\n /** A file entry's contents, as a `File`. */\n file?: (success: (file: File) => void, failure?: (error: unknown) => void) => void;\n /** A folder entry's reader; `readEntries` yields the children in batches, then an empty one. */\n createReader?: () => {\n readEntries: (success: (entries: DropEntry[]) => void, failure?: (error: unknown) => void) => void;\n };\n}\n\n/**\n * Every file in a drop, with dropped folders walked recursively.\n *\n * Files found inside a folder carry `webkitRelativePath` (`scene/meshes/base.glb`), as the\n * files of `<input webkitdirectory>` do, so both routes give the same shape. Where the entries\n * API is missing, the drop's plain file list is returned.\n *\n * @param dataTransfer - The drop's data.\n * @returns The files, in the order the browser listed them.\n */\nexport async function collectDroppedFiles(dataTransfer: Pick<DataTransfer, \"files\" | \"items\">): Promise<File[]> {\n // Everything is read before the first `await`: a drop's data is emptied once its event\n // handler returns.\n const plain = Array.from(dataTransfer.files);\n const entries = Array.from(dataTransfer.items ?? [])\n .filter((item) => item.kind === \"file\")\n .map((item) => (typeof item.webkitGetAsEntry === \"function\" ? (item.webkitGetAsEntry() as DropEntry | null) : null));\n // No folder among them (or no entries API): the plain list is already the answer.\n if (!entries.some((entry) => entry?.isDirectory)) return plain;\n const files: File[] = [];\n for (const entry of entries) if (entry) await walkEntry(entry, files);\n return files;\n}\n\nasync function walkEntry(entry: DropEntry, out: File[]): Promise<void> {\n if (entry.isFile && entry.file) {\n const read = entry.file.bind(entry);\n const file = await new Promise<File>((resolve, reject) => read(resolve, reject));\n const path = entry.fullPath.replace(/^\\//, \"\");\n out.push(path.includes(\"/\") ? withRelativePath(file, path) : file);\n } else if (entry.isDirectory && entry.createReader) {\n const reader = entry.createReader();\n // `readEntries` returns a directory in batches (100 in Chromium) until an empty one.\n for (;;) {\n const batch = await new Promise<DropEntry[]>((resolve, reject) => reader.readEntries(resolve, reject));\n if (batch.length === 0) break;\n for (const child of batch) await walkEntry(child, out);\n }\n }\n}\n\n/**\n * The file, carrying `webkitRelativePath` — a read-only accessor on `File.prototype`,\n * shadowed here on the instance.\n */\nfunction withRelativePath(file: File, path: string): File {\n Object.defineProperty(file, \"webkitRelativePath\", { value: path, configurable: true });\n return file;\n}\n","/*\n * Opening local files: by dropping them, or through the picker.\n *\n * Both routes are always offered. A drop target alone is invisible to a keyboard and to\n * anyone who does not know it is there; a picker alone makes a folder of scenario files a\n * dozen clicks. The picker is a real `<button>`, so the component is operable without a\n * pointer.\n */\n\nimport { FolderOpen } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ChangeEvent, DragEvent, ReactNode } from \"react\";\n\nimport { Button, cn } from \"@vitavision/ui\";\n\nimport { acceptsPath, carriesFiles, collectDroppedFiles, partitionFiles } from \"./dropFiles\";\n\n/**\n * Where paths come from in a desktop shell whose native drops and dialogs yield paths, not\n * `File`s (Tauri, Electron). The app implements it over its shell's APIs; the package stays\n * shell-agnostic. See the README for a Tauri implementation.\n */\nexport interface PathSource {\n /** Opens the native picker; resolves with the chosen paths, `[]` if cancelled. */\n pick: (options: { multiple: boolean; directory: boolean; accept?: string | undefined }) => Promise<string[]>;\n /**\n * Subscribes to native drags of files over the window: `onEnter` and `onLeave` while a drag\n * hovers, `onDrop` with its paths. Returns the unsubscribe. Optional: without it, only the\n * picker offers paths.\n */\n subscribe?: (handlers: { onEnter: () => void; onLeave: () => void; onDrop: (paths: string[]) => void }) => () => void;\n}\n\n/** Props of `FileDrop`. */\nexport interface FileDropProps {\n /** Called with the accepted files of a drop or a pick (never with an empty list). */\n onFiles?: ((files: File[]) => void) | undefined;\n /**\n * The desktop route: paths from `pathSource`'s picker and native drops, filtered by\n * `accept` on their extensions. With a `pathSource`, the picker and drops go through it\n * instead of the browser's `File` route.\n */\n pathSource?: PathSource | undefined;\n /** Called with the accepted paths of a native drop or pick (never with an empty list). */\n onPaths?: ((paths: string[]) => void) | undefined;\n /** Called with the paths `accept` turned away. */\n onRejectPaths?: ((paths: string[]) => void) | undefined;\n /** Called with the files a drop or a pick brought that `accept` turned away. */\n onReject?: ((files: File[]) => void) | undefined;\n /**\n * Which files to take, as `<input accept>`: extensions (`.json`), MIME types and MIME\n * wildcards (`image/*`), comma-separated. Applied to drops as well as the picker. Default: all.\n */\n accept?: string | undefined;\n /** Take several files at once. Defaults to true; when false only the first accepted file is passed. */\n multiple?: boolean | undefined;\n /**\n * The picker chooses a folder (`webkitdirectory`) instead of files. Dropped folders are\n * walked either way; files found in a folder carry `webkitRelativePath`.\n */\n directory?: boolean | undefined;\n /**\n * Take drops anywhere in the window, showing a full-window overlay while files are dragged\n * over it; the component itself then renders only the picker button (for a header). Without\n * it, the component is an inline drop zone.\n */\n overlay?: boolean | undefined;\n /** Refuses drops and blocks the picker. */\n disabled?: boolean | undefined;\n /** The picker button's label. Defaults to \"Open files…\" (or \"Open folder…\" with `directory`). */\n buttonLabel?: string | undefined;\n /** The overlay's message. Defaults to \"Drop to open\". */\n overlayMessage?: ReactNode;\n /** The inline zone's message, before the button. Defaults to \"Drop files here, or\". */\n children?: ReactNode;\n /** Merged with the zone's (or, with `overlay`, the button's) own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A drop target plus an \"Open files…\" button over a hidden `<input type=\"file\">`.\n *\n * Inline (the default) it is a dashed zone with a message and the button, carrying\n * `data-dragging` while files are dragged over it. With `overlay` it renders only the button\n * and takes drops anywhere in the window, showing a full-window overlay (`aria-hidden`: the\n * button is the accessible route) while a drag carrying files is over the window. Only drags\n * that carry files are reacted to; text and links pass through.\n *\n * Files are filtered by `accept` on both routes (the browser applies it to neither drops nor,\n * reliably, the picker); the rest go to `onReject`. A dropped folder is walked recursively.\n *\n * In a desktop shell, pass a `pathSource`: the picker and native drops then yield paths to\n * `onPaths`, filtered by `accept` on their extensions, and the browser `File` route is off.\n */\nexport function FileDrop({\n onFiles,\n pathSource,\n onPaths,\n onRejectPaths,\n onReject,\n accept,\n multiple = true,\n directory = false,\n overlay = false,\n disabled = false,\n buttonLabel,\n overlayMessage = \"Drop to open\",\n children = \"Drop files here, or\",\n className,\n}: FileDropProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const depthRef = useRef(0);\n const [dragging, setDragging] = useState(false);\n const label = buttonLabel ?? (directory ? \"Open folder…\" : \"Open files…\");\n\n const deliver = (files: readonly File[]) => {\n const { accepted, rejected } = partitionFiles(files, accept);\n if (accepted.length > 0) onFiles?.(multiple ? accepted : accepted.slice(0, 1));\n if (rejected.length > 0) onReject?.(rejected);\n };\n const deliverPaths = (paths: readonly string[]) => {\n const accepted = paths.filter((path) => acceptsPath(path, accept));\n const rejected = paths.filter((path) => !acceptsPath(path, accept));\n if (accepted.length > 0) onPaths?.(multiple ? accepted : accepted.slice(0, 1));\n if (rejected.length > 0) onRejectPaths?.(rejected);\n };\n const deliverRef = useRef(deliver);\n const deliverPathsRef = useRef(deliverPaths);\n useEffect(() => {\n deliverRef.current = deliver;\n deliverPathsRef.current = deliverPaths;\n });\n\n // The desktop route: native drags report paths through the source, for the overlay and the\n // inline zone alike (a webview with native drag-drop on fires no DOM drop with files).\n useEffect(() => {\n if (!pathSource?.subscribe || disabled) return;\n return pathSource.subscribe({\n onEnter: () => setDragging(true),\n onLeave: () => setDragging(false),\n onDrop: (paths) => {\n setDragging(false);\n deliverPathsRef.current(paths);\n },\n });\n }, [pathSource, disabled]);\n\n // The window-wide target. `dragenter`/`dragleave` fire for every element crossed, so the\n // overlay's visibility is a depth count rather than the last event seen.\n useEffect(() => {\n if (!overlay || disabled || pathSource) return;\n const onEnter = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n depthRef.current += 1;\n setDragging(true);\n };\n const onLeave = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n depthRef.current = Math.max(0, depthRef.current - 1);\n if (depthRef.current === 0) setDragging(false);\n };\n const onOver = (event: globalThis.DragEvent) => {\n if (!carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (event.dataTransfer) event.dataTransfer.dropEffect = \"copy\";\n };\n const onDrop = (event: globalThis.DragEvent) => {\n if (!event.dataTransfer || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n depthRef.current = 0;\n setDragging(false);\n void collectDroppedFiles(event.dataTransfer).then((files) => deliverRef.current(files));\n };\n window.addEventListener(\"dragenter\", onEnter);\n window.addEventListener(\"dragleave\", onLeave);\n window.addEventListener(\"dragover\", onOver);\n window.addEventListener(\"drop\", onDrop);\n return () => {\n window.removeEventListener(\"dragenter\", onEnter);\n window.removeEventListener(\"dragleave\", onLeave);\n window.removeEventListener(\"dragover\", onOver);\n window.removeEventListener(\"drop\", onDrop);\n depthRef.current = 0;\n };\n }, [overlay, disabled, pathSource]);\n\n const onPick = (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.currentTarget.files ?? []);\n // Cleared so that choosing the same file again is still a change.\n event.currentTarget.value = \"\";\n if (files.length > 0) deliver(files);\n };\n\n const picker = (\n <>\n <input\n ref={(element) => {\n inputRef.current = element;\n if (element) element.webkitdirectory = directory;\n }}\n type=\"file\"\n hidden\n tabIndex={-1}\n accept={accept}\n multiple={multiple || directory}\n disabled={disabled}\n onChange={onPick}\n />\n <Button\n icon={<FolderOpen />}\n disabled={disabled}\n onClick={() => {\n if (pathSource) {\n void pathSource.pick({ multiple: multiple || directory, directory, accept }).then((paths) => {\n if (paths.length > 0) deliverPathsRef.current(paths);\n });\n return;\n }\n inputRef.current?.click();\n }}\n className={overlay ? className : undefined}\n >\n {label}\n </Button>\n </>\n );\n\n if (overlay) {\n return (\n <>\n {picker}\n {dragging && (\n <div\n aria-hidden\n data-dragging=\"\"\n className=\"pointer-events-none fixed inset-0 z-50 grid place-items-center bg-ground/80 p-8 backdrop-blur-sm\"\n >\n <div className=\"rounded-panel border-2 border-dashed border-signal bg-surface px-10 py-8 text-sm font-medium text-fg shadow-lg\">\n {overlayMessage}\n </div>\n </div>\n )}\n </>\n );\n }\n\n const zoneDrag = (event: DragEvent<HTMLDivElement>, change: 1 | -1 | 0) => {\n if (disabled || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (change === 0) {\n event.dataTransfer.dropEffect = \"copy\";\n return;\n }\n depthRef.current = Math.max(0, depthRef.current + change);\n setDragging(depthRef.current > 0);\n };\n\n return (\n <div\n data-dragging={dragging ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n onDragEnter={(event) => zoneDrag(event, 1)}\n onDragLeave={(event) => zoneDrag(event, -1)}\n onDragOver={(event) => zoneDrag(event, 0)}\n onDrop={(event) => {\n if (disabled || !carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n depthRef.current = 0;\n setDragging(false);\n void collectDroppedFiles(event.dataTransfer).then(deliver);\n }}\n className={cn(\n \"flex flex-col items-center justify-center gap-3 rounded-panel border-2 border-dashed border-line-strong px-6 py-8 text-center text-sm text-fg-muted transition-colors\",\n \"data-dragging:border-signal data-dragging:bg-signal/8 data-dragging:text-fg\",\n // Not `opacity-50`: the message would fall below AA. The disabled button and the quieter\n // border say it instead.\n \"data-disabled:border-line\",\n className,\n )}\n >\n <p>{children}</p>\n {picker}\n </div>\n );\n}\n","/*\n * Stepping through an ordered set, as a pure function so its edge cases (an empty set, no\n * current item, wrapping) are tested without a DOM.\n */\n\n/**\n * The index one step from `index`.\n *\n * @param length - The number of items.\n * @param index - The current index, or -1 for none.\n * @param delta - +1 for next, -1 for previous.\n * @param wrap - Wrap from the last item to the first and back.\n * @returns The next index; the first (or, stepping back, the last) item when there is no\n * current one; the same index at an end without `wrap`; `null` for an empty set.\n */\nexport function stepIndex(length: number, index: number, delta: 1 | -1, wrap = false): number | null {\n if (length <= 0) return null;\n if (index < 0 || index >= length) return delta > 0 ? 0 : length - 1;\n const next = index + delta;\n if (wrap) return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\n}\n","/*\n * Which item of an ordered set is current — a frame of a capture, a page of a scan — as a\n * strip of thumbnails with previous/next and `[` / `]`.\n *\n * A capture is an ordered set and a person steps through it one item at a time, which a\n * dropdown hides and a library page makes a round trip. The strip keeps the neighbours in\n * view, and the keys work from anywhere on the screen.\n */\n\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { useEffect, useRef, type ReactNode } from \"react\";\n\nimport { Button, Kbd, StatusDot, cn, focusRing, type Tone } from \"@vitavision/ui\";\n\nimport { stepIndex } from \"./sequence\";\n\n/**\n * A per-item status — \"not found\" in a batch run, \"rejected\" by a reviewer — drawn as a dot in\n * the thumbnail's corner and said in words in the item's name.\n */\nexport interface SequenceItemStatus {\n /** The dot's colour, by meaning; also the item's `data-status`. */\n tone: Tone;\n /** The status in words, appended to the item's name and tooltip: `\"frame_0003.bmp, not found\"`. */\n label: string;\n}\n\n/** One item of a `SequenceNavigator`. */\nexport interface SequenceItem {\n /** Its identity, unique in the sequence. */\n id: string;\n /** Its name: the thumbnail's alt text and tooltip. */\n label: string;\n /** A thumbnail URL, loaded lazily. Without it, the default rendering is the label. */\n thumbnail?: string | undefined;\n /** A status, drawn as a dot in the thumbnail's corner over any thumbnail rendering. */\n status?: SequenceItemStatus | undefined;\n}\n\n/** Props of `SequenceNavigator`. */\nexport interface SequenceNavigatorProps {\n /** The items, in order. */\n items: readonly SequenceItem[];\n /** The current item's id, or `null` for none. */\n value: string | null;\n /** Called with the id of the item chosen by click, by previous/next, or by `[` / `]`. */\n onValueChange: (id: string) => void;\n /** Draws an item's thumbnail, e.g. one whose URL must be fetched. Defaults to a lazy `<img>`. */\n renderThumbnail?: ((item: SequenceItem) => ReactNode) | undefined;\n /** Step with `[` and `]` from anywhere outside a text field. Defaults to true. */\n keys?: boolean | undefined;\n /** Wrap from the last item to the first. Defaults to false. */\n wrap?: boolean | undefined;\n /** Names the strip (`aria-label`). */\n \"aria-label\": string;\n /** Merged with the row's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A horizontal strip of thumbnails between previous and next buttons, with the position\n * (\"3 / 50\").\n *\n * The current thumbnail carries `aria-current=\"true\"` and `data-current`, has an outline,\n * and is scrolled into view when it changes. An item with a `status` shows a dot in its\n * corner, carries `data-status` (the tone) and is named `\"label, status\"`. `[` and `]` step\n * from anywhere outside a text field. Thumbnails load lazily, so a capture of thousands of\n * frames opens at once. The strip is as wide as its thumbnails, so previous and next stay\n * beside a short sequence; a long one scrolls.\n */\nexport function SequenceNavigator({\n items,\n value,\n onValueChange,\n renderThumbnail,\n keys = true,\n wrap = false,\n \"aria-label\": ariaLabel,\n className,\n}: SequenceNavigatorProps) {\n const index = items.findIndex((item) => item.id === value);\n const listRef = useRef<HTMLOListElement>(null);\n\n const step = (delta: 1 | -1) => {\n const next = stepIndex(items.length, index, delta, wrap);\n const item = next === null ? undefined : items[next];\n if (item && item.id !== value) onValueChange(item.id);\n };\n const stepRef = useRef(step);\n useEffect(() => {\n stepRef.current = step;\n });\n\n useEffect(() => {\n if (!keys) return;\n const onKey = (event: KeyboardEvent) => {\n if (event.metaKey || event.ctrlKey || event.altKey || isTypingTarget(event.target)) return;\n if (event.key === \"[\") stepRef.current(-1);\n else if (event.key === \"]\") stepRef.current(1);\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [keys]);\n\n useEffect(() => {\n listRef.current?.querySelector(\"[data-current]\")?.scrollIntoView({ block: \"nearest\", inline: \"nearest\" });\n }, [value]);\n\n const atStart = !wrap && index <= 0;\n const atEnd = !wrap && (index < 0 || index >= items.length - 1);\n\n return (\n <div className={cn(\"flex min-w-0 items-center gap-1.5\", className)}>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n icon={<ChevronLeft />}\n aria-label=\"Previous\"\n aria-keyshortcuts={keys ? \"[\" : undefined}\n disabled={items.length < 2 || atStart}\n onClick={() => step(-1)}\n />\n {/* The padding (and the matching scroll padding, for the current item scrolled into view)\n is the room for the current ring and the focus outline: the scroller clips at its edge. */}\n <ol ref={listRef} aria-label={ariaLabel} className=\"flex min-w-0 scroll-px-1 gap-1 overflow-x-auto p-1\">\n {items.map((item) => {\n const current = item.id === value;\n const { status } = item;\n const name = status ? `${item.label}, ${status.label}` : item.label;\n return (\n <li key={item.id} className=\"shrink-0\">\n <button\n type=\"button\"\n title={name}\n aria-label={name}\n aria-current={current ? \"true\" : undefined}\n data-current={current ? \"\" : undefined}\n data-status={status?.tone}\n onClick={() => {\n if (!current) onValueChange(item.id);\n }}\n className={cn(\n \"relative block h-10 w-14 overflow-hidden rounded-control border border-line bg-raised text-fg\",\n \"data-current:ring-2 data-current:ring-signal\",\n focusRing,\n )}\n >\n {renderThumbnail ? (\n renderThumbnail(item)\n ) : item.thumbnail ? (\n <img src={item.thumbnail} alt=\"\" loading=\"lazy\" decoding=\"async\" className=\"h-full w-full object-cover\" />\n ) : (\n <span className={cn(\"block truncate px-1 font-mono text-[10px]\", status && \"pr-3\")}>{item.label}</span>\n )}\n {status && (\n // The surface-coloured backing keeps the dot legible over any thumbnail.\n <StatusDot tone={status.tone} className=\"absolute top-0.5 right-0.5 rounded-full bg-surface p-0.5\" />\n )}\n </button>\n </li>\n );\n })}\n </ol>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n icon={<ChevronRight />}\n aria-label=\"Next\"\n aria-keyshortcuts={keys ? \"]\" : undefined}\n disabled={items.length < 2 || atEnd}\n onClick={() => step(1)}\n />\n <span className=\"shrink-0 font-mono text-xs text-fg-muted tabular-nums\">\n {index >= 0 ? index + 1 : \"–\"} / {items.length}\n </span>\n {keys && (\n <span className=\"hidden shrink-0 items-center gap-0.5 text-xs text-fg-muted sm:flex\" aria-hidden>\n <Kbd>[</Kbd>\n <Kbd>]</Kbd>\n </span>\n )}\n </div>\n );\n}\n\nfunction isTypingTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" || target.isContentEditable;\n}\n","/*\n * The arithmetic of `SequenceMatrix`, apart from the DOM: where the cursor goes on a key, which\n * rows and columns a scroll position shows, how far to scroll to reveal a cell, and the rectangle\n * of a selection. Pure, so the edges (an empty grid, a page past the end) are tested without a browser.\n */\n\n/** A cell by position: zero-based row and column indices. */\nexport interface GridPos {\n /** The row index. */\n row: number;\n /** The column index. */\n col: number;\n}\n\n/** The grid's size in cells. */\nexport interface GridSize {\n /** The number of rows. */\n rows: number;\n /** The number of columns. */\n cols: number;\n}\n\n/** A rectangle of cells, both ends inclusive. */\nexport interface GridRect {\n /** The first row. */\n row0: number;\n /** The last row. */\n row1: number;\n /** The first column. */\n col0: number;\n /** The last column. */\n col1: number;\n}\n\nconst clamp = (value: number, low: number, high: number) => Math.min(high, Math.max(low, value));\n\n/**\n * Where a navigation key takes the cursor.\n *\n * - Arrows move one cell and stop at the edge.\n * - `Home` and `End` go to the first and last column of the row; with `ctrl`, to the first and\n * last cell of the grid.\n * - `PageUp` and `PageDown` move `page` rows.\n *\n * @param from - The cursor.\n * @param key - A `KeyboardEvent.key`.\n * @param size - The grid.\n * @param page - Rows in a page, at least 1.\n * @param ctrl - Whether Ctrl (or Cmd) is held.\n * @returns The new position, or `null` when the key is not a navigation key or the grid is empty.\n * The position is clamped, so it may equal `from`.\n */\nexport function moveFocus(from: GridPos, key: string, size: GridSize, page: number, ctrl = false): GridPos | null {\n if (size.rows <= 0 || size.cols <= 0) return null;\n const lastRow = size.rows - 1;\n const lastCol = size.cols - 1;\n const step = Math.max(1, Math.floor(page));\n const at = (row: number, col: number): GridPos => ({ row: clamp(row, 0, lastRow), col: clamp(col, 0, lastCol) });\n switch (key) {\n case \"ArrowUp\":\n return at(from.row - 1, from.col);\n case \"ArrowDown\":\n return at(from.row + 1, from.col);\n case \"ArrowLeft\":\n return at(from.row, from.col - 1);\n case \"ArrowRight\":\n return at(from.row, from.col + 1);\n case \"Home\":\n return ctrl ? at(0, 0) : at(from.row, 0);\n case \"End\":\n return ctrl ? at(lastRow, lastCol) : at(from.row, lastCol);\n case \"PageUp\":\n return at(from.row - step, from.col);\n case \"PageDown\":\n return at(from.row + step, from.col);\n default:\n return null;\n }\n}\n\n/**\n * The items of one axis to render for a scroll position, plus a margin.\n *\n * @param scroll - The scroll offset along the axis, in pixels, from the start of the body.\n * @param viewport - The room the body has on that axis (the scroller's size less the sticky header).\n * @param size - One item's size in pixels.\n * @param count - The number of items.\n * @param overscan - Extra items on each side.\n * @returns `[start, end)`: indices to render. `[0, 0)` for no items or a non-positive size.\n */\nexport function windowRange(scroll: number, viewport: number, size: number, count: number, overscan: number): [number, number] {\n if (count <= 0 || !(size > 0)) return [0, 0];\n const first = Math.floor(Math.max(0, scroll) / size);\n const last = Math.ceil((Math.max(0, scroll) + Math.max(0, viewport)) / size);\n // A scroll far past the end still shows the last item.\n if (first >= count) return [Math.max(0, count - 1 - overscan), count];\n const start = clamp(first - overscan, 0, count);\n return [start, clamp(last + overscan, start, count)];\n}\n\n/**\n * The scroll offset that brings an item fully into view, moving as little as possible.\n *\n * @param scroll - The current offset.\n * @param viewport - The room the body has on this axis.\n * @param index - The item.\n * @param size - One item's size.\n * @returns The offset: unchanged when the item is in view already, never negative.\n */\nexport function revealScroll(scroll: number, viewport: number, index: number, size: number): number {\n const start = index * size;\n const end = start + size;\n if (start < scroll) return Math.max(0, start);\n if (end > scroll + viewport) return Math.max(0, end - viewport);\n return scroll;\n}\n\n/** The rectangle between two cells, in whichever order they are given. */\nexport function rectBetween(a: GridPos, b: GridPos): GridRect {\n return { row0: Math.min(a.row, b.row), row1: Math.max(a.row, b.row), col0: Math.min(a.col, b.col), col1: Math.max(a.col, b.col) };\n}\n\n/** Whether a cell is in a rectangle. */\nexport function inRect(rect: GridRect | null, row: number, col: number): boolean {\n return rect !== null && row >= rect.row0 && row <= rect.row1 && col >= rect.col0 && col <= rect.col1;\n}\n","/*\n * A two-dimensional grid of captures: views down, cameras across, one cell each.\n *\n * Built for the overview of a calibration dataset, where ten cameras by several hundred views\n * must stay light and a person must be able to walk it cell by cell. A `Table` windows rows and\n * moves focus by row; this windows both axes and moves focus by cell. The caller draws each cell\n * (a thumbnail, a count, a state); the matrix owns the geometry, the sticky headers, the\n * keyboard, the selection and the grid roles.\n *\n * Only the cells in view, plus a margin and the focused cell, are in the DOM. Every handler is\n * on the scroller and finds its cell from the event's target, so there is no listener per cell.\n */\n\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, MouseEvent, ReactNode } from \"react\";\n\nimport { cn, focusRingInset } from \"@vitavision/ui\";\n\nimport { inRect, moveFocus, rectBetween, revealScroll, windowRange, type GridPos } from \"./matrixModel\";\n\n/** One row of a `SequenceMatrix`: a view, a frame. */\nexport interface SequenceMatrixRow {\n /** Its identity, unique among the rows. */\n id: string;\n /** What the row header shows. */\n label: ReactNode;\n /** The row's name for assistive technology, when `label` is not text. Defaults to `label` as text, else `id`. */\n name?: string | undefined;\n}\n\n/** One column of a `SequenceMatrix`: a camera, a channel. */\nexport interface SequenceMatrixColumn {\n /** Its identity, unique among the columns. */\n id: string;\n /** What the column header shows. */\n label: ReactNode;\n /** The column's name for assistive technology, when `label` is not text. Defaults to `label` as text, else `id`. */\n name?: string | undefined;\n}\n\n/**\n * A selection: the cell `row` / `col`, or the rectangle from it to `rowTo` / `colTo`.\n *\n * `row` and `col` are the anchor (where the selection started); a range extends from there, in\n * either direction. A whole row is `{ row, col: firstColumn, colTo: lastColumn }`.\n */\nexport interface SequenceMatrixSelection {\n /** The anchor's row id. */\n row: string;\n /** The anchor's column id. */\n col: string;\n /** The row id the range extends to. Omitted: the anchor's row. */\n rowTo?: string | undefined;\n /** The column id the range extends to. Omitted: the anchor's column. */\n colTo?: string | undefined;\n}\n\n/** What `renderCell` is told about the cell it draws. */\nexport interface SequenceMatrixCellState {\n /** The cell has the keyboard focus. */\n focused: boolean;\n /** The cell is in the selection. */\n selected: boolean;\n}\n\n/** Props of `SequenceMatrix`. */\nexport interface SequenceMatrixProps {\n /** The rows, top to bottom. */\n rows: readonly SequenceMatrixRow[];\n /** The columns, left to right. */\n columns: readonly SequenceMatrixColumn[];\n /**\n * Draws a cell's content. It fills the cell's box (`colWidth` by `rowHeight`) and is called for\n * the cells in view only, so it may be as rich as a thumbnail. The cell is a `gridcell`; give\n * it an accessible name with `cellLabel` when its content is not text.\n */\n renderCell: (row: SequenceMatrixRow, column: SequenceMatrixColumn, state: SequenceMatrixCellState) => ReactNode;\n /** The cell's accessible name (`aria-label`), e.g. `\"view 12, camera 3, 48 corners\"`. Omitted: the cell's content names it. */\n cellLabel?: ((row: SequenceMatrixRow, column: SequenceMatrixColumn) => string | undefined) | undefined;\n /** Draws a row header's content. Defaults to `row.label`. Interactive content here is the caller's to make focusable. */\n renderRowHeader?: ((row: SequenceMatrixRow) => ReactNode) | undefined;\n /** Draws a column header's content. Defaults to `column.label`. */\n renderColumnHeader?: ((column: SequenceMatrixColumn) => ReactNode) | undefined;\n /** The corner's text. Defaults to nothing visible; the corner is named \"Rows\". */\n corner?: ReactNode;\n /** A row's height in CSS pixels. Defaults to 36. */\n rowHeight?: number | undefined;\n /** Every column's width in CSS pixels. Defaults to 72. */\n colWidth?: number | undefined;\n /** The column headers' height. Defaults to 32. */\n headerHeight?: number | undefined;\n /** The row headers' width. Defaults to 96. */\n rowHeaderWidth?: number | undefined;\n /** Rows and columns rendered beyond the viewport on each side. Defaults to 3. */\n overscan?: number | undefined;\n /** Render only the cells in view. Defaults to true; off, every cell is rendered (a small matrix). */\n windowed?: boolean | undefined;\n /** The selection, controlled: `null` for none. Pair with `onValueChange`. */\n value?: SequenceMatrixSelection | null | undefined;\n /** The initial selection, when uncontrolled. */\n defaultValue?: SequenceMatrixSelection | null | undefined;\n /** Called with the new selection on a click, Space, Enter, or Shift + a move, and on a header click. */\n onValueChange?: ((value: SequenceMatrixSelection) => void) | undefined;\n /** Select the cell the arrow keys land on, as well as focus it. Defaults to false: arrows move, Space or Enter selects. */\n selectionFollowsFocus?: boolean | undefined;\n /** Allow a range (Shift + click or move, header click, Ctrl + A). Defaults to true; off, selection is one cell. */\n multiple?: boolean | undefined;\n /** Called with the cell's row and column ids on Enter and on a double click. */\n onCellAction?: ((row: string, column: string) => void) | undefined;\n /** Names the grid. */\n \"aria-label\": string;\n /** Merged onto the scroller with `cn`. Give the matrix a height (and a width): it scrolls inside its box. */\n className?: string | undefined;\n /** Inline style of the scroller, after the matrix's own: its size when a class is not at hand. */\n style?: CSSProperties | undefined;\n}\n\nconst DEFAULTS = { rowHeight: 36, colWidth: 72, headerHeight: 32, rowHeaderWidth: 96, overscan: 3 } as const;\n/** The room assumed before the scroller is measured, and on the server. */\nconst INITIAL_VIEWPORT = { width: 640, height: 400 } as const;\n\ninterface Win {\n rows: [number, number];\n cols: [number, number];\n}\n\nconst sameWin = (a: Win, b: Win) =>\n a.rows[0] === b.rows[0] && a.rows[1] === b.rows[1] && a.cols[0] === b.cols[0] && a.cols[1] === b.cols[1];\n\nconst nameOf = (item: { id: string; label: ReactNode; name?: string | undefined }) =>\n item.name ?? (typeof item.label === \"string\" || typeof item.label === \"number\" ? String(item.label) : item.id);\n\n/** The grid cell, row header or column header an event came from, with its position. */\nfunction locate(target: EventTarget | null): { kind: \"cell\" | \"row\" | \"col\"; row: number; col: number; element: HTMLElement } | null {\n const element = (target as Element | null)?.closest?.<HTMLElement>(\"[data-cell],[data-row-header],[data-col-header]\");\n if (!element) return null;\n const row = Number(element.dataset[\"r\"] ?? -1);\n const col = Number(element.dataset[\"c\"] ?? -1);\n if (element.hasAttribute(\"data-cell\")) return { kind: \"cell\", row, col, element };\n return element.hasAttribute(\"data-row-header\") ? { kind: \"row\", row, col, element } : { kind: \"col\", row, col, element };\n}\n\n/**\n * A windowed rows-by-columns grid with sticky headers and cell-level keyboard focus.\n *\n * - **Windowed in both axes**: only the cells in view (plus `overscan`, plus the focused cell) are\n * in the DOM, so ten columns by several hundred rows are a few dozen elements. Row height and\n * column width are uniform.\n * - **Keyboard**: the grid is one Tab stop (roving `tabindex` on the focused cell). Arrows move by\n * cell, Home/End to the ends of the row, Ctrl + Home/End to the corners, PageUp/PageDown by a\n * screenful of rows. Space or Enter selects the focused cell and Enter also calls `onCellAction`;\n * Shift + a move or Shift + click extends the selection to a rectangle; Shift + Space selects\n * the focused row, Ctrl + Space its column, Ctrl + A everything.\n * - **Selection**: one cell or a rectangle, controlled (`value`) or not. A click on a row or\n * column header selects that whole row or column.\n * - **Roles**: `grid` with `aria-rowcount` and `aria-colcount` (counting the headers), `row`s with\n * `aria-rowindex`, `columnheader`, `rowheader` and `gridcell`s with `aria-colindex` and\n * `aria-selected`; the whole rectangle is `aria-multiselectable`. Cells carry `data-selected`\n * and `data-focused`.\n * - **No listeners per cell**: clicks, keys and focus are handled once, on the scroller.\n *\n * Server rendering draws the first screenful of an assumed 640 by 400 px, without measuring.\n */\nexport function SequenceMatrix({\n rows,\n columns,\n renderCell,\n cellLabel,\n renderRowHeader,\n renderColumnHeader,\n corner,\n rowHeight = DEFAULTS.rowHeight,\n colWidth = DEFAULTS.colWidth,\n headerHeight = DEFAULTS.headerHeight,\n rowHeaderWidth = DEFAULTS.rowHeaderWidth,\n overscan = DEFAULTS.overscan,\n windowed = true,\n value: controlled,\n defaultValue = null,\n onValueChange,\n selectionFollowsFocus = false,\n multiple = true,\n onCellAction,\n \"aria-label\": ariaLabel,\n className,\n style,\n}: SequenceMatrixProps) {\n const scrollerRef = useRef<HTMLDivElement>(null);\n const [inner, setInner] = useState<SequenceMatrixSelection | null>(defaultValue);\n const value = controlled === undefined ? inner : controlled;\n const [focus, setFocus] = useState<GridPos | null>(null);\n const [hasFocus, setHasFocus] = useState(false);\n const focusPending = useRef(false);\n\n const rowIndex = useMemo(() => new Map(rows.map((row, i) => [row.id, i])), [rows]);\n const colIndex = useMemo(() => new Map(columns.map((column, i) => [column.id, i])), [columns]);\n const nRows = rows.length;\n const nCols = columns.length;\n\n const initialWin = (): Win =>\n windowed\n ? {\n rows: windowRange(0, INITIAL_VIEWPORT.height - headerHeight, rowHeight, nRows, overscan),\n cols: windowRange(0, INITIAL_VIEWPORT.width - rowHeaderWidth, colWidth, nCols, overscan),\n }\n : { rows: [0, nRows], cols: [0, nCols] };\n const [win, setWin] = useState<Win>(initialWin);\n\n const measure = useCallback(() => {\n const el = scrollerRef.current;\n if (!el) return;\n const next: Win = windowed\n ? {\n rows: windowRange(el.scrollTop, el.clientHeight - headerHeight, rowHeight, nRows, overscan),\n cols: windowRange(el.scrollLeft, el.clientWidth - rowHeaderWidth, colWidth, nCols, overscan),\n }\n : { rows: [0, nRows], cols: [0, nCols] };\n setWin((prev) => (sameWin(prev, next) ? prev : next));\n }, [windowed, headerHeight, rowHeight, nRows, overscan, rowHeaderWidth, colWidth, nCols]);\n\n // The window follows the geometry and the data; the scroller's size is observed.\n useLayoutEffect(() => {\n measure();\n }, [measure]);\n useEffect(() => {\n const el = scrollerRef.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(() => measure());\n observer.observe(el);\n return () => observer.disconnect();\n }, [measure]);\n\n const range = useMemo(() => {\n if (!value) return null;\n const a = { row: rowIndex.get(value.row), col: colIndex.get(value.col) };\n const b = { row: rowIndex.get(value.rowTo ?? value.row), col: colIndex.get(value.colTo ?? value.col) };\n if (a.row === undefined || a.col === undefined || b.row === undefined || b.col === undefined) return null;\n return rectBetween({ row: a.row, col: a.col }, { row: b.row, col: b.col });\n }, [value, rowIndex, colIndex]);\n\n const anchor: GridPos | null = useMemo(() => {\n if (!value) return null;\n const row = rowIndex.get(value.row);\n const col = colIndex.get(value.col);\n return row === undefined || col === undefined ? null : { row, col };\n }, [value, rowIndex, colIndex]);\n\n // The one cell in the tab order: the focused one, else the selection's anchor, else the first.\n const clampPos = (pos: GridPos): GridPos => ({\n row: Math.min(Math.max(0, pos.row), Math.max(0, nRows - 1)),\n col: Math.min(Math.max(0, pos.col), Math.max(0, nCols - 1)),\n });\n const tabStop = clampPos(focus ?? anchor ?? { row: 0, col: 0 });\n\n const commit = (next: SequenceMatrixSelection) => {\n if (controlled === undefined) setInner(next);\n onValueChange?.(next);\n };\n const selectRange = (from: GridPos, to: GridPos) => {\n const a = rows[from.row];\n const b = rows[to.row];\n const c = columns[from.col];\n const d = columns[to.col];\n if (!a || !b || !c || !d) return;\n const one = from.row === to.row && from.col === to.col;\n commit(one || !multiple ? { row: b.id, col: d.id } : { row: a.id, col: c.id, rowTo: b.id, colTo: d.id });\n };\n\n const bodyViewport = () => {\n const el = scrollerRef.current;\n return {\n height: (el?.clientHeight ?? INITIAL_VIEWPORT.height) - headerHeight,\n width: (el?.clientWidth ?? INITIAL_VIEWPORT.width) - rowHeaderWidth,\n };\n };\n\n /** Moves the cursor to `pos`: scrolls it into view and gives it the DOM focus once rendered. */\n const moveTo = (pos: GridPos) => {\n const el = scrollerRef.current;\n if (el) {\n const viewport = bodyViewport();\n el.scrollTop = revealScroll(el.scrollTop, viewport.height, pos.row, rowHeight);\n el.scrollLeft = revealScroll(el.scrollLeft, viewport.width, pos.col, colWidth);\n }\n focusPending.current = true;\n setFocus(pos);\n };\n\n useEffect(() => {\n if (!focusPending.current) return;\n const el = scrollerRef.current?.querySelector<HTMLElement>(`[data-cell][data-r=\"${tabStop.row}\"][data-c=\"${tabStop.col}\"]`);\n if (!el) return;\n focusPending.current = false;\n el.focus({ preventScroll: true });\n });\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const hit = locate(event.target);\n // Keys typed into something inside a cell (an input, a menu) are not the grid's.\n if (!hit || hit.kind !== \"cell\" || hit.element !== event.target || nRows === 0 || nCols === 0) return;\n const here = { row: hit.row, col: hit.col };\n const ctrl = event.ctrlKey || event.metaKey;\n if (event.altKey) return;\n\n if (event.key === \" \") {\n event.preventDefault();\n if (event.shiftKey && multiple) selectRange({ row: here.row, col: 0 }, { row: here.row, col: nCols - 1 });\n else if (ctrl && multiple) selectRange({ row: 0, col: here.col }, { row: nRows - 1, col: here.col });\n else selectRange(here, here);\n return;\n }\n if (event.key === \"Enter\") {\n event.preventDefault();\n selectRange(here, here);\n onCellAction?.(rows[here.row]!.id, columns[here.col]!.id);\n return;\n }\n if (ctrl && event.key.toLowerCase() === \"a\") {\n if (!multiple) return;\n event.preventDefault();\n selectRange({ row: 0, col: 0 }, { row: nRows - 1, col: nCols - 1 });\n return;\n }\n const page = Math.max(1, Math.floor(bodyViewport().height / rowHeight) - 1);\n const next = moveFocus(here, event.key, { rows: nRows, cols: nCols }, page, ctrl);\n if (next === null) return;\n event.preventDefault();\n moveTo(next);\n if (event.shiftKey && multiple) selectRange(anchor ?? here, next);\n else if (selectionFollowsFocus) selectRange(next, next);\n };\n\n const onClick = (event: MouseEvent<HTMLDivElement>) => {\n const hit = locate(event.target);\n if (!hit) return;\n // A button or menu the caller put in a header is its own: it does not also select the row.\n if (hit.kind !== \"cell\" && (event.target as Element).closest(\"button,a,input,select,textarea,[role=menu]\")) return;\n if (hit.kind === \"cell\") {\n setFocus({ row: hit.row, col: hit.col });\n const here = { row: hit.row, col: hit.col };\n if (event.shiftKey && multiple && anchor) selectRange(anchor, here);\n else selectRange(here, here);\n } else if (multiple && hit.kind === \"row\") selectRange({ row: hit.row, col: 0 }, { row: hit.row, col: nCols - 1 });\n else if (multiple && hit.kind === \"col\") selectRange({ row: 0, col: hit.col }, { row: nRows - 1, col: hit.col });\n };\n\n const onDoubleClick = (event: MouseEvent<HTMLDivElement>) => {\n const hit = locate(event.target);\n if (hit?.kind === \"cell\") onCellAction?.(rows[hit.row]!.id, columns[hit.col]!.id);\n };\n\n // Rows and columns to render: the window, and the focused ones wherever they are, so the tab stop never unmounts.\n const withFocus = (window: [number, number], at: number, count: number): number[] => {\n const out: number[] = [];\n let placed = at < 0 || at >= count || (at >= window[0] && at < window[1]);\n for (let i = window[0]; i < window[1]; i++) {\n if (!placed && at < i) {\n out.push(at);\n placed = true;\n }\n out.push(i);\n }\n if (!placed) out.push(at);\n return out;\n };\n // `win` is measured after a render, so on the render where the data shrinks it still names rows\n // and columns that are gone: clamp it to the data in hand.\n const clampWin = (w: [number, number], count: number): [number, number] => {\n const end = Math.min(w[1], count);\n return [Math.min(w[0], end), end];\n };\n const rowsShown = withFocus(clampWin(win.rows, nRows), tabStop.row, nRows);\n const colsShown = withFocus(clampWin(win.cols, nCols), tabStop.col, nCols);\n\n const totalWidth = rowHeaderWidth + nCols * colWidth;\n const totalHeight = headerHeight + nRows * rowHeight;\n const fullRow = (i: number) => range !== null && range.row0 <= i && i <= range.row1 && range.col0 === 0 && range.col1 === nCols - 1;\n const fullCol = (j: number) => range !== null && range.col0 <= j && j <= range.col1 && range.row0 === 0 && range.row1 === nRows - 1;\n\n return (\n <div\n ref={scrollerRef}\n role=\"grid\"\n aria-label={ariaLabel}\n aria-rowcount={nRows + 1}\n aria-colcount={nCols + 1}\n aria-multiselectable={multiple ? true : undefined}\n // With no cell to focus, the scroller itself is the keyboard stop.\n tabIndex={nRows === 0 || nCols === 0 ? 0 : undefined}\n onScroll={measure}\n onKeyDown={onKeyDown}\n onClick={onClick}\n onDoubleClick={onDoubleClick}\n onFocus={(event) => {\n setHasFocus(true);\n const hit = locate(event.target);\n if (hit?.kind === \"cell\") setFocus({ row: hit.row, col: hit.col });\n }}\n onBlur={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget)) setHasFocus(false);\n }}\n // Native focus scrolling keeps a cell clear of the sticky headers.\n style={{ position: \"relative\", overflow: \"auto\", scrollPaddingTop: headerHeight, scrollPaddingLeft: rowHeaderWidth, ...style }}\n className={cn(\"rounded-control border border-line bg-surface text-fg select-none\", className)}\n >\n <div style={{ position: \"relative\", width: totalWidth, height: totalHeight }}>\n <div role=\"row\" aria-rowindex={1} style={{ position: \"sticky\", top: 0, zIndex: 20, height: headerHeight, width: totalWidth }}>\n <div\n role=\"columnheader\"\n aria-colindex={1}\n className=\"flex items-center border-r border-b border-line bg-raised px-2 text-xs text-fg-muted\"\n style={{ position: \"sticky\", left: 0, zIndex: 30, width: rowHeaderWidth, height: headerHeight }}\n >\n {corner ?? <span className=\"sr-only\">Rows</span>}\n </div>\n {colsShown.map((j) => {\n const column = columns[j]!;\n return (\n <div\n key={column.id}\n role=\"columnheader\"\n aria-colindex={j + 2}\n aria-label={nameOf(column)}\n aria-selected={fullCol(j) ? true : undefined}\n data-col-header=\"\"\n data-c={j}\n data-selected={fullCol(j) ? \"\" : undefined}\n className={cn(\n \"flex items-center justify-center overflow-hidden border-r border-b border-line px-1 text-xs\",\n fullCol(j) ? \"bg-signal/12 text-fg\" : \"bg-raised text-fg-muted\",\n )}\n style={{ position: \"absolute\", top: 0, left: rowHeaderWidth + j * colWidth, width: colWidth, height: headerHeight }}\n >\n {renderColumnHeader ? renderColumnHeader(column) : column.label}\n </div>\n );\n })}\n </div>\n {rowsShown.map((i) => {\n const row = rows[i]!;\n return (\n <div\n key={row.id}\n role=\"row\"\n aria-rowindex={i + 2}\n style={{ position: \"absolute\", top: headerHeight + i * rowHeight, left: 0, height: rowHeight, width: totalWidth }}\n >\n <div\n role=\"rowheader\"\n aria-colindex={1}\n aria-label={nameOf(row)}\n aria-selected={fullRow(i) ? true : undefined}\n data-row-header=\"\"\n data-r={i}\n data-selected={fullRow(i) ? \"\" : undefined}\n className={cn(\n \"flex items-center overflow-hidden border-r border-b border-line px-2 text-xs\",\n fullRow(i) ? \"bg-signal/12 text-fg\" : \"bg-raised text-fg-muted\",\n )}\n style={{ position: \"sticky\", left: 0, zIndex: 10, width: rowHeaderWidth, height: rowHeight }}\n >\n {renderRowHeader ? renderRowHeader(row) : row.label}\n </div>\n {colsShown.map((j) => {\n const column = columns[j]!;\n const selected = inRect(range, i, j);\n const isStop = i === tabStop.row && j === tabStop.col;\n const focused = hasFocus && isStop;\n return (\n <div\n key={column.id}\n role=\"gridcell\"\n aria-colindex={j + 2}\n aria-selected={selected}\n aria-label={cellLabel?.(row, column)}\n tabIndex={isStop ? 0 : -1}\n data-cell=\"\"\n data-r={i}\n data-c={j}\n data-selected={selected ? \"\" : undefined}\n data-focused={focused ? \"\" : undefined}\n className={cn(\n \"overflow-hidden border-r border-b border-line\",\n selected ? \"bg-signal/12\" : \"hover:bg-raised\",\n focusRingInset,\n )}\n style={{ position: \"absolute\", top: 0, left: rowHeaderWidth + j * colWidth, width: colWidth, height: rowHeight }}\n >\n {renderCell(row, column, { focused, selected })}\n </div>\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n","/*\n * What each step of a `Stepper` is, as a pure function, so the rules (a blocked step cannot\n * be entered, the current step outranks every other state) are tested without a DOM.\n */\n\n/**\n * Where a step stands: `current` (the one a person is on), `blocked` (cannot be entered\n * yet; it says why), `complete` (done) or `upcoming` (not done, and open).\n */\nexport type StepState = \"current\" | \"complete\" | \"blocked\" | \"upcoming\";\n\n/** The part of a step its state depends on. */\nexport interface StepGate {\n /** Its identity, unique among the steps. */\n id: string;\n /** Why it cannot be entered yet. A step with a non-empty reason is blocked. */\n blockedBy?: string | undefined;\n /** Whether it is done. */\n complete?: boolean | undefined;\n}\n\n/** One step's state, and whether choosing it would make it current. */\nexport interface StepView {\n /** The step's id. */\n id: string;\n /** Where the step stands. */\n state: StepState;\n /** True when choosing it makes it current: it is neither blocked nor current already. */\n canActivate: boolean;\n}\n\n/**\n * Each step's state, in order.\n *\n * The step whose id is `current` is `current`, whatever else is true of it: the app put the\n * person there. Of the others, one with a `blockedBy` reason is `blocked` (even if `complete`:\n * a step can be done and then fall behind a newer gate), then `complete`, then `upcoming`.\n * Only a step that is neither current nor blocked can be activated.\n *\n * @param steps - The steps, in order.\n * @param current - The current step's id, or `null` for none.\n */\nexport function stepStates(steps: readonly StepGate[], current: string | null): StepView[] {\n return steps.map(({ id, blockedBy, complete }) => {\n const state: StepState = id === current ? \"current\" : blockedBy ? \"blocked\" : complete ? \"complete\" : \"upcoming\";\n return { id, state, canActivate: state === \"complete\" || state === \"upcoming\" };\n });\n}\n","/*\n * A gated sequence of steps — Teach, then Find, then Verify — where a step can be entered\n * only once what it depends on is in place, and says what that is.\n *\n * A disabled button would say nothing: it cannot be focused, so neither the tooltip nor a\n * screen reader can give the reason. A blocked step stays focusable, marked\n * `aria-disabled`, and carries its reason as its description.\n */\n\nimport { Check, Lock } from \"lucide-react\";\nimport { useId, useState, type ReactNode } from \"react\";\n\nimport { Tooltip, cn, focusRing } from \"@vitavision/ui\";\n\nimport { stepStates, type StepState } from \"./stepperModel\";\n\n/** One step of a `Stepper`. */\nexport interface StepperStep {\n /** Its identity, unique among the steps; the stepper's `value`. */\n id: string;\n /** Its name. */\n label: ReactNode;\n /**\n * Why it cannot be entered yet — \"Teach a model first\". A step with a reason is blocked:\n * shown, focusable and described by the reason, but not choosable.\n */\n blockedBy?: string | undefined;\n /** Marks it done (a check instead of its number). */\n complete?: boolean | undefined;\n}\n\n/** Props of `Stepper`. */\nexport interface StepperProps {\n /** The steps, in order. */\n steps: readonly StepperStep[];\n /** The current step's id, or `null` for none. Leave undefined to let the stepper keep it. */\n value?: string | null | undefined;\n /** The current step at first, when the stepper keeps it. Defaults to the first step. */\n defaultValue?: string | undefined;\n /** Called with a step's id when a person chooses a step that is neither current nor blocked. */\n onValueChange?: ((id: string) => void) | undefined;\n /** A row (the default) or a column. */\n orientation?: \"horizontal\" | \"vertical\" | undefined;\n /** Names the list of steps. */\n \"aria-label\": string;\n /** Merged with the list's own classes through `cn`. */\n className?: string | undefined;\n}\n\n/**\n * The steps of a gated sequence as an ordered list of buttons, numbered, with the current one\n * marked (`aria-current=\"step\"`) and done ones checked. Controlled with `value` and\n * `onValueChange`, or kept by the stepper from `defaultValue`.\n *\n * A step with `blockedBy` is blocked: it keeps its Tab stop but carries `aria-disabled`, its\n * reason is its description (`aria-describedby`) and its tooltip, and choosing it does nothing.\n * Each step carries `data-state` (`current`, `complete`, `blocked` or `upcoming`), and the\n * list `data-orientation`.\n */\nexport function Stepper({\n steps,\n value,\n defaultValue,\n onValueChange,\n orientation = \"horizontal\",\n \"aria-label\": ariaLabel,\n className,\n}: StepperProps) {\n const [kept, setKept] = useState<string | null>(() => defaultValue ?? steps[0]?.id ?? null);\n const current = value === undefined ? kept : value;\n const views = stepStates(steps, current);\n const baseId = useId();\n const vertical = orientation === \"vertical\";\n\n const choose = (id: string) => {\n if (value === undefined) setKept(id);\n onValueChange?.(id);\n };\n\n return (\n <ol\n aria-label={ariaLabel}\n data-orientation={orientation}\n className={cn(\"flex\", vertical ? \"flex-col items-start\" : \"flex-wrap items-center gap-y-1\", className)}\n >\n {steps.map((step, index) => {\n const view = views[index];\n if (view === undefined) return null;\n const { state, canActivate } = view;\n const blocked = state === \"blocked\";\n const reasonId = `${baseId}-${index}-reason`;\n const button = (\n <button\n type=\"button\"\n aria-current={state === \"current\" ? \"step\" : undefined}\n aria-disabled={blocked ? true : undefined}\n aria-describedby={blocked ? reasonId : undefined}\n data-state={state}\n onClick={() => {\n if (canActivate) choose(step.id);\n }}\n className={cn(\n \"flex items-center gap-2 rounded-control px-1.5 py-1 text-sm transition-colors\",\n state === \"current\" ? \"font-medium text-fg\" : \"text-fg-muted\",\n canActivate && \"hover:text-fg\",\n blocked && \"cursor-not-allowed\",\n focusRing,\n )}\n >\n <StepMarker state={state} number={index + 1} />\n <span>{step.label}</span>\n </button>\n );\n return (\n <li key={step.id} className={cn(\"flex\", vertical ? \"flex-col items-start\" : \"items-center\")}>\n {index > 0 && <span aria-hidden className={cn(\"bg-line-strong\", vertical ? \"ml-4 h-3 w-px\" : \"mx-1 h-px w-6\")} />}\n {blocked ? <Tooltip content={step.blockedBy}>{button}</Tooltip> : button}\n {blocked && (\n <span id={reasonId} className=\"sr-only\">\n {step.blockedBy}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n );\n}\n\n/** The step's number in a circle; a check when done, a lock when blocked. Decorative. */\nfunction StepMarker({ state, number }: { state: StepState; number: number }) {\n return (\n <span\n aria-hidden\n className={cn(\n \"grid size-5 shrink-0 place-items-center rounded-full border font-mono text-[11px] tabular-nums [&>svg]:size-3\",\n state === \"current\" && \"border-signal bg-signal text-signal-fg\",\n state === \"complete\" && \"border-signal text-signal\",\n state === \"blocked\" && \"border-line-strong text-fg-muted\",\n state === \"upcoming\" && \"border-line-strong text-fg-muted\",\n )}\n >\n {state === \"complete\" ? <Check /> : state === \"blocked\" ? <Lock /> : number}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,YAAY,MAAgB,QAAwB;CAClE,MAAM,KAAK,OAAO,SAAS,WAAW,OAAQ,OAAO,WAAW,IAAI,IAAI,MAAO;CAC/E,OAAO,OAAO,SAAS,EAAE,IAAI,KAAK,IAAI,GAAG,EAAE,IAAI;AACjD;;;;;;;;;;;AAYA,SAAgB,cAAc,QAAgB,UAAoB,GAAG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