@vivix-labs/media-tools 1.0.0-beta.3 → 1.0.0-beta.9

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.
@@ -1,5 +1,5 @@
1
1
  // packages/media-tools/src/client.tsx
2
- import * as React7 from "react";
2
+ import * as React8 from "react";
3
3
 
4
4
  // packages/media-tools/src/shared.ts
5
5
  import { z, PluginError } from "vivix-studio/sdk/shared";
@@ -244,6 +244,10 @@ var iconGeometry = {
244
244
  height: 15.5625,
245
245
  slot: 18
246
246
  },
247
+ "select-items": { width: 13.8681, height: 13.8667, slot: 16 },
248
+ trim: { width: 14.85, height: 14.85, slot: 16 },
249
+ crop: { width: 16.25, height: 16.25, slot: 16 },
250
+ filter: { width: 13.2, height: 13.2, slot: 16 },
247
251
  select: {
248
252
  width: 14.6298,
249
253
  height: 16.065,
@@ -324,6 +328,9 @@ var iconGeometry = {
324
328
  height: 13.2,
325
329
  slot: 16
326
330
  },
331
+ favorite: { width: 11.8667, height: 14.5333, slot: 16 },
332
+ download: { width: 13.2001, height: 13.1997, slot: 16 },
333
+ delete: { width: 13.2, height: 14.533, slot: 16 },
327
334
  edit: {
328
335
  width: 10.8791,
329
336
  height: 12.0459,
@@ -384,6 +391,9 @@ var buttonVariants = {
384
391
  "text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
385
392
  "text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
386
393
  "text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
394
+ "text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
395
+ "text-link-sm": { size: 32, appearance: "link", shape: "text" },
396
+ "text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
387
397
  "text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
388
398
  // The medium recipes are shared by all dialog footer actions.
389
399
  "text-filled-md": { size: 40, appearance: "filled", shape: "text" },
@@ -418,8 +428,8 @@ function ButtonFrame({ label, variant, loading = false, width, children, disable
418
428
  const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
419
429
  return _jsxs("button", { ...props, type, className: className ? `vx-button ${className}` : "vx-button", "data-variant": variant, "data-appearance": spec.appearance, "data-shape": spec.shape, "data-size": spec.size, "data-width": width, "data-state": loading ? "loading" : disabled ? "disabled" : "default", style: buttonStyle, disabled: disabled || loading, "aria-label": label, "aria-busy": loading || void 0, children: [_jsx2("span", { className: "vx-button-content", children }), loading && _jsx2("span", { className: "vx-button-loading", "aria-hidden": "true" })] });
420
430
  }
421
- function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
422
- return _jsxs(ButtonFrame, { ...props, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
431
+ function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
432
+ return _jsxs(ButtonFrame, { ...props, label: badge ? `${props.label} (${badge})` : props.label, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), badge !== void 0 && badge > 0 && _jsx2("span", { className: "vx-button-badge", children: badge }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
423
433
  }
424
434
  function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
425
435
  return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
@@ -433,20 +443,26 @@ function SegmentedControl({ label, items, value, onValueChange, size = "medium",
433
443
  return _jsx3("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs2("label", { children: [_jsx3("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs2("span", { className: "vx-segment-item", children: [item.icon && _jsx3(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
434
444
  }
435
445
 
446
+ // packages/ui-system/dist/input.js
447
+ import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
448
+ function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", ...props }) {
449
+ return _jsxs3("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx4("span", { children: label }), _jsx4("input", { ...props, type: "text", value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
450
+ }
451
+
436
452
  // packages/ui-system/dist/tag.js
437
- import { jsx as _jsx4 } from "react/jsx-runtime";
453
+ import { jsx as _jsx5 } from "react/jsx-runtime";
438
454
  function Tag({ children, variant = "overlay", className }) {
439
- return _jsx4("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
455
+ return _jsx5("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
440
456
  }
441
457
 
442
458
  // packages/ui-system/dist/frame-range.js
443
- import { jsx as _jsx5, jsxs as _jsxs3, Fragment as _Fragment } from "react/jsx-runtime";
459
+ import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment } from "react/jsx-runtime";
444
460
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
445
461
  function timeLabel(seconds) {
446
462
  const whole = Math.floor(seconds);
447
- return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
463
+ return `${String(Math.floor(whole / 60)).padStart(2, "0")}:${String(whole % 60).padStart(2, "0")}`;
448
464
  }
449
- function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range", onValueChange }) {
465
+ function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant = "range", onValueChange }) {
450
466
  const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
451
467
  const increment = Math.min(length, Number.isFinite(step) && step > 0 ? step : 0.1);
452
468
  const start = clamp(Number.isFinite(value.start) ? value.start : 0, 0, length - increment);
@@ -479,12 +495,12 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
479
495
  event.preventDefault();
480
496
  move(edge, next);
481
497
  }
482
- return _jsxs3("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
498
+ return _jsxs4("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
483
499
  "--vx-range-start": `${start / length * 100}%`,
484
500
  "--vx-range-end": `${end / length * 100}%`
485
- } : void 0, children: [thumbnail && length > 0 && _jsx5("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs3(_Fragment, { children: [_jsx5("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs3(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
501
+ } : void 0, children: [frames?.length && length > 0 ? _jsx6("div", { className: "vx-frame-filmstrip", children: frames.map((src, index) => _jsx6("img", { src, alt: "" }, index)) }) : thumbnail && length > 0 && _jsx6("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs4(_Fragment, { children: [_jsx6("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs4(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
486
502
  const current = edge === "start" ? start : end;
487
- return _jsx5("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
503
+ return _jsx6("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
488
504
  if (event.button !== 0)
489
505
  return;
490
506
  event.currentTarget.focus();
@@ -494,7 +510,7 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
494
510
  }
495
511
 
496
512
  // packages/ui-system/dist/dialog.js
497
- import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment2 } from "react/jsx-runtime";
513
+ import { jsx as _jsx7, jsxs as _jsxs5, Fragment as _Fragment2 } from "react/jsx-runtime";
498
514
  import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
499
515
  import { createPortal } from "react-dom";
500
516
 
@@ -547,7 +563,7 @@ function createDialogSurface(anchor) {
547
563
  }
548
564
 
549
565
  // packages/ui-system/dist/dialog.js
550
- function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
566
+ function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default", focusTitleOnOpen = variant === "welcome" }) {
551
567
  const ref = useRef(null);
552
568
  const anchor = useRef(null);
553
569
  const [surface, setSurface] = useState();
@@ -577,28 +593,51 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
577
593
  dialog2.close();
578
594
  };
579
595
  }, [open, surface]);
580
- const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
596
+ const welcome = variant === "welcome";
597
+ const closeButton = _jsx7(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
598
+ const dialog = _jsxs5("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
581
599
  event.preventDefault();
582
600
  event.stopPropagation();
583
601
  onOpenChange(false);
584
602
  }, onClose: (event) => {
585
603
  if (open && event.currentTarget.isConnected && !event.currentTarget.open)
586
604
  onOpenChange(false);
587
- }, children: [_jsxs4("header", { children: [_jsx6("h2", { id: heading, children: title }), _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx6("div", { className: "vx-dialog-body", children }), actions && _jsx6("footer", { children: actions })] });
588
- return _jsxs4(_Fragment2, { children: [_jsx6("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
605
+ }, children: [_jsxs5("header", { children: [_jsx7("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx7("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs5("footer", { children: [actions, welcome && closeButton] })] });
606
+ return _jsxs5(_Fragment2, { children: [_jsx7("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
589
607
  }
590
608
 
591
609
  // packages/ui-system/dist/menu.js
592
- import { jsx as _jsx7, jsxs as _jsxs5 } from "react/jsx-runtime";
610
+ import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
593
611
  import { useEffect, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
594
612
  import { createPortal as createPortal2 } from "react-dom";
613
+ function MenuPreview({ children }) {
614
+ const ref = useRef2(null);
615
+ const [visible, setVisible] = useState2(false);
616
+ useEffect(() => {
617
+ const node = ref.current;
618
+ if (!node)
619
+ return;
620
+ const observer = new IntersectionObserver(([entry]) => {
621
+ if (entry?.isIntersecting) {
622
+ setVisible(true);
623
+ observer.disconnect();
624
+ }
625
+ });
626
+ observer.observe(node);
627
+ return () => observer.disconnect();
628
+ }, []);
629
+ return _jsx8("span", { ref, className: "vx-menu-preview", "aria-hidden": "true", children: visible && children });
630
+ }
595
631
  function isEnabled(item) {
596
632
  return !item.disabled && item.items?.length !== 0;
597
633
  }
598
- function Menu({ label, items, triggerIcon, floating = false }) {
634
+ function Menu({ label, items, triggerIcon, textTrigger = "dropdown", floating = false, cascading = false }) {
599
635
  const id = useId3();
600
636
  const trigger = useRef2(null);
601
637
  const popup = useRef2(null);
638
+ const children = useRef2(/* @__PURE__ */ new Map());
639
+ const focusOnOpen = useRef2(true);
640
+ const cascade = floating && cascading;
602
641
  const focusIndex = useRef2(0);
603
642
  const [path, setPath] = useState2(null);
604
643
  const [placement, setPlacement] = useState2({ visibility: "hidden" });
@@ -620,19 +659,38 @@ function Menu({ label, items, triggerIcon, floating = false }) {
620
659
  const flip = naturalHeight > below && above > below;
621
660
  const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
622
661
  const menuHeight = Math.min(naturalHeight, maxHeight);
662
+ const left = Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8));
663
+ const top = Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8));
623
664
  setPlacement({
624
665
  position: "fixed",
625
666
  visibility: "visible",
626
667
  insetInlineStart: "auto",
627
- left: Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8)),
628
- top: Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8)),
668
+ left,
669
+ top,
629
670
  maxHeight,
630
671
  zIndex: 100
631
672
  });
673
+ let parent = menu2, parentLeft = left, parentTop = top;
674
+ for (let depth = 1; cascade && depth <= path.length; depth++) {
675
+ const panel = children.current.get(depth);
676
+ const item = Array.from(parent.querySelectorAll("button")).find((b) => b.dataset.key === path[depth - 1]);
677
+ if (!panel || !item)
678
+ break;
679
+ const parentBox = parent.getBoundingClientRect(), box = panel.getBoundingClientRect();
680
+ const nextLeft = parentLeft + parentBox.width;
681
+ parentLeft = Math.max(8, Math.min(nextLeft + box.width <= width - 8 ? nextLeft : parentLeft - box.width, width - box.width - 8));
682
+ parentTop = Math.max(8, Math.min(parentTop + item.getBoundingClientRect().top - parentBox.top - 4, height - box.height - 8));
683
+ Object.assign(panel.style, {
684
+ left: parentLeft + "px",
685
+ top: parentTop + "px",
686
+ visibility: "visible"
687
+ });
688
+ parent = panel;
689
+ }
632
690
  };
633
691
  const outside = (event) => {
634
692
  const path2 = event.composedPath();
635
- if (!path2.includes(trigger.current) && !path2.includes(popup.current))
693
+ if (!path2.includes(trigger.current) && !path2.includes(popup.current) && ![...children.current.values()].some((panel) => path2.includes(panel)))
636
694
  setPath(null);
637
695
  };
638
696
  const document2 = portalRoot.ownerDocument;
@@ -646,21 +704,23 @@ function Menu({ label, items, triggerIcon, floating = false }) {
646
704
  window.removeEventListener("scroll", position, true);
647
705
  document2.removeEventListener("pointerdown", outside);
648
706
  };
649
- }, [floating, path, portalRoot]);
707
+ }, [floating, path, portalRoot, cascade]);
650
708
  let entries = items;
651
709
  let menuLabel = label;
710
+ const levels = [{ entries, menuLabel }];
652
711
  for (const key of path ?? []) {
653
712
  const entry = entries.find((item) => item.id === key);
654
713
  if (!entry?.items)
655
714
  break;
656
715
  menuLabel = entry.label;
657
716
  entries = entry.items;
717
+ levels.push({ entries, menuLabel });
658
718
  }
659
- function buttons() {
660
- return [...popup.current?.querySelectorAll("button:not(:disabled)") ?? []];
719
+ function buttons(panel = cascade && path?.length ? children.current.get(path.length) : popup.current) {
720
+ return [...panel?.querySelectorAll("button:not(:disabled)") ?? []];
661
721
  }
662
722
  useEffect(() => {
663
- if (path && (!floating || !portalRoot || placement.visibility === "visible"))
723
+ if (focusOnOpen.current && path && (!floating || !portalRoot || placement.visibility === "visible"))
664
724
  buttons().at(focusIndex.current)?.focus();
665
725
  }, [path, floating && placement.visibility, portalRoot]);
666
726
  function close() {
@@ -668,6 +728,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
668
728
  trigger.current?.focus();
669
729
  }
670
730
  function back() {
731
+ focusOnOpen.current = true;
671
732
  if (!path?.length)
672
733
  return;
673
734
  const parentPath = path.slice(0, -1);
@@ -675,24 +736,27 @@ function Menu({ label, items, triggerIcon, floating = false }) {
675
736
  focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
676
737
  setPath(parentPath);
677
738
  }
678
- function choose(item) {
739
+ function choose(item, depth) {
740
+ focusOnOpen.current = true;
679
741
  if (item.items?.length) {
680
742
  focusIndex.current = 0;
681
- setPath([...path ?? [], item.id]);
743
+ setPath([...(path ?? []).slice(0, depth), item.id]);
744
+ if (cascade && path?.[depth] === item.id)
745
+ buttons(children.current.get(depth + 1))?.at(0)?.focus();
682
746
  } else if (item.onSelect) {
683
747
  if (item.checked === void 0)
684
748
  close();
685
749
  item.onSelect();
686
750
  }
687
751
  }
688
- function handleKey(event) {
752
+ function handleKey(event, depth) {
689
753
  if (event.key === "Tab" && floating && portalRoot) {
690
754
  if (event.shiftKey)
691
755
  event.preventDefault();
692
756
  close();
693
757
  return;
694
758
  }
695
- const available = buttons();
759
+ const available = buttons(event.currentTarget);
696
760
  const index = available.findIndex((button) => button === event.target);
697
761
  if (event.key === "Escape") {
698
762
  event.preventDefault();
@@ -709,10 +773,10 @@ function Menu({ label, items, triggerIcon, floating = false }) {
709
773
  return;
710
774
  }
711
775
  if (event.key === "ArrowRight") {
712
- const item = entries.filter(isEnabled)[index];
776
+ const item = levels[depth]?.entries.filter(isEnabled)[index];
713
777
  if (item?.items?.length) {
714
778
  event.preventDefault();
715
- choose(item);
779
+ choose(item, depth);
716
780
  }
717
781
  return;
718
782
  }
@@ -728,6 +792,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
728
792
  }
729
793
  }
730
794
  function open(index = 0) {
795
+ focusOnOpen.current = true;
731
796
  focusIndex.current = index;
732
797
  setPath([]);
733
798
  }
@@ -737,37 +802,74 @@ function Menu({ label, items, triggerIcon, floating = false }) {
737
802
  open(event.key === "ArrowUp" ? -1 : 0);
738
803
  }
739
804
  }
740
- const menu = _jsx7("div", { ref: popup, className: "vx-action-menu-items", role: "menu", id, "aria-label": menuLabel, hidden: !path, onKeyDown: handleKey, "data-floating": floating || void 0, style: floating && portalRoot ? placement : void 0, children: entries.map((item) => _jsxs5("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-size": item.size ?? "medium", disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item), children: [item.icon && _jsx7(Icon, { name: item.icon }), _jsx7("span", { children: item.label }), item.checked && _jsx7(Icon, { name: "check" }), item.items?.length ? _jsx7(Icon, { name: "chevron-right" }) : null] }, item.id)) });
741
- return _jsxs5("div", { className: "vx-action-menu", onBlur: (event) => {
742
- if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)))
805
+ function hover(item, depth) {
806
+ if (!cascade || !path)
807
+ return;
808
+ const next = path.slice(0, depth);
809
+ if (item.items?.length && isEnabled(item))
810
+ next.push(item.id);
811
+ if (next.length === path.length && next.every((key, i) => path[i] === key))
812
+ return;
813
+ focusOnOpen.current = false;
814
+ setPath(next);
815
+ }
816
+ const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx8("div", { ref: !cascade || depth === 0 ? popup : (el) => {
817
+ if (el)
818
+ children.current.set(depth, el);
819
+ else
820
+ children.current.delete(depth);
821
+ }, className: "vx-action-menu-items", role: "menu", id: !cascade || !depth ? id : id + "-" + depth, "aria-label": menuLabel2, hidden: !path, onKeyDown: (e) => handleKey(e, depth), "data-with-previews": entries2.some((item) => item.preview) || void 0, "data-floating": floating || void 0, style: floating && portalRoot ? cascade && depth ? {
822
+ position: "fixed",
823
+ insetInlineStart: "auto",
824
+ visibility: "hidden",
825
+ maxHeight: "min(480px, calc(100dvh - 16px))",
826
+ zIndex: 100 + depth
827
+ } : placement : void 0, children: entries2.map((item) => _jsxs6("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-key": item.id, "aria-expanded": cascade && item.items ? path?.[depth] === item.id : void 0, onPointerEnter: cascade ? (e) => {
828
+ if (e.pointerType !== "touch")
829
+ hover(item, depth);
830
+ } : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx8(Icon, { name: item.icon }), path && item.preview && _jsx8(MenuPreview, { children: item.preview }), _jsx8("span", { className: "vx-menu-label", children: item.label }), item.checked && _jsx8(Icon, { name: "check" }), item.items?.length ? _jsx8(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
831
+ return _jsxs6("div", { className: "vx-action-menu", onBlur: (event) => {
832
+ if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
743
833
  setPath(null);
744
- }, children: [triggerIcon ? _jsx7(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx7(Button, { ref: trigger, label, variant: "text-tonal-sm", trailingIcon: "chevron-down", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
834
+ }, children: [triggerIcon ? _jsx8(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx8(Button, { ref: trigger, label, variant: textTrigger === "plain" ? "text-plain-sm" : "text-tonal-sm", trailingIcon: textTrigger === "dropdown" ? "chevron-down" : void 0, "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
745
835
  }
746
836
 
747
837
  // packages/ui-system/dist/video-player.js
748
- import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
838
+ import { jsx as _jsx9, jsxs as _jsxs7, Fragment as _Fragment3 } from "react/jsx-runtime";
749
839
  import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
750
- function timeLabel2(seconds) {
840
+ function timeLabel2(seconds, padMinutes = false) {
751
841
  const whole = Math.floor(seconds);
752
- return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
842
+ const minutes = String(Math.floor(whole / 60));
843
+ return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
753
844
  }
754
- function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen }) {
755
- return _jsxs6("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, style: {
845
+ function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreenLabel = "Toggle fullscreen", actions, appearance = "on-content", timeDisplay = "combined" }) {
846
+ return _jsxs7("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-appearance": appearance, style: {
756
847
  "--vx-playback-progress": `${duration > 0 ? Math.min(100, Math.max(0, time / duration * 100)) : 0}%`
757
- }, children: [_jsx8(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), _jsx8("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsxs6("span", { "aria-hidden": "true", children: [timeLabel2(time), " / ", timeLabel2(duration)] }), _jsx8(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), onFullscreen && _jsx8(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: "Toggle fullscreen", onClick: onFullscreen })] });
848
+ }, children: [_jsx9(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx9("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), _jsx9("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsx9("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx9(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx9(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, onClick: onFullscreen })] });
758
849
  }
759
850
  function VideoPlayer(props) {
760
- return _jsx8(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
851
+ return _jsx9(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
761
852
  }
762
- function Playback({ src, poster, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", controlsSize, showFullscreen = true, overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
853
+ function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, showCoverInfo = true, showCoverPlay = true, fitExpandedContent = false, controlsSize, controlsAppearance, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
763
854
  const root = useRef3(null);
764
855
  const video = useRef3(null);
765
856
  const position = useRef3(0);
766
857
  const callbacks = useRef3({ onTimeChange, onStateChange, onEnded });
767
858
  const [time, setTime] = useState3(0);
859
+ const [ratio, setRatio] = useState3(16 / 9);
768
860
  const [metadataDuration, setMetadataDuration] = useState3(0);
769
861
  const [state, setState] = useState3("cover");
770
862
  const [muted, setMuted] = useState3(defaultMuted);
863
+ const [expanded, setExpanded] = useState3(false);
864
+ const [inlineHeight, setInlineHeight] = useState3();
865
+ const restoreFocus = useRef3(false);
866
+ useEffect2(() => {
867
+ if (!expanded && restoreFocus.current) {
868
+ restoreFocus.current = false;
869
+ root.current?.querySelector('button[aria-label="Expand video"]')?.focus();
870
+ }
871
+ }, [expanded]);
872
+ const restore = useRef3(void 0);
771
873
  const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
772
874
  const duration = src ? metadataDuration : stillDuration;
773
875
  useEffect2(() => {
@@ -779,7 +881,7 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
779
881
  element.removeAttribute("src");
780
882
  element.load();
781
883
  };
782
- }, []);
884
+ }, [expanded, src]);
783
885
  function updateTime(next) {
784
886
  position.current = next;
785
887
  setTime(next);
@@ -838,25 +940,72 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
838
940
  updateTime(seconds);
839
941
  }
840
942
  async function toggleFullscreen() {
943
+ if (fullscreenMode === "dialog") {
944
+ changeExpanded(!expanded);
945
+ return;
946
+ }
841
947
  try {
842
- const player = root.current;
843
- if (!player?.requestFullscreen)
948
+ const player2 = root.current;
949
+ if (!player2?.requestFullscreen)
844
950
  return;
845
- if (player.ownerDocument.fullscreenElement === player)
846
- await player.ownerDocument.exitFullscreen();
951
+ if (player2.ownerDocument.fullscreenElement === player2)
952
+ await player2.ownerDocument.exitFullscreen();
847
953
  else
848
- await player.requestFullscreen();
954
+ await player2.requestFullscreen();
849
955
  } catch (error) {
850
956
  onError?.(error);
851
957
  }
852
958
  }
853
- return _jsxs6("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-placement": controlsPlacement, "data-state": state, children: [_jsxs6("div", { className: "vx-video-stage", children: [src ? _jsx8("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onDurationChange: (event) => {
959
+ function changeExpanded(next) {
960
+ const element = video.current;
961
+ restore.current = {
962
+ time: element?.currentTime ?? position.current,
963
+ playing: element ? !element.paused : state === "playing",
964
+ state
965
+ };
966
+ if (next)
967
+ setInlineHeight(root.current?.getBoundingClientRect().height);
968
+ else
969
+ restoreFocus.current = true;
970
+ element?.pause();
971
+ setExpanded(next);
972
+ }
973
+ const fitted = fitContent || expanded && fitExpandedContent;
974
+ const player = _jsxs7("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-fit": fitted ? "content" : void 0, style: fitted ? { "--vx-video-ratio": aspectRatio ?? ratio } : void 0, "data-placement": controlsPlacement, "data-controls-size": controlsSize, "data-state": state, children: [_jsxs7("div", { className: "vx-video-stage", style: aspectRatio ? { aspectRatio } : void 0, children: [src ? _jsx9("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onResize: (event) => {
975
+ const { videoWidth, videoHeight } = event.currentTarget;
976
+ if (videoWidth && videoHeight)
977
+ setRatio(videoWidth / videoHeight);
978
+ }, onLoadedMetadata: (event) => {
979
+ const element = event.currentTarget;
980
+ const { videoWidth, videoHeight } = element;
981
+ if (videoWidth && videoHeight)
982
+ setRatio(videoWidth / videoHeight);
983
+ const previous = restore.current;
984
+ if (!previous)
985
+ return;
986
+ element.currentTime = Math.min(previous.time, element.duration);
987
+ updateTime(element.currentTime);
988
+ restore.current = void 0;
989
+ if (previous.playing)
990
+ void element.play().catch(() => changeState("paused"));
991
+ else
992
+ changeState(previous.state);
993
+ }, onDurationChange: (event) => {
854
994
  const value = event.currentTarget.duration;
855
995
  setMetadataDuration(Number.isFinite(value) ? value : 0);
856
996
  }, onPlay: () => changeState("playing"), onPause: (event) => {
997
+ if (restore.current)
998
+ return;
857
999
  updateTime(event.currentTarget.currentTime);
858
1000
  changeState("paused");
859
- }, onTimeUpdate: (event) => updateTime(event.currentTarget.currentTime), onEnded, onError: (event) => onError?.(event.currentTarget.error) }) : poster && _jsx8("img", { src: poster, alt: "" }), overlay, state === "cover" && _jsxs6("div", { className: "vx-video-cover", children: [_jsxs6("div", { className: "vx-video-info", children: [_jsxs6("div", { className: "vx-video-title", children: [_jsx8("strong", { title, children: title }), version && _jsx8(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs6("div", { className: "vx-video-meta", children: [durationLabel && _jsx8("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx8("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx8("span", { children: sceneLabel })] })] }), (src || duration > 0) && _jsx8(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx8(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen ? () => void toggleFullscreen() : void 0 })] });
1001
+ }, onTimeUpdate: (event) => {
1002
+ if (!restore.current)
1003
+ updateTime(event.currentTarget.currentTime);
1004
+ }, onEnded, onError: (event) => {
1005
+ if (event.currentTarget.error)
1006
+ onError?.(event.currentTarget.error);
1007
+ } }) : poster && _jsx9("img", { src: poster, alt: "" }), overlay, state === "cover" && !fitted && _jsxs7("div", { className: "vx-video-cover", "data-plain": !showCoverInfo || void 0, children: [showCoverInfo && _jsxs7("div", { className: "vx-video-info", children: [_jsxs7("div", { className: "vx-video-title", children: [_jsx9("strong", { title, children: title }), version && _jsx9(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs7("div", { className: "vx-video-meta", children: [durationLabel && _jsx9("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx9("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx9("span", { children: sceneLabel })] })] }), showCoverPlay && (src || duration > 0) && _jsx9(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx9(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, appearance: controlsAppearance, timeDisplay, actions: controlsActions, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen && !(expanded && fitExpandedContent) ? () => void toggleFullscreen() : void 0, fullscreenLabel: fullscreenMode === "dialog" ? expanded ? "Close expanded video" : "Expand video" : void 0 })] });
1008
+ return _jsxs7(_Fragment3, { children: [expanded ? _jsx9("div", { "aria-hidden": "true", style: { height: inlineHeight } }) : player, _jsx9(Dialog, { title, open: expanded, onOpenChange: changeExpanded, className: fitExpandedContent ? "vx-video-dialog vx-video-dialog-fit" : "vx-video-dialog", children: expanded && player })] });
860
1009
  }
861
1010
 
862
1011
  // packages/media-tools/src/ui/recipe-player.tsx
@@ -1475,8 +1624,259 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1475
1624
  );
1476
1625
  }
1477
1626
 
1478
- // packages/media-tools/src/ui/compare.tsx
1627
+ // packages/media-tools/src/ui/export-dialog.tsx
1479
1628
  import * as React5 from "react";
1629
+ import { useEffect as useEffect6, useRef as useRef6, useState as useState7 } from "react";
1630
+ var terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled", "interrupted"]);
1631
+ function VideoExport({
1632
+ title,
1633
+ preview,
1634
+ aspectRatio,
1635
+ canvas: canvas2,
1636
+ issue,
1637
+ legacyTracking,
1638
+ prepare,
1639
+ resolveDownload,
1640
+ onClose
1641
+ }) {
1642
+ const { client, instanceId } = useMediaClient();
1643
+ const storageKey = `studio-video-export:${client.project.id}:${instanceId}`;
1644
+ const [tracking, setTracking] = useState7(() => {
1645
+ try {
1646
+ const raw = localStorage.getItem(storageKey);
1647
+ const stored = raw ? JSON.parse(raw) : legacyTracking;
1648
+ const parsed = mediaRequest.safeParse(stored?.pending?.request);
1649
+ return {
1650
+ jobId: typeof stored?.jobId === "string" ? stored.jobId : void 0,
1651
+ pending: typeof stored?.pending?.key === "string" && parsed.success ? { key: stored.pending.key, request: parsed.data } : void 0,
1652
+ recoverIntent: raw ? void 0 : legacyTracking?.recoverIntent
1653
+ };
1654
+ } catch {
1655
+ return { jobId: void 0, pending: void 0, recoverIntent: void 0 };
1656
+ }
1657
+ });
1658
+ const [name, setName] = useState7(title.slice(0, 196));
1659
+ const [job, setJob] = useState7();
1660
+ const [error, setError] = useState7("");
1661
+ const [pollError, setPollError] = useState7("");
1662
+ const [busy, setBusy] = useState7(false);
1663
+ const lock = useRef6(false);
1664
+ const cancelKey = useRef6(void 0);
1665
+ const { jobId, pending, recoverIntent } = tracking;
1666
+ const unresolved = Boolean(pending || recoverIntent);
1667
+ const active = Boolean(jobId && (!job || !terminal.has(job.state)));
1668
+ useEffect6(() => setName(title.slice(0, 196)), [title]);
1669
+ useEffect6(() => {
1670
+ if (!jobId || job && job.jobId === jobId && terminal.has(job.state)) return;
1671
+ let live = true;
1672
+ let timer;
1673
+ async function poll(id) {
1674
+ try {
1675
+ const result = await client.invoke(
1676
+ { instanceId, operationId: "jobs.get" },
1677
+ { jobId: id }
1678
+ );
1679
+ if (!live) return;
1680
+ updateJob(result);
1681
+ setPollError("");
1682
+ if (terminal.has(result.state)) return;
1683
+ } catch (error2) {
1684
+ if (live) setPollError(readableError(error2));
1685
+ }
1686
+ if (live) timer = setTimeout(() => void poll(id), 750);
1687
+ }
1688
+ void poll(jobId);
1689
+ return () => {
1690
+ live = false;
1691
+ clearTimeout(timer);
1692
+ };
1693
+ }, [client, instanceId, jobId, job?.state]);
1694
+ function updateJob(result) {
1695
+ setJob(
1696
+ (current) => current?.jobId === result.jobId && current.revision > result.revision ? current : result
1697
+ );
1698
+ }
1699
+ function track(next) {
1700
+ try {
1701
+ localStorage.setItem(storageKey, JSON.stringify(next));
1702
+ } catch {
1703
+ }
1704
+ setTracking({ ...next, recoverIntent: void 0 });
1705
+ }
1706
+ async function act(run) {
1707
+ if (lock.current) return;
1708
+ lock.current = true;
1709
+ setBusy(true);
1710
+ setError("");
1711
+ try {
1712
+ await run();
1713
+ } catch (error2) {
1714
+ setError(readableError(error2));
1715
+ } finally {
1716
+ lock.current = false;
1717
+ setBusy(false);
1718
+ }
1719
+ }
1720
+ async function submit(intent) {
1721
+ track({ jobId, pending: intent });
1722
+ try {
1723
+ const result = await client.invoke(
1724
+ { instanceId, operationId: intent.request.operation },
1725
+ intent.request.input,
1726
+ { requestKey: intent.key }
1727
+ );
1728
+ setJob(void 0);
1729
+ track({ jobId: result.jobId, pending: void 0 });
1730
+ } catch (error2) {
1731
+ const code = error2 && typeof error2 === "object" && "code" in error2 ? error2.code : void 0;
1732
+ if (typeof code === "string" && !["EXECUTION_UNKNOWN", "OPERATION_CONTRACT_CHANGED", "TRANSPORT_UNKNOWN"].includes(code))
1733
+ track({ jobId, pending: void 0 });
1734
+ throw error2;
1735
+ }
1736
+ }
1737
+ async function findOriginal() {
1738
+ const original = pending ?? await recoverIntent?.();
1739
+ if (!original) return;
1740
+ const found = await client.invoke(
1741
+ { instanceId, operationId: "jobs.list" },
1742
+ {
1743
+ request: {
1744
+ operation: original.request.operation,
1745
+ requestKey: original.key,
1746
+ intent: original.request.input
1747
+ }
1748
+ }
1749
+ );
1750
+ if (!found.items[0]) throw Error("No accepted export was found. No new task was submitted.");
1751
+ updateJob(found.items[0]);
1752
+ track({ jobId: found.items[0].jobId, pending: void 0 });
1753
+ }
1754
+ async function exportVideo() {
1755
+ const outputName2 = name.trim().replace(/\.mp4$/i, "") + ".mp4";
1756
+ const input = await prepare();
1757
+ await submit({
1758
+ key: crypto.randomUUID(),
1759
+ request: { operation: "sequence.process", input: { ...input, outputName: outputName2 } }
1760
+ });
1761
+ }
1762
+ const settings = [
1763
+ ["Format", "MP4 \xB7 H.264"],
1764
+ ["Aspect ratio", aspectRatio || (canvas2 ? `${canvas2.width}:${canvas2.height}` : "Match source")],
1765
+ ["Resolution", canvas2 ? `${canvas2.width} \xD7 ${canvas2.height}` : "Match source"],
1766
+ ["Frame rate", "Match source"],
1767
+ ["Quality", "High"],
1768
+ ["Audio", "Include source audio"]
1769
+ ];
1770
+ return /* @__PURE__ */ React5.createElement(
1771
+ Dialog,
1772
+ {
1773
+ open: true,
1774
+ title: "Export Settings",
1775
+ className: "mt-export-dialog",
1776
+ onOpenChange: (open) => {
1777
+ if (!open && !lock.current) onClose();
1778
+ },
1779
+ actions: /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
1780
+ Button,
1781
+ {
1782
+ label: jobId || unresolved ? "Close" : "Cancel",
1783
+ variant: "text-tonal-lg",
1784
+ width: "hug",
1785
+ onClick: onClose,
1786
+ disabled: busy
1787
+ }
1788
+ ), /* @__PURE__ */ React5.createElement(
1789
+ Button,
1790
+ {
1791
+ label: "Export",
1792
+ variant: "text-filled-lg",
1793
+ width: "hug",
1794
+ disabled: busy || active || Boolean(unresolved || issue) || !name.trim().replace(/\.mp4$/i, "").trim(),
1795
+ onClick: () => void act(exportVideo)
1796
+ }
1797
+ ))
1798
+ },
1799
+ /* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview" }, preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
1800
+ TextInput,
1801
+ {
1802
+ label: "Title",
1803
+ maxLength: 196,
1804
+ value: name,
1805
+ onValueChange: setName,
1806
+ disabled: busy
1807
+ }
1808
+ ), /* @__PURE__ */ React5.createElement("dl", null, settings.map(([label, value]) => /* @__PURE__ */ React5.createElement("div", { key: label }, /* @__PURE__ */ React5.createElement("dt", null, label), /* @__PURE__ */ React5.createElement("dd", null, value)))))),
1809
+ issue && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice" }, issue),
1810
+ busy && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice", role: "status" }, "Working\u2026"),
1811
+ unresolved && !busy && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, "Export outcome has not been confirmed.", /* @__PURE__ */ React5.createElement(
1812
+ Button,
1813
+ {
1814
+ label: "Find original export",
1815
+ variant: "text-ghost-sm",
1816
+ onClick: () => void act(findOriginal)
1817
+ }
1818
+ )),
1819
+ job && !unresolved && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, /* @__PURE__ */ React5.createElement("span", { role: "status" }, "Export: ", job.state, active && job.progress != null ? ` \xB7 ${Math.min(99, Math.round(job.progress * 100))}%` : ""), active && /* @__PURE__ */ React5.createElement(
1820
+ Button,
1821
+ {
1822
+ label: "Cancel export",
1823
+ variant: "text-ghost-sm",
1824
+ disabled: busy || job.cancelRequested,
1825
+ onClick: () => void act(async () => {
1826
+ if (cancelKey.current?.jobId !== job.jobId)
1827
+ cancelKey.current = { jobId: job.jobId, key: crypto.randomUUID() };
1828
+ updateJob(
1829
+ await client.invoke(
1830
+ { instanceId, operationId: "jobs.cancel" },
1831
+ { jobId: job.jobId },
1832
+ { requestKey: cancelKey.current.key }
1833
+ )
1834
+ );
1835
+ })
1836
+ }
1837
+ ), !active && job.state !== "succeeded" && /* @__PURE__ */ React5.createElement(
1838
+ Button,
1839
+ {
1840
+ label: "Retry export",
1841
+ variant: "text-ghost-sm",
1842
+ disabled: busy || job.cleanupPending,
1843
+ onClick: () => void act(() => submit({ key: crypto.randomUUID(), request: job.retryRequest }))
1844
+ }
1845
+ ), job.state === "succeeded" && job.result && /* @__PURE__ */ React5.createElement(
1846
+ Button,
1847
+ {
1848
+ label: "Download exported video",
1849
+ variant: "text-ghost-sm",
1850
+ disabled: busy,
1851
+ onClick: (event) => {
1852
+ const doc = event.currentTarget.ownerDocument;
1853
+ void act(async () => {
1854
+ const url = await resolveDownload(job.result);
1855
+ if (!url) throw Error("The exported video is unavailable.");
1856
+ const link = doc.createElement("a");
1857
+ link.href = url;
1858
+ link.download = job.outputName;
1859
+ link.click();
1860
+ });
1861
+ }
1862
+ }
1863
+ ), job.error && /* @__PURE__ */ React5.createElement("span", { className: "mt-export-error", role: "alert" }, job.error.message)),
1864
+ (error || pollError) && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-error", role: "alert" }, error || pollError)
1865
+ );
1866
+ }
1867
+
1868
+ // packages/media-tools/src/ui/compare.tsx
1869
+ import * as React6 from "react";
1870
+ function inputKey(input) {
1871
+ const ref = input.kind === "source" ? input.file.source : input.editRef;
1872
+ return JSON.stringify([
1873
+ input.kind,
1874
+ ref.storeId,
1875
+ ref.objectId,
1876
+ ref.versionId,
1877
+ input.kind === "source" ? input.file.fileId : null
1878
+ ]);
1879
+ }
1480
1880
  function formatLabel(width, height) {
1481
1881
  let a = width, b = height;
1482
1882
  while (b) {
@@ -1494,12 +1894,12 @@ function Candidate({
1494
1894
  emptyState
1495
1895
  }) {
1496
1896
  const { resolve } = useMediaClient();
1497
- const [video, setVideo] = React5.useState(null);
1498
- const [error, setError] = React5.useState("");
1499
- const [revision, setRevision] = React5.useState(0);
1897
+ const [video, setVideo] = React6.useState(null);
1898
+ const [error, setError] = React6.useState("");
1899
+ const [revision, setRevision] = React6.useState(0);
1500
1900
  const title = slot.context?.shotName?.trim() || video?.name || "Video";
1501
1901
  const identity = JSON.stringify(slot.input);
1502
- React5.useEffect(() => {
1902
+ React6.useEffect(() => {
1503
1903
  let active = true;
1504
1904
  setVideo(null);
1505
1905
  setError("");
@@ -1513,15 +1913,15 @@ function Candidate({
1513
1913
  active = false;
1514
1914
  };
1515
1915
  }, [resolve, identity, revision]);
1516
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "mt-compare-preview" }, replacing ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "status" }, "Choosing replacement\u2026") : !slot.input ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty" }, emptyState ?? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("p", null, "No video selected."), /* @__PURE__ */ React5.createElement(
1916
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("div", { className: "mt-compare-preview" }, replacing ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Choosing replacement\u2026") : !slot.input ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty" }, /* @__PURE__ */ React6.createElement("p", null, "No video selected."), emptyState ?? /* @__PURE__ */ React6.createElement(
1517
1917
  Button,
1518
1918
  {
1519
- label: "Choose video",
1520
- variant: "text-tonal-sm",
1919
+ label: "Select a shot",
1920
+ variant: "text-plain-sm",
1521
1921
  width: "hug",
1522
1922
  onClick: onChoose
1523
1923
  }
1524
- ))) : error ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React5.createElement("p", null, error), /* @__PURE__ */ React5.createElement(
1924
+ )) : error ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React6.createElement("p", null, error), /* @__PURE__ */ React6.createElement(
1525
1925
  Button,
1526
1926
  {
1527
1927
  label: "Reload preview",
@@ -1529,29 +1929,30 @@ function Candidate({
1529
1929
  width: "hug",
1530
1930
  onClick: () => setRevision(revision + 1)
1531
1931
  }
1532
- )) : !video ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React5.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React5.createElement(
1932
+ )) : !video ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React6.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React6.createElement(
1533
1933
  VideoPlayer,
1534
1934
  {
1535
1935
  src: video.previewUrl,
1536
1936
  title,
1937
+ showCoverInfo: false,
1537
1938
  controlsPlacement: "overlay",
1538
1939
  onError: () => setError("This video could not be played. Reload its fixed preview.")
1539
1940
  }
1540
- )), /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-caption" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-heading" }, /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("strong", null, slot.input ? title : "Candidate"), video && /* @__PURE__ */ React5.createElement("span", null, "Variant ", video.versionNumber, video.edited ? " \xB7 Edited" : "")), menu), video?.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React5.createElement("span", null, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")), /* @__PURE__ */ React5.createElement("div", { className: "mt-candidate-context" }, slot.input && (video || slot.context?.spokenLine || slot.context?.hook || slot.context?.cta) && /* @__PURE__ */ React5.createElement("dl", null, slot.context?.spokenLine && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Spoken line"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.spokenLine)), slot.context?.hook && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Opening Hook"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.hook)), slot.context && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "CTA"), /* @__PURE__ */ React5.createElement("dd", null, slot.context.cta || "None")), video && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("dt", null, "Format"), /* @__PURE__ */ React5.createElement("dd", null, formatLabel(video.geometry.pixelRect.width, video.geometry.pixelRect.height)), /* @__PURE__ */ React5.createElement("dt", null, "Duration"), /* @__PURE__ */ React5.createElement("dd", null, Number((video.effectiveDurationMs / 1e3).toFixed(2)), "s")))));
1941
+ )), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-caption" }, /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-heading" }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("strong", null, slot.input ? title : "Candidate"), video && /* @__PURE__ */ React6.createElement("span", null, "Variant ", video.versionNumber, video.edited ? " \xB7 Edited" : "")), menu), video?.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React6.createElement("span", null, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-context" }, slot.input && (video || slot.context?.spokenLine || slot.context?.hook || slot.context?.cta) && /* @__PURE__ */ React6.createElement("dl", null, slot.context?.spokenLine && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Spoken line"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.spokenLine)), slot.context?.hook && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Opening Hook"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.hook)), slot.context && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "CTA"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.cta || "None")), video && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Format"), /* @__PURE__ */ React6.createElement("dd", null, formatLabel(video.geometry.pixelRect.width, video.geometry.pixelRect.height)), /* @__PURE__ */ React6.createElement("dt", null, "Duration"), /* @__PURE__ */ React6.createElement("dd", null, Number((video.effectiveDurationMs / 1e3).toFixed(2)), "s")))));
1541
1942
  }
1542
1943
  function VideoCompare(props) {
1543
- const [generation, setGeneration] = React5.useState(0);
1544
- const [replacing, setReplacing] = React5.useState(null);
1545
- const [error, setError] = React5.useState("");
1546
- const active = React5.useRef(true);
1547
- React5.useEffect(() => {
1944
+ const [generation, setGeneration] = React6.useState(0);
1945
+ const [replacing, setReplacing] = React6.useState(null);
1946
+ const [error, setError] = React6.useState("");
1947
+ const active = React6.useRef(true);
1948
+ React6.useEffect(() => {
1548
1949
  active.current = true;
1549
1950
  return () => {
1550
1951
  active.current = false;
1551
1952
  };
1552
1953
  }, []);
1553
1954
  if (props.slots.length < 2 || props.slots.length > 4 || new Set(props.slots.map((slot) => slot.id)).size !== props.slots.length)
1554
- return /* @__PURE__ */ React5.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
1955
+ return /* @__PURE__ */ React6.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
1555
1956
  const remove = (slot) => props.onSlotsChange(
1556
1957
  props.slots.length > 2 ? props.slots.filter((value) => value.id !== slot.id) : props.slots.map((value) => value.id === slot.id ? { ...value, input: null } : value)
1557
1958
  );
@@ -1571,91 +1972,118 @@ function VideoCompare(props) {
1571
1972
  if (active.current) setReplacing(null);
1572
1973
  }
1573
1974
  }
1975
+ const slotKeys = props.slots.map(({ input }) => input && inputKey(input));
1574
1976
  function candidateChoices(slot) {
1575
- return (props.candidates || []).filter(
1576
- (candidate) => !props.slots.some(
1577
- (other) => other.id !== slot.id && JSON.stringify(other.input) === JSON.stringify(candidate.input)
1578
- )
1579
- ).map((candidate, index) => ({
1580
- id: `candidate-${index}`,
1581
- label: candidate.label,
1582
- onSelect: () => props.onSlotsChange(
1583
- props.slots.map(
1584
- (value) => value.id === slot.id ? { ...value, input: candidate.input, context: candidate.context } : value
1585
- )
1586
- )
1587
- }));
1977
+ return (props.candidates || []).flatMap((candidate) => {
1978
+ const key = inputKey(candidate.input);
1979
+ const occupied = props.slots[slotKeys.indexOf(key)];
1980
+ if (occupied && (props.allowCandidateSwap ? occupied.id === slot.id : occupied.id !== slot.id))
1981
+ return [];
1982
+ return [
1983
+ {
1984
+ id: key,
1985
+ label: props.allowCandidateSwap && occupied ? "Swap with " + candidate.label : candidate.label,
1986
+ preview: candidate.preview,
1987
+ onSelect: () => props.onSlotsChange(
1988
+ props.slots.map((column) => {
1989
+ if (column.id === slot.id)
1990
+ return { ...column, input: candidate.input, context: candidate.context };
1991
+ if (column.id === occupied?.id)
1992
+ return { ...column, input: slot.input, context: slot.context };
1993
+ return column;
1994
+ })
1995
+ )
1996
+ }
1997
+ ];
1998
+ });
1588
1999
  }
1589
- return /* @__PURE__ */ React5.createElement("section", { className: "mt-compare", "aria-label": "Compare videos" }, error && /* @__PURE__ */ React5.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React5.createElement(
2000
+ return /* @__PURE__ */ React6.createElement("section", { className: "mt-compare", "aria-label": "Compare videos" }, error && /* @__PURE__ */ React6.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React6.createElement(
1590
2001
  "div",
1591
2002
  {
1592
2003
  className: "mt-compare-columns",
1593
2004
  style: { gridTemplateColumns: `repeat(${props.slots.length}, minmax(240px,1fr))` }
1594
2005
  },
1595
- props.slots.map((slot, index) => /* @__PURE__ */ React5.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React5.createElement(
1596
- Candidate,
1597
- {
1598
- key: JSON.stringify([slot.id, slot.input, generation]),
1599
- slot,
1600
- replacing: replacing === slot.id,
1601
- onChoose: () => void replace(slot),
1602
- emptyState: props.candidates ? candidateChoices(slot).length ? /* @__PURE__ */ React5.createElement(Menu, { label: "Choose video", floating: true, items: candidateChoices(slot) }) : /* @__PURE__ */ React5.createElement("p", null, "No other candidates yet.") : void 0,
1603
- menu: /* @__PURE__ */ React5.createElement(
1604
- Menu,
1605
- {
1606
- label: `Options for video ${index + 1}`,
1607
- triggerIcon: "more",
1608
- floating: true,
1609
- items: [
1610
- ...props.slotMenuItems?.(slot) ?? [],
1611
- ...props.candidates ? [
2006
+ props.slots.map((slot, index) => {
2007
+ const replacements = candidateChoices(slot);
2008
+ return /* @__PURE__ */ React6.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React6.createElement(
2009
+ Candidate,
2010
+ {
2011
+ key: JSON.stringify([slot.id, slot.input, generation]),
2012
+ slot,
2013
+ replacing: replacing === slot.id,
2014
+ onChoose: () => void replace(slot),
2015
+ emptyState: props.candidates ? replacements.length || props.allowCandidateSwap ? /* @__PURE__ */ React6.createElement(
2016
+ Menu,
2017
+ {
2018
+ label: "Select a shot",
2019
+ textTrigger: "plain",
2020
+ floating: true,
2021
+ items: replacements
2022
+ }
2023
+ ) : /* @__PURE__ */ React6.createElement("p", null, "No other candidates yet.") : void 0,
2024
+ menu: /* @__PURE__ */ React6.createElement(
2025
+ Menu,
2026
+ {
2027
+ label: `Options for video ${index + 1}`,
2028
+ triggerIcon: "more",
2029
+ cascading: props.allowCandidateSwap,
2030
+ floating: true,
2031
+ items: [
2032
+ ...props.slotMenuItems?.(slot) ?? [],
2033
+ ...props.candidates ? [
2034
+ {
2035
+ id: "replace",
2036
+ label: "Choose video",
2037
+ disabled: replacements.length === 0,
2038
+ items: replacements
2039
+ }
2040
+ ] : [
2041
+ {
2042
+ id: "replace",
2043
+ label: slot.input ? "Replace" : "Choose video",
2044
+ disabled: replacing !== null,
2045
+ onSelect: () => void replace(slot)
2046
+ }
2047
+ ],
2048
+ ...slot.input ? [
2049
+ {
2050
+ id: "details",
2051
+ label: "Details",
2052
+ onSelect: () => {
2053
+ setGeneration((value) => value + 1);
2054
+ props.onOpenDetails(slot.input, {
2055
+ slots: props.slots,
2056
+ origin: props.origin
2057
+ });
2058
+ }
2059
+ }
2060
+ ] : [],
1612
2061
  {
1613
- id: "replace",
1614
- label: "Choose video",
1615
- disabled: candidateChoices(slot).length === 0,
1616
- items: candidateChoices(slot)
1617
- }
1618
- ] : [
2062
+ id: "add-column",
2063
+ label: "Add column",
2064
+ disabled: props.slots.length >= 4,
2065
+ onSelect: () => props.onSlotsChange([
2066
+ ...props.slots,
2067
+ { id: crypto.randomUUID(), input: null }
2068
+ ])
2069
+ },
1619
2070
  {
1620
- id: "replace",
1621
- label: slot.input ? "Replace" : "Choose video",
1622
- disabled: replacing !== null,
1623
- onSelect: () => void replace(slot)
2071
+ id: "remove",
2072
+ label: "Remove",
2073
+ tone: "danger",
2074
+ onSelect: () => remove(slot)
1624
2075
  }
1625
- ],
1626
- ...slot.input ? [
1627
- {
1628
- id: "details",
1629
- label: "Details",
1630
- onSelect: () => {
1631
- setGeneration((value) => value + 1);
1632
- props.onOpenDetails(slot.input, {
1633
- slots: props.slots,
1634
- origin: props.origin
1635
- });
1636
- }
1637
- }
1638
- ] : [],
1639
- {
1640
- id: "add-column",
1641
- label: "Add column",
1642
- disabled: props.slots.length >= 4,
1643
- onSelect: () => props.onSlotsChange([
1644
- ...props.slots,
1645
- { id: crypto.randomUUID(), input: null }
1646
- ])
1647
- },
1648
- { id: "remove", label: "Remove", onSelect: () => remove(slot) }
1649
- ]
1650
- }
1651
- )
1652
- }
1653
- ), slot.input && props.renderSlotActions && /* @__PURE__ */ React5.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot))))
2076
+ ]
2077
+ }
2078
+ )
2079
+ }
2080
+ ), slot.input && props.renderSlotActions && /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot)));
2081
+ })
1654
2082
  ));
1655
2083
  }
1656
2084
 
1657
2085
  // packages/media-tools/src/ui/jobs.tsx
1658
- import * as React6 from "react";
2086
+ import * as React7 from "react";
1659
2087
  var labels = {
1660
2088
  queued: "Queued",
1661
2089
  running: "Processing",
@@ -1667,20 +2095,20 @@ var labels = {
1667
2095
  };
1668
2096
  function MediaJobs({ onOpenResult }) {
1669
2097
  const { client, instanceId } = useMediaClient();
1670
- const [page, setPage] = React6.useState({ items: [], nextOffset: null });
1671
- const [offset, setOffset] = React6.useState(0);
1672
- const [refresh, setRefresh] = React6.useState(0);
1673
- const [error, setError] = React6.useState("");
1674
- const [pending, setPending] = React6.useState(null);
1675
- const keys = React6.useRef(/* @__PURE__ */ new Map());
1676
- const live = React6.useRef(true);
1677
- React6.useEffect(() => {
2098
+ const [page, setPage] = React7.useState({ items: [], nextOffset: null });
2099
+ const [offset, setOffset] = React7.useState(0);
2100
+ const [refresh, setRefresh] = React7.useState(0);
2101
+ const [error, setError] = React7.useState("");
2102
+ const [pending, setPending] = React7.useState(null);
2103
+ const keys = React7.useRef(/* @__PURE__ */ new Map());
2104
+ const live = React7.useRef(true);
2105
+ React7.useEffect(() => {
1678
2106
  live.current = true;
1679
2107
  return () => {
1680
2108
  live.current = false;
1681
2109
  };
1682
2110
  }, []);
1683
- React6.useEffect(() => {
2111
+ React7.useEffect(() => {
1684
2112
  let active = true, timer;
1685
2113
  async function poll() {
1686
2114
  try {
@@ -1730,7 +2158,7 @@ function MediaJobs({ onOpenResult }) {
1730
2158
  if (live.current) setPending(null);
1731
2159
  }
1732
2160
  }
1733
- return /* @__PURE__ */ React6.createElement("section", { className: "mt-jobs", "aria-label": "Media tasks" }, /* @__PURE__ */ React6.createElement("div", { className: "mt-toolbar" }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("h2", null, "Media tasks"), /* @__PURE__ */ React6.createElement("p", { className: "mt-help" }, "Processing continues when this page closes.")), /* @__PURE__ */ React6.createElement(
2161
+ return /* @__PURE__ */ React7.createElement("section", { className: "mt-jobs", "aria-label": "Media tasks" }, /* @__PURE__ */ React7.createElement("div", { className: "mt-toolbar" }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h2", null, "Media tasks"), /* @__PURE__ */ React7.createElement("p", { className: "mt-help" }, "Processing continues when this page closes.")), /* @__PURE__ */ React7.createElement(
1734
2162
  Button,
1735
2163
  {
1736
2164
  label: "Refresh tasks",
@@ -1738,14 +2166,14 @@ function MediaJobs({ onOpenResult }) {
1738
2166
  width: "hug",
1739
2167
  onClick: () => setRefresh(refresh + 1)
1740
2168
  }
1741
- )), error && /* @__PURE__ */ React6.createElement("p", { role: "alert", className: "mt-error" }, error), !page.items.length && /* @__PURE__ */ React6.createElement("p", { className: "mt-empty" }, "No media tasks on this page."), page.items.map((job) => /* @__PURE__ */ React6.createElement("article", { className: "mt-job", key: job.jobId }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("strong", null, job.outputName), /* @__PURE__ */ React6.createElement("p", null, job.kind === "sequence" ? "Sequence export" : "Video processing", " \xB7", " ", job.cancelRequested && !["succeeded", "failed", "canceled", "interrupted"].includes(job.state) ? "Stopping\u2026" : labels[job.state]), job.cleanupPending && /* @__PURE__ */ React6.createElement("p", { className: "mt-error" }, "Cleanup is pending. New processing is blocked until the old process is confirmed stopped."), job.error && /* @__PURE__ */ React6.createElement("p", { className: "mt-error" }, job.error.message)), /* @__PURE__ */ React6.createElement("div", { className: "mt-job-progress" }, /* @__PURE__ */ React6.createElement(
2169
+ )), error && /* @__PURE__ */ React7.createElement("p", { role: "alert", className: "mt-error" }, error), !page.items.length && /* @__PURE__ */ React7.createElement("p", { className: "mt-empty" }, "No media tasks on this page."), page.items.map((job) => /* @__PURE__ */ React7.createElement("article", { className: "mt-job", key: job.jobId }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("strong", null, job.outputName), /* @__PURE__ */ React7.createElement("p", null, job.kind === "sequence" ? "Sequence export" : "Video processing", " \xB7", " ", job.cancelRequested && !["succeeded", "failed", "canceled", "interrupted"].includes(job.state) ? "Stopping\u2026" : labels[job.state]), job.cleanupPending && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, "Cleanup is pending. New processing is blocked until the old process is confirmed stopped."), job.error && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, job.error.message)), /* @__PURE__ */ React7.createElement("div", { className: "mt-job-progress" }, /* @__PURE__ */ React7.createElement(
1742
2170
  "progress",
1743
2171
  {
1744
2172
  "aria-label": `Progress for ${job.outputName}`,
1745
2173
  max: 1,
1746
2174
  value: job.state === "succeeded" ? 1 : job.progress === null ? void 0 : Math.min(0.99, job.progress)
1747
2175
  }
1748
- ), /* @__PURE__ */ React6.createElement("span", null, job.state === "succeeded" ? "100%" : job.progress === null ? "Unknown progress" : `${Math.floor(Math.min(0.99, job.progress) * 100)}%`)), /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, ["queued", "running", "saving"].includes(job.state) && /* @__PURE__ */ React6.createElement(
2176
+ ), /* @__PURE__ */ React7.createElement("span", null, job.state === "succeeded" ? "100%" : job.progress === null ? "Unknown progress" : `${Math.floor(Math.min(0.99, job.progress) * 100)}%`)), /* @__PURE__ */ React7.createElement("div", { className: "mt-column-actions" }, ["queued", "running", "saving"].includes(job.state) && /* @__PURE__ */ React7.createElement(
1749
2177
  Button,
1750
2178
  {
1751
2179
  label: "Cancel task",
@@ -1754,7 +2182,7 @@ function MediaJobs({ onOpenResult }) {
1754
2182
  disabled: pending !== null || job.cancelRequested,
1755
2183
  onClick: () => void act(job, "cancel")
1756
2184
  }
1757
- ), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React6.createElement(
2185
+ ), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React7.createElement(
1758
2186
  Button,
1759
2187
  {
1760
2188
  label: "Retry task",
@@ -1763,7 +2191,7 @@ function MediaJobs({ onOpenResult }) {
1763
2191
  disabled: pending !== null || job.cleanupPending,
1764
2192
  onClick: () => void act(job, "retry")
1765
2193
  }
1766
- ), job.result && onOpenResult && /* @__PURE__ */ React6.createElement(Button, { label: "Open result", width: "hug", onClick: () => onOpenResult(job.result) }), /* @__PURE__ */ React6.createElement("details", null, /* @__PURE__ */ React6.createElement("summary", null, "Task identity"), /* @__PURE__ */ React6.createElement("code", null, job.jobId))))), /* @__PURE__ */ React6.createElement("div", { className: "mt-pagination" }, /* @__PURE__ */ React6.createElement(
2194
+ ), job.result && onOpenResult && /* @__PURE__ */ React7.createElement(Button, { label: "Open result", width: "hug", onClick: () => onOpenResult(job.result) }), /* @__PURE__ */ React7.createElement("details", null, /* @__PURE__ */ React7.createElement("summary", null, "Task identity"), /* @__PURE__ */ React7.createElement("code", null, job.jobId))))), /* @__PURE__ */ React7.createElement("div", { className: "mt-pagination" }, /* @__PURE__ */ React7.createElement(
1767
2195
  Button,
1768
2196
  {
1769
2197
  label: "Previous tasks",
@@ -1771,7 +2199,7 @@ function MediaJobs({ onOpenResult }) {
1771
2199
  disabled: offset === 0,
1772
2200
  onClick: () => setOffset(Math.max(0, offset - 50))
1773
2201
  }
1774
- ), /* @__PURE__ */ React6.createElement(
2202
+ ), /* @__PURE__ */ React7.createElement(
1775
2203
  Button,
1776
2204
  {
1777
2205
  label: "Next tasks",
@@ -1829,30 +2257,36 @@ async function activate(client) {
1829
2257
  component: Component,
1830
2258
  props
1831
2259
  }) {
1832
- const ready = React7.useSyncExternalStore(
2260
+ const ready = React8.useSyncExternalStore(
1833
2261
  subscribe,
1834
2262
  () => active,
1835
2263
  () => active
1836
2264
  );
1837
- return ready ? /* @__PURE__ */ React7.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React7.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React7.createElement(Component, { ...props }))) : null;
2265
+ return ready ? /* @__PURE__ */ React8.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React8.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React8.createElement(Component, { ...props }))) : null;
1838
2266
  }
1839
2267
  client.registerUI({
1840
2268
  id: "media.video-editor",
1841
2269
  title: "Video editor",
1842
2270
  kind: "component",
1843
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoEditor, props })
2271
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoEditor, props })
2272
+ });
2273
+ client.registerUI({
2274
+ id: "media.video-export",
2275
+ title: "Export settings",
2276
+ kind: "component",
2277
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoExport, props })
1844
2278
  });
1845
2279
  client.registerUI({
1846
2280
  id: "media.video-compare",
1847
2281
  title: "Video comparison",
1848
2282
  kind: "component",
1849
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoCompare, props })
2283
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoCompare, props })
1850
2284
  });
1851
2285
  client.registerUI({
1852
2286
  id: "media.jobs",
1853
2287
  title: "Media tasks",
1854
2288
  kind: "component",
1855
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: MediaJobs, props })
2289
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: MediaJobs, props })
1856
2290
  });
1857
2291
  client.onDispose(() => {
1858
2292
  active = false;