strata-react 1.3.16 → 1.3.18

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 CHANGED
@@ -1,13 +1,12 @@
1
- import { a as Textarea, c as useSearchParam, d as cn, f as typeSteps, i as NativeSelect, l as Tooltip, n as Field, o as useFieldControl, r as Input, s as controlHeight, t as ChoiceGroup, u as KeyText } from "./field-jfhLD5XX.js";
2
- import { a as toDate, i as format, n as NBSP, r as createFormat, t as MISSING } from "./format-BNkXVwFx.js";
3
- import { a as useAsyncAction, c as KeysLegend, d as useInView, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-WRXbtUp6.js";
4
- import { a as fieldErrorsOf, c as IconButton, d as isDev, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-D0TsKLwJ.js";
5
- import { a as useMicrophone, c as toastTimeout, d as fetchJson, f as staleOf, g as overlaySurface, h as usePoll, i as explainMicrophoneError, l as StrataQueryProvider, m as useLoad, n as MicrophoneError, o as StrataToastRegion, p as toLoad, r as browserMicrophone, s as toast, t as MicrophoneContext, u as createQueryClient } from "./microphone-CZy0bNEx.js";
1
+ import { _ as typeSteps, a as Textarea, c as useSearchParam, d as MISSING, f as NBSP, g as cn, h as toDate, i as NativeSelect, l as Tooltip, m as format, n as Field, o as useFieldControl, p as createFormat, r as Input, s as controlHeight, t as ChoiceGroup, u as KeyText } from "./field-t4Hoer0d.js";
2
+ import { a as fieldErrorsOf, c as IconButton, d as isDev, f as useInView, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-jep2voNI.js";
3
+ import { A as StrataQueryProvider, C as toast, D as LoadError, E as EmptyState, F as useLoad, I as usePoll, L as overlaySurface, M as fetchJson, N as staleOf, O as Skeleton, P as toLoad, S as StrataToastRegion, T as DataView$1, _ as clampViewport, a as useMicrophone, b as viewportTransform, d as zoomToBox, f as FIT, g as boxViewport, h as actualPixelsScale, i as explainMicrophoneError, j as createQueryClient, k as StaleNotice, l as readingOrder, m as MIN_SCALE, n as MicrophoneError, o as Thumbnail, p as MAX_SCALE, r as browserMicrophone, s as ThumbnailSkeleton, t as MicrophoneContext, u as regionStyle, v as frameBoxToShares, w as toastTimeout, x as zoomAt, y as regionShares } from "./microphone-B5ITwm4G.js";
4
+ import { a as useAsyncAction, c as KeysLegend, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-DB5l5Qe2.js";
6
5
  import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
7
- import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-CFBAYaiu.js";
6
+ import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-DXacprlw.js";
8
7
  import * as React from "react";
9
8
  import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
10
- import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, History, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
9
+ import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
11
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
11
  import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
13
12
  import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
@@ -1259,105 +1258,6 @@ function useWorkflowRun({ finished, ...options }) {
1259
1258
  isRunning: (run) => isWorkflowRunning(run, finished)
1260
1259
  });
1261
1260
  }
1262
- // src/components/data-view.tsx
1263
- /** The default failed-read panel: the reason on the danger tint, with Try again. Its parent carries `role="alert"`. */
1264
- function LoadError({ message, retry, className }) {
1265
- return /* @__PURE__ */ jsxs("div", {
1266
- className: cn("flex flex-wrap items-start gap-3 rounded-surface bg-danger-subtle p-4 text-danger", className),
1267
- children: [
1268
- /* @__PURE__ */ jsx(CircleAlert, {
1269
- "aria-hidden": true,
1270
- className: "mt-0.5 size-5 shrink-0"
1271
- }),
1272
- /* @__PURE__ */ jsx("p", {
1273
- className: "min-w-0 flex-1 type-body",
1274
- children: message
1275
- }),
1276
- /* @__PURE__ */ jsxs(Button, {
1277
- size: "sm",
1278
- onClick: retry,
1279
- children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), "Try again"]
1280
- })
1281
- ]
1282
- });
1283
- }
1284
- var defaultError = (failure) => /* @__PURE__ */ jsx(LoadError, { ...failure });
1285
- /** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`, under a `StaleNotice` when a refresh failed. The skeleton and empty state are required. */
1286
- function DataView$1({ state, isEmpty, skeleton, empty, children, staleNotice = (stale) => /* @__PURE__ */ jsx(StaleNotice, { stale }), error = defaultError, className }) {
1287
- return /* @__PURE__ */ jsxs("div", {
1288
- className: cn("min-w-0", className),
1289
- "aria-busy": state.status === "loading" || void 0,
1290
- children: [
1291
- state.status === "loading" && skeleton,
1292
- state.status === "error" && /* @__PURE__ */ jsx("div", {
1293
- role: "alert",
1294
- children: error({
1295
- message: state.message,
1296
- retry: state.retry
1297
- })
1298
- }),
1299
- state.status === "ready" && /* @__PURE__ */ jsxs(Fragment, { children: [state.stale && staleNotice(state.stale), isEmpty(state.data) ? empty : children(state.data)] })
1300
- ]
1301
- });
1302
- }
1303
- /** When `readAt` was, for a person: the clock time today, else the weekday and time. */
1304
- function readTime(readAt, now = /* @__PURE__ */ new Date()) {
1305
- return readAt.toDateString() === now.toDateString() ? format.clock.format(readAt) : format.shortDay.format(readAt);
1306
- }
1307
- /** The notice over data whose refresh failed: what happened, how old the data shown is, and Try again. A polite status, not an alert: nothing was lost. */
1308
- function StaleNotice({ stale, shown, className }) {
1309
- return /* @__PURE__ */ jsxs("div", {
1310
- role: "status",
1311
- className: cn("mb-4 flex flex-wrap items-start gap-3 rounded-surface bg-warning-subtle p-3 text-warning", className),
1312
- children: [
1313
- /* @__PURE__ */ jsx(History, {
1314
- "aria-hidden": true,
1315
- className: "mt-0.5 size-4 shrink-0"
1316
- }),
1317
- /* @__PURE__ */ jsxs("p", {
1318
- className: "min-w-0 flex-1 type-body-sm",
1319
- children: [
1320
- stale.message,
1321
- " ",
1322
- shown ? shown(readTime(stale.readAt)) : `Showing data from ${readTime(stale.readAt)}.`
1323
- ]
1324
- }),
1325
- /* @__PURE__ */ jsxs(Button, {
1326
- size: "sm",
1327
- onClick: stale.retry,
1328
- disabled: stale.retrying,
1329
- children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), stale.retrying ? "Trying again…" : "Try again"]
1330
- })
1331
- ]
1332
- });
1333
- }
1334
- /** An empty state that teaches the next action: a title, a sentence and an action. No illustration slot, on purpose. */
1335
- function EmptyState({ title, children, action }) {
1336
- return /* @__PURE__ */ jsxs("div", {
1337
- className: "grid justify-items-start gap-2 border-y border-border py-6",
1338
- children: [
1339
- /* @__PURE__ */ jsx("p", {
1340
- className: "type-heading",
1341
- children: title
1342
- }),
1343
- children && /* @__PURE__ */ jsx("p", {
1344
- className: "max-w-prose type-body text-muted-foreground",
1345
- children
1346
- }),
1347
- action && /* @__PURE__ */ jsx("div", {
1348
- className: "mt-2",
1349
- children: action
1350
- })
1351
- ]
1352
- });
1353
- }
1354
- /** A placeholder block for a loading layout. Size it with layout classes so it mirrors the final content. */
1355
- function Skeleton({ className }) {
1356
- return /* @__PURE__ */ jsx("div", {
1357
- "aria-hidden": true,
1358
- className: cn("rounded-control bg-muted motion-safe:animate-pulse", className)
1359
- });
1360
- }
1361
1261
  // src/components/system-panel.tsx
1362
1262
  /** The shared limits for a folder's disk, as shares of its size: filling up at 80%, nearly full at 95%. */
1363
1263
  var diskThresholds = [{
@@ -3366,96 +3266,6 @@ function ScheduleTable({ caption, rows, now, className }) {
3366
3266
  className
3367
3267
  });
3368
3268
  }
3369
- // src/components/thumbnail.tsx
3370
- var ratio = (aspect) => typeof aspect === "number" ? String(aspect) : aspect.replace("/", " / ");
3371
- /** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words (or a `fallback`) if it cannot, a request only when it nears the screen, and `children` overlaid in its corners. `alt` and `missing` or `fallback` are required. */
3372
- function Thumbnail({ src, alt, missing, aspect = 1, fit = "cover", srcSet, sizes, eager = false, rootMargin = "200px", className, fallback, onLoad, onMissing, children }) {
3373
- const sources = React.useMemo(() => src === null ? [] : typeof src === "string" ? src ? [src] : [] : src.filter(Boolean), [src]);
3374
- const key = sources.length ? `${sources.join("\n")} ${srcSet ?? ""}` : null;
3375
- const [outcome, setOutcome] = React.useState(null);
3376
- const mine = key !== null && outcome?.key === key ? outcome : null;
3377
- const index = mine?.index ?? 0;
3378
- const phase = key === null ? "missing" : mine?.done ?? "loading";
3379
- const current = sources[index];
3380
- const near = useInView({
3381
- active: !eager && sources.length > 0,
3382
- rootMargin,
3383
- once: true,
3384
- unsupported: true
3385
- });
3386
- const requested = eager || near.inView;
3387
- const fail = () => setOutcome(index + 1 < sources.length ? {
3388
- key,
3389
- index: index + 1,
3390
- done: null
3391
- } : {
3392
- key,
3393
- index,
3394
- done: "missing"
3395
- });
3396
- const told = React.useRef(null);
3397
- const tell = React.useRef(onMissing);
3398
- tell.current = onMissing;
3399
- React.useEffect(() => {
3400
- if (phase !== "missing") told.current = null;
3401
- else if (key !== null && told.current !== key) {
3402
- told.current = key;
3403
- tell.current?.();
3404
- }
3405
- }, [key, phase]);
3406
- const name = [alt, missing].filter(Boolean).join(": ");
3407
- return /* @__PURE__ */ jsxs("div", {
3408
- ref: near.ref,
3409
- className: cn("relative overflow-hidden rounded-control bg-muted", className),
3410
- style: { aspectRatio: ratio(aspect) },
3411
- "aria-busy": phase === "loading" || void 0,
3412
- children: [
3413
- phase === "loading" && /* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0" }),
3414
- key !== null && phase !== "missing" && requested && /* @__PURE__ */ jsx("img", {
3415
- src: current,
3416
- srcSet: index === 0 ? srcSet : void 0,
3417
- sizes,
3418
- alt,
3419
- decoding: "async",
3420
- onLoad: (e) => onLoad?.(e.currentTarget, index) === false ? fail() : setOutcome({
3421
- key,
3422
- index,
3423
- done: "loaded"
3424
- }),
3425
- onError: fail,
3426
- className: cn("absolute inset-0 size-full", fit === "cover" ? "object-cover" : "object-contain", phase === "loading" && "opacity-0")
3427
- }, `${key}#${index}`),
3428
- phase === "missing" && /* @__PURE__ */ jsx("div", {
3429
- ...name ? {
3430
- role: "img",
3431
- "aria-label": name
3432
- } : { "aria-hidden": true },
3433
- className: cn("absolute inset-0 grid", fallback === void 0 && "content-center justify-items-center gap-0.5 p-1 text-center text-muted-foreground"),
3434
- children: fallback === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ImageOff, {
3435
- "aria-hidden": true,
3436
- className: "size-4 shrink-0"
3437
- }), /* @__PURE__ */ jsx("span", {
3438
- className: "type-caption text-balance",
3439
- children: missing
3440
- })] }) : /* @__PURE__ */ jsx("div", {
3441
- "aria-hidden": true,
3442
- className: "grid size-full min-h-0 min-w-0",
3443
- children: fallback
3444
- })
3445
- }),
3446
- children
3447
- ]
3448
- });
3449
- }
3450
- /** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */
3451
- function ThumbnailSkeleton({ aspect = 1, className }) {
3452
- return /* @__PURE__ */ jsx("div", {
3453
- "aria-hidden": true,
3454
- className: cn("relative overflow-hidden rounded-control bg-muted", className),
3455
- style: { aspectRatio: ratio(aspect) },
3456
- children: /* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0" })
3457
- });
3458
- }
3459
3269
  // src/components/film-strip.tsx
3460
3270
  var GAP$1 = 4;
3461
3271
  /** `n` of `items` spread evenly from the first to the last (all of them when there are no more than `n`). */
@@ -3488,6 +3298,15 @@ function FilmStrip({ label, frames, span, time, onSeek, aspect = "4/3", frameWid
3488
3298
  }, []);
3489
3299
  const shown = pickEvenly(frames, Math.max(1, Math.floor((width + GAP$1) / (frameWidth + GAP$1))));
3490
3300
  const current = frameAt(shown, time, span ?? [frames[0]?.time ?? 0, frames.length ? frames[frames.length - 1].time + 1e-6 : 0]);
3301
+ const seen = /* @__PURE__ */ new Map();
3302
+ const keyed = shown.map((f) => {
3303
+ const n = seen.get(f.time) ?? 0;
3304
+ seen.set(f.time, n + 1);
3305
+ return {
3306
+ f,
3307
+ k: n ? `${f.time}#${n}` : String(f.time)
3308
+ };
3309
+ });
3491
3310
  const picture = (f, i) => /* @__PURE__ */ jsx(Thumbnail, {
3492
3311
  src: f.src,
3493
3312
  alt: onSeek ? "" : `Frame at ${format.runningTime(f.time)}`,
@@ -3512,22 +3331,22 @@ function FilmStrip({ label, frames, span, time, onSeek, aspect = "4/3", frameWid
3512
3331
  }) : onSeek ? /* @__PURE__ */ jsx(Toolbar, {
3513
3332
  label,
3514
3333
  className: "flex-nowrap gap-1",
3515
- children: shown.map((f, i) => /* @__PURE__ */ jsx(Button$1, {
3334
+ children: keyed.map(({ f, k }, i) => /* @__PURE__ */ jsx(Button$1, {
3516
3335
  "aria-label": `${seekVerb} ${format.runningTime(f.time)}`,
3517
3336
  "aria-current": i === current ? "time" : void 0,
3518
3337
  onPress: () => onSeek(f.time),
3519
3338
  className: "min-w-0 flex-1 rounded-control outline-offset-2 transition-state press",
3520
3339
  children: picture(f, i)
3521
- }, `${f.time}-${i}`))
3340
+ }, k))
3522
3341
  }) : /* @__PURE__ */ jsx("div", {
3523
3342
  role: "group",
3524
3343
  "aria-label": label,
3525
3344
  className: "flex gap-1",
3526
- children: shown.map((f, i) => /* @__PURE__ */ jsx("div", {
3345
+ children: keyed.map(({ f, k }, i) => /* @__PURE__ */ jsx("div", {
3527
3346
  "aria-current": i === current ? "time" : void 0,
3528
3347
  className: "min-w-0 flex-1",
3529
3348
  children: picture(f, i)
3530
- }, `${f.time}-${i}`))
3349
+ }, k))
3531
3350
  })
3532
3351
  });
3533
3352
  }
@@ -9209,90 +9028,6 @@ function TileBox({ label }) {
9209
9028
  })
9210
9029
  });
9211
9030
  }
9212
- // src/lib/viewport.ts
9213
- /** The picture fitted in its frame, not panned. */
9214
- var FIT = {
9215
- scale: 1,
9216
- x: 0,
9217
- y: 0
9218
- };
9219
- /** The least zoom: the whole picture fitted. */
9220
- var MIN_SCALE = 1;
9221
- /** The most zoom, 32 times the fit. */
9222
- var MAX_SCALE = 32;
9223
- /** Keeps the picture from being dragged out of its frame: at most half the extra width or height past each edge. */
9224
- function clampViewport(v, frame) {
9225
- const scale = Math.min(32, Math.max(1, v.scale));
9226
- if (scale === 1) return FIT;
9227
- const mx = (scale - 1) * frame.width / 2;
9228
- const my = (scale - 1) * frame.height / 2;
9229
- return {
9230
- scale,
9231
- x: Math.min(mx, Math.max(-mx, v.x)),
9232
- y: Math.min(my, Math.max(-my, v.y))
9233
- };
9234
- }
9235
- /** A new scale with the point under `at` (pixels from the frame's centre) staying under it. */
9236
- function zoomAt(v, nextScale, at, frame) {
9237
- const scale = Math.min(32, Math.max(1, nextScale));
9238
- const k = scale / v.scale;
9239
- return clampViewport({
9240
- scale,
9241
- x: at.x - k * (at.x - v.x),
9242
- y: at.y - k * (at.y - v.y)
9243
- }, frame);
9244
- }
9245
- /** The scale at which the picture's own pixels are drawn one to one: its natural width over the width it is fitted at. */
9246
- function actualPixelsScale(naturalWidth, fittedWidth) {
9247
- if (!naturalWidth || !fittedWidth) return 1;
9248
- return Math.min(32, Math.max(1, naturalWidth / fittedWidth));
9249
- }
9250
- /** The CSS transform for a viewport. */
9251
- function viewportTransform(v) {
9252
- return `translate(${v.x}px, ${v.y}px) scale(${v.scale})`;
9253
- }
9254
- /** A region as shares of the frame, so it lands on the same part of every candidate whatever its pixel size. */
9255
- function regionShares(region) {
9256
- const [x, y, w, h] = region.box;
9257
- if (!region.of) return [
9258
- x,
9259
- y,
9260
- w,
9261
- h
9262
- ];
9263
- const [ow, oh] = region.of;
9264
- return [
9265
- x / ow,
9266
- y / oh,
9267
- w / ow,
9268
- h / oh
9269
- ];
9270
- }
9271
- /** The viewport that fills the frame with a box (as much of it as fits, centred): the scale that fits the box, the offset that puts its centre at the frame's centre. */
9272
- function boxViewport(box, frame) {
9273
- const [x, y, w, h] = box;
9274
- const scale = Math.min(32, Math.max(1, Math.min(1 / Math.max(w, 1e-6), 1 / Math.max(h, 1e-6))));
9275
- return clampViewport({
9276
- scale,
9277
- x: -scale * (x + w / 2 - .5) * frame.width,
9278
- y: -scale * (y + h / 2 - .5) * frame.height
9279
- }, frame);
9280
- }
9281
- /** A rectangle drawn on the frame (pixels from its top left) as shares of the picture under the viewport now. */
9282
- function frameBoxToShares(rect, v, frame) {
9283
- const toShare = (p, offset, size) => size ? (p - size / 2 - offset) / v.scale / size + .5 : 0;
9284
- const clamp = (n) => Math.min(1, Math.max(0, n));
9285
- const xa = clamp(toShare(Math.min(rect.x0, rect.x1), v.x, frame.width));
9286
- const xb = clamp(toShare(Math.max(rect.x0, rect.x1), v.x, frame.width));
9287
- const ya = clamp(toShare(Math.min(rect.y0, rect.y1), v.y, frame.height));
9288
- const yb = clamp(toShare(Math.max(rect.y0, rect.y1), v.y, frame.height));
9289
- return [
9290
- xa,
9291
- ya,
9292
- xb - xa,
9293
- yb - ya
9294
- ];
9295
- }
9296
9031
  // src/components/compare-parts.tsx
9297
9032
  var VIEWPORT_HEIGHT = "max(16rem, calc(100svh - 14rem))";
9298
9033
  /** The tallest each row of frames may be so that all of `chrome` and `rows` rows fit in `space` pixels. Pure, so it is tested without a layout. */
@@ -17798,43 +17533,6 @@ function BookViewer({ label, pages, index, onIndexChange, missing, layout = "spr
17798
17533
  ]
17799
17534
  });
17800
17535
  }
17801
- // src/lib/boxes.ts
17802
- /**
17803
- * The boxes in reading order: top to bottom in rows, left to right within a row. A box joins the
17804
- * row above when its centre falls inside that row's first box vertically, so lines of text that
17805
- * wobble a few pixels still read in order and two columns read row by row, not column by column.
17806
- * Returns ids, so a caller keeps its own objects.
17807
- */
17808
- function readingOrder(boxes) {
17809
- const byTop = [...boxes].sort((a, b) => a.y + a.h / 2 - (b.y + b.h / 2) || a.x - b.x);
17810
- const rows = [];
17811
- for (const box of byTop) {
17812
- const row = rows[rows.length - 1];
17813
- const centre = box.y + box.h / 2;
17814
- if (row && centre >= row[0].y && centre <= row[0].y + row[0].h) row.push(box);
17815
- else rows.push([box]);
17816
- }
17817
- return rows.flatMap((row) => row.sort((a, b) => a.x - b.x).map((b) => b.id));
17818
- }
17819
- /**
17820
- * The viewport that fills a frame with one box of the picture. The picture sits in the frame the way
17821
- * `object-fit: contain` puts it (a frame of another shape leaves bars), which is also how
17822
- * `BoxOverlay` draws it, so the same numbers agree. `margin` is the share of the box added on every
17823
- * side so the box is not touching the frame (default 0.25).
17824
- */
17825
- function zoomToBox(box, of, frame, margin = .25) {
17826
- const s = Math.min(frame.width / of.w, frame.height / of.h);
17827
- const ox = (frame.width - of.w * s) / 2;
17828
- const oy = (frame.height - of.h * s) / 2;
17829
- const mx = box.w * margin;
17830
- const my = box.h * margin;
17831
- return boxViewport([
17832
- (ox + (box.x - mx) * s) / frame.width,
17833
- (oy + (box.y - my) * s) / frame.height,
17834
- (box.w + 2 * mx) * s / frame.width,
17835
- (box.h + 2 * my) * s / frame.height
17836
- ], frame);
17837
- }
17838
17536
  // src/components/box-overlay.tsx
17839
17537
  /** Holds the active and pointed box for a `BoxOverlay` and the `BoxList` beside it. */
17840
17538
  function useBoxes(initial = null) {
@@ -17873,7 +17571,7 @@ var FILL = {
17873
17571
  danger: "var(--danger-subtle)"
17874
17572
  };
17875
17573
  /** Read-only boxes drawn as one SVG layer over a picture, inside `ViewportFrame` so they zoom with it: outline by tone, hover and choice shared with a `BoxList`, one tab stop with arrows in reading order. */
17876
- function BoxOverlay({ label, of, boxes, state, onChoose }) {
17574
+ function BoxOverlay({ label, of, boxes, state, onChoose, fillLit = true }) {
17877
17575
  const order = React.useMemo(() => readingOrder(boxes), [boxes]);
17878
17576
  const byId = React.useMemo(() => new Map(boxes.map((b) => [b.id, b])), [boxes]);
17879
17577
  const group = React.useRef(null);
@@ -17910,6 +17608,7 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
17910
17608
  const tone = b.tone ?? "neutral";
17911
17609
  const on = id === state.active;
17912
17610
  const lit = on || id === state.pointed;
17611
+ const filled = lit && fillLit;
17913
17612
  const repeat = n >= order.length;
17914
17613
  return /* @__PURE__ */ jsx("rect", {
17915
17614
  "data-box-id": id,
@@ -17922,8 +17621,8 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
17922
17621
  y: b.y,
17923
17622
  width: b.w,
17924
17623
  height: b.h,
17925
- fill: lit ? FILL[tone] : "none",
17926
- fillOpacity: lit ? .25 : void 0,
17624
+ fill: filled ? FILL[tone] : "none",
17625
+ fillOpacity: filled ? .25 : void 0,
17927
17626
  stroke: STROKE[tone],
17928
17627
  strokeWidth: on ? 3 : 1.5,
17929
17628
  strokeOpacity: lit || tone !== "neutral" ? 1 : .55,
@@ -17977,6 +17676,71 @@ function BoxList({ label, boxes, state, renderBox, className }) {
17977
17676
  })
17978
17677
  });
17979
17678
  }
17679
+ // src/components/boxed-picture.tsx
17680
+ /** A picture with its boxes drawn on it, opened zoomed to the chosen one (a face in its photo): `ViewportFrame` + `BoxOverlay` + `zoomToBox`, with the picture's missing state. Pair it with a `BoxList` through one `useBoxes`. */
17681
+ function BoxedPicture({ label, src, alt, missing, of, boxes, state, boxesLabel, zoom = true, margin = .75, maxHeight = "70svh", onChoose, className }) {
17682
+ const view = useViewport();
17683
+ const frame = React.useRef(null);
17684
+ const { setViewport } = view;
17685
+ const box = state.active ? boxes.find((b) => b.id === state.active) : void 0;
17686
+ const [size, setSize] = React.useState(null);
17687
+ React.useLayoutEffect(() => {
17688
+ const el = frame.current;
17689
+ if (!el) return;
17690
+ const read = () => {
17691
+ const r = el.getBoundingClientRect();
17692
+ setSize((was) => was && was.width === r.width && was.height === r.height ? was : {
17693
+ width: r.width,
17694
+ height: r.height
17695
+ });
17696
+ };
17697
+ read();
17698
+ if (typeof ResizeObserver === "undefined") return;
17699
+ const ro = new ResizeObserver(read);
17700
+ ro.observe(el);
17701
+ return () => ro.disconnect();
17702
+ }, []);
17703
+ React.useLayoutEffect(() => {
17704
+ if (!zoom) return setViewport(FIT);
17705
+ if (box && size && size.width > 0 && size.height > 0) setViewport(zoomToBox(box, of, size, margin));
17706
+ }, [
17707
+ zoom,
17708
+ box?.id,
17709
+ box?.x,
17710
+ box?.y,
17711
+ box?.w,
17712
+ box?.h,
17713
+ of.w,
17714
+ of.h,
17715
+ margin,
17716
+ size,
17717
+ setViewport
17718
+ ]);
17719
+ return /* @__PURE__ */ jsxs(ViewportFrame, {
17720
+ ref: frame,
17721
+ label,
17722
+ aspect: of.w / of.h,
17723
+ maxHeight,
17724
+ className,
17725
+ ...view,
17726
+ children: [/* @__PURE__ */ jsx(Thumbnail, {
17727
+ src,
17728
+ alt,
17729
+ missing,
17730
+ aspect: of.w / of.h,
17731
+ fit: "contain",
17732
+ eager: true,
17733
+ className: "size-full rounded-none"
17734
+ }), /* @__PURE__ */ jsx(BoxOverlay, {
17735
+ label: boxesLabel,
17736
+ of,
17737
+ boxes,
17738
+ state,
17739
+ onChoose,
17740
+ fillLit: false
17741
+ })]
17742
+ });
17743
+ }
17980
17744
  // src/lib/sequence.ts
17981
17745
  var EPS = 1e-9;
17982
17746
  /** The grid point nearest to `time`, or `time` itself when there is no grid. */
@@ -18886,6 +18650,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
18886
18650
  ]
18887
18651
  });
18888
18652
  }
18889
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, ButtonLink, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, Workspace, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
18653
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, Workspace, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
18890
18654
 
18891
18655
  //# sourceMappingURL=index.js.map