@vivix-labs/media-tools 1.0.0-beta.2 → 1.0.0-beta.20

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.
Files changed (60) hide show
  1. package/README.md +38 -12
  2. package/dist/assets/1-1-WUUPNDJP.svg +7 -0
  3. package/dist/assets/16-9-BAFQTZK7.svg +9 -0
  4. package/dist/assets/2-3-WPG3UQBV.svg +7 -0
  5. package/dist/assets/3-2-YZTSUZ37.svg +7 -0
  6. package/dist/assets/3-4-7YROL4JU.svg +7 -0
  7. package/dist/assets/4-3-YG4LTLGD.svg +7 -0
  8. package/dist/assets/9-16-CYXX6QAR.svg +9 -0
  9. package/dist/assets/add-circle-RPMXNTWW.svg +4 -0
  10. package/dist/assets/captions-16-55I6JRWY.svg +5 -0
  11. package/dist/assets/captions-24-4YNDEZZX.svg +5 -0
  12. package/dist/assets/chevrons-up-down-KDZMS6DI.svg +3 -0
  13. package/dist/assets/collapse-diagonal-16-2IRQGCLB.svg +6 -0
  14. package/dist/assets/collapse-diagonal-24-GHD6Z54K.svg +6 -0
  15. package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
  16. package/dist/assets/crop-5JXWHIPN.svg +6 -0
  17. package/dist/assets/delete-4Y3OUMEL.svg +8 -0
  18. package/dist/assets/download-16-QVS2YNPN.svg +4 -0
  19. package/dist/assets/download-24-ARCWU2MF.svg +4 -0
  20. package/dist/assets/download-VTKCEAZG.svg +6 -0
  21. package/dist/assets/expand-diagonal-16-QUIZSPJN.svg +10 -0
  22. package/dist/assets/expand-diagonal-24-XPK72ILY.svg +10 -0
  23. package/dist/assets/favorite-6GMNHJCN.svg +5 -0
  24. package/dist/assets/favorite-filled-FR74TEBM.svg +3 -0
  25. package/dist/assets/filter-JSDZZVGN.svg +5 -0
  26. package/dist/assets/freeform-E5MLUKDE.svg +18 -0
  27. package/dist/assets/fullscreen-exit-ADYOPBYH.svg +3 -0
  28. package/dist/assets/grid-16-POIO22HZ.svg +6 -0
  29. package/dist/assets/grid-24-U6IRT56K.svg +6 -0
  30. package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
  31. package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
  32. package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
  33. package/dist/assets/list-16-YAVTLHXZ.svg +8 -0
  34. package/dist/assets/list-24-O6WDB6WJ.svg +8 -0
  35. package/dist/assets/original-LBKLUQVV.svg +18 -0
  36. package/dist/assets/pause-16-444PD7SY.svg +4 -0
  37. package/dist/assets/pause-24-WQXRNLW3.svg +4 -0
  38. package/dist/assets/play-16-5B2LZITW.svg +3 -0
  39. package/dist/assets/play-24-3IPXXAC4.svg +3 -0
  40. package/dist/assets/refresh-WQ3CTB57.svg +3 -0
  41. package/dist/assets/replace-PJXDOQDX.svg +3 -0
  42. package/dist/assets/{search-JUOSGQRM.svg → search-FMYQZJWA.svg} +1 -1
  43. package/dist/assets/select-items-GJZIVO37.svg +6 -0
  44. package/dist/assets/trim-LQMHHN2M.svg +9 -0
  45. package/dist/assets/upload-U5RZT5QI.svg +5 -0
  46. package/dist/assets/volume-16-ENYWJAGG.svg +5 -0
  47. package/dist/assets/volume-24-MVQ6CAXW.svg +5 -0
  48. package/dist/assets/volume-off-16-ALKG7632.svg +4 -0
  49. package/dist/assets/volume-off-24-2R4VED3N.svg +4 -0
  50. package/dist/client.bundle.js +1444 -252
  51. package/dist/client.css +2368 -181
  52. package/dist/server.d.ts +1 -1
  53. package/dist/server.js +257 -63
  54. package/dist/shared.d.ts +188 -3
  55. package/dist/shared.js +86 -3
  56. package/{skills/SKILL.md → docs/operations.md} +7 -7
  57. package/package.json +5 -4
  58. package/studio-plugin.json +1 -4
  59. package/dist/assets/player-cover-shade-LLH6KOCQ.png +0 -0
  60. /package/{skills/references → docs}/processing.md +0 -0
@@ -1,5 +1,52 @@
1
1
  // packages/media-tools/src/client.tsx
2
- import * as React7 from "react";
2
+ import * as React8 from "react";
3
+
4
+ // packages/media-tools/src/export-settings.ts
5
+ var exportProfiles = {
6
+ h264: {
7
+ label: "MP4 \xB7 H.264",
8
+ extension: "mp4",
9
+ container: "mp4",
10
+ codec: "h264",
11
+ encoder: "libx264",
12
+ audio: "aac",
13
+ crf: [18, 23, 28]
14
+ },
15
+ hevc: {
16
+ label: "MP4 \xB7 H.265",
17
+ extension: "mp4",
18
+ container: "mp4",
19
+ codec: "hevc",
20
+ encoder: "libx265",
21
+ audio: "aac",
22
+ crf: [20, 25, 30]
23
+ },
24
+ vp9: {
25
+ label: "WebM \xB7 VP9",
26
+ extension: "webm",
27
+ container: "webm",
28
+ codec: "vp9",
29
+ encoder: "libvpx-vp9",
30
+ audio: "opus",
31
+ crf: [23, 31, 39]
32
+ }
33
+ };
34
+ var exportAspects = ["source", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];
35
+ var exportResolutions = [480, 720, 1080, 2160];
36
+ var exportRates = [24, 25, 30, 50, 60];
37
+ var exportQualities = ["high", "standard", "small"];
38
+ function exportDimensions(source, aspect, resolution) {
39
+ if (aspect === "source" && resolution === "source") return source;
40
+ const [w = source.width, h = source.height] = aspect === "source" ? [] : aspect.split(":").map(Number);
41
+ const short = resolution === "source" ? Math.min(source.width, source.height) : resolution;
42
+ const even = (n) => 2 * Math.round(n / 2);
43
+ const width = w >= h ? even(short * w / h) : short;
44
+ const height = h >= w ? even(short * h / w) : short;
45
+ return Math.min(width, height) >= 2 && Math.max(width, height) <= 3840 && Math.min(width, height) <= 2160 ? { width, height } : null;
46
+ }
47
+ function exportName(name, extension) {
48
+ return `${name.trim().replace(/\.(mp4|webm)$/i, "").trim()}.${extension}`;
49
+ }
3
50
 
4
51
  // packages/media-tools/src/shared.ts
5
52
  import { z, PluginError } from "vivix-studio/sdk/shared";
@@ -19,6 +66,12 @@ var sequenceVideoInput = z.discriminatedUnion("kind", [
19
66
  sourceInput.extend({ trimEndMs: z.number().int().positive().optional() }),
20
67
  editInput
21
68
  ]);
69
+ var colorAdjustment = z.object({
70
+ brightness: z.number().finite().min(-0.5).max(0.5),
71
+ contrast: z.number().finite().min(0).max(2),
72
+ saturation: z.number().finite().min(0).max(2)
73
+ }).strict();
74
+ var neutralColor = { brightness: 0, contrast: 1, saturation: 1 };
22
75
  var recipe = z.object({
23
76
  trim: z.object({ inMs: z.number().int().nonnegative(), outMs: z.number().int().positive() }).strict(),
24
77
  crop: z.object({
@@ -26,13 +79,24 @@ var recipe = z.object({
26
79
  y: z.number().finite().nonnegative(),
27
80
  width: z.number().finite().positive().max(1),
28
81
  height: z.number().finite().positive().max(1)
29
- }).strict()
82
+ }).strict(),
83
+ color: colorAdjustment.optional(),
84
+ speed: z.number().finite().min(0.25).max(4).optional()
30
85
  }).strict().superRefine((v, c) => {
31
86
  if (v.trim.inMs >= v.trim.outMs)
32
87
  c.addIssue({ code: "custom", message: "The selected interval must have positive duration." });
33
88
  if (v.crop.x + v.crop.width > 1 + 1e-9 || v.crop.y + v.crop.height > 1 + 1e-9)
34
89
  c.addIssue({ code: "custom", message: "The crop must remain inside the source picture." });
35
90
  });
91
+ function recipeDurationMs(value) {
92
+ return Math.max(1, Math.round((value.trim.outMs - value.trim.inMs) / (value.speed ?? 1)));
93
+ }
94
+ var videoEditorTitles = {
95
+ crop: "Crop Video",
96
+ trim: "Trim Video",
97
+ color: "Adjust Color",
98
+ speed: "Video Speed"
99
+ };
36
100
  var pixelRect = z.object({
37
101
  x: z.number().int().nonnegative(),
38
102
  y: z.number().int().nonnegative(),
@@ -77,10 +141,35 @@ var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.numb
77
141
  (v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
78
142
  "Canvas dimensions must be even and within 3840 by 2160."
79
143
  );
144
+ var exportFormat = z.enum(
145
+ Object.keys(exportProfiles)
146
+ );
147
+ var exportSettings = z.object({
148
+ format: exportFormat,
149
+ aspect: z.enum(exportAspects),
150
+ resolution: z.union([
151
+ z.literal("source"),
152
+ z.literal(480),
153
+ z.literal(720),
154
+ z.literal(1080),
155
+ z.literal(2160)
156
+ ]),
157
+ frameRate: z.union([
158
+ z.literal("source"),
159
+ z.literal(24),
160
+ z.literal(25),
161
+ z.literal(30),
162
+ z.literal(50),
163
+ z.literal(60)
164
+ ]),
165
+ quality: z.enum(exportQualities),
166
+ audio: z.boolean()
167
+ }).strict();
80
168
  var processSequence = z.object({
81
169
  inputs: z.array(sequenceVideoInput).min(1).max(64),
82
170
  outputName,
83
171
  canvas,
172
+ settings: exportSettings.optional(),
84
173
  retryOfJobId: z.uuid().optional()
85
174
  }).strict();
86
175
  var mediaRequest = z.discriminatedUnion("operation", [
@@ -125,7 +214,9 @@ function normalizeRecipe(raw, displayWidth, displayHeight, durationMs) {
125
214
  y: y / displayHeight,
126
215
  width: pixelRect2.width / displayWidth,
127
216
  height: pixelRect2.height / displayHeight
128
- }
217
+ },
218
+ ...value.color ? { color: { ...value.color } } : {},
219
+ ...value.speed === void 0 ? {} : { speed: value.speed }
129
220
  },
130
221
  geometry: { displayWidth, displayHeight, pixelRect: pixelRect2 }
131
222
  };
@@ -174,10 +265,10 @@ async function submitOrFind(client, instanceId, request, requestKey) {
174
265
  import * as React4 from "react";
175
266
 
176
267
  // packages/ui-system/dist/button.js
177
- import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
268
+ import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
178
269
 
179
270
  // packages/ui-system/dist/icon.js
180
- import { jsx as _jsx } from "react/jsx-runtime";
271
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
181
272
  var iconGeometry = {
182
273
  add: {
183
274
  width: 16,
@@ -244,6 +335,10 @@ var iconGeometry = {
244
335
  height: 15.5625,
245
336
  slot: 18
246
337
  },
338
+ "select-items": { width: 13.8681, height: 13.8667, slot: 16 },
339
+ trim: { width: 14.85, height: 14.85, slot: 16 },
340
+ crop: { width: 16.25, height: 16.25, slot: 16 },
341
+ filter: { width: 13.2, height: 13.2, slot: 16 },
247
342
  select: {
248
343
  width: 14.6298,
249
344
  height: 16.065,
@@ -299,6 +394,7 @@ var iconGeometry = {
299
394
  height: 20,
300
395
  slot: 20
301
396
  },
397
+ "fullscreen-exit": { width: 20, height: 20, slot: 20 },
302
398
  "placeholder-image": {
303
399
  width: 20,
304
400
  height: 20,
@@ -324,6 +420,9 @@ var iconGeometry = {
324
420
  height: 13.2,
325
421
  slot: 16
326
422
  },
423
+ favorite: { width: 11.8667, height: 14.5333, slot: 16 },
424
+ download: { width: 13.2001, height: 13.1997, slot: 16 },
425
+ delete: { width: 13.2, height: 14.533, slot: 16 },
327
426
  edit: {
328
427
  width: 10.8791,
329
428
  height: 12.0459,
@@ -365,7 +464,7 @@ var iconGeometry = {
365
464
  slot: 24
366
465
  }
367
466
  };
368
- function Icon({ name, size }) {
467
+ function Icon({ name, size, iconSet }) {
369
468
  const geometry2 = iconGeometry[name];
370
469
  const style = {
371
470
  ...geometry2 && {
@@ -375,7 +474,10 @@ function Icon({ name, size }) {
375
474
  },
376
475
  ...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
377
476
  };
378
- return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style });
477
+ if (name === "menu" || name === "relationships" || name === "color-adjust" || name === "speed") {
478
+ return _jsx("svg", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, "data-icon-set": iconSet === "chat" ? "chat" : void 0, style, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: name === "menu" ? _jsx("path", { d: "M3 5h14M3 10h14M3 15h14" }) : name === "color-adjust" ? _jsxs(_Fragment, { children: [_jsx("path", { d: "M3 5h3m4 0h7M3 10h8m4 0h2M3 15h3m4 0h7" }), _jsx("circle", { cx: "8", cy: "5", r: "2" }), _jsx("circle", { cx: "13", cy: "10", r: "2" }), _jsx("circle", { cx: "8", cy: "15", r: "2" })] }) : name === "speed" ? _jsxs(_Fragment, { children: [_jsx("path", { d: "M4 16a8 8 0 1 1 12 0M10 3v2M3 10h2m10 0h2M5 5l1.4 1.4M10 12l4-5" }), _jsx("circle", { cx: "10", cy: "12", r: "1.5" })] }) : _jsxs(_Fragment, { children: [_jsx("path", { d: "M8.5 6.3 5 11.7M11.5 6.3 15 11.7M6.5 14.5h7" }), _jsx("circle", { cx: "10", cy: "4", r: "2.5" }), _jsx("circle", { cx: "4", cy: "14.5", r: "2.5" }), _jsx("circle", { cx: "16", cy: "14.5", r: "2.5" })] }) });
479
+ }
480
+ return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, "data-icon-set": iconSet === "chat" ? "chat" : void 0, style });
379
481
  }
380
482
 
381
483
  // packages/ui-system/dist/button-variants.js
@@ -384,6 +486,9 @@ var buttonVariants = {
384
486
  "text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
385
487
  "text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
386
488
  "text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
489
+ "text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
490
+ "text-link-sm": { size: 32, appearance: "link", shape: "text" },
491
+ "text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
387
492
  "text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
388
493
  // The medium recipes are shared by all dialog footer actions.
389
494
  "text-filled-md": { size: 40, appearance: "filled", shape: "text" },
@@ -404,7 +509,7 @@ var buttonVariants = {
404
509
  "icon-outline-sm": { size: 32, appearance: "outline", shape: "icon" },
405
510
  "icon-on-content": { size: 24, appearance: "on-content", shape: "icon" },
406
511
  "icon-outline-lg": { size: 48, appearance: "outline", shape: "icon" },
407
- // Compact bare action: reuse the transparent/default and surface-hover ghost treatment.
512
+ // Compact bare action: remain transparent at rest and on hover.
408
513
  "icon-bare-xs": { size: 24, appearance: "ghost", shape: "icon" },
409
514
  "icon-ghost-sm": { size: 32, appearance: "ghost", shape: "icon" },
410
515
  "icon-ghost-lg": { size: 48, appearance: "ghost", shape: "icon" },
@@ -416,55 +521,225 @@ var buttonVariants = {
416
521
  function ButtonFrame({ label, variant, loading = false, width, children, disabled, type = "button", style, className, ...props }) {
417
522
  const spec = buttonVariants[variant];
418
523
  const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
419
- 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" })] });
524
+ return _jsxs2("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
525
  }
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 }) })] });
526
+ function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
527
+ return _jsxs2(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
528
  }
424
529
  function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
425
530
  return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
426
531
  }
427
532
 
533
+ // packages/ui-system/dist/tag.js
534
+ import { jsx as _jsx3 } from "react/jsx-runtime";
535
+ function Tag({ children, variant = "overlay", className }) {
536
+ return _jsx3("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
537
+ }
538
+
539
+ // packages/ui-system/dist/dropdown.js
540
+ import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
541
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
542
+ function optionIcon(icon) {
543
+ return typeof icon === "string" ? _jsx4(Icon, { name: icon }) : icon;
544
+ }
545
+ function Dropdown({ label, options, value, onValueChange, placeholder = "Select an option", size = "medium", width = "fixed", appearance = "default", textSize = 14, floating = false, disabled = false }) {
546
+ const id = useId();
547
+ const trigger = useRef(null);
548
+ const list = useRef(null);
549
+ const heading = appearance === "heading";
550
+ const popover = heading || floating;
551
+ const activeOption = useRef(null);
552
+ const search = useRef({ query: "", time: 0 });
553
+ const [open, setOpen] = useState(false);
554
+ const [highlighted, setHighlighted] = useState(null);
555
+ const enabled = options.filter((option) => !option.disabled);
556
+ const canOpen = !disabled && enabled.length > 0;
557
+ const expanded = canOpen && open;
558
+ const selected = options.find((option) => option.value === value);
559
+ const active = enabled.find((option) => option.value === highlighted) ?? enabled.find((option) => option.value === value) ?? enabled[0];
560
+ const activeIndex = active ? enabled.indexOf(active) : -1;
561
+ useLayoutEffect(() => {
562
+ const anchor = trigger.current;
563
+ const popup = list.current;
564
+ if (!expanded || !popover || !popup || !anchor)
565
+ return;
566
+ const win = anchor.ownerDocument.defaultView;
567
+ popup.showPopover?.();
568
+ function place() {
569
+ if (!anchor || !popup)
570
+ return;
571
+ const box = anchor.getBoundingClientRect();
572
+ const width2 = anchor.ownerDocument.documentElement.clientWidth;
573
+ const margin = 8;
574
+ const gap = 4;
575
+ const below = win.innerHeight - box.bottom - gap - margin;
576
+ const above = box.top - gap - margin;
577
+ const up = below < Math.min(popup.scrollHeight, 240) && above > below;
578
+ popup.style.maxHeight = Math.max(0, Math.min(240, up ? above : below)) + "px";
579
+ if (floating)
580
+ popup.style.width = box.width + "px";
581
+ const size2 = popup.getBoundingClientRect();
582
+ popup.style.left = Math.max(margin, Math.min(box.left, width2 - size2.width - margin)) + "px";
583
+ popup.style.top = (up ? box.top - gap - size2.height : box.bottom + gap) + "px";
584
+ }
585
+ place();
586
+ win.addEventListener("resize", place);
587
+ win.addEventListener("scroll", place, true);
588
+ return () => {
589
+ popup.hidePopover?.();
590
+ win.removeEventListener("resize", place);
591
+ win.removeEventListener("scroll", place, true);
592
+ };
593
+ }, [expanded, floating, popover]);
594
+ useEffect(() => {
595
+ if (expanded)
596
+ activeOption.current?.scrollIntoView({ block: "nearest" });
597
+ }, [expanded, active?.value]);
598
+ useEffect(() => {
599
+ if (!canOpen) {
600
+ setOpen(false);
601
+ setHighlighted(null);
602
+ }
603
+ }, [canOpen]);
604
+ function close() {
605
+ search.current = { query: "", time: 0 };
606
+ setHighlighted(null);
607
+ setOpen(false);
608
+ }
609
+ function choose(option) {
610
+ close();
611
+ if (option && !option.disabled && option.value !== value)
612
+ onValueChange(option.value);
613
+ }
614
+ function handleKey(event) {
615
+ if (!canOpen || event.nativeEvent.isComposing)
616
+ return;
617
+ const { key } = event;
618
+ if (key === "Tab") {
619
+ if (expanded)
620
+ choose(active);
621
+ return;
622
+ }
623
+ if (key === "Escape") {
624
+ if (!expanded)
625
+ return;
626
+ event.preventDefault();
627
+ event.stopPropagation();
628
+ close();
629
+ return;
630
+ }
631
+ if (key === " " || key === "Enter") {
632
+ event.preventDefault();
633
+ if (expanded)
634
+ choose(active);
635
+ else
636
+ setOpen(true);
637
+ return;
638
+ }
639
+ if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
640
+ event.preventDefault();
641
+ if (event.altKey && key === "ArrowUp" && expanded) {
642
+ choose(active);
643
+ return;
644
+ }
645
+ setOpen(true);
646
+ let index = activeIndex;
647
+ if (key === "Home")
648
+ index = 0;
649
+ else if (key === "End")
650
+ index = enabled.length - 1;
651
+ else if (expanded && !event.altKey) {
652
+ const step = key === "ArrowDown" ? 1 : -1;
653
+ index = Math.max(0, Math.min(activeIndex + step, enabled.length - 1));
654
+ }
655
+ setHighlighted(enabled[index]?.value ?? null);
656
+ return;
657
+ }
658
+ if (key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey)
659
+ return;
660
+ event.preventDefault();
661
+ const char = key.toLocaleLowerCase();
662
+ const previous = performance.now() - search.current.time < 500 ? search.current.query : "";
663
+ const repeated = previous.length > 0 && [...previous].every((letter) => letter === char);
664
+ const query = repeated ? char : previous + char;
665
+ search.current = { query, time: performance.now() };
666
+ const start = previous && !repeated ? activeIndex : activeIndex + 1;
667
+ const ordered = [...enabled.slice(start), ...enabled.slice(0, start)];
668
+ const match = ordered.find((option) => option.label.toLocaleLowerCase().startsWith(query));
669
+ setOpen(true);
670
+ if (match)
671
+ setHighlighted(match.value);
672
+ }
673
+ return _jsxs3("div", { className: "vx-dropdown", "data-size": size, "data-width": width, "data-appearance": appearance, "data-text-size": textSize, "data-floating": floating || void 0, children: [_jsxs3("button", { type: "button", ref: trigger, role: "combobox", className: "vx-dropdown-trigger", "aria-label": label, "aria-expanded": expanded, "aria-controls": `${id}-listbox`, "aria-activedescendant": expanded && active ? `${id}-option-${options.indexOf(active)}` : void 0, disabled: !canOpen, onClick: () => expanded ? close() : setOpen(true), onBlur: close, onKeyDown: handleKey, children: [_jsxs3("span", { className: "vx-dropdown-value", "data-placeholder": !selected || void 0, children: [optionIcon(selected?.icon), _jsx4("span", { children: selected?.triggerLabel ?? selected?.label ?? placeholder })] }), _jsx4(Icon, { name: expanded ? "chevron-up" : "chevron-down" })] }), _jsx4("ul", { ref: list, popover: popover ? "manual" : void 0, id: `${id}-listbox`, role: "listbox", "aria-label": label, hidden: !expanded, children: options.map((option, index) => _jsxs3("li", { id: `${id}-option-${index}`, ref: active === option ? activeOption : void 0, role: "option", "aria-selected": option.value === value, "aria-disabled": option.disabled || void 0, "data-active": active === option, onMouseDown: (event) => event.preventDefault(), onClick: () => {
674
+ if (!option.disabled)
675
+ choose(option);
676
+ }, children: [optionIcon(option.icon), option.label, width === "hug" && option.value === value && _jsx4(Icon, { name: "check" })] }, option.value)) })] });
677
+ }
678
+
428
679
  // packages/ui-system/dist/segmented-control.js
429
- import { jsx as _jsx3, jsxs as _jsxs2 } from "react/jsx-runtime";
430
- import { useId } from "react";
680
+ import { jsx as _jsx5, jsxs as _jsxs4 } from "react/jsx-runtime";
681
+ import { useId as useId2 } from "react";
431
682
  function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
432
- const id = useId();
433
- 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)) });
683
+ const id = useId2();
684
+ return _jsx5("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs4("label", { title: iconOnly ? item.label : void 0, children: [_jsx5("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs4("span", { className: "vx-segment-item", children: [item.icon && _jsx5(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
434
685
  }
435
686
 
436
- // packages/ui-system/dist/tag.js
437
- import { jsx as _jsx4 } from "react/jsx-runtime";
438
- function Tag({ children, variant = "overlay", className }) {
439
- return _jsx4("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
687
+ // packages/ui-system/dist/input.js
688
+ import { jsx as _jsx6, jsxs as _jsxs5 } from "react/jsx-runtime";
689
+ import { useEffect as useEffect2, useState as useState2 } from "react";
690
+ function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", placeholder, ...props }) {
691
+ return _jsxs5("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx6("span", { children: label }), _jsx6("input", { ...props, type: "text", placeholder: placeholder ?? (props.readOnly ? void 0 : "Enter text"), value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
692
+ }
693
+
694
+ // packages/ui-system/dist/slider.js
695
+ import { jsx as _jsx7, jsxs as _jsxs6 } from "react/jsx-runtime";
696
+ function Slider({ label, value, unit = "", showHeading = true, appearance = "default", thumbSize = "default", headingWeight = "default", markers, hideCoveredMarkers = false, endpoints, endpointSize = 10, sourceBounds, onValueChange, ...props }) {
697
+ const control = _jsxs6("label", { className: "vx-slider", "data-appearance": appearance, "data-thumb-size": thumbSize === "large" ? "large" : void 0, "data-heading-weight": headingWeight === "semibold" ? "semibold" : void 0, "data-hide-covered-markers": hideCoveredMarkers || void 0, style: {
698
+ "--vx-slider-fill": `${Math.max(0, Math.min(100, (value - props.min) / (props.max - props.min || 1) * 100))}%`,
699
+ "--vx-slider-fraction": Math.max(0, Math.min(1, (value - props.min) / (props.max - props.min || 1)))
700
+ }, children: [showHeading && _jsxs6("span", { className: "vx-slider-heading", children: [_jsx7("span", { children: label }), _jsxs6("span", { "aria-hidden": "true", children: [value, unit] })] }), _jsx7("input", { ...props, type: "range", value, "aria-label": label, "aria-valuetext": unit ? `${value}${unit}` : void 0, onChange: (event) => onValueChange(event.currentTarget.valueAsNumber) }), markers && _jsx7("span", { className: "vx-slider-markers", "aria-hidden": "true", children: markers.map((markerValue, index) => _jsx7("span", { style: {
701
+ left: `${100 * (markerValue - props.min) / (props.max - props.min || 1)}%`
702
+ } }, index)) })] });
703
+ const trackNode = sourceBounds ? _jsx7("div", { className: "vx-source-slider", style: {
704
+ "--vx-source-start": (props.min - sourceBounds.min) / (sourceBounds.max - sourceBounds.min || 1),
705
+ "--vx-source-span": (props.max - props.min) / (sourceBounds.max - sourceBounds.min || 1),
706
+ "--vx-source-fraction": (value - sourceBounds.min) / (sourceBounds.max - sourceBounds.min || 1)
707
+ }, children: control }) : control;
708
+ if (!endpoints)
709
+ return trackNode;
710
+ return _jsxs6("div", { className: "vx-slider-group", children: [trackNode, _jsxs6("span", { className: "vx-slider-endpoints", "data-size": endpointSize, "aria-hidden": "true", children: [_jsx7("span", { children: endpoints[0] }), _jsx7("span", { children: endpoints[1] })] })] });
440
711
  }
441
712
 
442
713
  // packages/ui-system/dist/frame-range.js
443
- import { jsx as _jsx5, jsxs as _jsxs3, Fragment as _Fragment } from "react/jsx-runtime";
714
+ import { jsx as _jsx8, jsxs as _jsxs7, Fragment as _Fragment2 } from "react/jsx-runtime";
444
715
  var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
445
716
  function timeLabel(seconds) {
446
717
  const whole = Math.floor(seconds);
447
- return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
718
+ return `${String(Math.floor(whole / 60)).padStart(2, "0")}:${String(whole % 60).padStart(2, "0")}`;
448
719
  }
449
- function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range", onValueChange }) {
720
+ function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant = "range", appearance = "workbench", rulerTicks, disabled, trackTitle, onValueChange }) {
450
721
  const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
451
722
  const increment = Math.min(length, Number.isFinite(step) && step > 0 ? step : 0.1);
452
723
  const start = clamp(Number.isFinite(value.start) ? value.start : 0, 0, length - increment);
453
724
  const end = clamp(Number.isFinite(value.end) ? value.end : length, Math.min(length, start + increment), length);
454
725
  function move(edge, next) {
726
+ if (disabled)
727
+ return;
455
728
  const rounded = Math.round(next / increment) * increment;
456
729
  const range = edge === "start" ? { start: clamp(rounded, 0, end - increment), end } : { start, end: clamp(next >= length ? length : rounded, start + increment, length) };
457
730
  if (range.start !== start || range.end !== end)
458
731
  onValueChange(range);
459
732
  }
460
733
  function drag(event, edge) {
461
- if (!event.currentTarget.hasPointerCapture(event.pointerId))
734
+ if (disabled || !event.currentTarget.hasPointerCapture(event.pointerId))
462
735
  return;
463
736
  const box = event.currentTarget.closest(".vx-frame-range")?.getBoundingClientRect();
464
737
  if (box?.width)
465
738
  move(edge, (event.clientX - box.left) / box.width * length);
466
739
  }
467
740
  function handleKey(event, edge, current) {
741
+ if (disabled)
742
+ return;
468
743
  const changes = {
469
744
  ArrowLeft: current - increment,
470
745
  ArrowDown: current - increment,
@@ -479,39 +754,53 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
479
754
  event.preventDefault();
480
755
  move(edge, next);
481
756
  }
482
- return _jsxs3("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
757
+ const rangeElement = _jsxs7("div", { className: "vx-frame-range", "data-variant": variant, "data-appearance": appearance === "chat" ? "chat" : void 0, role: "group", "aria-label": "Playback range", "aria-disabled": !length || disabled || void 0, style: length ? {
483
758
  "--vx-range-start": `${start / length * 100}%`,
484
759
  "--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) => {
760
+ } : void 0, children: [frames?.length && length > 0 ? _jsx8("div", { className: "vx-frame-filmstrip", children: frames.map((src, index) => _jsx8("img", { src, alt: "" }, index)) }) : thumbnail && length > 0 && _jsx8("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs7(_Fragment2, { children: [_jsx8("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs7(Tag, { variant: variant === "trim" ? "selected" : "overlay", children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
486
761
  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) => {
488
- if (event.button !== 0)
762
+ return _jsx8("div", { tabIndex: disabled ? -1 : 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) => {
763
+ if (disabled || event.button !== 0)
489
764
  return;
490
765
  event.currentTarget.focus();
491
766
  event.currentTarget.setPointerCapture(event.pointerId);
492
767
  }, onPointerMove: (event) => drag(event, edge) }, edge);
493
768
  })] })] });
769
+ if (!rulerTicks)
770
+ return rangeElement;
771
+ return _jsxs7("div", { className: "vx-frame-range-timeline", children: [_jsx8("div", { className: "vx-frame-range-ticks", "aria-hidden": "true", children: rulerTicks.map((tick, index) => _jsx8("span", { style: { left: `${tick.positionPercent}%` }, children: tick.label }, tick.key ?? index)) }), _jsx8("div", { className: "vx-frame-range-track", inert: disabled || void 0, "aria-disabled": disabled || void 0, title: trackTitle, style: {
772
+ "--vx-trim-label-space": `${(1 - start / (length || 1)) * 100}cqw`
773
+ }, children: rangeElement })] });
494
774
  }
495
775
 
496
776
  // packages/ui-system/dist/dialog.js
497
- import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment2 } from "react/jsx-runtime";
498
- import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
777
+ import { jsx as _jsx9, jsxs as _jsxs8, Fragment as _Fragment3 } from "react/jsx-runtime";
778
+ import { useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState3 } from "react";
499
779
  import { createPortal } from "react-dom";
500
780
 
501
781
  // packages/ui-system/dist/dialog-surface.js
502
- function createDialogSurface(anchor) {
782
+ var overlayOpeningEvent = "vx-overlay-opening";
783
+ function outerDialogDocument(anchor) {
503
784
  const source = anchor.ownerDocument;
504
- let target;
505
785
  try {
506
- target = source.defaultView?.top?.document ?? source;
786
+ const target = source.defaultView?.top?.document;
787
+ return target && target !== source ? target : void 0;
507
788
  } catch {
508
789
  return void 0;
509
790
  }
510
- if (target === source)
791
+ }
792
+ function createDialogSurface(anchor) {
793
+ const source = anchor.ownerDocument;
794
+ const target = outerDialogDocument(anchor);
795
+ if (!target)
511
796
  return void 0;
512
797
  const host = target.createElement("div");
513
798
  host.dataset.studioDialogSurface = "";
514
799
  const shadow = host.attachShadow({ mode: "open" });
800
+ shadow.addEventListener("beforetoggle", (event) => {
801
+ if (event.newState === "open" && !event.target.classList.contains("vx-toast"))
802
+ target.dispatchEvent(new Event(overlayOpeningEvent));
803
+ }, true);
515
804
  for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
516
805
  const clone = original.cloneNode(true);
517
806
  if (original.tagName === "LINK")
@@ -547,13 +836,21 @@ function createDialogSurface(anchor) {
547
836
  }
548
837
 
549
838
  // packages/ui-system/dist/dialog.js
550
- function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
551
- const ref = useRef(null);
552
- const anchor = useRef(null);
553
- const [surface, setSurface] = useState();
554
- const heading = useId2();
555
- useLayoutEffect(() => {
556
- if (!open || !anchor.current)
839
+ function useInlineDialog(anchor) {
840
+ const [inline, setInline] = useState3(false);
841
+ useLayoutEffect2(() => {
842
+ if (anchor.current)
843
+ setInline(!outerDialogDocument(anchor.current));
844
+ }, [anchor]);
845
+ return inline;
846
+ }
847
+ function Dialog({ title, open, onOpenChange, children, actions, className, inlineWhenClosed = false, variant = "default", closeOnEscape = true, focusTitleOnOpen = variant === "welcome" }) {
848
+ const ref = useRef2(null);
849
+ const anchor = useRef2(null);
850
+ const [surface, setSurface] = useState3();
851
+ const heading = useId3();
852
+ useLayoutEffect2(() => {
853
+ if (inlineWhenClosed || !open || !anchor.current)
557
854
  return;
558
855
  const mounted = createDialogSurface(anchor.current);
559
856
  const active = anchor.current.getRootNode().activeElement;
@@ -566,9 +863,20 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
566
863
  active.focus();
567
864
  });
568
865
  };
569
- }, [open]);
570
- useLayoutEffect(() => {
866
+ }, [open, inlineWhenClosed]);
867
+ useLayoutEffect2(() => {
571
868
  const dialog2 = ref.current;
869
+ if (inlineWhenClosed && dialog2) {
870
+ if (open) {
871
+ dialog2.close();
872
+ dialog2.showModal();
873
+ } else {
874
+ if (dialog2.matches(":modal"))
875
+ dialog2.close();
876
+ dialog2.open = true;
877
+ }
878
+ return;
879
+ }
572
880
  if (!open || surface === void 0 || !dialog2)
573
881
  return;
574
882
  dialog2.showModal();
@@ -576,34 +884,123 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
576
884
  if (dialog2.open)
577
885
  dialog2.close();
578
886
  };
579
- }, [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) => {
887
+ }, [open, surface, inlineWhenClosed]);
888
+ const welcome = variant === "welcome";
889
+ const closeButton = _jsx9(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
890
+ const dialog = _jsxs8("dialog", { ref, open: inlineWhenClosed || void 0, className: inlineWhenClosed && !open ? "vx-dialog vx-dialog-inline" : className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, role: inlineWhenClosed && !open ? "presentation" : void 0, "aria-labelledby": inlineWhenClosed && !open ? void 0 : heading, onCancel: (event) => {
581
891
  event.preventDefault();
582
892
  event.stopPropagation();
583
- onOpenChange(false);
893
+ if (closeOnEscape)
894
+ onOpenChange(false);
584
895
  }, onClose: (event) => {
585
896
  if (open && event.currentTarget.isConnected && !event.currentTarget.open)
586
897
  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)] });
898
+ }, children: [_jsxs8("header", { hidden: inlineWhenClosed && !open, children: [_jsx9("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx9("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs8("footer", { hidden: inlineWhenClosed && !open, children: [actions, welcome && closeButton] })] });
899
+ return _jsxs8(_Fragment3, { children: [_jsx9("span", { ref: anchor, hidden: true }), (open || inlineWhenClosed) && (surface ? createPortal(dialog, surface) : dialog)] });
589
900
  }
590
901
 
591
- // packages/ui-system/dist/menu.js
592
- import { jsx as _jsx7, jsxs as _jsxs5 } from "react/jsx-runtime";
593
- import { useEffect, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
902
+ // packages/ui-system/dist/toast.js
903
+ import { jsx as _jsx10, jsxs as _jsxs9, Fragment as _Fragment4 } from "react/jsx-runtime";
904
+ import { useCallback, useEffect as useEffect3, useLayoutEffect as useLayoutEffect3, useRef as useRef3, useState as useState4 } from "react";
594
905
  import { createPortal as createPortal2 } from "react-dom";
906
+ function useToastMessage() {
907
+ const [message, setMessage] = useState4("");
908
+ const timeout = useRef3(void 0);
909
+ useEffect3(() => () => clearTimeout(timeout.current), []);
910
+ const show = useCallback((text) => {
911
+ clearTimeout(timeout.current);
912
+ setMessage(text);
913
+ if (text)
914
+ timeout.current = setTimeout(() => setMessage(""), 2e3);
915
+ }, []);
916
+ return [message, show];
917
+ }
918
+ function Toast({ message, leading, className }) {
919
+ const anchor = useRef3(null);
920
+ const ref = useRef3(null);
921
+ const [surface, setSurface] = useState4();
922
+ const visible = Boolean(message);
923
+ useLayoutEffect3(() => {
924
+ if (!visible || !anchor.current)
925
+ return;
926
+ const mounted = createDialogSurface(anchor.current);
927
+ setSurface(mounted?.root ?? null);
928
+ return () => {
929
+ mounted?.dispose();
930
+ setSurface(void 0);
931
+ };
932
+ }, [visible]);
933
+ useLayoutEffect3(() => {
934
+ const toast = ref.current;
935
+ if (!toast || !visible)
936
+ return;
937
+ const doc = toast.ownerDocument;
938
+ const win = doc.defaultView;
939
+ let frame = 0;
940
+ const bringToFront = () => {
941
+ win.cancelAnimationFrame(frame);
942
+ frame = win.requestAnimationFrame(() => {
943
+ toast.hidePopover();
944
+ toast.showPopover();
945
+ });
946
+ };
947
+ function onOpening(event) {
948
+ const target = event.target;
949
+ if (event.newState === "open" && !target.classList.contains("vx-toast"))
950
+ bringToFront();
951
+ }
952
+ toast.showPopover();
953
+ doc.addEventListener("beforetoggle", onOpening, true);
954
+ doc.addEventListener(overlayOpeningEvent, bringToFront);
955
+ doc.addEventListener("fullscreenchange", bringToFront);
956
+ return () => {
957
+ win.cancelAnimationFrame(frame);
958
+ doc.removeEventListener("beforetoggle", onOpening, true);
959
+ doc.removeEventListener(overlayOpeningEvent, bringToFront);
960
+ doc.removeEventListener("fullscreenchange", bringToFront);
961
+ };
962
+ }, [visible, surface]);
963
+ const notice = visible && surface !== void 0 && _jsxs9("div", { ref, popover: "manual", role: "status", "aria-atomic": "true", className: className ? `vx-toast ${className}` : "vx-toast", children: [leading, _jsx10("span", { children: message })] });
964
+ return _jsxs9(_Fragment4, { children: [_jsx10("span", { hidden: true, ref: anchor }), surface ? createPortal2(notice, surface) : notice] });
965
+ }
966
+
967
+ // packages/ui-system/dist/menu.js
968
+ import { jsx as _jsx11, jsxs as _jsxs10 } from "react/jsx-runtime";
969
+ import { useEffect as useEffect4, useId as useId4, useLayoutEffect as useLayoutEffect4, useRef as useRef4, useState as useState5 } from "react";
970
+ import { createPortal as createPortal3 } from "react-dom";
971
+ function MenuPreview({ children }) {
972
+ const ref = useRef4(null);
973
+ const [visible, setVisible] = useState5(false);
974
+ useEffect4(() => {
975
+ const node = ref.current;
976
+ if (!node)
977
+ return;
978
+ const observer = new IntersectionObserver(([entry]) => {
979
+ if (entry?.isIntersecting) {
980
+ setVisible(true);
981
+ observer.disconnect();
982
+ }
983
+ });
984
+ observer.observe(node);
985
+ return () => observer.disconnect();
986
+ }, []);
987
+ return _jsx11("span", { ref, className: "vx-menu-preview", "aria-hidden": "true", children: visible && children });
988
+ }
595
989
  function isEnabled(item) {
596
990
  return !item.disabled && item.items?.length !== 0;
597
991
  }
598
- function Menu({ label, items, triggerIcon, floating = false }) {
599
- const id = useId3();
600
- const trigger = useRef2(null);
601
- const popup = useRef2(null);
602
- const focusIndex = useRef2(0);
603
- const [path, setPath] = useState2(null);
604
- const [placement, setPlacement] = useState2({ visibility: "hidden" });
992
+ function Menu({ label, items, triggerIcon, textTrigger = "dropdown", floating = false, cascading = false }) {
993
+ const id = useId4();
994
+ const trigger = useRef4(null);
995
+ const popup = useRef4(null);
996
+ const children = useRef4(/* @__PURE__ */ new Map());
997
+ const focusOnOpen = useRef4(true);
998
+ const cascade = floating && cascading;
999
+ const focusIndex = useRef4(0);
1000
+ const [path, setPath] = useState5(null);
1001
+ const [placement, setPlacement] = useState5({ visibility: "hidden" });
605
1002
  const portalRoot = floating ? trigger.current?.closest("dialog, [data-vx-theme]") : null;
606
- useLayoutEffect2(() => {
1003
+ useLayoutEffect4(() => {
607
1004
  if (!floating || !path || !portalRoot)
608
1005
  return;
609
1006
  const position = () => {
@@ -620,19 +1017,38 @@ function Menu({ label, items, triggerIcon, floating = false }) {
620
1017
  const flip = naturalHeight > below && above > below;
621
1018
  const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
622
1019
  const menuHeight = Math.min(naturalHeight, maxHeight);
1020
+ const left = Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8));
1021
+ const top = Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8));
623
1022
  setPlacement({
624
1023
  position: "fixed",
625
1024
  visibility: "visible",
626
1025
  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)),
1026
+ left,
1027
+ top,
629
1028
  maxHeight,
630
1029
  zIndex: 100
631
1030
  });
1031
+ let parent = menu2, parentLeft = left, parentTop = top;
1032
+ for (let depth = 1; cascade && depth <= path.length; depth++) {
1033
+ const panel = children.current.get(depth);
1034
+ const item = Array.from(parent.querySelectorAll("button")).find((b) => b.dataset.key === path[depth - 1]);
1035
+ if (!panel || !item)
1036
+ break;
1037
+ const parentBox = parent.getBoundingClientRect(), box = panel.getBoundingClientRect();
1038
+ const nextLeft = parentLeft + parentBox.width;
1039
+ parentLeft = Math.max(8, Math.min(nextLeft + box.width <= width - 8 ? nextLeft : parentLeft - box.width, width - box.width - 8));
1040
+ parentTop = Math.max(8, Math.min(parentTop + item.getBoundingClientRect().top - parentBox.top - 4, height - box.height - 8));
1041
+ Object.assign(panel.style, {
1042
+ left: parentLeft + "px",
1043
+ top: parentTop + "px",
1044
+ visibility: "visible"
1045
+ });
1046
+ parent = panel;
1047
+ }
632
1048
  };
633
1049
  const outside = (event) => {
634
1050
  const path2 = event.composedPath();
635
- if (!path2.includes(trigger.current) && !path2.includes(popup.current))
1051
+ if (!path2.includes(trigger.current) && !path2.includes(popup.current) && ![...children.current.values()].some((panel) => path2.includes(panel)))
636
1052
  setPath(null);
637
1053
  };
638
1054
  const document2 = portalRoot.ownerDocument;
@@ -646,21 +1062,23 @@ function Menu({ label, items, triggerIcon, floating = false }) {
646
1062
  window.removeEventListener("scroll", position, true);
647
1063
  document2.removeEventListener("pointerdown", outside);
648
1064
  };
649
- }, [floating, path, portalRoot]);
1065
+ }, [floating, path, portalRoot, cascade]);
650
1066
  let entries = items;
651
1067
  let menuLabel = label;
1068
+ const levels = [{ entries, menuLabel }];
652
1069
  for (const key of path ?? []) {
653
1070
  const entry = entries.find((item) => item.id === key);
654
1071
  if (!entry?.items)
655
1072
  break;
656
1073
  menuLabel = entry.label;
657
1074
  entries = entry.items;
1075
+ levels.push({ entries, menuLabel });
658
1076
  }
659
- function buttons() {
660
- return [...popup.current?.querySelectorAll("button:not(:disabled)") ?? []];
1077
+ function buttons(panel = cascade && path?.length ? children.current.get(path.length) : popup.current) {
1078
+ return [...panel?.querySelectorAll("button:not(:disabled)") ?? []];
661
1079
  }
662
- useEffect(() => {
663
- if (path && (!floating || !portalRoot || placement.visibility === "visible"))
1080
+ useEffect4(() => {
1081
+ if (focusOnOpen.current && path && (!floating || !portalRoot || placement.visibility === "visible"))
664
1082
  buttons().at(focusIndex.current)?.focus();
665
1083
  }, [path, floating && placement.visibility, portalRoot]);
666
1084
  function close() {
@@ -668,6 +1086,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
668
1086
  trigger.current?.focus();
669
1087
  }
670
1088
  function back() {
1089
+ focusOnOpen.current = true;
671
1090
  if (!path?.length)
672
1091
  return;
673
1092
  const parentPath = path.slice(0, -1);
@@ -675,24 +1094,27 @@ function Menu({ label, items, triggerIcon, floating = false }) {
675
1094
  focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
676
1095
  setPath(parentPath);
677
1096
  }
678
- function choose(item) {
1097
+ function choose(item, depth) {
1098
+ focusOnOpen.current = true;
679
1099
  if (item.items?.length) {
680
1100
  focusIndex.current = 0;
681
- setPath([...path ?? [], item.id]);
1101
+ setPath([...(path ?? []).slice(0, depth), item.id]);
1102
+ if (cascade && path?.[depth] === item.id)
1103
+ buttons(children.current.get(depth + 1))?.at(0)?.focus();
682
1104
  } else if (item.onSelect) {
683
1105
  if (item.checked === void 0)
684
1106
  close();
685
1107
  item.onSelect();
686
1108
  }
687
1109
  }
688
- function handleKey(event) {
1110
+ function handleKey(event, depth) {
689
1111
  if (event.key === "Tab" && floating && portalRoot) {
690
1112
  if (event.shiftKey)
691
1113
  event.preventDefault();
692
1114
  close();
693
1115
  return;
694
1116
  }
695
- const available = buttons();
1117
+ const available = buttons(event.currentTarget);
696
1118
  const index = available.findIndex((button) => button === event.target);
697
1119
  if (event.key === "Escape") {
698
1120
  event.preventDefault();
@@ -709,10 +1131,10 @@ function Menu({ label, items, triggerIcon, floating = false }) {
709
1131
  return;
710
1132
  }
711
1133
  if (event.key === "ArrowRight") {
712
- const item = entries.filter(isEnabled)[index];
1134
+ const item = levels[depth]?.entries.filter(isEnabled)[index];
713
1135
  if (item?.items?.length) {
714
1136
  event.preventDefault();
715
- choose(item);
1137
+ choose(item, depth);
716
1138
  }
717
1139
  return;
718
1140
  }
@@ -728,6 +1150,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
728
1150
  }
729
1151
  }
730
1152
  function open(index = 0) {
1153
+ focusOnOpen.current = true;
731
1154
  focusIndex.current = index;
732
1155
  setPath([]);
733
1156
  }
@@ -737,40 +1160,147 @@ function Menu({ label, items, triggerIcon, floating = false }) {
737
1160
  open(event.key === "ArrowUp" ? -1 : 0);
738
1161
  }
739
1162
  }
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)))
1163
+ function hover(item, depth) {
1164
+ if (!cascade || !path)
1165
+ return;
1166
+ const next = path.slice(0, depth);
1167
+ if (item.items?.length && isEnabled(item))
1168
+ next.push(item.id);
1169
+ if (next.length === path.length && next.every((key, i) => path[i] === key))
1170
+ return;
1171
+ focusOnOpen.current = false;
1172
+ setPath(next);
1173
+ }
1174
+ const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx11("div", { ref: !cascade || depth === 0 ? popup : (el) => {
1175
+ if (el)
1176
+ children.current.set(depth, el);
1177
+ else
1178
+ children.current.delete(depth);
1179
+ }, 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 ? {
1180
+ position: "fixed",
1181
+ insetInlineStart: "auto",
1182
+ visibility: "hidden",
1183
+ maxHeight: "min(480px, calc(100dvh - 16px))",
1184
+ zIndex: 100 + depth
1185
+ } : placement : void 0, children: entries2.map((item) => _jsxs10("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) => {
1186
+ if (e.pointerType !== "touch")
1187
+ hover(item, depth);
1188
+ } : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx11(Icon, { name: item.icon }), path && item.preview && _jsx11(MenuPreview, { children: item.preview }), _jsx11("span", { className: "vx-menu-label", children: item.label }), item.checked && _jsx11(Icon, { name: "check" }), item.items?.length ? _jsx11(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
1189
+ return _jsxs10("div", { className: "vx-action-menu", onBlur: (event) => {
1190
+ if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
743
1191
  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] });
1192
+ }, children: [triggerIcon ? _jsx11(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 }) : _jsx11(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 ? createPortal3(menu, portalRoot) : menu] });
1193
+ }
1194
+
1195
+ // packages/ui-system/dist/video-player.js
1196
+ import { jsx as _jsx12, jsxs as _jsxs11, Fragment as _Fragment5 } from "react/jsx-runtime";
1197
+ import { useEffect as useEffect6, useLayoutEffect as useLayoutEffect5, useRef as useRef5, useState as useState7 } from "react";
1198
+
1199
+ // packages/ui-system/dist/fullscreen.js
1200
+ import { useEffect as useEffect5, useState as useState6 } from "react";
1201
+ function isFullscreen(element) {
1202
+ const tree = element.getRootNode();
1203
+ return tree.fullscreenElement === element || element.matches(":fullscreen");
1204
+ }
1205
+ function useFullscreen(target) {
1206
+ const [fullscreen, setFullscreen] = useState6(false);
1207
+ useEffect5(() => {
1208
+ const element = target.current;
1209
+ if (!element)
1210
+ return;
1211
+ const doc = element.ownerDocument;
1212
+ const update = () => setFullscreen(isFullscreen(element));
1213
+ const escape = (event) => {
1214
+ if (event.key !== "Escape" || !isFullscreen(element))
1215
+ return;
1216
+ event.preventDefault();
1217
+ event.stopPropagation();
1218
+ void doc.exitFullscreen().catch(update);
1219
+ };
1220
+ update();
1221
+ doc.addEventListener("fullscreenchange", update);
1222
+ doc.addEventListener("keydown", escape, true);
1223
+ return () => {
1224
+ doc.removeEventListener("fullscreenchange", update);
1225
+ doc.removeEventListener("keydown", escape, true);
1226
+ };
1227
+ }, [target]);
1228
+ async function toggleFullscreen() {
1229
+ const element = target.current;
1230
+ if (!element)
1231
+ return;
1232
+ if (isFullscreen(element))
1233
+ await element.ownerDocument.exitFullscreen();
1234
+ else
1235
+ await element.requestFullscreen();
1236
+ }
1237
+ return { fullscreen, toggleFullscreen };
745
1238
  }
746
1239
 
747
1240
  // packages/ui-system/dist/video-player.js
748
- import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
749
- import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
750
- function timeLabel2(seconds) {
1241
+ function timeLabel2(seconds, padMinutes = false) {
751
1242
  const whole = Math.floor(seconds);
752
- return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
1243
+ const minutes = String(Math.floor(whole / 60));
1244
+ return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
753
1245
  }
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: {
756
- "--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 })] });
1246
+ function PlaybackControls({ playing, muted, time, duration, size = "medium", variant = "default", iconSet, singleVideo = false, disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreen = false, fullscreenLabel = fullscreen ? "Exit fullscreen" : "Enter fullscreen", actions, appearance = "on-content", timeDisplay = "combined", renderTimeline }) {
1247
+ const resolvedIconSet = iconSet ?? (variant === "chat" ? "chat" : "workbench");
1248
+ const slider = _jsx12("input", { className: "vx-playback-range", "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) });
1249
+ return _jsxs11("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-variant": variant === "chat" ? "chat" : void 0, "data-icon-set": resolvedIconSet === "chat" ? "chat" : void 0, "data-single-video": singleVideo || void 0, "data-appearance": appearance, "data-time-display": timeDisplay, style: {
1250
+ "--vx-playback-fraction": duration > 0 ? Math.min(1, Math.max(0, time / duration)) : 0
1251
+ }, children: [_jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx12("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), renderTimeline ? renderTimeline(slider) : slider, _jsx12("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: fullscreen ? "fullscreen-exit" : size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, "aria-pressed": fullscreen, onClick: onFullscreen })] });
758
1252
  }
759
1253
  function VideoPlayer(props) {
760
- return _jsx8(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
1254
+ return _jsx12(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
761
1255
  }
762
- function Playback({ src, poster, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", controlsSize, showFullscreen = true, overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
763
- const root = useRef3(null);
764
- const video = useRef3(null);
765
- const position = useRef3(0);
766
- const callbacks = useRef3({ onTimeChange, onStateChange, onEnded });
767
- const [time, setTime] = useState3(0);
768
- const [metadataDuration, setMetadataDuration] = useState3(0);
769
- const [state, setState] = useState3("cover");
770
- const [muted, setMuted] = useState3(defaultMuted);
771
- const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
772
- const duration = src ? metadataDuration : stillDuration;
773
- useEffect2(() => {
1256
+ function Playback({ src, poster, aspectRatio, stageAspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, fillContainer = false, compactCover = false, showCoverInfo = true, showCoverPlay = true, fitExpandedContent = false, fillExpandedFrame = false, controlsSize, controlsVariant, iconSet, controlsAppearance, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, deferred = false, onActivate, containerRef, onBeforePlay, onStateChange, onTimeChange, onAspectRatio, onEnded, onError }) {
1257
+ const root = useRef5(null);
1258
+ const expandedPlaceholder = useRef5(null);
1259
+ const video = useRef5(null);
1260
+ const nativeFullscreen = useFullscreen(root);
1261
+ const playbackEpoch = useRef5(0);
1262
+ const localDialog = useInlineDialog(root);
1263
+ const frameExpansion = fillExpandedFrame && !fitExpandedContent;
1264
+ const inlineDialog = fullscreenMode === "dialog" && (frameExpansion || localDialog);
1265
+ const position = useRef5(0);
1266
+ const callbacks = useRef5({ onTimeChange, onStateChange, onEnded });
1267
+ const [time, setTime] = useState7(0);
1268
+ const [ratio, setRatio] = useState7();
1269
+ const [metadataDuration, setMetadataDuration] = useState7(0);
1270
+ const [state, setState] = useState7("cover");
1271
+ const [muted, setMuted] = useState7(defaultMuted);
1272
+ const [expanded, setExpanded] = useState7(false);
1273
+ const [inlineHeight, setInlineHeight] = useState7();
1274
+ const restoreFocus = useRef5(false);
1275
+ useEffect6(() => {
1276
+ if (!expanded && restoreFocus.current) {
1277
+ restoreFocus.current = false;
1278
+ root.current?.querySelector('button[aria-label="Expand video"]')?.focus();
1279
+ }
1280
+ }, [expanded]);
1281
+ const restore = useRef5(void 0);
1282
+ const wasDeferred = useRef5(deferred);
1283
+ if (deferred)
1284
+ wasDeferred.current = true;
1285
+ const mountVideo = Boolean(src) && !deferred;
1286
+ const fallbackDuration = Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
1287
+ const stillDuration = poster ? fallbackDuration : 0;
1288
+ const duration = src ? metadataDuration || (deferred || wasDeferred.current ? fallbackDuration : 0) : stillDuration;
1289
+ const displayRatio = stageAspectRatio ?? ratio ?? aspectRatio ?? 16 / 9;
1290
+ const dialogLayout = fitExpandedContent ? " vx-video-dialog-fit" : frameExpansion ? " vx-video-dialog-frame" : "";
1291
+ useLayoutEffect5(() => {
1292
+ const view = root.current?.ownerDocument.defaultView;
1293
+ if (expanded && frameExpansion && inlineDialog && view && view !== view.top)
1294
+ expandedPlaceholder.current?.scrollIntoView({ block: "start", inline: "nearest" });
1295
+ }, [expanded, frameExpansion, inlineDialog]);
1296
+ function setRootRef(node) {
1297
+ root.current = node;
1298
+ if (typeof containerRef === "function")
1299
+ containerRef(node);
1300
+ else if (containerRef)
1301
+ containerRef.current = node;
1302
+ }
1303
+ useEffect6(() => {
774
1304
  const element = video.current;
775
1305
  return () => {
776
1306
  if (!element)
@@ -779,7 +1309,7 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
779
1309
  element.removeAttribute("src");
780
1310
  element.load();
781
1311
  };
782
- }, []);
1312
+ }, [inlineDialog ? false : expanded, src, inlineDialog, mountVideo]);
783
1313
  function updateTime(next) {
784
1314
  position.current = next;
785
1315
  setTime(next);
@@ -789,10 +1319,10 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
789
1319
  setState(next);
790
1320
  onStateChange?.(next);
791
1321
  }
792
- useEffect2(() => {
1322
+ useEffect6(() => {
793
1323
  callbacks.current = { onTimeChange, onStateChange, onEnded };
794
1324
  }, [onTimeChange, onStateChange, onEnded]);
795
- useEffect2(() => {
1325
+ useEffect6(() => {
796
1326
  if (src || state !== "playing" || !duration)
797
1327
  return;
798
1328
  let previous = performance.now();
@@ -813,9 +1343,21 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
813
1343
  }
814
1344
  return () => cancelAnimationFrame(frame);
815
1345
  }, [src, state, duration]);
1346
+ function requestPlay(element, onRejected) {
1347
+ const epoch = playbackEpoch.current;
1348
+ void element.play().catch((error) => {
1349
+ if (epoch === playbackEpoch.current && video.current === element && element.isConnected)
1350
+ onRejected(error);
1351
+ });
1352
+ }
1353
+ function isAwaitingDeferredMetadata() {
1354
+ return !mountVideo && Boolean(src) || Boolean(wasDeferred.current && video.current && !video.current.error && video.current.readyState < 1);
1355
+ }
816
1356
  function togglePlay() {
1357
+ playbackEpoch.current++;
817
1358
  if (state === "playing") {
818
- if (video.current)
1359
+ restore.current = void 0;
1360
+ if (video.current && !video.current.paused)
819
1361
  video.current.pause();
820
1362
  else
821
1363
  changeState("paused");
@@ -823,8 +1365,18 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
823
1365
  }
824
1366
  if (onBeforePlay?.() === false)
825
1367
  return;
1368
+ if (isAwaitingDeferredMetadata()) {
1369
+ const nextTime = !mountVideo && duration && position.current >= duration ? 0 : restore.current?.time ?? position.current;
1370
+ if (nextTime !== position.current)
1371
+ updateTime(nextTime);
1372
+ restore.current = { time: nextTime, playing: true, state: "playing", reportError: true };
1373
+ changeState("playing");
1374
+ if (!mountVideo)
1375
+ onActivate?.();
1376
+ return;
1377
+ }
826
1378
  if (video.current)
827
- void video.current.play().catch((error) => onError?.(error));
1379
+ requestPlay(video.current, (error) => onError?.(error));
828
1380
  else if (duration) {
829
1381
  if (position.current >= duration)
830
1382
  updateTime(0);
@@ -832,31 +1384,113 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
832
1384
  }
833
1385
  }
834
1386
  function seek(seconds) {
1387
+ if (isAwaitingDeferredMetadata()) {
1388
+ updateTime(seconds);
1389
+ restore.current = {
1390
+ time: seconds,
1391
+ playing: restore.current?.playing ?? state === "playing",
1392
+ state,
1393
+ reportError: restore.current?.reportError
1394
+ };
1395
+ if (!mountVideo)
1396
+ onActivate?.();
1397
+ return;
1398
+ }
835
1399
  if (video.current)
836
1400
  video.current.currentTime = seconds;
837
1401
  else
838
1402
  updateTime(seconds);
839
1403
  }
840
1404
  async function toggleFullscreen() {
1405
+ if (!mountVideo && src)
1406
+ onActivate?.();
1407
+ if (fullscreenMode === "dialog") {
1408
+ changeExpanded(!expanded);
1409
+ return;
1410
+ }
841
1411
  try {
842
- const player = root.current;
843
- if (!player?.requestFullscreen)
844
- return;
845
- if (player.ownerDocument.fullscreenElement === player)
846
- await player.ownerDocument.exitFullscreen();
847
- else
848
- await player.requestFullscreen();
1412
+ await nativeFullscreen.toggleFullscreen();
849
1413
  } catch (error) {
850
1414
  onError?.(error);
851
1415
  }
852
1416
  }
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) => {
1417
+ function changeExpanded(next) {
1418
+ if (next) {
1419
+ const player2 = root.current;
1420
+ const height = player2?.getBoundingClientRect().height;
1421
+ const view = player2?.ownerDocument.defaultView;
1422
+ if (frameExpansion && inlineDialog && view && view !== view.top && height !== void 0) {
1423
+ const maxFrameHeight = Math.min(view.innerHeight, view.screen.availHeight || view.innerHeight);
1424
+ const otherContentHeight = Math.max(0, view.innerHeight - height);
1425
+ setInlineHeight(Math.max(1, maxFrameHeight - otherContentHeight));
1426
+ } else
1427
+ setInlineHeight(height);
1428
+ } else
1429
+ restoreFocus.current = true;
1430
+ if (inlineDialog) {
1431
+ setExpanded(next);
1432
+ return;
1433
+ }
1434
+ playbackEpoch.current++;
1435
+ const element = video.current;
1436
+ restore.current = {
1437
+ time: element && element.readyState >= 1 ? element.currentTime : restore.current?.time ?? position.current,
1438
+ playing: element && element.readyState >= 1 ? !element.paused : restore.current?.playing ?? state === "playing",
1439
+ state,
1440
+ reportError: restore.current?.reportError
1441
+ };
1442
+ element?.pause();
1443
+ setExpanded(next);
1444
+ }
1445
+ const fitted = fitContent || expanded && fitExpandedContent;
1446
+ function readAspectRatio({ videoWidth, videoHeight }) {
1447
+ if (!videoWidth || !videoHeight)
1448
+ return;
1449
+ const next = videoWidth / videoHeight;
1450
+ setRatio(next);
1451
+ onAspectRatio?.(next);
1452
+ }
1453
+ const player = _jsxs11("section", { ref: setRootRef, className: "vx-video-player", "aria-label": title, "data-fit": fitted ? "content" : void 0, "data-frame-expansion": frameExpansion || void 0, "data-fill-container": fillContainer || void 0, "data-compact-cover": compactCover || void 0, style: { "--vx-video-ratio": displayRatio }, "data-placement": controlsPlacement, "data-controls-size": controlsSize, "data-state": state, children: [_jsxs11("div", { className: "vx-video-stage", children: [mountVideo ? _jsx12("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onResize: (event) => readAspectRatio(event.currentTarget), onLoadedMetadata: (event) => {
1454
+ const element = event.currentTarget;
1455
+ readAspectRatio(element);
1456
+ const previous = restore.current;
1457
+ if (!previous)
1458
+ return;
1459
+ element.currentTime = Math.min(previous.time, element.duration);
1460
+ updateTime(element.currentTime);
1461
+ restore.current = void 0;
1462
+ if (previous.playing)
1463
+ requestPlay(element, (error) => {
1464
+ changeState("paused");
1465
+ if (previous.reportError)
1466
+ onError?.(error);
1467
+ });
1468
+ else
1469
+ changeState(previous.state);
1470
+ }, onDurationChange: (event) => {
854
1471
  const value = event.currentTarget.duration;
855
1472
  setMetadataDuration(Number.isFinite(value) ? value : 0);
856
1473
  }, onPlay: () => changeState("playing"), onPause: (event) => {
1474
+ if (restore.current)
1475
+ return;
857
1476
  updateTime(event.currentTarget.currentTime);
858
1477
  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 })] });
1478
+ }, onTimeUpdate: (event) => {
1479
+ if (!restore.current)
1480
+ updateTime(event.currentTarget.currentTime);
1481
+ }, onEnded, onError: (event) => {
1482
+ restore.current = void 0;
1483
+ if (state === "playing")
1484
+ changeState("paused");
1485
+ if (event.currentTarget.error)
1486
+ onError?.(event.currentTarget.error);
1487
+ } }) : poster && _jsx12("img", { src: poster, alt: "" }), overlay, state === "cover" && !fitted && _jsxs11("div", { className: "vx-video-cover", "data-plain": !showCoverInfo || void 0, children: [showCoverInfo && _jsxs11("div", { className: "vx-video-info", children: [_jsxs11("div", { className: "vx-video-title", children: [_jsx12("strong", { title, children: title }), version && _jsx12(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs11("div", { className: "vx-video-meta", children: [durationLabel && _jsx12("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx12("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx12("span", { children: sceneLabel })] })] }), showCoverPlay && (src || duration > 0) && _jsx12(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx12(PlaybackControls, { fullscreen: fullscreenMode === "dialog" ? expanded : nativeFullscreen.fullscreen, playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, variant: controlsVariant, iconSet, appearance: controlsAppearance, timeDisplay, actions: controlsActions, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen && !(expanded && (fitExpandedContent || frameExpansion)) ? () => void toggleFullscreen() : void 0, fullscreenLabel: fullscreenMode === "dialog" ? expanded ? "Close expanded video" : "Expand video" : void 0 })] });
1488
+ return _jsxs11(_Fragment5, { children: [expanded ? _jsx12("div", { ref: expandedPlaceholder, "aria-hidden": "true", style: { height: inlineHeight } }) : !inlineDialog && player, _jsx12(Dialog, { title, open: expanded, onOpenChange: changeExpanded, className: `vx-video-dialog${dialogLayout}`, inlineWhenClosed: inlineDialog, children: (expanded || inlineDialog) && player })] });
1489
+ }
1490
+
1491
+ // packages/ui-system/dist/duration.js
1492
+ function formatDurationSeconds(durationMs) {
1493
+ return (Math.round(durationMs / 100) / 10).toFixed(1).replace(/\.0$/, "");
860
1494
  }
861
1495
 
862
1496
  // packages/media-tools/src/ui/recipe-player.tsx
@@ -869,6 +1503,7 @@ function RecipePlayer({
869
1503
  children
870
1504
  }) {
871
1505
  const root = React2.useRef(null);
1506
+ const fullscreenState = useFullscreen(root);
872
1507
  const media = React2.useRef(null);
873
1508
  const fit = React2.useRef(null);
874
1509
  const [box, setBox] = React2.useState({ width: 640, height: 360 });
@@ -876,11 +1511,20 @@ function RecipePlayer({
876
1511
  const [muted, setMuted] = React2.useState(false);
877
1512
  const [time, setTime] = React2.useState(recipe2.trim.inMs / 1e3);
878
1513
  const [error, setError] = React2.useState("");
1514
+ const speed = recipe2.speed ?? 1;
1515
+ const color = recipe2.color;
879
1516
  const bounds = React2.useRef(recipe2.trim);
1517
+ const previousTrim = React2.useRef(recipe2.trim);
880
1518
  bounds.current = recipe2.trim;
881
1519
  const crop = editingCrop ? { x: 0, y: 0, width: 1, height: 1 } : recipe2.crop;
882
1520
  const aspect = video.displayWidth * crop.width / (video.displayHeight * crop.height);
883
1521
  const width = Math.max(1, Math.min(box.width, box.height * aspect));
1522
+ React2.useEffect(() => {
1523
+ if (media.current) {
1524
+ media.current.playbackRate = speed;
1525
+ media.current.preservesPitch = true;
1526
+ }
1527
+ }, [speed, video.previewUrl]);
884
1528
  React2.useEffect(() => {
885
1529
  const element = fit.current;
886
1530
  if (!element) return;
@@ -918,11 +1562,16 @@ function RecipePlayer({
918
1562
  }, [video.previewUrl, playing]);
919
1563
  React2.useEffect(() => {
920
1564
  const element = media.current;
1565
+ const previous = previousTrim.current;
1566
+ previousTrim.current = recipe2.trim;
921
1567
  if (element && Number.isFinite(element.duration)) {
1568
+ const changed = previous.inMs !== recipe2.trim.inMs || previous.outMs !== recipe2.trim.outMs;
1569
+ const previewTime = previous.inMs !== recipe2.trim.inMs ? recipe2.trim.inMs / 1e3 : previous.outMs !== recipe2.trim.outMs ? (recipe2.trim.outMs - 1) / 1e3 : element.currentTime;
922
1570
  const clamped = Math.max(
923
1571
  recipe2.trim.inMs / 1e3,
924
- Math.min((recipe2.trim.outMs - 1) / 1e3, element.currentTime)
1572
+ Math.min((recipe2.trim.outMs - 1) / 1e3, previewTime)
925
1573
  );
1574
+ if (changed) element.pause();
926
1575
  if (element.currentTime !== clamped) element.currentTime = clamped;
927
1576
  setTime(clamped);
928
1577
  }
@@ -932,13 +1581,12 @@ function RecipePlayer({
932
1581
  if (element)
933
1582
  element.currentTime = Math.max(
934
1583
  recipe2.trim.inMs,
935
- Math.min(recipe2.trim.outMs - 1, recipe2.trim.inMs + seconds * 1e3)
1584
+ Math.min(recipe2.trim.outMs - 1, recipe2.trim.inMs + seconds * 1e3 * speed)
936
1585
  ) / 1e3;
937
1586
  };
938
1587
  async function fullscreen() {
939
1588
  try {
940
- if (document.fullscreenElement === root.current) await document.exitFullscreen();
941
- else await root.current?.requestFullscreen();
1589
+ await fullscreenState.toggleFullscreen();
942
1590
  } catch (failure) {
943
1591
  setError(readableError(failure));
944
1592
  }
@@ -964,10 +1612,13 @@ function RecipePlayer({
964
1612
  width: `${100 / crop.width}%`,
965
1613
  height: `${100 / crop.height}%`,
966
1614
  left: `${-crop.x * 100 / crop.width}%`,
967
- top: `${-crop.y * 100 / crop.height}%`
1615
+ top: `${-crop.y * 100 / crop.height}%`,
1616
+ filter: color ? `brightness(${1 + color.brightness}) contrast(${color.contrast}) saturate(${color.saturation})` : void 0
968
1617
  },
969
1618
  onLoadedMetadata: (event) => {
970
1619
  event.currentTarget.currentTime = bounds.current.inMs / 1e3;
1620
+ event.currentTarget.playbackRate = speed;
1621
+ event.currentTarget.preservesPitch = true;
971
1622
  setTime(bounds.current.inMs / 1e3);
972
1623
  },
973
1624
  onSeeking: (event) => {
@@ -988,10 +1639,11 @@ function RecipePlayer({
988
1639
  /* @__PURE__ */ React2.createElement(
989
1640
  PlaybackControls,
990
1641
  {
1642
+ fullscreen: fullscreenState.fullscreen,
991
1643
  playing,
992
1644
  muted,
993
- time: Math.max(0, time - recipe2.trim.inMs / 1e3),
994
- duration: (recipe2.trim.outMs - recipe2.trim.inMs) / 1e3,
1645
+ time: Math.max(0, (time - recipe2.trim.inMs / 1e3) / speed),
1646
+ duration: recipeDurationMs(recipe2) / 1e3,
995
1647
  onSeek: seek,
996
1648
  onToggleMute: () => setMuted(!muted),
997
1649
  onFullscreen: () => void fullscreen(),
@@ -1250,6 +1902,23 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1250
1902
  const [ratio, setRatio] = React4.useState("Freeform");
1251
1903
  const [error, setError] = React4.useState("");
1252
1904
  const [saving, setSaving] = React4.useState(false);
1905
+ const focusCancel = React4.useCallback((button) => {
1906
+ if (!button) return;
1907
+ let opener;
1908
+ queueMicrotask(() => {
1909
+ const frame = button.ownerDocument.activeElement;
1910
+ if (button.closest("dialog")?.open && frame?.tagName === "IFRAME") {
1911
+ opener = frame.contentDocument?.activeElement;
1912
+ button.focus({ preventScroll: true });
1913
+ }
1914
+ });
1915
+ return () => {
1916
+ const target = opener;
1917
+ target?.ownerDocument.defaultView?.requestAnimationFrame(() => {
1918
+ if (target.isConnected) target.focus({ preventScroll: true });
1919
+ });
1920
+ };
1921
+ }, []);
1253
1922
  const [reload, setReload] = React4.useState(0);
1254
1923
  const generation = React4.useRef(0);
1255
1924
  const edit = React4.useRef(null);
@@ -1359,7 +2028,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1359
2028
  /* @__PURE__ */ React4.createElement(
1360
2029
  Dialog,
1361
2030
  {
1362
- title: mode === "crop" ? "Crop Video" : "Trim Video",
2031
+ title: videoEditorTitles[mode],
1363
2032
  open: true,
1364
2033
  onOpenChange: (open) => {
1365
2034
  if (!open && !saving) onClose();
@@ -1377,12 +2046,16 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1377
2046
  if (mode === "crop") {
1378
2047
  setRatio("Original");
1379
2048
  change({ ...draft, crop: { x: 0, y: 0, width: 1, height: 1 } });
1380
- } else change({ ...draft, trim: { inMs: 0, outMs: video.durationMs } });
2049
+ } else if (mode === "trim")
2050
+ change({ ...draft, trim: { inMs: 0, outMs: video.durationMs } });
2051
+ else if (mode === "color") change({ ...draft, color: { ...neutralColor } });
2052
+ else change({ ...draft, speed: 1 });
1381
2053
  }
1382
2054
  }
1383
2055
  ), /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-confirm" }, /* @__PURE__ */ React4.createElement(
1384
2056
  Button,
1385
2057
  {
2058
+ ref: focusCancel,
1386
2059
  label: "Cancel",
1387
2060
  variant: "text-tonal-md",
1388
2061
  width: "hug",
@@ -1401,7 +2074,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1401
2074
  }
1402
2075
  )))
1403
2076
  },
1404
- video && draft ? /* @__PURE__ */ React4.createElement("div", { inert: saving, "aria-busy": saving }, /* @__PURE__ */ React4.createElement("p", { className: "mt-subtitle" }, video.name, " \xB7 v", video.versionNumber), video.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React4.createElement("p", { className: "mt-subtitle" }, "Color information is missing. Standard SDR colors are assumed; export may differ slightly."), /* @__PURE__ */ React4.createElement(
2077
+ video && draft ? /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-content", inert: saving, "aria-busy": saving }, /* @__PURE__ */ React4.createElement(
1405
2078
  RecipePlayer,
1406
2079
  {
1407
2080
  video,
@@ -1434,27 +2107,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1434
2107
  }
1435
2108
  })
1436
2109
  }
1437
- ), filmstrip?.error && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, filmstrip.error), /* @__PURE__ */ React4.createElement("details", { className: "mt-precision" }, /* @__PURE__ */ React4.createElement("summary", null, "Precise timing"), /* @__PURE__ */ React4.createElement("div", { className: "mt-fields" }, ["inMs", "outMs"].map((edge) => /* @__PURE__ */ React4.createElement("label", { key: edge }, edge === "inMs" ? "In (seconds)" : "Out (seconds)", /* @__PURE__ */ React4.createElement(
1438
- "input",
1439
- {
1440
- type: "number",
1441
- min: "0",
1442
- max: video.durationMs / 1e3,
1443
- step: "0.001",
1444
- value: draft.trim[edge] / 1e3,
1445
- disabled: saving,
1446
- onChange: (event) => {
1447
- if (Number.isFinite(event.currentTarget.valueAsNumber))
1448
- change({
1449
- ...draft,
1450
- trim: {
1451
- ...draft.trim,
1452
- [edge]: Math.round(event.currentTarget.valueAsNumber * 1e3)
1453
- }
1454
- });
1455
- }
1456
- }
1457
- )))))) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-hint" }, /* @__PURE__ */ React4.createElement("span", null, "Drag the frame to move. Drag a corner to resize."), /* @__PURE__ */ React4.createElement("span", { role: "status" }, rect?.width, " \xD7 ", rect?.height)), /* @__PURE__ */ React4.createElement(
2110
+ ), filmstrip?.error && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, filmstrip.error)) : mode === "crop" ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-hint" }, /* @__PURE__ */ React4.createElement("span", null, "Drag the frame to move. Drag a corner to resize."), /* @__PURE__ */ React4.createElement("span", { role: "status" }, rect?.width, " \xD7 ", rect?.height)), /* @__PURE__ */ React4.createElement(
1458
2111
  SegmentedControl,
1459
2112
  {
1460
2113
  label: "Aspect ratio",
@@ -1464,7 +2117,46 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1464
2117
  size: "large",
1465
2118
  width: "full"
1466
2119
  }
1467
- ))) : !error && /* @__PURE__ */ React4.createElement("p", { role: "status" }, "Loading fixed video\u2026"),
2120
+ )) : mode === "color" ? /* @__PURE__ */ React4.createElement("div", { className: "mt-adjustments" }, ["brightness", "contrast", "saturation"].map((key) => /* @__PURE__ */ React4.createElement(
2121
+ Slider,
2122
+ {
2123
+ key,
2124
+ label: { brightness: "Brightness", contrast: "Contrast", saturation: "Saturation" }[key],
2125
+ min: key === "brightness" ? -50 : 0,
2126
+ max: key === "brightness" ? 50 : 200,
2127
+ step: 1,
2128
+ unit: "%",
2129
+ value: Math.round((draft.color ?? neutralColor)[key] * 100),
2130
+ onValueChange: (value) => change({
2131
+ ...draft,
2132
+ color: { ...draft.color ?? neutralColor, [key]: value / 100 }
2133
+ })
2134
+ }
2135
+ )), /* @__PURE__ */ React4.createElement("p", { className: "mt-help" }, "Live preview is approximate. Apply renders the final colors.")) : /* @__PURE__ */ React4.createElement("div", { className: "mt-adjustments" }, /* @__PURE__ */ React4.createElement(
2136
+ Slider,
2137
+ {
2138
+ label: "Playback speed",
2139
+ min: 0.25,
2140
+ max: 4,
2141
+ step: 0.05,
2142
+ unit: "\xD7",
2143
+ value: draft.speed ?? 1,
2144
+ onValueChange: (speed) => change({ ...draft, speed: Math.round(speed * 100) / 100 })
2145
+ }
2146
+ ), /* @__PURE__ */ React4.createElement(
2147
+ SegmentedControl,
2148
+ {
2149
+ label: "Speed presets",
2150
+ size: "large",
2151
+ width: "full",
2152
+ items: [0.25, 0.5, 1, 1.5, 2, 4].map((speed) => ({
2153
+ value: String(speed),
2154
+ label: `${speed}\xD7`
2155
+ })),
2156
+ value: String(draft.speed ?? 1),
2157
+ onValueChange: (speed) => change({ ...draft, speed: Number(speed) })
2158
+ }
2159
+ ), /* @__PURE__ */ React4.createElement("p", { className: "mt-editor-hint", role: "status" }, /* @__PURE__ */ React4.createElement("span", null, ((draft.trim.outMs - draft.trim.inMs) / 1e3).toFixed(2), "s \u2192", " ", (recipeDurationMs(draft) / 1e3).toFixed(2), "s"), /* @__PURE__ */ React4.createElement("span", null, "Keep original pitch"))), video.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")) : !error && /* @__PURE__ */ React4.createElement("p", { role: "status" }, "Loading fixed video\u2026"),
1468
2160
  error && /* @__PURE__ */ React4.createElement("div", { role: "alert", className: "mt-error" }, error, !video && /* @__PURE__ */ React4.createElement(
1469
2161
  Button,
1470
2162
  {
@@ -1477,8 +2169,473 @@ function VideoEditor({ input, mode, onApply, onClose }) {
1477
2169
  );
1478
2170
  }
1479
2171
 
1480
- // packages/media-tools/src/ui/compare.tsx
2172
+ // packages/media-tools/src/ui/export-dialog.tsx
1481
2173
  import * as React5 from "react";
2174
+ import { useEffect as useEffect10, useRef as useRef8, useState as useState11 } from "react";
2175
+ var defaultSettings = {
2176
+ format: "h264",
2177
+ aspect: "source",
2178
+ resolution: "source",
2179
+ frameRate: "source",
2180
+ quality: "high",
2181
+ audio: true
2182
+ };
2183
+ var terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled", "interrupted"]);
2184
+ var exportNotices = {
2185
+ failed: "Export failed. Try again.",
2186
+ interrupted: "Export stopped because Studio was closed. Try again.",
2187
+ canceled: "Export canceled."
2188
+ };
2189
+ var idleTracking = { jobId: void 0, downloadPending: false, pending: void 0 };
2190
+ function VideoExport({
2191
+ title,
2192
+ preview,
2193
+ canvas: canvas2,
2194
+ issue,
2195
+ legacyTracking,
2196
+ prepare,
2197
+ resolveDownload,
2198
+ onClose
2199
+ }) {
2200
+ const { client, instanceId } = useMediaClient();
2201
+ const storageKey = `studio-video-export:${client.project.id}:${instanceId}`;
2202
+ const [tracking, setTracking] = useState11(() => {
2203
+ try {
2204
+ const raw = localStorage.getItem(storageKey);
2205
+ const stored = raw ? JSON.parse(raw) : legacyTracking;
2206
+ const parsed = mediaRequest.safeParse(stored?.pending?.request);
2207
+ return {
2208
+ jobId: typeof stored?.jobId === "string" && stored.downloadPending !== false ? stored.jobId : void 0,
2209
+ downloadPending: stored?.downloadPending === true,
2210
+ pending: typeof stored?.pending?.key === "string" && parsed.success ? { key: stored.pending.key, request: parsed.data } : void 0,
2211
+ recoverIntent: raw ? void 0 : legacyTracking?.recoverIntent
2212
+ };
2213
+ } catch {
2214
+ return {
2215
+ jobId: void 0,
2216
+ downloadPending: false,
2217
+ pending: void 0,
2218
+ recoverIntent: void 0
2219
+ };
2220
+ }
2221
+ });
2222
+ const [name, setName] = useState11(title.slice(0, 196));
2223
+ const [settings, setSettings] = useState11(defaultSettings);
2224
+ const [preparedCanvas, setPreparedCanvas] = useState11();
2225
+ const [formats, setFormats] = useState11(["h264"]);
2226
+ const [checking, setChecking] = useState11(!issue);
2227
+ const prepareRef = useRef8(prepare);
2228
+ prepareRef.current = prepare;
2229
+ const source = canvas2 ?? preparedCanvas;
2230
+ const dimensions = source && exportDimensions(source, settings.aspect, settings.resolution);
2231
+ const invalidSize = dimensions === null;
2232
+ const [job, setJob] = useState11();
2233
+ const [error, setError] = useState11("");
2234
+ const [pollError, setPollError] = useState11("");
2235
+ const [notice, showNotice] = useToastMessage();
2236
+ const notifiedFailure = useRef8(void 0);
2237
+ const [busy, setBusy] = useState11(false);
2238
+ const lock = useRef8(false);
2239
+ const { jobId, downloadPending, pending, recoverIntent } = tracking;
2240
+ const unresolved = Boolean(pending || recoverIntent);
2241
+ const active = Boolean(jobId && (!job || !terminal.has(job.state)));
2242
+ const completed = !unresolved && job?.state === "succeeded" && (!jobId || job.jobId === jobId);
2243
+ const settingsLocked = busy || active || unresolved || completed && downloadPending;
2244
+ useEffect10(() => setName(title.slice(0, 196)), [title]);
2245
+ useEffect10(() => {
2246
+ if (issue) {
2247
+ setChecking(false);
2248
+ return;
2249
+ }
2250
+ let live = true;
2251
+ setChecking(true);
2252
+ void (async () => {
2253
+ try {
2254
+ if (!canvas2) {
2255
+ try {
2256
+ const input = await prepareRef.current();
2257
+ if (live) setPreparedCanvas(input.canvas);
2258
+ } catch {
2259
+ }
2260
+ }
2261
+ if (!live) return;
2262
+ const result = await client.invoke(
2263
+ { instanceId, operationId: "export.capabilities" },
2264
+ {}
2265
+ );
2266
+ const player = document.createElement("video");
2267
+ if (live)
2268
+ setFormats(
2269
+ result.formats.filter(
2270
+ (format) => format === "h264" || Boolean(
2271
+ player.canPlayType(
2272
+ format === "hevc" ? 'video/mp4; codecs="hvc1.1.6.L93.B0"' : 'video/webm; codecs="vp9, opus"'
2273
+ )
2274
+ )
2275
+ )
2276
+ );
2277
+ } catch {
2278
+ } finally {
2279
+ if (live) setChecking(false);
2280
+ }
2281
+ })();
2282
+ return () => {
2283
+ live = false;
2284
+ };
2285
+ }, [canvas2?.width, canvas2?.height, client, instanceId, issue, title]);
2286
+ useEffect10(() => {
2287
+ if (!jobId || unresolved || job && job.jobId === jobId && terminal.has(job.state)) return;
2288
+ let live = true;
2289
+ let timer;
2290
+ async function poll(id) {
2291
+ try {
2292
+ const result = await client.invoke(
2293
+ { instanceId, operationId: "jobs.get" },
2294
+ { jobId: id }
2295
+ );
2296
+ if (!live) return;
2297
+ updateJob(result, downloadPending);
2298
+ setPollError("");
2299
+ if (terminal.has(result.state)) return;
2300
+ } catch (error2) {
2301
+ if (!live) return;
2302
+ if (error2 && typeof error2 === "object" && "code" in error2 && error2.code === "JOB_NOT_FOUND") {
2303
+ showNotice("The previous export could not be found. Try again.");
2304
+ setPollError("");
2305
+ track(idleTracking);
2306
+ return;
2307
+ }
2308
+ setPollError(readableError(error2));
2309
+ }
2310
+ if (live) timer = setTimeout(() => void poll(id), 750);
2311
+ }
2312
+ void poll(jobId);
2313
+ return () => {
2314
+ live = false;
2315
+ clearTimeout(timer);
2316
+ };
2317
+ }, [client, instanceId, jobId, job?.state, unresolved, downloadPending]);
2318
+ function updateJob(result, shouldDownload) {
2319
+ const notice2 = exportNotices[result.state];
2320
+ if (notice2 && notifiedFailure.current !== result.jobId) {
2321
+ notifiedFailure.current = result.jobId;
2322
+ showNotice(
2323
+ result.cleanupPending ? "The previous export is still cleaning up. Try again in a moment." : notice2
2324
+ );
2325
+ }
2326
+ if (terminal.has(result.state) && (result.state !== "succeeded" || !shouldDownload))
2327
+ track(idleTracking);
2328
+ setJob(
2329
+ (current) => current?.jobId === result.jobId && current.revision > result.revision ? current : result
2330
+ );
2331
+ }
2332
+ function track(next) {
2333
+ try {
2334
+ localStorage.setItem(storageKey, JSON.stringify(next));
2335
+ } catch {
2336
+ }
2337
+ setTracking({ ...next, recoverIntent: void 0 });
2338
+ }
2339
+ async function act(run) {
2340
+ if (lock.current) return;
2341
+ lock.current = true;
2342
+ setBusy(true);
2343
+ setError("");
2344
+ try {
2345
+ await run();
2346
+ } catch (error2) {
2347
+ setError(readableError(error2));
2348
+ } finally {
2349
+ lock.current = false;
2350
+ setBusy(false);
2351
+ }
2352
+ }
2353
+ async function submit(intent) {
2354
+ track({ jobId, downloadPending, pending: intent });
2355
+ try {
2356
+ const result = await client.invoke(
2357
+ { instanceId, operationId: intent.request.operation },
2358
+ intent.request.input,
2359
+ { requestKey: intent.key }
2360
+ );
2361
+ setJob(void 0);
2362
+ track({ jobId: result.jobId, downloadPending: true, pending: void 0 });
2363
+ } catch (error2) {
2364
+ const code = error2 && typeof error2 === "object" && "code" in error2 ? error2.code : void 0;
2365
+ if (typeof code === "string" && !["EXECUTION_UNKNOWN", "OPERATION_CONTRACT_CHANGED", "TRANSPORT_UNKNOWN"].includes(code))
2366
+ track({ jobId, downloadPending, pending: void 0 });
2367
+ throw error2;
2368
+ }
2369
+ }
2370
+ async function findOriginal() {
2371
+ const original = pending ?? await recoverIntent?.();
2372
+ if (!original) return;
2373
+ const found = await client.invoke(
2374
+ { instanceId, operationId: "jobs.list" },
2375
+ {
2376
+ request: {
2377
+ operation: original.request.operation,
2378
+ requestKey: original.key,
2379
+ intent: original.request.input
2380
+ }
2381
+ }
2382
+ );
2383
+ if (!found.items[0]) throw Error("No accepted export was found. No new task was submitted.");
2384
+ track({ jobId: found.items[0].jobId, downloadPending: true, pending: void 0 });
2385
+ updateJob(found.items[0], true);
2386
+ }
2387
+ async function exportVideo() {
2388
+ const outputName2 = exportName(name, exportProfiles[settings.format].extension);
2389
+ const input = await prepare();
2390
+ if (!exportDimensions(input.canvas, settings.aspect, settings.resolution))
2391
+ throw Error("Choose a smaller resolution for this aspect ratio.");
2392
+ await submit({
2393
+ key: crypto.randomUUID(),
2394
+ request: { operation: "sequence.process", input: { ...input, outputName: outputName2, settings } }
2395
+ });
2396
+ }
2397
+ function update(key, value) {
2398
+ setSettings((current) => ({ ...current, [key]: value }));
2399
+ }
2400
+ const fields = [
2401
+ {
2402
+ label: "Format",
2403
+ value: settings.format,
2404
+ change: (value) => update("format", value),
2405
+ options: Object.keys(exportProfiles).map((value) => ({
2406
+ value,
2407
+ label: exportProfiles[value].label + (formats.includes(value) ? "" : " (Unavailable)"),
2408
+ disabled: !formats.includes(value)
2409
+ }))
2410
+ },
2411
+ {
2412
+ label: "Aspect ratio",
2413
+ value: settings.aspect,
2414
+ change: (value) => update("aspect", value),
2415
+ options: exportAspects.map((value) => {
2416
+ if (value === "source") return { value, label: "Match source" };
2417
+ const [width, height] = value.split(":").map(Number);
2418
+ return {
2419
+ value,
2420
+ label: value,
2421
+ icon: /* @__PURE__ */ React5.createElement("span", { className: "mt-export-ratio-icon", "aria-hidden": "true" }, /* @__PURE__ */ React5.createElement(
2422
+ "span",
2423
+ {
2424
+ style: {
2425
+ width: 14 * Math.min(1, width / height),
2426
+ height: 14 * Math.min(1, height / width)
2427
+ }
2428
+ }
2429
+ ))
2430
+ };
2431
+ })
2432
+ },
2433
+ {
2434
+ label: "Resolution",
2435
+ value: String(settings.resolution),
2436
+ change: (value) => update(
2437
+ "resolution",
2438
+ value === "source" ? value : Number(value)
2439
+ ),
2440
+ options: ["source", ...exportResolutions].map((value) => {
2441
+ const size = source && exportDimensions(source, settings.aspect, value);
2442
+ const label = value === "source" ? "Match source" : `${value}p`;
2443
+ return {
2444
+ value: String(value),
2445
+ label: size ? `${label} \xB7 ${size.width} \xD7 ${size.height}` : label,
2446
+ triggerLabel: label,
2447
+ disabled: size === null
2448
+ };
2449
+ })
2450
+ },
2451
+ {
2452
+ label: "Frame rate",
2453
+ value: String(settings.frameRate),
2454
+ change: (value) => update(
2455
+ "frameRate",
2456
+ value === "source" ? value : Number(value)
2457
+ ),
2458
+ options: [
2459
+ { value: "source", label: "Match source" },
2460
+ ...exportRates.map((fps) => ({ value: String(fps), label: `${fps}fps` }))
2461
+ ]
2462
+ },
2463
+ {
2464
+ label: "Quality",
2465
+ value: settings.quality,
2466
+ change: (value) => update("quality", value),
2467
+ options: [
2468
+ { value: "high", label: "High" },
2469
+ { value: "standard", label: "Standard" },
2470
+ { value: "small", label: "Small file" }
2471
+ ]
2472
+ },
2473
+ {
2474
+ label: "Audio",
2475
+ value: String(settings.audio),
2476
+ change: (value) => update("audio", value === "true"),
2477
+ options: [
2478
+ { value: "true", label: "Include audio" },
2479
+ { value: "false", label: "No audio" }
2480
+ ]
2481
+ }
2482
+ ];
2483
+ const ratio = dimensions ? dimensions.width / dimensions.height : settings.aspect !== "source" ? Number(settings.aspect.split(":")[0]) / Number(settings.aspect.split(":")[1]) : void 0;
2484
+ const previewStyle = {
2485
+ "--mt-export-frame-ratio": ratio,
2486
+ ...ratio && settings.aspect !== "source" ? {
2487
+ "--mt-export-frame-width": `${Math.min(1, ratio / (16 / 9)) * 100}%`,
2488
+ "--mt-export-frame-height": `${Math.min(1, 16 / 9 / ratio) * 100}%`
2489
+ } : {}
2490
+ };
2491
+ return /* @__PURE__ */ React5.createElement(
2492
+ Dialog,
2493
+ {
2494
+ open: true,
2495
+ title: "Export Settings",
2496
+ className: "mt-export-dialog",
2497
+ onOpenChange: (open) => {
2498
+ if (!open && !lock.current) onClose();
2499
+ },
2500
+ actions: /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
2501
+ Button,
2502
+ {
2503
+ label: "Cancel",
2504
+ variant: "text-tonal-lg",
2505
+ width: "hug",
2506
+ onClick: onClose,
2507
+ disabled: busy
2508
+ }
2509
+ ), /* @__PURE__ */ React5.createElement(
2510
+ Button,
2511
+ {
2512
+ label: "Export",
2513
+ loading: busy || active,
2514
+ variant: "text-filled-lg",
2515
+ width: "hug",
2516
+ disabled: settingsLocked || checking || invalidSize || Boolean(issue) || exportName(name, "mp4") === ".mp4",
2517
+ onClick: () => void act(exportVideo)
2518
+ }
2519
+ ))
2520
+ },
2521
+ /* @__PURE__ */ React5.createElement(Toast, { message: notice }),
2522
+ /* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview", style: previewStyle }, preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
2523
+ TextInput,
2524
+ {
2525
+ placeholder: "Enter a title for the exported video",
2526
+ label: "Title",
2527
+ maxLength: 196,
2528
+ value: name,
2529
+ onValueChange: setName,
2530
+ disabled: settingsLocked
2531
+ }
2532
+ ), /* @__PURE__ */ React5.createElement("dl", null, fields.map(({ label, value, options, change }) => /* @__PURE__ */ React5.createElement("div", { key: label }, /* @__PURE__ */ React5.createElement("dt", null, label), /* @__PURE__ */ React5.createElement("dd", null, /* @__PURE__ */ React5.createElement(
2533
+ Dropdown,
2534
+ {
2535
+ label,
2536
+ value,
2537
+ options,
2538
+ onValueChange: change,
2539
+ appearance: "field",
2540
+ floating: true,
2541
+ disabled: settingsLocked || label === "Format" && checking
2542
+ }
2543
+ ))))))),
2544
+ completed && /* @__PURE__ */ React5.createElement(
2545
+ ExportDownload,
2546
+ {
2547
+ key: job.jobId,
2548
+ job,
2549
+ resolveDownload,
2550
+ autoDownload: downloadPending,
2551
+ onDownloadHandled: () => track(idleTracking),
2552
+ onClose
2553
+ }
2554
+ ),
2555
+ invalidSize && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice", role: "status" }, "Choose a smaller resolution for this aspect ratio."),
2556
+ issue && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice" }, issue),
2557
+ unresolved && !busy && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, "Export outcome has not been confirmed.", /* @__PURE__ */ React5.createElement(
2558
+ Button,
2559
+ {
2560
+ label: "Find original export",
2561
+ variant: "text-ghost-sm",
2562
+ onClick: () => void act(findOriginal)
2563
+ }
2564
+ )),
2565
+ (error || pollError) && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-error", role: "alert" }, error || pollError)
2566
+ );
2567
+ }
2568
+ function ExportDownload({
2569
+ job,
2570
+ resolveDownload,
2571
+ autoDownload,
2572
+ onDownloadHandled,
2573
+ onClose
2574
+ }) {
2575
+ const [url, setUrl] = useState11("");
2576
+ const [error, setError] = useState11("");
2577
+ const [retry, setRetry] = useState11(0);
2578
+ const link = useRef8(null);
2579
+ const attempted = useRef8(false);
2580
+ const resolver = useRef8(resolveDownload);
2581
+ resolver.current = resolveDownload;
2582
+ useEffect10(() => {
2583
+ if (!autoDownload && retry === 0) return;
2584
+ let live = true;
2585
+ async function prepareLink() {
2586
+ try {
2587
+ const resolved = job.result && await resolver.current(job.result, job.outputName);
2588
+ if (!resolved) throw Error("The download link is unavailable.");
2589
+ if (live) setUrl(resolved);
2590
+ } catch (error2) {
2591
+ if (live) setError(readableError(error2) || "The download link is unavailable.");
2592
+ }
2593
+ }
2594
+ void prepareLink();
2595
+ return () => {
2596
+ live = false;
2597
+ };
2598
+ }, [job.result, job.outputName, autoDownload, retry]);
2599
+ useEffect10(() => {
2600
+ if (error) {
2601
+ if (autoDownload) onDownloadHandled();
2602
+ return;
2603
+ }
2604
+ if (!url || !link.current || !autoDownload && retry === 0 || attempted.current) return;
2605
+ attempted.current = true;
2606
+ link.current.click();
2607
+ if (autoDownload) onDownloadHandled();
2608
+ onClose();
2609
+ }, [url, error, autoDownload, retry, onDownloadHandled, onClose]);
2610
+ if (url && (autoDownload || retry > 0)) {
2611
+ return /* @__PURE__ */ React5.createElement("a", { hidden: true, ref: link, href: url, download: job.outputName });
2612
+ }
2613
+ if (!error) return null;
2614
+ return /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, /* @__PURE__ */ React5.createElement("span", { className: "mt-export-error", role: "alert" }, error), /* @__PURE__ */ React5.createElement(
2615
+ Button,
2616
+ {
2617
+ label: "Retry download",
2618
+ variant: "text-ghost-sm",
2619
+ onClick: () => {
2620
+ setError("");
2621
+ setRetry((value) => value + 1);
2622
+ }
2623
+ }
2624
+ ));
2625
+ }
2626
+
2627
+ // packages/media-tools/src/ui/compare.tsx
2628
+ import * as React6 from "react";
2629
+ function inputKey(input) {
2630
+ const ref = input.kind === "source" ? input.file.source : input.editRef;
2631
+ return JSON.stringify([
2632
+ input.kind,
2633
+ ref.storeId,
2634
+ ref.objectId,
2635
+ ref.versionId,
2636
+ input.kind === "source" ? input.file.fileId : null
2637
+ ]);
2638
+ }
1482
2639
  function formatLabel(width, height) {
1483
2640
  let a = width, b = height;
1484
2641
  while (b) {
@@ -1496,11 +2653,12 @@ function Candidate({
1496
2653
  emptyState
1497
2654
  }) {
1498
2655
  const { resolve } = useMediaClient();
1499
- const [video, setVideo] = React5.useState(null);
1500
- const [error, setError] = React5.useState("");
1501
- const [revision, setRevision] = React5.useState(0);
2656
+ const [video, setVideo] = React6.useState(null);
2657
+ const [error, setError] = React6.useState("");
2658
+ const [revision, setRevision] = React6.useState(0);
2659
+ const title = slot.context?.shotName?.trim() || video?.name || "Video";
1502
2660
  const identity = JSON.stringify(slot.input);
1503
- React5.useEffect(() => {
2661
+ React6.useEffect(() => {
1504
2662
  let active = true;
1505
2663
  setVideo(null);
1506
2664
  setError("");
@@ -1514,15 +2672,15 @@ function Candidate({
1514
2672
  active = false;
1515
2673
  };
1516
2674
  }, [resolve, identity, revision]);
1517
- 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(
2675
+ 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(
1518
2676
  Button,
1519
2677
  {
1520
- label: "Choose video",
1521
- variant: "text-tonal-sm",
2678
+ label: "Select a shot",
2679
+ variant: "text-plain-sm",
1522
2680
  width: "hug",
1523
2681
  onClick: onChoose
1524
2682
  }
1525
- ))) : error ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React5.createElement("p", null, error), /* @__PURE__ */ React5.createElement(
2683
+ )) : error ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React6.createElement("p", null, error), /* @__PURE__ */ React6.createElement(
1526
2684
  Button,
1527
2685
  {
1528
2686
  label: "Reload preview",
@@ -1530,29 +2688,30 @@ function Candidate({
1530
2688
  width: "hug",
1531
2689
  onClick: () => setRevision(revision + 1)
1532
2690
  }
1533
- )) : !video ? /* @__PURE__ */ React5.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React5.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React5.createElement(
2691
+ )) : !video ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React6.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React6.createElement(
1534
2692
  VideoPlayer,
1535
2693
  {
1536
2694
  src: video.previewUrl,
1537
- title: video.name,
2695
+ title,
2696
+ showCoverInfo: false,
1538
2697
  controlsPlacement: "overlay",
1539
2698
  onError: () => setError("This video could not be played. Reload its fixed preview.")
1540
2699
  }
1541
- )), /* @__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 ? slot.context?.shotName || video?.name || "Video" : "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")))));
2700
+ )), /* @__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, formatDurationSeconds(video.effectiveDurationMs), "s")))));
1542
2701
  }
1543
2702
  function VideoCompare(props) {
1544
- const [generation, setGeneration] = React5.useState(0);
1545
- const [replacing, setReplacing] = React5.useState(null);
1546
- const [error, setError] = React5.useState("");
1547
- const active = React5.useRef(true);
1548
- React5.useEffect(() => {
2703
+ const [generation, setGeneration] = React6.useState(0);
2704
+ const [replacing, setReplacing] = React6.useState(null);
2705
+ const [error, setError] = React6.useState("");
2706
+ const active = React6.useRef(true);
2707
+ React6.useEffect(() => {
1549
2708
  active.current = true;
1550
2709
  return () => {
1551
2710
  active.current = false;
1552
2711
  };
1553
2712
  }, []);
1554
2713
  if (props.slots.length < 2 || props.slots.length > 4 || new Set(props.slots.map((slot) => slot.id)).size !== props.slots.length)
1555
- return /* @__PURE__ */ React5.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
2714
+ return /* @__PURE__ */ React6.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
1556
2715
  const remove = (slot) => props.onSlotsChange(
1557
2716
  props.slots.length > 2 ? props.slots.filter((value) => value.id !== slot.id) : props.slots.map((value) => value.id === slot.id ? { ...value, input: null } : value)
1558
2717
  );
@@ -1572,91 +2731,118 @@ function VideoCompare(props) {
1572
2731
  if (active.current) setReplacing(null);
1573
2732
  }
1574
2733
  }
2734
+ const slotKeys = props.slots.map(({ input }) => input && inputKey(input));
1575
2735
  function candidateChoices(slot) {
1576
- return (props.candidates || []).filter(
1577
- (candidate) => !props.slots.some(
1578
- (other) => other.id !== slot.id && JSON.stringify(other.input) === JSON.stringify(candidate.input)
1579
- )
1580
- ).map((candidate, index) => ({
1581
- id: `candidate-${index}`,
1582
- label: candidate.label,
1583
- onSelect: () => props.onSlotsChange(
1584
- props.slots.map(
1585
- (value) => value.id === slot.id ? { ...value, input: candidate.input, context: candidate.context } : value
1586
- )
1587
- )
1588
- }));
2736
+ return (props.candidates || []).flatMap((candidate) => {
2737
+ const key = inputKey(candidate.input);
2738
+ const occupied = props.slots[slotKeys.indexOf(key)];
2739
+ if (occupied && (props.allowCandidateSwap ? occupied.id === slot.id : occupied.id !== slot.id))
2740
+ return [];
2741
+ return [
2742
+ {
2743
+ id: key,
2744
+ label: props.allowCandidateSwap && occupied ? "Swap with " + candidate.label : candidate.label,
2745
+ preview: candidate.preview,
2746
+ onSelect: () => props.onSlotsChange(
2747
+ props.slots.map((column) => {
2748
+ if (column.id === slot.id)
2749
+ return { ...column, input: candidate.input, context: candidate.context };
2750
+ if (column.id === occupied?.id)
2751
+ return { ...column, input: slot.input, context: slot.context };
2752
+ return column;
2753
+ })
2754
+ )
2755
+ }
2756
+ ];
2757
+ });
1589
2758
  }
1590
- 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(
2759
+ 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(
1591
2760
  "div",
1592
2761
  {
1593
2762
  className: "mt-compare-columns",
1594
2763
  style: { gridTemplateColumns: `repeat(${props.slots.length}, minmax(240px,1fr))` }
1595
2764
  },
1596
- props.slots.map((slot, index) => /* @__PURE__ */ React5.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React5.createElement(
1597
- Candidate,
1598
- {
1599
- key: JSON.stringify([slot.id, slot.input, generation]),
1600
- slot,
1601
- replacing: replacing === slot.id,
1602
- onChoose: () => void replace(slot),
1603
- 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,
1604
- menu: /* @__PURE__ */ React5.createElement(
1605
- Menu,
1606
- {
1607
- label: `Options for video ${index + 1}`,
1608
- triggerIcon: "more",
1609
- floating: true,
1610
- items: [
1611
- ...props.slotMenuItems?.(slot) ?? [],
1612
- ...props.candidates ? [
1613
- {
1614
- id: "replace",
1615
- label: "Choose video",
1616
- disabled: candidateChoices(slot).length === 0,
1617
- items: candidateChoices(slot)
1618
- }
1619
- ] : [
2765
+ props.slots.map((slot, index) => {
2766
+ const replacements = candidateChoices(slot);
2767
+ return /* @__PURE__ */ React6.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React6.createElement(
2768
+ Candidate,
2769
+ {
2770
+ key: JSON.stringify([slot.id, slot.input, generation]),
2771
+ slot,
2772
+ replacing: replacing === slot.id,
2773
+ onChoose: () => void replace(slot),
2774
+ emptyState: props.candidates ? replacements.length || props.allowCandidateSwap ? /* @__PURE__ */ React6.createElement(
2775
+ Menu,
2776
+ {
2777
+ label: "Select a shot",
2778
+ textTrigger: "plain",
2779
+ floating: true,
2780
+ items: replacements
2781
+ }
2782
+ ) : /* @__PURE__ */ React6.createElement("p", null, "No other candidates yet.") : void 0,
2783
+ menu: /* @__PURE__ */ React6.createElement(
2784
+ Menu,
2785
+ {
2786
+ label: `Options for video ${index + 1}`,
2787
+ triggerIcon: "more",
2788
+ cascading: props.allowCandidateSwap,
2789
+ floating: true,
2790
+ items: [
2791
+ ...props.slotMenuItems?.(slot) ?? [],
2792
+ ...props.candidates ? [
2793
+ {
2794
+ id: "replace",
2795
+ label: "Choose video",
2796
+ disabled: replacements.length === 0,
2797
+ items: replacements
2798
+ }
2799
+ ] : [
2800
+ {
2801
+ id: "replace",
2802
+ label: slot.input ? "Replace" : "Choose video",
2803
+ disabled: replacing !== null,
2804
+ onSelect: () => void replace(slot)
2805
+ }
2806
+ ],
2807
+ ...slot.input ? [
2808
+ {
2809
+ id: "details",
2810
+ label: "Details",
2811
+ onSelect: () => {
2812
+ setGeneration((value) => value + 1);
2813
+ props.onOpenDetails(slot.input, {
2814
+ slots: props.slots,
2815
+ origin: props.origin
2816
+ });
2817
+ }
2818
+ }
2819
+ ] : [],
1620
2820
  {
1621
- id: "replace",
1622
- label: slot.input ? "Replace" : "Choose video",
1623
- disabled: replacing !== null,
1624
- onSelect: () => void replace(slot)
1625
- }
1626
- ],
1627
- ...slot.input ? [
2821
+ id: "add-column",
2822
+ label: "Add column",
2823
+ disabled: props.slots.length >= 4,
2824
+ onSelect: () => props.onSlotsChange([
2825
+ ...props.slots,
2826
+ { id: crypto.randomUUID(), input: null }
2827
+ ])
2828
+ },
1628
2829
  {
1629
- id: "details",
1630
- label: "Details",
1631
- onSelect: () => {
1632
- setGeneration((value) => value + 1);
1633
- props.onOpenDetails(slot.input, {
1634
- slots: props.slots,
1635
- origin: props.origin
1636
- });
1637
- }
2830
+ id: "remove",
2831
+ label: "Remove",
2832
+ tone: "danger",
2833
+ onSelect: () => remove(slot)
1638
2834
  }
1639
- ] : [],
1640
- {
1641
- id: "add-column",
1642
- label: "Add column",
1643
- disabled: props.slots.length >= 4,
1644
- onSelect: () => props.onSlotsChange([
1645
- ...props.slots,
1646
- { id: crypto.randomUUID(), input: null }
1647
- ])
1648
- },
1649
- { id: "remove", label: "Remove", onSelect: () => remove(slot) }
1650
- ]
1651
- }
1652
- )
1653
- }
1654
- ), slot.input && props.renderSlotActions && /* @__PURE__ */ React5.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot))))
2835
+ ]
2836
+ }
2837
+ )
2838
+ }
2839
+ ), slot.input && props.renderSlotActions && /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot)));
2840
+ })
1655
2841
  ));
1656
2842
  }
1657
2843
 
1658
2844
  // packages/media-tools/src/ui/jobs.tsx
1659
- import * as React6 from "react";
2845
+ import * as React7 from "react";
1660
2846
  var labels = {
1661
2847
  queued: "Queued",
1662
2848
  running: "Processing",
@@ -1668,20 +2854,20 @@ var labels = {
1668
2854
  };
1669
2855
  function MediaJobs({ onOpenResult }) {
1670
2856
  const { client, instanceId } = useMediaClient();
1671
- const [page, setPage] = React6.useState({ items: [], nextOffset: null });
1672
- const [offset, setOffset] = React6.useState(0);
1673
- const [refresh, setRefresh] = React6.useState(0);
1674
- const [error, setError] = React6.useState("");
1675
- const [pending, setPending] = React6.useState(null);
1676
- const keys = React6.useRef(/* @__PURE__ */ new Map());
1677
- const live = React6.useRef(true);
1678
- React6.useEffect(() => {
2857
+ const [page, setPage] = React7.useState({ items: [], nextOffset: null });
2858
+ const [offset, setOffset] = React7.useState(0);
2859
+ const [refresh, setRefresh] = React7.useState(0);
2860
+ const [error, setError] = React7.useState("");
2861
+ const [pending, setPending] = React7.useState(null);
2862
+ const keys = React7.useRef(/* @__PURE__ */ new Map());
2863
+ const live = React7.useRef(true);
2864
+ React7.useEffect(() => {
1679
2865
  live.current = true;
1680
2866
  return () => {
1681
2867
  live.current = false;
1682
2868
  };
1683
2869
  }, []);
1684
- React6.useEffect(() => {
2870
+ React7.useEffect(() => {
1685
2871
  let active = true, timer;
1686
2872
  async function poll() {
1687
2873
  try {
@@ -1731,7 +2917,7 @@ function MediaJobs({ onOpenResult }) {
1731
2917
  if (live.current) setPending(null);
1732
2918
  }
1733
2919
  }
1734
- 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(
2920
+ 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(
1735
2921
  Button,
1736
2922
  {
1737
2923
  label: "Refresh tasks",
@@ -1739,14 +2925,14 @@ function MediaJobs({ onOpenResult }) {
1739
2925
  width: "hug",
1740
2926
  onClick: () => setRefresh(refresh + 1)
1741
2927
  }
1742
- )), 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(
2928
+ )), 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(
1743
2929
  "progress",
1744
2930
  {
1745
2931
  "aria-label": `Progress for ${job.outputName}`,
1746
2932
  max: 1,
1747
2933
  value: job.state === "succeeded" ? 1 : job.progress === null ? void 0 : Math.min(0.99, job.progress)
1748
2934
  }
1749
- ), /* @__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(
2935
+ ), /* @__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(
1750
2936
  Button,
1751
2937
  {
1752
2938
  label: "Cancel task",
@@ -1755,7 +2941,7 @@ function MediaJobs({ onOpenResult }) {
1755
2941
  disabled: pending !== null || job.cancelRequested,
1756
2942
  onClick: () => void act(job, "cancel")
1757
2943
  }
1758
- ), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React6.createElement(
2944
+ ), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React7.createElement(
1759
2945
  Button,
1760
2946
  {
1761
2947
  label: "Retry task",
@@ -1764,7 +2950,7 @@ function MediaJobs({ onOpenResult }) {
1764
2950
  disabled: pending !== null || job.cleanupPending,
1765
2951
  onClick: () => void act(job, "retry")
1766
2952
  }
1767
- ), 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(
2953
+ ), 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(
1768
2954
  Button,
1769
2955
  {
1770
2956
  label: "Previous tasks",
@@ -1772,7 +2958,7 @@ function MediaJobs({ onOpenResult }) {
1772
2958
  disabled: offset === 0,
1773
2959
  onClick: () => setOffset(Math.max(0, offset - 50))
1774
2960
  }
1775
- ), /* @__PURE__ */ React6.createElement(
2961
+ ), /* @__PURE__ */ React7.createElement(
1776
2962
  Button,
1777
2963
  {
1778
2964
  label: "Next tasks",
@@ -1830,30 +3016,36 @@ async function activate(client) {
1830
3016
  component: Component,
1831
3017
  props
1832
3018
  }) {
1833
- const ready = React7.useSyncExternalStore(
3019
+ const ready = React8.useSyncExternalStore(
1834
3020
  subscribe,
1835
3021
  () => active,
1836
3022
  () => active
1837
3023
  );
1838
- return ready ? /* @__PURE__ */ React7.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React7.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React7.createElement(Component, { ...props }))) : null;
3024
+ return ready ? /* @__PURE__ */ React8.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React8.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React8.createElement(Component, { ...props }))) : null;
1839
3025
  }
1840
3026
  client.registerUI({
1841
3027
  id: "media.video-editor",
1842
3028
  title: "Video editor",
1843
3029
  kind: "component",
1844
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoEditor, props })
3030
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoEditor, props })
3031
+ });
3032
+ client.registerUI({
3033
+ id: "media.video-export",
3034
+ title: "Export settings",
3035
+ kind: "component",
3036
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoExport, props })
1845
3037
  });
1846
3038
  client.registerUI({
1847
3039
  id: "media.video-compare",
1848
3040
  title: "Video comparison",
1849
3041
  kind: "component",
1850
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: VideoCompare, props })
3042
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoCompare, props })
1851
3043
  });
1852
3044
  client.registerUI({
1853
3045
  id: "media.jobs",
1854
3046
  title: "Media tasks",
1855
3047
  kind: "component",
1856
- component: (props) => /* @__PURE__ */ React7.createElement(Bound, { component: MediaJobs, props })
3048
+ component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: MediaJobs, props })
1857
3049
  });
1858
3050
  client.onDispose(() => {
1859
3051
  active = false;