@pixerate/editor-react 0.91.1 → 0.93.1

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 (63) hide show
  1. package/dist/animation-editor/AnimationEditor.d.cts +11 -1
  2. package/dist/animation-editor/AnimationEditor.d.ts +11 -1
  3. package/dist/animation-editor/index.cjs +494 -366
  4. package/dist/animation-editor/index.js +48 -4
  5. package/dist/canvas/AgentPresenceLayer.d.cts +3 -0
  6. package/dist/canvas/AgentPresenceLayer.d.ts +3 -0
  7. package/dist/canvas/index.cjs +1033 -893
  8. package/dist/canvas/index.d.cts +2 -0
  9. package/dist/canvas/index.d.ts +2 -0
  10. package/dist/canvas/index.js +125 -74
  11. package/dist/canvas/useCanvasPlaybackSurface.d.cts +28 -0
  12. package/dist/canvas/useCanvasPlaybackSurface.d.ts +28 -0
  13. package/dist/chart/ChartEditor.d.cts +12 -1
  14. package/dist/chart/ChartEditor.d.ts +12 -1
  15. package/dist/chart/index.cjs +187 -29
  16. package/dist/chart/index.js +74 -10
  17. package/dist/{chunk-SMMO7CZB.js → chunk-6YRSQW2V.js} +84 -2
  18. package/dist/chunk-7I73DW4V.js +43 -0
  19. package/dist/{chunk-GML6BYCN.js → chunk-GECXTPSH.js} +53 -3
  20. package/dist/chunk-IPVWWVSF.js +96 -0
  21. package/dist/hooks/useAgentToolProvider.d.cts +6 -2
  22. package/dist/hooks/useAgentToolProvider.d.ts +6 -2
  23. package/dist/image-editor/ImageEditor.d.cts +10 -0
  24. package/dist/image-editor/ImageEditor.d.ts +10 -0
  25. package/dist/image-editor/index.cjs +1028 -864
  26. package/dist/image-editor/index.js +2 -1
  27. package/dist/index.cjs +2070 -1812
  28. package/dist/index.d.cts +1 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +21 -3
  31. package/dist/paint-editor/PaintEditor.d.cts +12 -1
  32. package/dist/paint-editor/PaintEditor.d.ts +12 -1
  33. package/dist/paint-editor/index.cjs +319 -164
  34. package/dist/paint-editor/index.js +84 -11
  35. package/dist/parameters/ParametersPanel.d.cts +11 -1
  36. package/dist/parameters/ParametersPanel.d.ts +11 -1
  37. package/dist/parameters/index.cjs +190 -41
  38. package/dist/parameters/index.js +23 -4
  39. package/dist/playback/AgentPlaybackContext.d.cts +9 -0
  40. package/dist/playback/AgentPlaybackContext.d.ts +9 -0
  41. package/dist/playback/PresenceLayer.d.cts +28 -0
  42. package/dist/playback/PresenceLayer.d.ts +28 -0
  43. package/dist/playback/index.d.cts +4 -0
  44. package/dist/playback/index.d.ts +4 -0
  45. package/dist/playback/useElementPlaybackSurface.d.cts +19 -0
  46. package/dist/playback/useElementPlaybackSurface.d.ts +19 -0
  47. package/dist/playback/usePlaybackSurface.d.cts +11 -0
  48. package/dist/playback/usePlaybackSurface.d.ts +11 -0
  49. package/dist/spreadsheet/SpreadsheetEditor.d.cts +10 -0
  50. package/dist/spreadsheet/SpreadsheetEditor.d.ts +10 -0
  51. package/dist/spreadsheet/index.cjs +443 -313
  52. package/dist/spreadsheet/index.js +2 -1
  53. package/dist/vector/VectorCanvas.d.cts +11 -1
  54. package/dist/vector/VectorCanvas.d.ts +11 -1
  55. package/dist/vector/index.cjs +946 -826
  56. package/dist/vector/index.js +42 -3
  57. package/dist/video-editor/VideoEditor.d.cts +6 -1
  58. package/dist/video-editor/VideoEditor.d.ts +6 -1
  59. package/dist/video-editor/VideoTimeline.d.cts +11 -1
  60. package/dist/video-editor/VideoTimeline.d.ts +11 -1
  61. package/dist/video-editor/index.cjs +463 -332
  62. package/dist/video-editor/index.js +53 -5
  63. package/package.json +3 -3
@@ -1334,18 +1334,106 @@ var StickerPanel = ({ controller, className }) => {
1334
1334
  };
1335
1335
 
1336
1336
  // src/paint-editor/PaintEditor.tsx
1337
- var import_react17 = require("react");
1337
+ var import_react20 = require("react");
1338
+ var import_paint_editor14 = require("@pixerate/editor/paint-editor");
1339
+
1340
+ // src/playback/AgentPlaybackContext.tsx
1341
+ var import_react11 = require("react");
1342
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1343
+ var AgentPlaybackContext = (0, import_react11.createContext)(null);
1344
+ function useAgentPlayback() {
1345
+ return (0, import_react11.useContext)(AgentPlaybackContext);
1346
+ }
1347
+
1348
+ // src/playback/usePlaybackSurface.ts
1349
+ var import_react12 = require("react");
1350
+ var import_tools = require("@pixerate/editor/tools");
1351
+ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1352
+ const ambient = useAgentPlayback();
1353
+ const target = playback === void 0 ? ambient : playback;
1354
+ const [ownPresence] = (0, import_react12.useState)(() => new import_tools.PresenceStore());
1355
+ const presence = sharedPresence ?? ownPresence;
1356
+ const latest = (0, import_react12.useRef)(options);
1357
+ latest.current = options;
1358
+ (0, import_react12.useEffect)(() => {
1359
+ if (!target || !id) return;
1360
+ const o = () => latest.current;
1361
+ const surface = {
1362
+ presence,
1363
+ locate: (ref) => o().locate?.(ref) ?? null,
1364
+ bounds: () => o().bounds?.() ?? null,
1365
+ visible: () => o().visible?.() ?? true,
1366
+ toViewport: (p) => o().toViewport?.(p) ?? p,
1367
+ fromViewport: (p) => o().fromViewport?.(p) ?? p,
1368
+ beginGesture: (key) => o().beginGesture?.(key),
1369
+ endGesture: () => o().endGesture?.(),
1370
+ reveal: () => o().reveal?.(),
1371
+ open: (ref) => o().open?.(ref),
1372
+ get defaultKind() {
1373
+ return o().defaultKind;
1374
+ }
1375
+ };
1376
+ const detach = target.attach(id, surface);
1377
+ return () => {
1378
+ detach();
1379
+ for (const a of presence.getState().actors) presence.remove(a.id);
1380
+ };
1381
+ }, [target, id, presence]);
1382
+ return presence;
1383
+ }
1384
+
1385
+ // src/playback/PresenceLayer.tsx
1386
+ var import_react13 = __toESM(require("react"), 1);
1387
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1388
+ function PresenceLayer({ presence, viewport, className = "" }) {
1389
+ const { actors } = (0, import_react13.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1390
+ if (!actors.length) return null;
1391
+ const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
1392
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1393
+ "div",
1394
+ {
1395
+ className: `pixerate-presence ${className}`.trim(),
1396
+ "aria-hidden": "true",
1397
+ "data-testid": "presence-layer",
1398
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
1399
+ children: actors.map((a) => {
1400
+ const at = map(a);
1401
+ const ring = a.focus && (() => {
1402
+ const tl = map(a.focus);
1403
+ const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
1404
+ return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
1405
+ })();
1406
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react13.default.Fragment, { children: [
1407
+ ring && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1408
+ "div",
1409
+ {
1410
+ "data-actor-focus": a.id,
1411
+ style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
1412
+ }
1413
+ ),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
1415
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
1416
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
1417
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
1418
+ a.message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
1419
+ ] })
1420
+ ] })
1421
+ ] }, a.id);
1422
+ })
1423
+ }
1424
+ );
1425
+ }
1338
1426
 
1339
1427
  // src/paint-editor/PaintEffectsPanel.tsx
1340
- var import_react16 = require("react");
1428
+ var import_react19 = require("react");
1341
1429
  var import_paint_editor13 = require("@pixerate/editor/paint-editor");
1342
1430
 
1343
1431
  // src/effects/useEffects.ts
1344
- var import_react11 = require("react");
1432
+ var import_react14 = require("react");
1345
1433
  function useEffectDescription(provider, effect) {
1346
- const [state, setState] = (0, import_react11.useState)({ key: "", description: null, error: null });
1434
+ const [state, setState] = (0, import_react14.useState)({ key: "", description: null, error: null });
1347
1435
  const key = provider && effect ? `${provider.id}:${effect}` : "";
1348
- (0, import_react11.useEffect)(() => {
1436
+ (0, import_react14.useEffect)(() => {
1349
1437
  if (!provider || !effect) return;
1350
1438
  let live = true;
1351
1439
  Promise.resolve().then(() => provider.describe(effect)).then(
@@ -1360,13 +1448,13 @@ function useEffectDescription(provider, effect) {
1360
1448
  }
1361
1449
 
1362
1450
  // src/effects/EffectThumbnail.tsx
1363
- var import_react12 = require("react");
1451
+ var import_react15 = require("react");
1364
1452
  var import_effects = require("@pixerate/editor/effects");
1365
- var import_jsx_runtime12 = require("react/jsx-runtime");
1453
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1366
1454
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
1367
- const ref = (0, import_react12.useRef)(null);
1368
- const [failed, setFailed] = (0, import_react12.useState)(effect.kind === "motion");
1369
- (0, import_react12.useEffect)(() => {
1455
+ const ref = (0, import_react15.useRef)(null);
1456
+ const [failed, setFailed] = (0, import_react15.useState)(effect.kind === "motion");
1457
+ (0, import_react15.useEffect)(() => {
1370
1458
  if (effect.kind === "motion") return;
1371
1459
  let live = true;
1372
1460
  (0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
@@ -1381,28 +1469,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
1381
1469
  live = false;
1382
1470
  };
1383
1471
  }, [provider, effect, width, height]);
1384
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1472
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1385
1473
  "div",
1386
1474
  {
1387
1475
  className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
1388
1476
  style: { aspectRatio: `${width} / ${height}` },
1389
1477
  "data-effect-thumbnail": effect.id,
1390
- children: failed ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: effect.kind === "motion" ? "Motion" : "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
1478
+ children: failed ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: effect.kind === "motion" ? "Motion" : "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
1391
1479
  }
1392
1480
  );
1393
1481
  }
1394
1482
 
1395
1483
  // src/effects/EffectsBrowser.tsx
1396
- var import_react13 = require("react");
1484
+ var import_react16 = require("react");
1397
1485
  var import_effects2 = require("@pixerate/editor/effects");
1398
- var import_jsx_runtime13 = require("react/jsx-runtime");
1486
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1399
1487
  function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
1400
- const [all, setAll] = (0, import_react13.useState)([]);
1401
- const [query, setQuery] = (0, import_react13.useState)("");
1402
- const [category, setCategory] = (0, import_react13.useState)("");
1403
- const [use, setUse] = (0, import_react13.useState)("");
1404
- const [error, setError] = (0, import_react13.useState)(null);
1405
- (0, import_react13.useEffect)(() => {
1488
+ const [all, setAll] = (0, import_react16.useState)([]);
1489
+ const [query, setQuery] = (0, import_react16.useState)("");
1490
+ const [category, setCategory] = (0, import_react16.useState)("");
1491
+ const [use, setUse] = (0, import_react16.useState)("");
1492
+ const [error, setError] = (0, import_react16.useState)(null);
1493
+ (0, import_react16.useEffect)(() => {
1406
1494
  if (!provider) return setAll([]);
1407
1495
  let live = true;
1408
1496
  Promise.resolve().then(() => provider.list()).then(
@@ -1413,8 +1501,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1413
1501
  live = false;
1414
1502
  };
1415
1503
  }, [provider]);
1416
- const [found, setFound] = (0, import_react13.useState)([]);
1417
- (0, import_react13.useEffect)(() => {
1504
+ const [found, setFound] = (0, import_react16.useState)([]);
1505
+ (0, import_react16.useEffect)(() => {
1418
1506
  if (!provider) return setFound([]);
1419
1507
  let live = true;
1420
1508
  Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
@@ -1423,14 +1511,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1423
1511
  };
1424
1512
  }, [provider, query, category, use]);
1425
1513
  const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
1426
- const categories = (0, import_react13.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
1514
+ const categories = (0, import_react16.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
1427
1515
  const shown = found.filter(allowed);
1428
1516
  if (!provider)
1429
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
1430
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
1431
- title && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-xs font-semibold", children: title }),
1432
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1433
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
1518
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
1519
+ title && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h3", { className: "text-xs font-semibold", children: title }),
1520
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1521
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1434
1522
  "input",
1435
1523
  {
1436
1524
  type: "search",
@@ -1441,17 +1529,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1441
1529
  onChange: (e) => setQuery(e.currentTarget.value)
1442
1530
  }
1443
1531
  ),
1444
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
1445
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "All categories" }),
1446
- categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: c, children: c }, c))
1532
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
1533
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "All categories" }),
1534
+ categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: c, children: c }, c))
1447
1535
  ] }),
1448
- uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
1449
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "Any use" }),
1450
- uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
1536
+ uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
1537
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "Any use" }),
1538
+ uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
1451
1539
  ] })
1452
1540
  ] }),
1453
- error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
1454
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1541
+ error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1455
1543
  "button",
1456
1544
  {
1457
1545
  type: "button",
@@ -1460,25 +1548,25 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1460
1548
  "data-effect-id": e.id,
1461
1549
  onClick: () => onPick(e),
1462
1550
  children: [
1463
- thumbnails && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectThumbnail, { provider, effect: e }),
1464
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
1465
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
1551
+ thumbnails && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EffectThumbnail, { provider, effect: e }),
1552
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
1466
1554
  ]
1467
1555
  }
1468
1556
  ) }, e.id)) }),
1469
- !shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
1557
+ !shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
1470
1558
  ] });
1471
1559
  }
1472
1560
 
1473
1561
  // src/effects/EffectParameters.tsx
1474
- var import_react15 = __toESM(require("react"), 1);
1562
+ var import_react18 = __toESM(require("react"), 1);
1475
1563
  var import_effects3 = require("@pixerate/editor/effects");
1476
1564
  var import_parameters2 = require("@pixerate/editor/parameters");
1477
1565
 
1478
1566
  // src/parameters/fields.tsx
1479
- var import_react14 = require("react");
1567
+ var import_react17 = require("react");
1480
1568
  var import_parameters = require("@pixerate/editor/parameters");
1481
- var import_jsx_runtime14 = require("react/jsx-runtime");
1569
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1482
1570
  var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
1483
1571
  var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
1484
1572
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
@@ -1502,7 +1590,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
1502
1590
  onKeyDown: keyDown,
1503
1591
  ...rest
1504
1592
  };
1505
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "text", ...props }, value);
1593
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "text", ...props }, value);
1506
1594
  }
1507
1595
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
1508
1596
  function ParameterNumberInput({
@@ -1513,8 +1601,8 @@ function ParameterNumberInput({
1513
1601
  id,
1514
1602
  "aria-label": ariaLabel
1515
1603
  }) {
1516
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1517
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1604
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1605
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1518
1606
  ParameterCommitInput,
1519
1607
  {
1520
1608
  id,
@@ -1536,21 +1624,21 @@ function ParameterNumberInput({
1536
1624
  }
1537
1625
  }
1538
1626
  ),
1539
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1627
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1540
1628
  ] });
1541
1629
  }
1542
1630
  function ParameterSlider(props) {
1543
1631
  const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
1544
- const dragging = (0, import_react14.useRef)(false);
1632
+ const dragging = (0, import_react17.useRef)(false);
1545
1633
  const end = () => {
1546
1634
  if (!dragging.current) return;
1547
1635
  dragging.current = false;
1548
1636
  onGestureEnd?.();
1549
1637
  };
1550
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterNumberInput, { ...props });
1638
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterNumberInput, { ...props });
1551
1639
  const step = (0, import_parameters.parameterStep)(field);
1552
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
1553
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1640
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
1641
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1554
1642
  "input",
1555
1643
  {
1556
1644
  type: "range",
@@ -1573,11 +1661,11 @@ function ParameterSlider(props) {
1573
1661
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
1574
1662
  }
1575
1663
  ),
1576
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
1664
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
1577
1665
  ] });
1578
1666
  }
1579
1667
  function ParameterToggle({ field, value, onChange, disabled, id }) {
1580
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1581
1669
  "button",
1582
1670
  {
1583
1671
  type: "button",
@@ -1588,7 +1676,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
1588
1676
  disabled: disabled || field.readOnly,
1589
1677
  onClick: () => onChange(!value),
1590
1678
  className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
1591
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1679
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1592
1680
  "span",
1593
1681
  {
1594
1682
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -1601,7 +1689,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1601
1689
  const options = (0, import_parameters.getChoiceOptions)(field);
1602
1690
  const off = disabled || field.readOnly;
1603
1691
  if (field.control === "segmented") {
1604
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1692
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1605
1693
  "button",
1606
1694
  {
1607
1695
  type: "button",
@@ -1617,7 +1705,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1617
1705
  )) });
1618
1706
  }
1619
1707
  const index = options.findIndex((o) => o.value === value);
1620
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1708
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1621
1709
  "select",
1622
1710
  {
1623
1711
  id,
@@ -1629,12 +1717,12 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1629
1717
  if (option) onChange(option.value);
1630
1718
  },
1631
1719
  className: parameterInputClass,
1632
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
1720
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
1633
1721
  }
1634
1722
  );
1635
1723
  }
1636
1724
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
1637
- const picking = (0, import_react14.useRef)(false);
1725
+ const picking = (0, import_react17.useRef)(false);
1638
1726
  const alpha = !!field.alpha;
1639
1727
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
1640
1728
  const rgb = hex.slice(0, 7);
@@ -1650,11 +1738,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1650
1738
  picking.current = false;
1651
1739
  onGestureEnd?.();
1652
1740
  };
1653
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1.5", children: [
1654
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
1655
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px]", children: [
1656
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
1657
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1741
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1.5", children: [
1742
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
1743
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px]", children: [
1744
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
1745
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1658
1746
  "input",
1659
1747
  {
1660
1748
  type: "color",
@@ -1670,7 +1758,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1670
1758
  }
1671
1759
  )
1672
1760
  ] }),
1673
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1761
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1674
1762
  ParameterCommitInput,
1675
1763
  {
1676
1764
  id,
@@ -1686,7 +1774,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1686
1774
  }
1687
1775
  )
1688
1776
  ] }),
1689
- alpha && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1777
+ alpha && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1690
1778
  "input",
1691
1779
  {
1692
1780
  type: "range",
@@ -1704,10 +1792,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1704
1792
  onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
1705
1793
  }
1706
1794
  ),
1707
- field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
1795
+ field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
1708
1796
  const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
1709
1797
  if (!swatch) return null;
1710
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1798
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1711
1799
  "button",
1712
1800
  {
1713
1801
  type: "button",
@@ -1726,11 +1814,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1726
1814
  }
1727
1815
  function ParameterVector({ field, value, onChange, disabled, id }) {
1728
1816
  const size = (0, import_parameters.vectorSize)(field);
1729
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1817
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1730
1818
  const component = (0, import_parameters.vectorComponentField)(field, i);
1731
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1732
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1733
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1819
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1820
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1821
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1734
1822
  ParameterNumberInput,
1735
1823
  {
1736
1824
  field: component,
@@ -1747,11 +1835,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
1747
1835
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1748
1836
  const off = disabled || field.readOnly;
1749
1837
  const name = (0, import_parameters.parameterLabel)(field);
1750
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1.5", children: [
1751
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
1752
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1753
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1754
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1838
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1.5", children: [
1839
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
1840
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1841
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1842
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1755
1843
  ParameterCommitInput,
1756
1844
  {
1757
1845
  id,
@@ -1762,10 +1850,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1762
1850
  onCommit: (text) => onChange(text.trim())
1763
1851
  }
1764
1852
  ),
1765
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex gap-1", children: [
1766
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex gap-1", children: [
1854
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1767
1855
  "Choose file\u2026",
1768
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1856
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1769
1857
  "input",
1770
1858
  {
1771
1859
  type: "file",
@@ -1781,11 +1869,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1781
1869
  }
1782
1870
  )
1783
1871
  ] }),
1784
- value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1872
+ value && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1785
1873
  ] })
1786
1874
  ] })
1787
1875
  ] }),
1788
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1876
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1789
1877
  "button",
1790
1878
  {
1791
1879
  type: "button",
@@ -1795,14 +1883,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1795
1883
  disabled: off,
1796
1884
  onClick: () => onChange(o.url),
1797
1885
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
1798
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1886
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1799
1887
  },
1800
1888
  o.url
1801
1889
  )) })
1802
1890
  ] });
1803
1891
  }
1804
1892
  function ParameterText({ field, value, onChange, disabled, id }) {
1805
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1893
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1806
1894
  ParameterCommitInput,
1807
1895
  {
1808
1896
  id,
@@ -1821,31 +1909,31 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
1821
1909
  switch (field.type) {
1822
1910
  case "number":
1823
1911
  case "int":
1824
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1912
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1825
1913
  case "boolean":
1826
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1914
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1827
1915
  case "choice":
1828
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1916
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1829
1917
  case "color":
1830
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1918
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1831
1919
  case "vector":
1832
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1920
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1833
1921
  case "image":
1834
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1922
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1835
1923
  case "text":
1836
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1924
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1837
1925
  }
1838
1926
  }
1839
1927
 
1840
1928
  // src/effects/EffectParameters.tsx
1841
- var import_jsx_runtime15 = require("react/jsx-runtime");
1929
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1842
1930
  function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
1843
- const fields = (0, import_react15.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1844
- const idBase = (0, import_react15.useId)();
1845
- const gesture = import_react15.default.useRef(null);
1846
- const count = import_react15.default.useRef(0);
1847
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1848
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1931
+ const fields = (0, import_react18.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1932
+ const idBase = (0, import_react18.useId)();
1933
+ const gesture = import_react18.default.useRef(null);
1934
+ const count = import_react18.default.useRef(0);
1935
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1936
+ onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1849
1937
  "select",
1850
1938
  {
1851
1939
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -1857,8 +1945,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1857
1945
  if (preset) onPreset({ ...description.defaults, ...preset.values });
1858
1946
  },
1859
1947
  children: [
1860
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "Presets\u2026" }),
1861
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: p.name, children: p.name }, p.name))
1948
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "Presets\u2026" }),
1949
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: p.name, children: p.name }, p.name))
1862
1950
  ]
1863
1951
  }
1864
1952
  ),
@@ -1868,13 +1956,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1868
1956
  const keyed = keyframed?.has(field.id) ?? false;
1869
1957
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
1870
1958
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
1871
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
1872
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1873
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
1874
- keyed && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1875
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
1959
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
1960
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1961
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
1962
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1963
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
1876
1964
  ] }),
1877
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1965
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1878
1966
  ParameterFieldControl,
1879
1967
  {
1880
1968
  field,
@@ -1888,15 +1976,15 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1888
1976
  )
1889
1977
  ] }, field.id);
1890
1978
  }),
1891
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1979
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1892
1980
  ] });
1893
1981
  }
1894
1982
 
1895
1983
  // src/paint-editor/PaintEffectsPanel.tsx
1896
- var import_jsx_runtime16 = require("react/jsx-runtime");
1984
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1897
1985
  function usePaintEffectsProvider(controller) {
1898
- const [provider, setProvider] = (0, import_react16.useState)(controller.effectsProvider);
1899
- (0, import_react16.useEffect)(() => {
1986
+ const [provider, setProvider] = (0, import_react19.useState)(controller.effectsProvider);
1987
+ (0, import_react19.useEffect)(() => {
1900
1988
  setProvider(controller.effectsProvider);
1901
1989
  return controller.effects.subscribe(setProvider);
1902
1990
  }, [controller]);
@@ -1904,27 +1992,27 @@ function usePaintEffectsProvider(controller) {
1904
1992
  }
1905
1993
  function usePaintEffectsTools(registry, controller, options = {}) {
1906
1994
  const { id, namespace, readOnly } = options;
1907
- (0, import_react16.useEffect)(() => {
1995
+ (0, import_react19.useEffect)(() => {
1908
1996
  if (!registry) return;
1909
1997
  return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly }));
1910
1998
  }, [registry, controller, id, namespace, readOnly]);
1911
1999
  }
1912
2000
  function Controls({ provider, effect, name, values, apply }) {
1913
2001
  const { description, error } = useEffectDescription(provider, effect);
1914
- const drags = (0, import_react16.useRef)(/* @__PURE__ */ new Set());
1915
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
2002
+ const drags = (0, import_react19.useRef)(/* @__PURE__ */ new Set());
2003
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
1916
2004
  'No effects provider: "',
1917
2005
  name ?? effect,
1918
2006
  '" is kept as it was drawn.'
1919
2007
  ] });
1920
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
1921
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
2008
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
2009
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1922
2010
  const commit = (gesture) => {
1923
2011
  if (!gesture || drags.current.has(gesture)) return !gesture;
1924
2012
  drags.current.add(gesture);
1925
2013
  return true;
1926
2014
  };
1927
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2015
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1928
2016
  EffectParameters,
1929
2017
  {
1930
2018
  description,
@@ -1945,8 +2033,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1945
2033
  const state = usePaintEditorState(controller);
1946
2034
  const provider = usePaintEffectsProvider(controller);
1947
2035
  const [error, attempt] = useAttempt();
1948
- const [browse, setBrowse] = (0, import_react16.useState)(null);
1949
- const [busy, setBusy] = (0, import_react16.useState)(false);
2036
+ const [browse, setBrowse] = (0, import_react19.useState)(null);
2037
+ const [busy, setBusy] = (0, import_react19.useState)(false);
1950
2038
  const paper = controller.getPaperEffect();
1951
2039
  const activeId = state.document.activeLayerId;
1952
2040
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
@@ -1965,27 +2053,27 @@ var PaintEffectsPanel = ({ controller, className }) => {
1965
2053
  };
1966
2054
  const toggle = (b) => setBrowse(browse === b ? null : b);
1967
2055
  const pixel = active?.type === "pixel";
1968
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
1969
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
1970
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
1971
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1972
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1973
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1974
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
2056
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
2057
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
2058
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
2059
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
2060
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
2061
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
2062
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
1975
2063
  ] }),
1976
- !provider && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1977
- browse && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
1978
- paper && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
1979
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
1980
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex-1 truncate", children: [
2064
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
2065
+ browse && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
2066
+ paper && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
2067
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
2068
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "flex-1 truncate", children: [
1981
2069
  "Paper: ",
1982
2070
  paper.name ?? paper.effect
1983
2071
  ] }),
1984
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
2072
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
1985
2073
  ] }),
1986
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
1987
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
1988
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2074
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1", children: [
2075
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
2076
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1989
2077
  "input",
1990
2078
  {
1991
2079
  type: "range",
@@ -2007,53 +2095,120 @@ var PaintEffectsPanel = ({ controller, className }) => {
2007
2095
  `o${paper.opacity}`
2008
2096
  )
2009
2097
  ] }),
2010
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2011
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
2012
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
2098
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1", children: [
2099
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
2100
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
2013
2101
  const blend = e.currentTarget.value;
2014
2102
  run(() => controller.updatePaperEffect({ blend }));
2015
- }, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: b, children: b }, b)) })
2103
+ }, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: b, children: b }, b)) })
2016
2104
  ] }),
2017
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
2105
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
2018
2106
  ] }),
2019
- layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
2020
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2021
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "flex-1 truncate", children: [
2107
+ layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
2108
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
2109
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "flex-1 truncate", children: [
2022
2110
  "Layer: ",
2023
2111
  layerEffect.name ?? layerEffect.effect
2024
2112
  ] }),
2025
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
2113
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
2026
2114
  ] }),
2027
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
2115
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
2028
2116
  ] }),
2029
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ErrorLine, { error })
2117
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ErrorLine, { error })
2030
2118
  ] });
2031
2119
  };
2032
2120
 
2033
2121
  // src/paint-editor/PaintEditor.tsx
2034
- var import_jsx_runtime17 = require("react/jsx-runtime");
2035
- var PaintEditor = ({ controller, fileName, height = 720, presence, className }) => {
2036
- const [tool, setTool] = (0, import_react17.useState)("brush");
2037
- const [tab, setTab] = (0, import_react17.useState)("color");
2038
- const [error, setError] = (0, import_react17.useState)(null);
2122
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2123
+ var PAINT_CONTROLS = {
2124
+ "mixing-pad": '[data-testid="mixing-pad"]',
2125
+ lighting: '[data-testid="light-panel"]',
2126
+ symmetry: '[aria-label="Symmetry"]'
2127
+ };
2128
+ var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
2129
+ const [tool, setTool] = (0, import_react20.useState)("brush");
2130
+ const [tab, setTab] = (0, import_react20.useState)("color");
2131
+ const tabRef = (0, import_react20.useRef)(tab);
2132
+ tabRef.current = tab;
2133
+ const rootRef = (0, import_react20.useRef)(null);
2134
+ const [ownPresence] = (0, import_react20.useState)(() => new import_paint_editor14.PaintPresence());
2135
+ const ambientPlayback = useAgentPlayback();
2136
+ const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
2137
+ const viewBox = () => {
2138
+ const el = rootRef.current?.querySelector('[data-testid="paint-canvas"]');
2139
+ const r = el?.getBoundingClientRect();
2140
+ return r && r.width > 0 ? r : null;
2141
+ };
2142
+ const docToClient = (p) => {
2143
+ const r = viewBox();
2144
+ if (!r) return null;
2145
+ const q = (0, import_paint_editor14.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
2146
+ return { x: r.left + q.x, y: r.top + q.y };
2147
+ };
2148
+ const clientToDoc = (p) => {
2149
+ const r = viewBox();
2150
+ return r ? (0, import_paint_editor14.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
2151
+ };
2152
+ const elementRect = (selector) => {
2153
+ const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
2154
+ if (!r || r.width <= 0) return null;
2155
+ const c = clientToDoc({ x: r.left + r.width / 2, y: r.top + r.height / 2 });
2156
+ const zoom = controller.getState().view.zoom || 1;
2157
+ return c ? { x: c.x - r.width / zoom / 2, y: c.y - r.height / zoom / 2, width: r.width / zoom, height: r.height / zoom } : null;
2158
+ };
2159
+ const agentPresence = usePlaybackSurface(
2160
+ playing,
2161
+ playbackId,
2162
+ {
2163
+ locate: (ref) => {
2164
+ if (ref.kind === "panel") return elementRect(`[data-paint-tab="${CSS.escape(ref.id)}"]`);
2165
+ if (ref.kind === "panel-body") return elementRect(`[data-paint-panel="${CSS.escape(ref.id)}"]`);
2166
+ if (ref.kind === "control" && PAINT_CONTROLS[ref.id]) return elementRect(PAINT_CONTROLS[ref.id]);
2167
+ return null;
2168
+ },
2169
+ open: async (ref) => {
2170
+ if (ref.kind !== "panel" || tabRef.current === ref.id) return;
2171
+ rootRef.current?.querySelector(`[data-paint-tab="${CSS.escape(ref.id)}"]`)?.click();
2172
+ await new Promise((resolve) => setTimeout(resolve, 60));
2173
+ },
2174
+ bounds: () => ({ x: 0, y: 0, width: controller.document.canvas.width, height: controller.document.canvas.height }),
2175
+ visible: () => {
2176
+ const r = rootRef.current?.getBoundingClientRect();
2177
+ return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
2178
+ },
2179
+ toViewport: (p) => docToClient(p) ?? p,
2180
+ fromViewport: (p) => clientToDoc(p) ?? p,
2181
+ reveal: () => onPlaybackReveal?.()
2182
+ },
2183
+ presence ?? ownPresence
2184
+ );
2185
+ const docToRoot = (p) => {
2186
+ const c = docToClient(p);
2187
+ const box = rootRef.current?.getBoundingClientRect();
2188
+ return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
2189
+ };
2190
+ const [error, setError] = (0, import_react20.useState)(null);
2039
2191
  const effects = usePaintEffectsProvider(controller);
2040
2192
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
2041
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
2042
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
2043
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
2044
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
2045
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
2046
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintCanvas, { controller, tool, onError: setError, presence, className: "flex-1 rounded-lg" }),
2047
- error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
2193
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
2194
+ playing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
2195
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
2196
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
2197
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
2199
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
2200
+ error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
2048
2201
  ] }),
2049
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
2050
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
2051
- tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ColorPanel, { controller }),
2052
- tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(WetPanel, { controller }),
2053
- tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaperPanel, { controller }),
2054
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintLayersPanel, { controller }),
2055
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(StickerPanel, { controller }),
2056
- tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintEffectsPanel, { controller })
2202
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
2203
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
2204
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
2205
+ tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ColorPanel, { controller }),
2206
+ tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(WetPanel, { controller }),
2207
+ tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaperPanel, { controller }),
2208
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaintLayersPanel, { controller }),
2209
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StickerPanel, { controller }),
2210
+ tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaintEffectsPanel, { controller })
2211
+ ] })
2057
2212
  ] })
2058
2213
  ] })
2059
2214
  ] });