strata-react 1.0.37 → 1.0.38

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,7 +1,7 @@
1
1
  import { a as Textarea, c as cn, i as NativeSelect, l as typeSteps, n as Field, r as Input, t as ChoiceGroup } from "./field-7Z4N5r5g.js";
2
2
  import { a as toDate, i as format, n as NBSP, r as createFormat, t as MISSING } from "./format-B32-PVi2.js";
3
3
  import { i as useInView, n as NumberField, r as Slider, t as ColorField } from "./value-controls-D6O9TsM6.js";
4
- import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-BJcxJLhh.js";
4
+ import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-CJ1pSPiC.js";
5
5
  import { a as useColorScheme, c as Tooltip, i as colorSchemeScript, l as KeyText, n as ColorSchemeChoice, o as useSystemColorScheme, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY } from "./theme-CFNi6WUO.js";
6
6
  import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
7
7
  import * as React from "react";
@@ -1678,17 +1678,41 @@ function JobStatus({ label, running, words, summary, current, total, failures =
1678
1678
  // src/components/thumbnail.tsx
1679
1679
  var ratio = (aspect) => typeof aspect === "number" ? String(aspect) : aspect.replace("/", " / ");
1680
1680
  /** 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. */
1681
- function Thumbnail({ src, alt, missing, aspect = 1, fit = "cover", srcSet, sizes, eager = false, rootMargin = "200px", className, fallback, children }) {
1682
- const request = src ? `${src} ${srcSet ?? ""}` : null;
1683
- const [result, setResult] = React.useState(null);
1684
- const phase = !request ? "missing" : result?.request === request ? result.ok ? "loaded" : "missing" : "loading";
1681
+ function Thumbnail({ src, alt, missing, aspect = 1, fit = "cover", srcSet, sizes, eager = false, rootMargin = "200px", className, fallback, onLoad, onMissing, children }) {
1682
+ const sources = React.useMemo(() => src === null ? [] : typeof src === "string" ? src ? [src] : [] : src.filter(Boolean), [src]);
1683
+ const key = sources.length ? `${sources.join("\n")} ${srcSet ?? ""}` : null;
1684
+ const [outcome, setOutcome] = React.useState(null);
1685
+ const mine = key !== null && outcome?.key === key ? outcome : null;
1686
+ const index = mine?.index ?? 0;
1687
+ const phase = key === null ? "missing" : mine?.done ?? "loading";
1688
+ const current = sources[index];
1685
1689
  const near = useInView({
1686
- active: !eager && !!src,
1690
+ active: !eager && sources.length > 0,
1687
1691
  rootMargin,
1688
1692
  once: true,
1689
1693
  unsupported: true
1690
1694
  });
1691
1695
  const requested = eager || near.inView;
1696
+ const fail = () => setOutcome(index + 1 < sources.length ? {
1697
+ key,
1698
+ index: index + 1,
1699
+ done: null
1700
+ } : {
1701
+ key,
1702
+ index,
1703
+ done: "missing"
1704
+ });
1705
+ const told = React.useRef(null);
1706
+ const tell = React.useRef(onMissing);
1707
+ tell.current = onMissing;
1708
+ React.useEffect(() => {
1709
+ if (phase !== "missing") told.current = null;
1710
+ else if (key !== null && told.current !== key) {
1711
+ told.current = key;
1712
+ tell.current?.();
1713
+ }
1714
+ }, [key, phase]);
1715
+ const name = [alt, missing].filter(Boolean).join(": ");
1692
1716
  return /* @__PURE__ */ jsxs("div", {
1693
1717
  ref: near.ref,
1694
1718
  className: cn("relative overflow-hidden rounded-control bg-muted", className),
@@ -1696,25 +1720,25 @@ function Thumbnail({ src, alt, missing, aspect = 1, fit = "cover", srcSet, sizes
1696
1720
  "aria-busy": phase === "loading" || void 0,
1697
1721
  children: [
1698
1722
  phase === "loading" && /* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0" }),
1699
- src && request && phase !== "missing" && requested && /* @__PURE__ */ jsx("img", {
1700
- src,
1701
- srcSet,
1723
+ key !== null && phase !== "missing" && requested && /* @__PURE__ */ jsx("img", {
1724
+ src: current,
1725
+ srcSet: index === 0 ? srcSet : void 0,
1702
1726
  sizes,
1703
1727
  alt,
1704
1728
  decoding: "async",
1705
- onLoad: () => setResult({
1706
- request,
1707
- ok: true
1708
- }),
1709
- onError: () => setResult({
1710
- request,
1711
- ok: false
1729
+ onLoad: (e) => onLoad?.(e.currentTarget, index) === false ? fail() : setOutcome({
1730
+ key,
1731
+ index,
1732
+ done: "loaded"
1712
1733
  }),
1734
+ onError: fail,
1713
1735
  className: cn("absolute inset-0 size-full", fit === "cover" ? "object-cover" : "object-contain", phase === "loading" && "opacity-0")
1714
- }, request),
1736
+ }, `${key}#${index}`),
1715
1737
  phase === "missing" && /* @__PURE__ */ jsx("div", {
1716
- role: "img",
1717
- "aria-label": [alt, missing].filter(Boolean).join(": "),
1738
+ ...name ? {
1739
+ role: "img",
1740
+ "aria-label": name
1741
+ } : { "aria-hidden": true },
1718
1742
  className: cn("absolute inset-0 grid", fallback === void 0 && "content-center justify-items-center gap-0.5 p-1 text-center text-muted-foreground"),
1719
1743
  children: fallback === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ImageOff, {
1720
1744
  "aria-hidden": true,
@@ -2326,8 +2350,23 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
2326
2350
  ]
2327
2351
  });
2328
2352
  }
2353
+ var SPAN_TONE = {
2354
+ info: "bg-info",
2355
+ success: "bg-success",
2356
+ warning: "bg-warning",
2357
+ danger: "bg-danger",
2358
+ neutral: "bg-neutral-8"
2359
+ };
2360
+ /** The spans a bar of `duration` seconds can draw: in order, cut to the bar, and none that are empty or backwards. */
2361
+ function drawableSpans(spans, duration) {
2362
+ return spans.map((s) => ({
2363
+ ...s,
2364
+ start: clamp$3(s.start, 0, duration),
2365
+ end: clamp$3(s.end, 0, duration)
2366
+ })).filter((s) => Number.isFinite(s.start) && Number.isFinite(s.end) && s.end > s.start).sort((a, b) => a.start - b.start);
2367
+ }
2329
2368
  /** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
2330
- function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, cursor: cursorProp, className }) {
2369
+ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, cursor: cursorProp, className }) {
2331
2370
  const duration = known && Number.isFinite(known) && known > 0 ? known : 0;
2332
2371
  const disabled = off || duration === 0;
2333
2372
  const track = React.useRef(null);
@@ -2433,6 +2472,26 @@ function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffe
2433
2472
  className: "absolute left-0 h-1.5 rounded-pill bg-primary",
2434
2473
  style: { width: `${frac * 100}%` }
2435
2474
  }),
2475
+ duration > 0 && drawableSpans(spans, duration).map((s) => {
2476
+ const name = `${s.label}, ${timecode(s.start, {
2477
+ precision,
2478
+ fps
2479
+ })} to ${timecode(s.end, {
2480
+ precision,
2481
+ fps
2482
+ })}`;
2483
+ return /* @__PURE__ */ jsx("span", {
2484
+ role: "img",
2485
+ "aria-label": name,
2486
+ title: name,
2487
+ "data-span": "",
2488
+ className: cn("absolute h-1.5 min-w-1 rounded-pill opacity-70", SPAN_TONE[s.tone ?? "info"]),
2489
+ style: {
2490
+ left: `${s.start / duration * 100}%`,
2491
+ width: `${(s.end - s.start) / duration * 100}%`
2492
+ }
2493
+ }, `${s.start}-${s.end}-${s.label}`);
2494
+ }),
2436
2495
  otherTime !== null && otherTime >= 0 && otherTime <= duration && /* @__PURE__ */ jsx("span", {
2437
2496
  "aria-hidden": true,
2438
2497
  "data-cursor": "",
@@ -2524,7 +2583,7 @@ function VolumeControl({ volume, onVolumeChange, max = 100, disabled, className
2524
2583
  if (volume > 0) last.current = volume;
2525
2584
  const muted = volume === 0;
2526
2585
  return /* @__PURE__ */ jsxs("div", {
2527
- className: cn("flex items-center gap-2", className),
2586
+ className: cn("flex min-w-0 items-center gap-2", className),
2528
2587
  children: [/* @__PURE__ */ jsx(IconButton, {
2529
2588
  icon: muted ? VolumeX : Volume2,
2530
2589
  label: muted ? "Unmute" : "Mute",
@@ -2539,7 +2598,7 @@ function VolumeControl({ volume, onVolumeChange, max = 100, disabled, className
2539
2598
  max,
2540
2599
  unit: "%",
2541
2600
  disabled,
2542
- className: "w-40"
2601
+ className: "w-40 min-w-24 shrink"
2543
2602
  })]
2544
2603
  });
2545
2604
  }
@@ -2768,6 +2827,198 @@ function PlayWindowButton({ media, window: w, label, size = "sm", className }) {
2768
2827
  onClick: () => playing ? media.pause() : void media.playWindow(w)
2769
2828
  });
2770
2829
  }
2830
+ // src/components/media-spans.tsx
2831
+ var lower = (label) => label.charAt(0).toLowerCase() + label.slice(1);
2832
+ var WORDS$1 = {
2833
+ skip: (l) => `Skip ${lower(l)}`,
2834
+ skipped: (l) => `Skipped ${lower(l)}`,
2835
+ mute: (l) => `Mute ${lower(l)}`,
2836
+ muted: (l) => `Muted ${lower(l)}`,
2837
+ undo: "Undo"
2838
+ };
2839
+ /** How long "Skipped intro, Undo" stays. */
2840
+ var NOTICE_MS = 6e3;
2841
+ /** Draws the spans' ranges and acts on them as playback reaches them. See the file comment for the rules. */
2842
+ function useMediaSpans({ spans, kinds = {}, words, onSpan, time, playing, duration, limit = Infinity, seek, volume, setVolume }) {
2843
+ const w = {
2844
+ ...WORDS$1,
2845
+ ...words
2846
+ };
2847
+ const list = React.useMemo(() => {
2848
+ const out = [];
2849
+ for (const s of spans ?? []) {
2850
+ const end = duration ? Math.min(s.end, duration) : s.end;
2851
+ const start = Math.max(s.start, 0);
2852
+ if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) continue;
2853
+ const def = kinds[s.kind] ?? { label: s.kind.charAt(0).toUpperCase() + s.kind.slice(1) };
2854
+ out.push({
2855
+ ...s,
2856
+ start,
2857
+ end,
2858
+ id: `${s.kind}:${s.start}-${s.end}`,
2859
+ def,
2860
+ action: s.action ?? "skip",
2861
+ data: s
2862
+ });
2863
+ }
2864
+ return out.sort((a, b) => a.start - b.start);
2865
+ }, [
2866
+ spans,
2867
+ kinds,
2868
+ duration
2869
+ ]);
2870
+ const bars = React.useMemo(() => list.map((s) => ({
2871
+ start: s.start,
2872
+ end: s.end,
2873
+ label: s.def.label,
2874
+ tone: s.def.tone
2875
+ })), [list]);
2876
+ const acted = React.useRef(/* @__PURE__ */ new Set());
2877
+ const undone = React.useRef(/* @__PURE__ */ new Set());
2878
+ const inside = React.useRef(null);
2879
+ const muteHold = React.useRef(null);
2880
+ const [notice, setNotice] = React.useState(null);
2881
+ const noticeKey = React.useRef(0);
2882
+ const latest = React.useRef({
2883
+ onSpan,
2884
+ seek,
2885
+ setVolume,
2886
+ volume,
2887
+ w
2888
+ });
2889
+ latest.current = {
2890
+ onSpan,
2891
+ seek,
2892
+ setVolume,
2893
+ volume,
2894
+ w
2895
+ };
2896
+ const content = (spans ?? []).map((s) => `${s.kind}:${s.start}-${s.end}:${s.action ?? ""}`).join("|");
2897
+ React.useEffect(() => {
2898
+ acted.current.clear();
2899
+ undone.current.clear();
2900
+ inside.current = null;
2901
+ const held = muteHold.current;
2902
+ muteHold.current = null;
2903
+ if (held && latest.current.volume === 0) latest.current.setVolume(held.volume);
2904
+ setNotice(null);
2905
+ }, [content]);
2906
+ React.useEffect(() => {
2907
+ if (!notice) return;
2908
+ const t = setTimeout(() => setNotice((n) => n?.key === notice.key ? null : n), NOTICE_MS);
2909
+ return () => clearTimeout(t);
2910
+ }, [notice]);
2911
+ const current = list.find((s) => time >= s.start && time < s.end) ?? null;
2912
+ const act = React.useCallback((s, from) => {
2913
+ const l = latest.current;
2914
+ acted.current.add(s.id);
2915
+ const key = ++noticeKey.current;
2916
+ if (s.action === "mute") {
2917
+ if (l.volume === 0) return;
2918
+ muteHold.current = {
2919
+ id: s.id,
2920
+ volume: l.volume
2921
+ };
2922
+ l.setVolume(0);
2923
+ l.onSpan?.(s.data, "muted");
2924
+ setNotice({
2925
+ key,
2926
+ text: l.w.muted(s.def.label),
2927
+ undo: () => {
2928
+ const held = muteHold.current;
2929
+ if (held?.id === s.id) {
2930
+ muteHold.current = null;
2931
+ latest.current.setVolume(held.volume);
2932
+ }
2933
+ undone.current.add(s.id);
2934
+ latest.current.onSpan?.(s.data, "undone");
2935
+ setNotice(null);
2936
+ }
2937
+ });
2938
+ return;
2939
+ }
2940
+ l.seek(s.end);
2941
+ l.onSpan?.(s.data, "skipped");
2942
+ setNotice({
2943
+ key,
2944
+ text: l.w.skipped(s.def.label),
2945
+ undo: () => {
2946
+ undone.current.add(s.id);
2947
+ latest.current.seek(from);
2948
+ latest.current.onSpan?.(s.data, "undone");
2949
+ setNotice(null);
2950
+ }
2951
+ });
2952
+ }, []);
2953
+ React.useEffect(() => {
2954
+ const was = inside.current;
2955
+ const now = current?.id ?? null;
2956
+ if (was !== null && was !== now) {
2957
+ const left = list.find((s) => s.id === was);
2958
+ if (muteHold.current?.id === was) {
2959
+ const held = muteHold.current;
2960
+ muteHold.current = null;
2961
+ if (latest.current.volume === 0) latest.current.setVolume(held.volume);
2962
+ }
2963
+ if (left && (undone.current.has(was) || left.def.behaviour === "ask" && !acted.current.has(was))) {
2964
+ undone.current.delete(was);
2965
+ latest.current.onSpan?.(left.data, "played");
2966
+ }
2967
+ }
2968
+ inside.current = now;
2969
+ if (playing && current && current.def.behaviour === "auto" && !acted.current.has(current.id) && !undone.current.has(current.id) && current.end <= limit) act(current, time);
2970
+ }, [
2971
+ current?.id,
2972
+ list,
2973
+ limit,
2974
+ act,
2975
+ playing
2976
+ ]);
2977
+ const offered = playing && current && current.def.behaviour === "ask" && !acted.current.has(current.id) && current.end <= limit ? current : null;
2978
+ return {
2979
+ bars,
2980
+ offer: React.useMemo(() => offered ? {
2981
+ label: (offered.action === "mute" ? w.mute : w.skip)(offered.def.label),
2982
+ run: () => act(offered, time)
2983
+ } : null, [
2984
+ offered?.id,
2985
+ time,
2986
+ act,
2987
+ w.mute,
2988
+ w.skip
2989
+ ]),
2990
+ notice: notice ? {
2991
+ text: notice.text,
2992
+ undoLabel: w.undo,
2993
+ undo: notice.undo
2994
+ } : null
2995
+ };
2996
+ }
2997
+ /** The Skip button and the "Skipped intro, Undo" notice, for the player to draw over a picture or under the bar. The notice's live region is always present, so a screen reader hears what is put in it. */
2998
+ function SpanActions({ state, className }) {
2999
+ const { offer, notice } = state;
3000
+ return /* @__PURE__ */ jsxs("div", {
3001
+ className,
3002
+ children: [offer && /* @__PURE__ */ jsxs(Button, {
3003
+ variant: "outline",
3004
+ size: "sm",
3005
+ onClick: offer.run,
3006
+ children: [offer.label, /* @__PURE__ */ jsx("span", {
3007
+ "aria-hidden": true,
3008
+ children: " ›"
3009
+ })]
3010
+ }), /* @__PURE__ */ jsx("div", {
3011
+ role: "status",
3012
+ className: notice ? "flex items-center gap-2 rounded-overlay border border-border bg-background px-3 py-1 type-body-sm text-foreground shadow-overlay" : void 0,
3013
+ children: notice && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: notice.text }), /* @__PURE__ */ jsx(Button, {
3014
+ variant: "ghost",
3015
+ size: "sm",
3016
+ onClick: notice.undo,
3017
+ children: notice.undoLabel
3018
+ })] })
3019
+ })]
3020
+ });
3021
+ }
2771
3022
  // src/components/media-player.tsx
2772
3023
  var idle = {
2773
3024
  ready: 0,
@@ -3071,10 +3322,12 @@ function useMediaElement(ref, options = {}) {
3071
3322
  * Use it for a plain `<video>` the app owns, with `useMediaElement`; `MediaPlayer` does it for `attach`.
3072
3323
  * Returns `reload`, for the player's Try again (`useMediaElement`'s `onRetry`), and gives the engine's failures to `onProblem` (`reportProblem`).
3073
3324
  */
3074
- function useAttachedSource(ref, src, attach, onProblem) {
3325
+ function useAttachedSource(ref, src, attach, onProblem, growing) {
3075
3326
  const hold = React.useRef(null);
3076
3327
  const problem = React.useRef(onProblem);
3077
3328
  problem.current = onProblem;
3329
+ const grows = React.useRef(growing);
3330
+ grows.current = growing;
3078
3331
  React.useEffect(() => {
3079
3332
  const el = ref.current;
3080
3333
  const now = hold.current;
@@ -3088,7 +3341,8 @@ function useAttachedSource(ref, src, attach, onProblem) {
3088
3341
  attach,
3089
3342
  attachment: attach(el, src, {
3090
3343
  startAt: 0,
3091
- onProblem: (m) => problem.current?.(m)
3344
+ onProblem: (m) => problem.current?.(m),
3345
+ growing: grows.current
3092
3346
  })
3093
3347
  };
3094
3348
  });
@@ -3169,7 +3423,7 @@ function useCoarsePointer() {
3169
3423
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
3170
3424
  * parts and `useMediaElement` directly.
3171
3425
  */
3172
- function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, className }) {
3426
+ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, mediaRef, overlay, aspect, className }) {
3173
3427
  const list = React.useMemo(() => sources ?? (src ? [{
3174
3428
  src,
3175
3429
  title: label
@@ -3192,7 +3446,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3192
3446
  growing: growing !== void 0,
3193
3447
  onRetry: attach ? (t) => stream.current.reload(t) : void 0
3194
3448
  });
3195
- stream.current = useAttachedSource(ref, current?.src, attach, media.reportProblem);
3449
+ stream.current = useAttachedSource(ref, current?.src, attach, media.reportProblem, growing !== void 0);
3196
3450
  const coarse = useCoarsePointer();
3197
3451
  const native = controls === "native" || controls === "auto" && coarse;
3198
3452
  const go = React.useCallback((to) => {
@@ -3276,6 +3530,44 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3276
3530
  resume.current = media.playing;
3277
3531
  go(to);
3278
3532
  };
3533
+ const spanState = useMediaSpans({
3534
+ spans,
3535
+ kinds: spanKinds,
3536
+ words: spanWords,
3537
+ onSpan,
3538
+ time,
3539
+ playing: media.playing,
3540
+ duration: growing ? null : duration,
3541
+ limit: growing ? media.ready : void 0,
3542
+ seek,
3543
+ volume: media.volume,
3544
+ setVolume: media.setVolume
3545
+ });
3546
+ const offer = spanState.offer;
3547
+ React.useEffect(() => {
3548
+ if (typeof mediaRef === "function") mediaRef(media);
3549
+ else if (mediaRef) mediaRef.current = media;
3550
+ });
3551
+ React.useEffect(() => () => {
3552
+ if (mediaRef && typeof mediaRef !== "function") mediaRef.current = null;
3553
+ }, []);
3554
+ const [natural, setNatural] = React.useState(null);
3555
+ useElementListeners(ref, (el) => {
3556
+ const read = () => setNatural(el instanceof HTMLVideoElement && el.videoWidth > 0 && el.videoHeight > 0 ? el.videoWidth / el.videoHeight : null);
3557
+ for (const t of [
3558
+ "loadedmetadata",
3559
+ "resize",
3560
+ "emptied"
3561
+ ]) el.addEventListener(t, read);
3562
+ read();
3563
+ return () => {
3564
+ for (const t of [
3565
+ "loadedmetadata",
3566
+ "resize",
3567
+ "emptied"
3568
+ ]) el.removeEventListener(t, read);
3569
+ };
3570
+ });
3279
3571
  React.useEffect(() => {
3280
3572
  if (onTimeChange) onTimeChange(time);
3281
3573
  }, [time]);
@@ -3301,12 +3593,18 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3301
3593
  keys: ["m"],
3302
3594
  label: "Mute",
3303
3595
  run: () => media.setVolume(media.muted ? 100 : 0)
3304
- }
3596
+ },
3597
+ ...offer ? [{
3598
+ keys: ["s"],
3599
+ label: offer.label,
3600
+ run: offer.run
3601
+ }] : []
3305
3602
  ], [
3306
3603
  media,
3307
3604
  time,
3308
3605
  offsets,
3309
- index
3606
+ index,
3607
+ offer
3310
3608
  ]);
3311
3609
  const id = React.useId();
3312
3610
  React.useEffect(() => {
@@ -3384,11 +3682,22 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3384
3682
  preload: "metadata",
3385
3683
  "aria-label": `${label}, ${kind}`
3386
3684
  };
3387
- const element = kind === "video" ? /* @__PURE__ */ jsx("video", {
3388
- ...common,
3389
- poster,
3390
- playsInline: true,
3391
- className: "w-full rounded-surface bg-surface-sunken"
3685
+ const hasSpans = (spans?.length ?? 0) > 0;
3686
+ const element = kind === "video" ? /* @__PURE__ */ jsxs("div", {
3687
+ className: "relative w-full overflow-hidden rounded-surface bg-surface-sunken",
3688
+ style: { aspectRatio: aspect ?? natural ?? 16 / 9 },
3689
+ children: [/* @__PURE__ */ jsx("video", {
3690
+ ...common,
3691
+ poster,
3692
+ playsInline: true,
3693
+ className: "absolute inset-0 size-full object-contain"
3694
+ }), (overlay || hasSpans) && /* @__PURE__ */ jsxs("div", {
3695
+ className: "pointer-events-none absolute inset-0 [&>*]:pointer-events-auto",
3696
+ children: [overlay?.(media), hasSpans && /* @__PURE__ */ jsx(SpanActions, {
3697
+ state: spanState,
3698
+ className: cn("absolute right-3 flex flex-col items-end gap-2", native ? "bottom-14" : "bottom-3")
3699
+ })]
3700
+ })]
3392
3701
  }) : /* @__PURE__ */ jsx("audio", {
3393
3702
  ...common,
3394
3703
  className: native ? "w-full" : "hidden"
@@ -3402,6 +3711,11 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3402
3711
  className: cn("grid w-full gap-2", className),
3403
3712
  children: [
3404
3713
  element,
3714
+ kind === "audio" && hasSpans && /* @__PURE__ */ jsx(SpanActions, {
3715
+ state: spanState,
3716
+ className: "flex flex-wrap items-center gap-2"
3717
+ }),
3718
+ kind === "audio" && overlay?.(media),
3405
3719
  media.error?.kind === "load" && /* @__PURE__ */ jsx(Alert, {
3406
3720
  tone: "danger",
3407
3721
  announce: true,
@@ -3459,6 +3773,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3459
3773
  duration,
3460
3774
  onSeek: seek,
3461
3775
  buffered: growing ? media.ready : offsets ? void 0 : media.buffered,
3776
+ spans: spanState.bars,
3462
3777
  marks: bound && showFull ? [{
3463
3778
  time: bound.start,
3464
3779
  label: "Window starts"
@@ -5922,7 +6237,7 @@ var defaultMoreError = (failure) => /* @__PURE__ */ jsx(MoreFailed, { ...failure
5922
6237
  * keyboard, and `end` after the last page. After Show more it focuses the first new item: mark
5923
6238
  * each item with `data-index` and put this row beside the list, in the same parent.
5924
6239
  */
5925
- function LoadMore({ state, moreLabel, moreSkeleton, end, rootMargin = "400px", keepAtLeast = 0, error: drawError = defaultMoreError, className }) {
6240
+ function LoadMore({ state, moreLabel, moreSkeleton, end, rootMargin = "400px", keepAtLeast = 0, error: drawError = defaultMoreError, more: drawMore, loading: drawLoading, ruled = true, className }) {
5926
6241
  const { more } = state;
5927
6242
  const ready = state.status === "ready";
5928
6243
  const held = ready ? state.data.length : 0;
@@ -5998,23 +6313,26 @@ function LoadMore({ state, moreLabel, moreSkeleton, end, rootMargin = "400px", k
5998
6313
  }),
5999
6314
  loadingMore ? /* @__PURE__ */ jsx("div", {
6000
6315
  "aria-hidden": true,
6001
- className: "border-t border-border",
6002
- children: moreSkeleton
6316
+ className: cn(ruled && "border-t border-border"),
6317
+ children: drawLoading ? drawLoading(moreSkeleton) : moreSkeleton
6003
6318
  }) : error ? /* @__PURE__ */ jsx("div", {
6004
6319
  role: "alert",
6005
6320
  children: drawError({
6006
6321
  message: error,
6007
6322
  retry: loadByHand
6008
6323
  })
6009
- }) : hasMore ? /* @__PURE__ */ jsx("div", {
6010
- className: "border-t border-border py-3",
6324
+ }) : hasMore ? drawMore ? drawMore({
6325
+ label: moreLabel,
6326
+ load: loadByHand
6327
+ }) : /* @__PURE__ */ jsx("div", {
6328
+ className: cn("py-3", ruled && "border-t border-border"),
6011
6329
  children: /* @__PURE__ */ jsx(Button, {
6012
6330
  size: "sm",
6013
6331
  onClick: loadByHand,
6014
6332
  children: moreLabel
6015
6333
  })
6016
6334
  }) : end && /* @__PURE__ */ jsx("div", {
6017
- className: "border-t border-border py-3 type-body-sm text-muted-foreground",
6335
+ className: cn("py-3 type-body-sm text-muted-foreground", ruled && "border-t border-border"),
6018
6336
  children: end
6019
6337
  }),
6020
6338
  /* @__PURE__ */ jsx("p", {
@@ -6026,7 +6344,7 @@ function LoadMore({ state, moreLabel, moreSkeleton, end, rootMargin = "400px", k
6026
6344
  });
6027
6345
  }
6028
6346
  /** A cursor-paged list for `useInfiniteLoad`: DataView's first-page states, virtual rows (or a page-scrolled grid), and a `LoadMore` row that loads on approach, shows a skeleton, or says why it failed with Try again. */
6029
- function InfiniteList({ state, label, children, skeleton, empty, moreLabel, moreSkeleton = skeleton, end, rootMargin = "400px", keepAtLeast = 0, scroll = "region", listClassName, error, moreError, estimateSize, height = 480, virtualizeFrom, className }) {
6347
+ function InfiniteList({ state, label, children, skeleton, empty, moreLabel, moreSkeleton = skeleton, end, rootMargin = "400px", keepAtLeast = 0, scroll = "region", listClassName, error, moreError, moreRow, moreLoading, ruled, estimateSize, height = 480, virtualizeFrom, className }) {
6030
6348
  const { more, itemKey } = state;
6031
6349
  const pendingFocus = React.useRef(null);
6032
6350
  const ready = state.status === "ready";
@@ -6052,7 +6370,10 @@ function InfiniteList({ state, label, children, skeleton, empty, moreLabel, more
6052
6370
  moreSkeleton,
6053
6371
  end,
6054
6372
  rootMargin,
6055
- error: moreError
6373
+ error: moreError,
6374
+ more: moreRow,
6375
+ loading: moreLoading,
6376
+ ruled
6056
6377
  })
6057
6378
  });
6058
6379
  return /* @__PURE__ */ jsx(DataView, {
@@ -13219,6 +13540,6 @@ function MarkableText({ label, ids, marks, kinds, onMark, clearKeys = [], onCare
13219
13540
  ]
13220
13541
  });
13221
13542
  }
13222
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, fitRect, format, formatChord, gainToVolume, geo, gridPoints, isReservedChord, isTypingTarget, joinMediaGroup, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveRect, noOverlap, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, plainText, rangeBetween, readErrorBody, readPixels, regionShares, resample, resamplePeaks, resizeRect, safeHref, serialiseSort, settleCut, snapToGrid, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, valueAt, wordAt, zoomAt };
13543
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, fitRect, format, formatChord, gainToVolume, geo, gridPoints, isReservedChord, isTypingTarget, joinMediaGroup, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveRect, noOverlap, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, plainText, rangeBetween, readErrorBody, readPixels, regionShares, resample, resamplePeaks, resizeRect, safeHref, serialiseSort, settleCut, snapToGrid, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useMediaSpans, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, valueAt, wordAt, zoomAt };
13223
13544
 
13224
13545
  //# sourceMappingURL=index.js.map