@pixerate/editor-react 0.94.0 → 0.96.0

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 (56) hide show
  1. package/README.md +3 -1
  2. package/dist/animation-editor/index.cjs +1240 -195
  3. package/dist/animation-editor/index.js +4 -2
  4. package/dist/canvas/index.cjs +1419 -372
  5. package/dist/canvas/index.js +9 -4
  6. package/dist/canvas/useMermaidDiagram.d.cts +7 -1
  7. package/dist/canvas/useMermaidDiagram.d.ts +7 -1
  8. package/dist/chunk-3I7FOSLF.js +988 -0
  9. package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
  10. package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
  11. package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
  12. package/dist/chunk-KIRIU53A.js +72 -0
  13. package/dist/{chunk-NNM633RN.js → chunk-R7MEGRPV.js} +23 -0
  14. package/dist/color/ColorPicker.d.cts +30 -0
  15. package/dist/color/ColorPicker.d.ts +30 -0
  16. package/dist/color/DualColorPicker.d.cts +29 -0
  17. package/dist/color/DualColorPicker.d.ts +29 -0
  18. package/dist/color/index.cjs +1067 -0
  19. package/dist/color/index.d.cts +7 -0
  20. package/dist/color/index.d.ts +7 -0
  21. package/dist/color/index.js +14 -0
  22. package/dist/color/useColorScheme.d.cts +16 -0
  23. package/dist/color/useColorScheme.d.ts +16 -0
  24. package/dist/effects/index.cjs +1169 -124
  25. package/dist/effects/index.js +4 -2
  26. package/dist/gradient/FillPicker.d.cts +27 -0
  27. package/dist/gradient/FillPicker.d.ts +27 -0
  28. package/dist/gradient/GradientEditor.d.cts +21 -0
  29. package/dist/gradient/GradientEditor.d.ts +21 -0
  30. package/dist/gradient/index.cjs +1601 -0
  31. package/dist/gradient/index.d.cts +6 -0
  32. package/dist/gradient/index.d.ts +6 -0
  33. package/dist/gradient/index.js +617 -0
  34. package/dist/gradient/useGradientController.d.cts +10 -0
  35. package/dist/gradient/useGradientController.d.ts +10 -0
  36. package/dist/image-editor/index.cjs +1742 -697
  37. package/dist/image-editor/index.js +5 -3
  38. package/dist/index.cjs +2181 -1115
  39. package/dist/index.js +9 -5
  40. package/dist/paint-editor/index.cjs +1233 -188
  41. package/dist/paint-editor/index.js +4 -2
  42. package/dist/parameters/fields.d.cts +1 -1
  43. package/dist/parameters/fields.d.ts +1 -1
  44. package/dist/parameters/index.cjs +1218 -173
  45. package/dist/parameters/index.js +3 -1
  46. package/dist/persistence/index.cjs +25 -4
  47. package/dist/persistence/index.d.cts +1 -0
  48. package/dist/persistence/index.d.ts +1 -0
  49. package/dist/persistence/index.js +5 -3
  50. package/dist/persistence/useEditorAutosave.d.cts +17 -0
  51. package/dist/persistence/useEditorAutosave.d.ts +17 -0
  52. package/dist/vector/index.cjs +1219 -174
  53. package/dist/vector/index.js +4 -2
  54. package/dist/video-editor/index.cjs +1230 -185
  55. package/dist/video-editor/index.js +4 -2
  56. package/package.json +29 -3
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -1290,7 +1291,7 @@ function TranscriptPanel({ controller, track, editable = true, className = "" })
1290
1291
  }
1291
1292
 
1292
1293
  // src/video-editor/VideoEditor.tsx
1293
- var import_react17 = require("react");
1294
+ var import_react20 = require("react");
1294
1295
 
1295
1296
  // src/effects/useEffects.ts
1296
1297
  var import_react11 = require("react");
@@ -1429,14 +1430,1055 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1429
1430
  }
1430
1431
 
1431
1432
  // src/effects/EffectParameters.tsx
1432
- var import_react15 = __toESM(require("react"), 1);
1433
+ var import_react18 = __toESM(require("react"), 1);
1433
1434
  var import_effects3 = require("@pixerate/editor/effects");
1434
1435
  var import_parameters2 = require("@pixerate/editor/parameters");
1435
1436
 
1436
1437
  // src/parameters/fields.tsx
1437
- var import_react14 = require("react");
1438
+ var import_react17 = require("react");
1438
1439
  var import_parameters = require("@pixerate/editor/parameters");
1440
+
1441
+ // src/color/index.ts
1442
+ var color_exports = {};
1443
+ __export(color_exports, {
1444
+ ColorPicker: () => ColorPicker,
1445
+ DualColorPicker: () => DualColorPicker,
1446
+ useColorScheme: () => useColorScheme,
1447
+ useResolvedColor: () => useResolvedColor
1448
+ });
1449
+
1450
+ // src/color/ColorPicker.tsx
1451
+ var import_react14 = require("react");
1452
+ var import_color = require("@pixerate/editor/color");
1439
1453
  var import_jsx_runtime12 = require("react/jsx-runtime");
1454
+ var LOCAL_STORAGE_KEY = "pixerate:color:recent";
1455
+ function readLocalRecents() {
1456
+ try {
1457
+ if (typeof localStorage === "undefined") return [];
1458
+ const raw = localStorage.getItem(LOCAL_STORAGE_KEY);
1459
+ if (!raw) return [];
1460
+ const parsed = JSON.parse(raw);
1461
+ return Array.isArray(parsed) ? parsed : [];
1462
+ } catch {
1463
+ return [];
1464
+ }
1465
+ }
1466
+ function writeLocalRecents(list) {
1467
+ try {
1468
+ if (typeof localStorage !== "undefined") {
1469
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(list));
1470
+ }
1471
+ } catch {
1472
+ }
1473
+ }
1474
+ var CHECKERBOARD_BG = "repeating-conic-gradient(var(--pixerate-checker-a, #d4d4d8) 0 25%, var(--pixerate-checker-b, #ffffff) 0 50%)";
1475
+ var DEFAULT_PICKER_STATE = { h: 0, s: 1, v: 1, alpha: 1 };
1476
+ var ColorPicker = ({
1477
+ value,
1478
+ onChange,
1479
+ onGestureStart,
1480
+ onGestureEnd,
1481
+ alpha = false,
1482
+ swatches,
1483
+ recent: controlledRecent,
1484
+ onRecentChange,
1485
+ contrastAgainst,
1486
+ disabled = false,
1487
+ className,
1488
+ id,
1489
+ "aria-label": ariaLabel = "Color picker"
1490
+ }) => {
1491
+ const generatedId = (0, import_react14.useId)();
1492
+ const pickerId = id || generatedId;
1493
+ const [pickerState, setPickerState] = (0, import_react14.useState)(
1494
+ () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
1495
+ );
1496
+ const stateRef = (0, import_react14.useRef)(pickerState);
1497
+ stateRef.current = pickerState;
1498
+ (0, import_react14.useEffect)(() => {
1499
+ const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
1500
+ if (next) {
1501
+ setPickerState(next);
1502
+ }
1503
+ }, [value]);
1504
+ const [internalRecent, setInternalRecent] = (0, import_react14.useState)(
1505
+ () => controlledRecent ? [] : readLocalRecents()
1506
+ );
1507
+ const activeRecent = controlledRecent ?? internalRecent;
1508
+ const recordRecent = (0, import_react14.useCallback)(
1509
+ (color) => {
1510
+ const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
1511
+ if (!controlledRecent) {
1512
+ setInternalRecent(updated);
1513
+ writeLocalRecents(updated);
1514
+ }
1515
+ onRecentChange?.(updated);
1516
+ },
1517
+ [activeRecent, controlledRecent, onRecentChange]
1518
+ );
1519
+ const [textDraft, setTextDraft] = (0, import_react14.useState)(value);
1520
+ const [isInvalid, setIsInvalid] = (0, import_react14.useState)(false);
1521
+ const [isClipped, setIsClipped] = (0, import_react14.useState)(false);
1522
+ const isTypingRef = (0, import_react14.useRef)(false);
1523
+ (0, import_react14.useEffect)(() => {
1524
+ if (!isTypingRef.current) {
1525
+ setTextDraft(value);
1526
+ setIsInvalid(false);
1527
+ const parsed = (0, import_color.parseColor)(value);
1528
+ setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
1529
+ }
1530
+ }, [value]);
1531
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react14.useState)(false);
1532
+ (0, import_react14.useEffect)(() => {
1533
+ setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
1534
+ }, []);
1535
+ const emitColorChange = (0, import_react14.useCallback)(
1536
+ (nextState) => {
1537
+ setPickerState(nextState);
1538
+ const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
1539
+ onChange(hex);
1540
+ },
1541
+ [alpha, onChange]
1542
+ );
1543
+ const latest = (0, import_react14.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
1544
+ latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
1545
+ const endDragRef = (0, import_react14.useRef)(null);
1546
+ (0, import_react14.useEffect)(() => () => endDragRef.current?.(), []);
1547
+ const startDrag = (e, next) => {
1548
+ if (disabled) return;
1549
+ e.preventDefault();
1550
+ endDragRef.current?.();
1551
+ onGestureStart?.();
1552
+ const rect = e.currentTarget.getBoundingClientRect();
1553
+ const update = (clientX, clientY) => {
1554
+ const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
1555
+ const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
1556
+ latest.current.emitColorChange(next(stateRef.current, x, y));
1557
+ };
1558
+ update(e.clientX, e.clientY);
1559
+ const onPointerMove = (ev) => update(ev.clientX, ev.clientY);
1560
+ const end = () => {
1561
+ window.removeEventListener("pointermove", onPointerMove);
1562
+ window.removeEventListener("pointerup", onPointerUp);
1563
+ window.removeEventListener("pointercancel", onPointerUp);
1564
+ endDragRef.current = null;
1565
+ latest.current.onGestureEnd?.();
1566
+ };
1567
+ const onPointerUp = () => {
1568
+ end();
1569
+ latest.current.recordRecent((0, import_color.pickerStateToHex)(stateRef.current, latest.current.alpha));
1570
+ };
1571
+ endDragRef.current = end;
1572
+ window.addEventListener("pointermove", onPointerMove);
1573
+ window.addEventListener("pointerup", onPointerUp);
1574
+ window.addEventListener("pointercancel", onPointerUp);
1575
+ };
1576
+ const handleAreaPointerDown = (e) => startDrag(e, (state, x, y) => (0, import_color.pickerStateFromArea)(state, x, y));
1577
+ const handleHuePointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromHue)(state, x));
1578
+ const handleAlphaPointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromAlpha)(state, x));
1579
+ const handleAreaKeyDown = (e) => {
1580
+ if (disabled) return;
1581
+ const next = (0, import_color.pickerKeyStep)(pickerState, "area", e.key, e.shiftKey);
1582
+ if (next) {
1583
+ e.preventDefault();
1584
+ emitColorChange(next);
1585
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1586
+ }
1587
+ };
1588
+ const handleHueKeyDown = (e) => {
1589
+ if (disabled) return;
1590
+ const next = (0, import_color.pickerKeyStep)(pickerState, "hue", e.key, e.shiftKey);
1591
+ if (next) {
1592
+ e.preventDefault();
1593
+ emitColorChange(next);
1594
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1595
+ }
1596
+ };
1597
+ const handleAlphaKeyDown = (e) => {
1598
+ if (disabled) return;
1599
+ const next = (0, import_color.pickerKeyStep)(pickerState, "alpha", e.key, e.shiftKey);
1600
+ if (next) {
1601
+ e.preventDefault();
1602
+ emitColorChange(next);
1603
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1604
+ }
1605
+ };
1606
+ const commitTextInput = (inputElement) => {
1607
+ isTypingRef.current = false;
1608
+ const parsed = (0, import_color.parseColor)(textDraft);
1609
+ if (parsed) {
1610
+ setIsInvalid(false);
1611
+ setIsClipped(!(0, import_color.inSrgbGamut)(parsed));
1612
+ const formatted = (0, import_color.formatHex)(parsed);
1613
+ onChange(formatted);
1614
+ recordRecent(formatted);
1615
+ } else {
1616
+ setIsInvalid(true);
1617
+ setTextDraft(value);
1618
+ if (inputElement) {
1619
+ inputElement.value = value;
1620
+ }
1621
+ }
1622
+ };
1623
+ const handleTextKeyDown = (e) => {
1624
+ if (e.key === "Enter") {
1625
+ e.preventDefault();
1626
+ commitTextInput(e.currentTarget);
1627
+ } else if (e.key === "Escape") {
1628
+ e.preventDefault();
1629
+ isTypingRef.current = false;
1630
+ setIsInvalid(false);
1631
+ setTextDraft(value);
1632
+ e.currentTarget.value = value;
1633
+ }
1634
+ };
1635
+ const handleEyeDropper = async () => {
1636
+ if (disabled || !hasEyeDropper) return;
1637
+ try {
1638
+ const EyeDropperClass = window.EyeDropper;
1639
+ const eyeDropper = new EyeDropperClass();
1640
+ const res = await eyeDropper.open();
1641
+ if (res?.sRGBHex) {
1642
+ onChange(res.sRGBHex);
1643
+ recordRecent(res.sRGBHex);
1644
+ }
1645
+ } catch {
1646
+ }
1647
+ };
1648
+ const contrastResult = (0, import_react14.useMemo)(() => {
1649
+ if (!contrastAgainst) return null;
1650
+ const fg = (0, import_color.parseColor)(value);
1651
+ const bg = (0, import_color.parseColor)(contrastAgainst);
1652
+ if (!fg || !bg) return null;
1653
+ const ratio = (0, import_color.contrastRatio)(fg, bg);
1654
+ const aa = ratio >= 4.5;
1655
+ const aaa = ratio >= 7;
1656
+ return { ratio, aa, aaa };
1657
+ }, [value, contrastAgainst]);
1658
+ const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
1659
+ const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
1660
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1661
+ "div",
1662
+ {
1663
+ id: pickerId,
1664
+ role: "group",
1665
+ "aria-label": ariaLabel,
1666
+ className,
1667
+ style: {
1668
+ boxSizing: "border-box",
1669
+ width: "var(--pixerate-color-picker-width, 240px)",
1670
+ borderRadius: "var(--pixerate-color-picker-radius, 8px)",
1671
+ background: "var(--pixerate-color-picker-bg, #1f2430)",
1672
+ color: "var(--pixerate-color-picker-fg, #f0f2f5)",
1673
+ padding: "12px",
1674
+ display: "flex",
1675
+ flexDirection: "column",
1676
+ gap: "10px",
1677
+ fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
1678
+ fontSize: "12px",
1679
+ userSelect: "none",
1680
+ opacity: disabled ? 0.6 : 1,
1681
+ pointerEvents: disabled ? "none" : "auto"
1682
+ },
1683
+ children: [
1684
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1685
+ "span",
1686
+ {
1687
+ role: "status",
1688
+ "aria-live": "polite",
1689
+ style: {
1690
+ position: "absolute",
1691
+ width: "1px",
1692
+ height: "1px",
1693
+ padding: 0,
1694
+ margin: "-1px",
1695
+ overflow: "hidden",
1696
+ clip: "rect(0, 0, 0, 0)",
1697
+ whiteSpace: "nowrap",
1698
+ border: 0
1699
+ },
1700
+ children: liveDescription
1701
+ }
1702
+ ),
1703
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1704
+ "div",
1705
+ {
1706
+ role: "slider",
1707
+ tabIndex: disabled ? -1 : 0,
1708
+ "aria-label": "Saturation and brightness",
1709
+ "aria-valuetext": `Saturation ${Math.round(pickerState.s * 100)}%, Brightness ${Math.round(
1710
+ pickerState.v * 100
1711
+ )}%`,
1712
+ "aria-disabled": disabled,
1713
+ onPointerDown: handleAreaPointerDown,
1714
+ onKeyDown: handleAreaKeyDown,
1715
+ style: {
1716
+ position: "relative",
1717
+ width: "100%",
1718
+ height: "150px",
1719
+ borderRadius: "6px",
1720
+ background: (0, import_color.pickerAreaBackground)(pickerState),
1721
+ cursor: disabled ? "default" : "crosshair",
1722
+ touchAction: "none",
1723
+ outline: "none"
1724
+ },
1725
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1726
+ "div",
1727
+ {
1728
+ style: {
1729
+ position: "absolute",
1730
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1731
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1732
+ borderRadius: "50%",
1733
+ transform: "translate(-50%, -50%)",
1734
+ left: `${pickerState.s * 100}%`,
1735
+ top: `${(1 - pickerState.v) * 100}%`,
1736
+ border: "2px solid #ffffff",
1737
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1738
+ pointerEvents: "none",
1739
+ backgroundColor: currentHex
1740
+ }
1741
+ }
1742
+ )
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1746
+ "div",
1747
+ {
1748
+ role: "slider",
1749
+ tabIndex: disabled ? -1 : 0,
1750
+ "aria-label": "Hue",
1751
+ "aria-valuenow": Math.round(pickerState.h),
1752
+ "aria-valuemin": 0,
1753
+ "aria-valuemax": 360,
1754
+ "aria-valuetext": `${Math.round(pickerState.h)} degrees`,
1755
+ "aria-disabled": disabled,
1756
+ onPointerDown: handleHuePointerDown,
1757
+ onKeyDown: handleHueKeyDown,
1758
+ style: {
1759
+ position: "relative",
1760
+ width: "100%",
1761
+ height: "12px",
1762
+ borderRadius: "6px",
1763
+ background: import_color.PICKER_HUE_BACKGROUND,
1764
+ cursor: disabled ? "default" : "pointer",
1765
+ touchAction: "none",
1766
+ outline: "none"
1767
+ },
1768
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1769
+ "div",
1770
+ {
1771
+ style: {
1772
+ position: "absolute",
1773
+ top: "50%",
1774
+ transform: "translate(-50%, -50%)",
1775
+ left: `${pickerState.h / 360 * 100}%`,
1776
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1777
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1778
+ borderRadius: "50%",
1779
+ border: "2px solid #ffffff",
1780
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1781
+ pointerEvents: "none",
1782
+ backgroundColor: `hsl(${pickerState.h}, 100%, 50%)`
1783
+ }
1784
+ }
1785
+ )
1786
+ }
1787
+ ),
1788
+ alpha && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1789
+ "div",
1790
+ {
1791
+ role: "slider",
1792
+ tabIndex: disabled ? -1 : 0,
1793
+ "aria-label": "Alpha",
1794
+ "aria-valuenow": Math.round(pickerState.alpha * 100),
1795
+ "aria-valuemin": 0,
1796
+ "aria-valuemax": 100,
1797
+ "aria-valuetext": `${Math.round(pickerState.alpha * 100)}%`,
1798
+ "aria-disabled": disabled,
1799
+ onPointerDown: handleAlphaPointerDown,
1800
+ onKeyDown: handleAlphaKeyDown,
1801
+ style: {
1802
+ position: "relative",
1803
+ width: "100%",
1804
+ height: "12px",
1805
+ borderRadius: "6px",
1806
+ backgroundImage: CHECKERBOARD_BG,
1807
+ backgroundSize: "8px 8px",
1808
+ cursor: disabled ? "default" : "pointer",
1809
+ touchAction: "none",
1810
+ outline: "none",
1811
+ overflow: "hidden"
1812
+ },
1813
+ children: [
1814
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1815
+ "div",
1816
+ {
1817
+ style: {
1818
+ position: "absolute",
1819
+ inset: 0,
1820
+ background: (0, import_color.pickerAlphaBackground)(pickerState)
1821
+ }
1822
+ }
1823
+ ),
1824
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1825
+ "div",
1826
+ {
1827
+ style: {
1828
+ position: "absolute",
1829
+ top: "50%",
1830
+ transform: "translate(-50%, -50%)",
1831
+ left: `${pickerState.alpha * 100}%`,
1832
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1833
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1834
+ borderRadius: "50%",
1835
+ border: "2px solid #ffffff",
1836
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1837
+ pointerEvents: "none",
1838
+ backgroundColor: currentHex
1839
+ }
1840
+ }
1841
+ )
1842
+ ]
1843
+ }
1844
+ ),
1845
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
1846
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1847
+ "div",
1848
+ {
1849
+ style: {
1850
+ position: "relative",
1851
+ width: "28px",
1852
+ height: "28px",
1853
+ borderRadius: "4px",
1854
+ backgroundImage: CHECKERBOARD_BG,
1855
+ backgroundSize: "8px 8px",
1856
+ overflow: "hidden",
1857
+ flexShrink: 0,
1858
+ border: "1px solid rgba(255,255,255,0.15)"
1859
+ },
1860
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1861
+ "div",
1862
+ {
1863
+ style: {
1864
+ width: "100%",
1865
+ height: "100%",
1866
+ backgroundColor: currentHex
1867
+ }
1868
+ }
1869
+ )
1870
+ }
1871
+ ),
1872
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1873
+ "input",
1874
+ {
1875
+ type: "text",
1876
+ value: textDraft,
1877
+ disabled,
1878
+ "aria-label": "Color hex or CSS string",
1879
+ "aria-invalid": isInvalid ? "true" : void 0,
1880
+ onChange: (e) => {
1881
+ isTypingRef.current = true;
1882
+ setTextDraft(e.target.value);
1883
+ setIsInvalid(false);
1884
+ },
1885
+ onKeyDown: handleTextKeyDown,
1886
+ onBlur: (e) => commitTextInput(e.currentTarget),
1887
+ style: {
1888
+ flex: 1,
1889
+ minWidth: 0,
1890
+ height: "28px",
1891
+ padding: "0 8px",
1892
+ fontSize: "12px",
1893
+ fontFamily: "monospace",
1894
+ borderRadius: "4px",
1895
+ border: isInvalid ? "1px solid #ef4444" : "1px solid rgba(255,255,255,0.2)",
1896
+ background: "rgba(0,0,0,0.2)",
1897
+ color: "inherit",
1898
+ outline: "none"
1899
+ }
1900
+ }
1901
+ ),
1902
+ hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1903
+ "button",
1904
+ {
1905
+ type: "button",
1906
+ disabled,
1907
+ "aria-label": "Pick color from screen",
1908
+ title: "Pick color from screen",
1909
+ onClick: handleEyeDropper,
1910
+ style: {
1911
+ display: "inline-flex",
1912
+ alignItems: "center",
1913
+ justifyContent: "center",
1914
+ width: "28px",
1915
+ height: "28px",
1916
+ borderRadius: "4px",
1917
+ border: "1px solid rgba(255,255,255,0.2)",
1918
+ background: "transparent",
1919
+ color: "inherit",
1920
+ cursor: disabled ? "default" : "pointer"
1921
+ },
1922
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1923
+ "svg",
1924
+ {
1925
+ width: "14",
1926
+ height: "14",
1927
+ viewBox: "0 0 24 24",
1928
+ fill: "none",
1929
+ stroke: "currentColor",
1930
+ strokeWidth: "2",
1931
+ strokeLinecap: "round",
1932
+ strokeLinejoin: "round",
1933
+ children: [
1934
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
1935
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
1936
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "m14 6 4 4" })
1937
+ ]
1938
+ }
1939
+ )
1940
+ }
1941
+ )
1942
+ ] }),
1943
+ isClipped && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1944
+ "div",
1945
+ {
1946
+ role: "note",
1947
+ title: "This colour was outside standard sRGB and clipped.",
1948
+ style: {
1949
+ display: "inline-flex",
1950
+ alignItems: "center",
1951
+ gap: "4px",
1952
+ fontSize: "10px",
1953
+ color: "#f59e0b",
1954
+ background: "rgba(245, 158, 11, 0.1)",
1955
+ padding: "2px 6px",
1956
+ borderRadius: "4px",
1957
+ alignSelf: "flex-start"
1958
+ },
1959
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
1960
+ }
1961
+ ),
1962
+ contrastResult && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1963
+ "div",
1964
+ {
1965
+ style: {
1966
+ display: "flex",
1967
+ alignItems: "center",
1968
+ justifyContent: "space-between",
1969
+ fontSize: "11px",
1970
+ padding: "4px 8px",
1971
+ borderRadius: "4px",
1972
+ background: "rgba(255,255,255,0.05)",
1973
+ border: "1px solid rgba(255,255,255,0.1)"
1974
+ },
1975
+ children: [
1976
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
1977
+ "Contrast: ",
1978
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("strong", { children: [
1979
+ contrastResult.ratio.toFixed(2),
1980
+ ":1"
1981
+ ] })
1982
+ ] }),
1983
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
1984
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1985
+ "span",
1986
+ {
1987
+ style: {
1988
+ color: contrastResult.aa ? "#10b981" : "#ef4444",
1989
+ fontWeight: 600
1990
+ },
1991
+ children: [
1992
+ "AA ",
1993
+ contrastResult.aa ? "\u2713" : "\u2717"
1994
+ ]
1995
+ }
1996
+ ),
1997
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1998
+ "span",
1999
+ {
2000
+ style: {
2001
+ color: contrastResult.aaa ? "#10b981" : "#ef4444",
2002
+ fontWeight: 600
2003
+ },
2004
+ children: [
2005
+ "AAA ",
2006
+ contrastResult.aaa ? "\u2713" : "\u2717"
2007
+ ]
2008
+ }
2009
+ )
2010
+ ] })
2011
+ ]
2012
+ }
2013
+ ),
2014
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2015
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
2016
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2017
+ "button",
2018
+ {
2019
+ type: "button",
2020
+ "data-testid": "color-picker-swatch",
2021
+ title: color,
2022
+ disabled,
2023
+ "aria-label": `Color ${color}`,
2024
+ onClick: () => {
2025
+ onChange(color);
2026
+ recordRecent(color);
2027
+ },
2028
+ style: {
2029
+ width: "18px",
2030
+ height: "18px",
2031
+ borderRadius: "3px",
2032
+ backgroundColor: color,
2033
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
2034
+ cursor: disabled ? "default" : "pointer",
2035
+ padding: 0,
2036
+ outline: "none"
2037
+ }
2038
+ },
2039
+ `${color}-${idx}`
2040
+ )) })
2041
+ ] }),
2042
+ activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2043
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
2044
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2045
+ "button",
2046
+ {
2047
+ type: "button",
2048
+ "data-testid": "color-picker-recent",
2049
+ disabled,
2050
+ "aria-label": `Color ${color}`,
2051
+ onClick: () => {
2052
+ onChange(color);
2053
+ recordRecent(color);
2054
+ },
2055
+ style: {
2056
+ width: "18px",
2057
+ height: "18px",
2058
+ borderRadius: "3px",
2059
+ backgroundColor: color,
2060
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
2061
+ cursor: disabled ? "default" : "pointer",
2062
+ padding: 0,
2063
+ outline: "none"
2064
+ }
2065
+ },
2066
+ `recent-${color}-${idx}`
2067
+ )) })
2068
+ ] })
2069
+ ]
2070
+ }
2071
+ );
2072
+ };
2073
+
2074
+ // src/color/DualColorPicker.tsx
2075
+ var import_react15 = require("react");
2076
+ var import_color2 = require("@pixerate/editor/color");
2077
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2078
+ function DualColorPicker({
2079
+ value,
2080
+ onChange,
2081
+ onGestureStart,
2082
+ onGestureEnd,
2083
+ scheme: controlledScheme,
2084
+ onSchemeChange,
2085
+ surfaces = import_color2.DEFAULT_SCHEME_SURFACES,
2086
+ contrastAgainst,
2087
+ alpha = false,
2088
+ swatches,
2089
+ disabled = false,
2090
+ className = ""
2091
+ }) {
2092
+ const sameId = (0, import_react15.useId)();
2093
+ const [internalScheme, setInternalScheme] = (0, import_react15.useState)("light");
2094
+ const activeScheme = controlledScheme ?? internalScheme;
2095
+ const handleSchemeSelect = (nextScheme) => {
2096
+ if (onSchemeChange) {
2097
+ onSchemeChange(nextScheme);
2098
+ } else {
2099
+ setInternalScheme(nextScheme);
2100
+ }
2101
+ };
2102
+ const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
2103
+ const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
2104
+ const [sameInBoth, setSameInBoth] = (0, import_react15.useState)(isSame);
2105
+ const handleSameToggle = (e) => {
2106
+ const nextSame = e.target.checked;
2107
+ setSameInBoth(nextSame);
2108
+ if (nextSame) {
2109
+ const activeVal = activeScheme === "dark" ? dual.dark : dual.light;
2110
+ onChange({ light: activeVal, dark: activeVal });
2111
+ }
2112
+ };
2113
+ const handleDerive = () => {
2114
+ if (disabled) return;
2115
+ onGestureStart?.();
2116
+ const currentActive = activeScheme === "dark" ? dual.dark : dual.light;
2117
+ const derived = (0, import_color2.deriveDualColor)(currentActive, {
2118
+ from: activeScheme,
2119
+ // An unreadable surfaces prop falls back to the defaults rather than throwing.
2120
+ surfaces: (0, import_color2.normalizeDualColor)(surfaces) ?? import_color2.DEFAULT_SCHEME_SURFACES
2121
+ });
2122
+ onChange(derived);
2123
+ onGestureEnd?.();
2124
+ };
2125
+ const handleInnerChange = (hex) => {
2126
+ if (sameInBoth) {
2127
+ onChange({ light: hex, dark: hex });
2128
+ } else {
2129
+ const updated = (0, import_color2.setDualColorSide)(dual, activeScheme, hex);
2130
+ onChange(updated);
2131
+ }
2132
+ };
2133
+ const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
2134
+ const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
2135
+ const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
2136
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2137
+ "div",
2138
+ {
2139
+ className: `pixerate-dual-color-picker ${className}`,
2140
+ style: {
2141
+ display: "flex",
2142
+ flexDirection: "column",
2143
+ gap: "12px",
2144
+ padding: "12px",
2145
+ background: "#1a1d24",
2146
+ color: "#e2e8f0",
2147
+ borderRadius: "10px",
2148
+ boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
2149
+ width: "260px",
2150
+ fontFamily: "system-ui, -apple-system, sans-serif",
2151
+ fontSize: "13px",
2152
+ boxSizing: "border-box"
2153
+ },
2154
+ children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2156
+ "div",
2157
+ {
2158
+ role: "tablist",
2159
+ "aria-label": "Color scheme mode",
2160
+ style: {
2161
+ display: "flex",
2162
+ background: "#111318",
2163
+ borderRadius: "6px",
2164
+ padding: "2px",
2165
+ gap: "2px"
2166
+ },
2167
+ children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2169
+ "button",
2170
+ {
2171
+ type: "button",
2172
+ role: "tab",
2173
+ "aria-selected": activeScheme === "light",
2174
+ onClick: () => handleSchemeSelect("light"),
2175
+ disabled,
2176
+ style: {
2177
+ flex: 1,
2178
+ padding: "6px 8px",
2179
+ border: "none",
2180
+ borderRadius: "4px",
2181
+ background: activeScheme === "light" ? "#2d3342" : "transparent",
2182
+ color: activeScheme === "light" ? "#ffffff" : "#8c95a6",
2183
+ fontWeight: activeScheme === "light" ? 600 : 400,
2184
+ cursor: disabled ? "not-allowed" : "pointer",
2185
+ fontSize: "12px",
2186
+ transition: "all 0.15s ease"
2187
+ },
2188
+ children: "Light"
2189
+ }
2190
+ ),
2191
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2192
+ "button",
2193
+ {
2194
+ type: "button",
2195
+ role: "tab",
2196
+ "aria-selected": activeScheme === "dark",
2197
+ onClick: () => handleSchemeSelect("dark"),
2198
+ disabled,
2199
+ style: {
2200
+ flex: 1,
2201
+ padding: "6px 8px",
2202
+ border: "none",
2203
+ borderRadius: "4px",
2204
+ background: activeScheme === "dark" ? "#2d3342" : "transparent",
2205
+ color: activeScheme === "dark" ? "#ffffff" : "#8c95a6",
2206
+ fontWeight: activeScheme === "dark" ? 600 : 400,
2207
+ cursor: disabled ? "not-allowed" : "pointer",
2208
+ fontSize: "12px",
2209
+ transition: "all 0.15s ease"
2210
+ },
2211
+ children: "Dark"
2212
+ }
2213
+ )
2214
+ ]
2215
+ }
2216
+ ),
2217
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
2218
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2219
+ "button",
2220
+ {
2221
+ type: "button",
2222
+ onClick: () => handleSchemeSelect("light"),
2223
+ disabled,
2224
+ title: "Edit light mode colour",
2225
+ style: {
2226
+ flex: 1,
2227
+ display: "flex",
2228
+ flexDirection: "column",
2229
+ alignItems: "center",
2230
+ gap: "6px",
2231
+ padding: "8px",
2232
+ background: surfaces.light,
2233
+ color: "#000000",
2234
+ border: activeScheme === "light" ? "2px solid #3b82f6" : "1px solid #333842",
2235
+ borderRadius: "6px",
2236
+ cursor: disabled ? "not-allowed" : "pointer",
2237
+ outline: "none"
2238
+ },
2239
+ children: [
2240
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2241
+ "span",
2242
+ {
2243
+ style: {
2244
+ width: "100%",
2245
+ height: "24px",
2246
+ borderRadius: "4px",
2247
+ background: dual.light,
2248
+ border: "1px solid rgba(0,0,0,0.15)"
2249
+ }
2250
+ }
2251
+ ),
2252
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
2253
+ ]
2254
+ }
2255
+ ),
2256
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2257
+ "button",
2258
+ {
2259
+ type: "button",
2260
+ onClick: () => handleSchemeSelect("dark"),
2261
+ disabled,
2262
+ title: "Edit dark mode colour",
2263
+ style: {
2264
+ flex: 1,
2265
+ display: "flex",
2266
+ flexDirection: "column",
2267
+ alignItems: "center",
2268
+ gap: "6px",
2269
+ padding: "8px",
2270
+ background: surfaces.dark,
2271
+ color: "#ffffff",
2272
+ border: activeScheme === "dark" ? "2px solid #3b82f6" : "1px solid #333842",
2273
+ borderRadius: "6px",
2274
+ cursor: disabled ? "not-allowed" : "pointer",
2275
+ outline: "none"
2276
+ },
2277
+ children: [
2278
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2279
+ "span",
2280
+ {
2281
+ style: {
2282
+ width: "100%",
2283
+ height: "24px",
2284
+ borderRadius: "4px",
2285
+ background: dual.dark,
2286
+ border: "1px solid rgba(255,255,255,0.15)"
2287
+ }
2288
+ }
2289
+ ),
2290
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
2291
+ ]
2292
+ }
2293
+ )
2294
+ ] }),
2295
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2296
+ "div",
2297
+ {
2298
+ style: {
2299
+ display: "flex",
2300
+ alignItems: "center",
2301
+ justifyContent: "space-between",
2302
+ gap: "8px",
2303
+ padding: "2px 0"
2304
+ },
2305
+ children: [
2306
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2307
+ "label",
2308
+ {
2309
+ htmlFor: sameId,
2310
+ style: {
2311
+ display: "flex",
2312
+ alignItems: "center",
2313
+ gap: "6px",
2314
+ cursor: disabled ? "not-allowed" : "pointer",
2315
+ userSelect: "none",
2316
+ fontSize: "12px",
2317
+ color: "#c4cad4"
2318
+ },
2319
+ children: [
2320
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2321
+ "input",
2322
+ {
2323
+ id: sameId,
2324
+ type: "checkbox",
2325
+ checked: sameInBoth,
2326
+ onChange: handleSameToggle,
2327
+ disabled,
2328
+ style: { cursor: disabled ? "not-allowed" : "pointer" }
2329
+ }
2330
+ ),
2331
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: "Same in both" })
2332
+ ]
2333
+ }
2334
+ ),
2335
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2336
+ "button",
2337
+ {
2338
+ type: "button",
2339
+ onClick: handleDerive,
2340
+ disabled,
2341
+ style: {
2342
+ padding: "4px 10px",
2343
+ background: "#2d3342",
2344
+ color: "#e2e8f0",
2345
+ border: "1px solid #3b4252",
2346
+ borderRadius: "4px",
2347
+ fontSize: "11px",
2348
+ fontWeight: 500,
2349
+ cursor: disabled ? "not-allowed" : "pointer"
2350
+ },
2351
+ children: "Derive"
2352
+ }
2353
+ )
2354
+ ]
2355
+ }
2356
+ ),
2357
+ dualContrast && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2358
+ "div",
2359
+ {
2360
+ "data-testid": "dual-contrast-summary",
2361
+ style: {
2362
+ display: "flex",
2363
+ justifyContent: "space-between",
2364
+ background: "#111318",
2365
+ padding: "6px 8px",
2366
+ borderRadius: "6px",
2367
+ fontSize: "11px",
2368
+ color: "#8c95a6"
2369
+ },
2370
+ children: [
2371
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
2372
+ "Light:",
2373
+ " ",
2374
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2375
+ dualContrast.light.ratio.toFixed(2),
2376
+ " (",
2377
+ dualContrast.light.level,
2378
+ ")"
2379
+ ] })
2380
+ ] }),
2381
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
2382
+ "Dark:",
2383
+ " ",
2384
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2385
+ dualContrast.dark.ratio.toFixed(2),
2386
+ " (",
2387
+ dualContrast.dark.level,
2388
+ ")"
2389
+ ] })
2390
+ ] })
2391
+ ]
2392
+ }
2393
+ ),
2394
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2395
+ ColorPicker,
2396
+ {
2397
+ value: activeColor,
2398
+ onChange: handleInnerChange,
2399
+ onGestureStart,
2400
+ onGestureEnd,
2401
+ contrastAgainst: activeContrastTarget,
2402
+ alpha,
2403
+ swatches,
2404
+ disabled
2405
+ }
2406
+ )
2407
+ ]
2408
+ }
2409
+ );
2410
+ }
2411
+
2412
+ // src/color/useColorScheme.ts
2413
+ var import_react16 = require("react");
2414
+ var import_color3 = require("@pixerate/editor/color");
2415
+ function getSnapshot(attribute) {
2416
+ if (typeof window === "undefined" || typeof document === "undefined") {
2417
+ return "light";
2418
+ }
2419
+ if (attribute) {
2420
+ const el = document.documentElement;
2421
+ if (attribute === "class") {
2422
+ return el.classList.contains("dark") ? "dark" : "light";
2423
+ }
2424
+ const val = el.getAttribute(attribute);
2425
+ return val === "dark" ? "dark" : "light";
2426
+ }
2427
+ if (typeof window.matchMedia === "function") {
2428
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
2429
+ }
2430
+ return "light";
2431
+ }
2432
+ function getServerSnapshot() {
2433
+ return "light";
2434
+ }
2435
+ function useColorScheme(options) {
2436
+ const override = options?.override;
2437
+ const attribute = options?.attribute;
2438
+ const subscribe = (0, import_react16.useMemo)(() => {
2439
+ return (callback) => {
2440
+ if (typeof window === "undefined" || typeof document === "undefined") {
2441
+ return () => {
2442
+ };
2443
+ }
2444
+ if (attribute) {
2445
+ const observer = new MutationObserver(() => {
2446
+ callback();
2447
+ });
2448
+ observer.observe(document.documentElement, {
2449
+ attributes: true,
2450
+ attributeFilter: [attribute]
2451
+ });
2452
+ return () => observer.disconnect();
2453
+ }
2454
+ if (typeof window.matchMedia === "function") {
2455
+ const mql = window.matchMedia("(prefers-color-scheme: dark)");
2456
+ const handler = () => callback();
2457
+ mql.addEventListener("change", handler);
2458
+ return () => mql.removeEventListener("change", handler);
2459
+ }
2460
+ return () => {
2461
+ };
2462
+ };
2463
+ }, [attribute]);
2464
+ const detected = (0, import_react16.useSyncExternalStore)(
2465
+ subscribe,
2466
+ () => getSnapshot(attribute),
2467
+ getServerSnapshot
2468
+ );
2469
+ return override ?? detected;
2470
+ }
2471
+ function useResolvedColor(value, scheme) {
2472
+ const detectedScheme = useColorScheme();
2473
+ const activeScheme = scheme ?? detectedScheme;
2474
+ return (0, import_color3.resolveColor)(value, activeScheme);
2475
+ }
2476
+
2477
+ // src/color/index.ts
2478
+ __reExport(color_exports, require("@pixerate/editor/color"));
2479
+
2480
+ // src/parameters/fields.tsx
2481
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1440
2482
  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";
1441
2483
  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";
1442
2484
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
@@ -1460,7 +2502,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
1460
2502
  onKeyDown: keyDown,
1461
2503
  ...rest
1462
2504
  };
1463
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "text", ...props }, value);
2505
+ 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);
1464
2506
  }
1465
2507
  var plainNumber = (field2, value) => (0, import_parameters.formatParameterNumber)({ ...field2, unit: void 0 }, value);
1466
2508
  function ParameterNumberInput({
@@ -1471,8 +2513,8 @@ function ParameterNumberInput({
1471
2513
  id,
1472
2514
  "aria-label": ariaLabel
1473
2515
  }) {
1474
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1475
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2516
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2517
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1476
2518
  ParameterCommitInput,
1477
2519
  {
1478
2520
  id,
@@ -1494,21 +2536,21 @@ function ParameterNumberInput({
1494
2536
  }
1495
2537
  }
1496
2538
  ),
1497
- field2.unit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field2.unit })
2539
+ field2.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: field2.unit })
1498
2540
  ] });
1499
2541
  }
1500
2542
  function ParameterSlider(props) {
1501
2543
  const { field: field2, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
1502
- const dragging = (0, import_react14.useRef)(false);
2544
+ const dragging = (0, import_react17.useRef)(false);
1503
2545
  const end = () => {
1504
2546
  if (!dragging.current) return;
1505
2547
  dragging.current = false;
1506
2548
  onGestureEnd?.();
1507
2549
  };
1508
- if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props });
2550
+ if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterNumberInput, { ...props });
1509
2551
  const step = (0, import_parameters.parameterStep)(field2);
1510
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
1511
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2552
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
2553
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1512
2554
  "input",
1513
2555
  {
1514
2556
  type: "range",
@@ -1531,11 +2573,11 @@ function ParameterSlider(props) {
1531
2573
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field2, Number(e.target.value)))
1532
2574
  }
1533
2575
  ),
1534
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field2)} value` }) })
2576
+ /* @__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)(field2)} value` }) })
1535
2577
  ] });
1536
2578
  }
1537
2579
  function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
1538
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2580
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1539
2581
  "button",
1540
2582
  {
1541
2583
  type: "button",
@@ -1546,7 +2588,7 @@ function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
1546
2588
  disabled: disabled || field2.readOnly,
1547
2589
  onClick: () => onChange(!value),
1548
2590
  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"}`,
1549
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2591
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1550
2592
  "span",
1551
2593
  {
1552
2594
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -1559,7 +2601,7 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
1559
2601
  const options = (0, import_parameters.getChoiceOptions)(field2);
1560
2602
  const off = disabled || field2.readOnly;
1561
2603
  if (field2.control === "segmented") {
1562
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field2), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2604
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field2), 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)(
1563
2605
  "button",
1564
2606
  {
1565
2607
  type: "button",
@@ -1575,7 +2617,7 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
1575
2617
  )) });
1576
2618
  }
1577
2619
  const index = options.findIndex((o) => o.value === value);
1578
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2620
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1579
2621
  "select",
1580
2622
  {
1581
2623
  id,
@@ -1587,53 +2629,64 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
1587
2629
  if (option) onChange(option.value);
1588
2630
  },
1589
2631
  className: parameterInputClass,
1590
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
2632
+ 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)))
1591
2633
  }
1592
2634
  );
1593
2635
  }
1594
2636
  function ParameterColor({ field: field2, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
1595
- const picking = (0, import_react14.useRef)(false);
2637
+ const [open, setOpen] = (0, import_react17.useState)(false);
2638
+ const containerRef = (0, import_react17.useRef)(null);
2639
+ const buttonRef = (0, import_react17.useRef)(null);
2640
+ const popoverRef = (0, import_react17.useRef)(null);
1596
2641
  const alpha = !!field2.alpha;
1597
2642
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
1598
2643
  const rgb = hex.slice(0, 7);
1599
- const a = hex.slice(7);
2644
+ const shown = alpha ? hex : rgb;
1600
2645
  const off = disabled || field2.readOnly;
1601
- const start = () => {
1602
- if (picking.current) return;
1603
- picking.current = true;
1604
- onGestureStart?.();
1605
- };
1606
- const end = () => {
1607
- if (!picking.current) return;
1608
- picking.current = false;
1609
- onGestureEnd?.();
1610
- };
1611
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1.5", children: [
1612
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
1613
- /* @__PURE__ */ (0, import_jsx_runtime12.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: [
1614
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
1615
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1616
- "input",
1617
- {
1618
- type: "color",
1619
- "aria-label": (0, import_parameters.parameterLabel)(field2),
1620
- value: rgb,
1621
- disabled: off,
1622
- className: "absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
1623
- onChange: (e) => {
1624
- start();
1625
- onChange(alpha ? `${e.target.value}${a}` : e.target.value);
1626
- },
1627
- onBlur: end
1628
- }
1629
- )
1630
- ] }),
1631
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2646
+ const name = (0, import_parameters.parameterLabel)(field2);
2647
+ (0, import_react17.useEffect)(() => {
2648
+ if (!open) return;
2649
+ const onPointerDown = (e) => {
2650
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
2651
+ setOpen(false);
2652
+ }
2653
+ };
2654
+ const onKeyDown = (e) => {
2655
+ if (e.key === "Escape") {
2656
+ e.stopPropagation();
2657
+ setOpen(false);
2658
+ buttonRef.current?.focus();
2659
+ }
2660
+ };
2661
+ window.addEventListener("pointerdown", onPointerDown, true);
2662
+ window.addEventListener("keydown", onKeyDown, true);
2663
+ return () => {
2664
+ window.removeEventListener("pointerdown", onPointerDown, true);
2665
+ window.removeEventListener("keydown", onKeyDown, true);
2666
+ };
2667
+ }, [open]);
2668
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2669
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
2670
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2671
+ "button",
2672
+ {
2673
+ ref: buttonRef,
2674
+ type: "button",
2675
+ "aria-label": name,
2676
+ "aria-expanded": open,
2677
+ "aria-haspopup": "dialog",
2678
+ disabled: off,
2679
+ onClick: () => setOpen((prev) => !prev),
2680
+ 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] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
2681
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
2682
+ }
2683
+ ),
2684
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1632
2685
  ParameterCommitInput,
1633
2686
  {
1634
2687
  id,
1635
- "aria-label": `${(0, import_parameters.parameterLabel)(field2)} hex`,
1636
- value: alpha ? hex : rgb,
2688
+ "aria-label": `${name} hex`,
2689
+ value: shown,
1637
2690
  disabled: off,
1638
2691
  spellCheck: false,
1639
2692
  className: `${parameterInputClass} font-mono`,
@@ -1644,51 +2697,43 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
1644
2697
  }
1645
2698
  )
1646
2699
  ] }),
1647
- alpha && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1648
- "input",
2700
+ open && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2701
+ "div",
1649
2702
  {
1650
- type: "range",
1651
- "aria-label": `${(0, import_parameters.parameterLabel)(field2)} opacity`,
1652
- min: 0,
1653
- max: 255,
1654
- step: 1,
1655
- value: parseInt(a, 16),
1656
- disabled: off,
1657
- className: rangeClass,
1658
- onPointerDown: start,
1659
- onPointerUp: end,
1660
- onPointerCancel: end,
1661
- onBlur: end,
1662
- onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
1663
- }
1664
- ),
1665
- field2.swatches && field2.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap gap-1", children: field2.swatches.map((s) => {
1666
- const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
1667
- if (!swatch) return null;
1668
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1669
- "button",
1670
- {
1671
- type: "button",
1672
- title: swatch,
1673
- "aria-label": `${(0, import_parameters.parameterLabel)(field2)} ${swatch}`,
1674
- "aria-pressed": swatch === (alpha ? hex : rgb),
1675
- disabled: off,
1676
- onClick: () => onChange(swatch),
1677
- className: "h-5 w-5 rounded border border-input aria-pressed:ring-1 aria-pressed:ring-primary",
1678
- style: { background: swatch }
2703
+ ref: popoverRef,
2704
+ role: "dialog",
2705
+ "aria-label": name,
2706
+ tabIndex: -1,
2707
+ onBlur: (e) => {
2708
+ if (popoverRef.current && !popoverRef.current.contains(e.relatedTarget)) {
2709
+ setOpen(false);
2710
+ }
1679
2711
  },
1680
- s
1681
- );
1682
- }) })
2712
+ className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
2713
+ style: { background: "var(--popover, var(--background, #fff))" },
2714
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2715
+ ColorPicker,
2716
+ {
2717
+ value: shown,
2718
+ alpha,
2719
+ swatches: field2.swatches,
2720
+ disabled: off,
2721
+ onChange,
2722
+ onGestureStart,
2723
+ onGestureEnd
2724
+ }
2725
+ )
2726
+ }
2727
+ )
1683
2728
  ] });
1684
2729
  }
1685
2730
  function ParameterVector({ field: field2, value, onChange, disabled, id }) {
1686
2731
  const size = (0, import_parameters.vectorSize)(field2);
1687
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
2732
+ 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) => {
1688
2733
  const component = (0, import_parameters.vectorComponentField)(field2, i);
1689
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1690
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1691
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2734
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
2735
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
2736
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1692
2737
  ParameterNumberInput,
1693
2738
  {
1694
2739
  field: component,
@@ -1705,11 +2750,11 @@ function ParameterVector({ field: field2, value, onChange, disabled, id }) {
1705
2750
  function ParameterImage({ field: field2, value, onChange, disabled, id, resolveFile }) {
1706
2751
  const off = disabled || field2.readOnly;
1707
2752
  const name = (0, import_parameters.parameterLabel)(field2);
1708
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1.5", children: [
1709
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
1710
- /* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1711
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1712
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2753
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1.5", children: [
2754
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
2755
+ /* @__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" }) }),
2756
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
2757
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1713
2758
  ParameterCommitInput,
1714
2759
  {
1715
2760
  id,
@@ -1720,10 +2765,10 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
1720
2765
  onCommit: (text) => onChange(text.trim())
1721
2766
  }
1722
2767
  ),
1723
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-1", children: [
1724
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
2768
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex gap-1", children: [
2769
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1725
2770
  "Choose file\u2026",
1726
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2771
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1727
2772
  "input",
1728
2773
  {
1729
2774
  type: "file",
@@ -1739,11 +2784,11 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
1739
2784
  }
1740
2785
  )
1741
2786
  ] }),
1742
- value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
2787
+ value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1743
2788
  ] })
1744
2789
  ] })
1745
2790
  ] }),
1746
- field2.options && field2.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap gap-1", children: field2.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2791
+ field2.options && field2.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex flex-wrap gap-1", children: field2.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1747
2792
  "button",
1748
2793
  {
1749
2794
  type: "button",
@@ -1753,14 +2798,14 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
1753
2798
  disabled: off,
1754
2799
  onClick: () => onChange(o.url),
1755
2800
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
1756
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
2801
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1757
2802
  },
1758
2803
  o.url
1759
2804
  )) })
1760
2805
  ] });
1761
2806
  }
1762
2807
  function ParameterText({ field: field2, value, onChange, disabled, id }) {
1763
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2808
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1764
2809
  ParameterCommitInput,
1765
2810
  {
1766
2811
  id,
@@ -1779,31 +2824,31 @@ function ParameterFieldControl({ field: field2, value, onChange, resolveFile, ..
1779
2824
  switch (field2.type) {
1780
2825
  case "number":
1781
2826
  case "int":
1782
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSlider, { field: field2, value, onChange: set, ...rest });
2827
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterSlider, { field: field2, value, onChange: set, ...rest });
1783
2828
  case "boolean":
1784
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterToggle, { field: field2, value, onChange: set, ...rest });
2829
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterToggle, { field: field2, value, onChange: set, ...rest });
1785
2830
  case "choice":
1786
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSelect, { field: field2, value, onChange: set, ...rest });
2831
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterSelect, { field: field2, value, onChange: set, ...rest });
1787
2832
  case "color":
1788
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterColor, { field: field2, value, onChange: set, ...rest });
2833
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterColor, { field: field2, value, onChange: set, ...rest });
1789
2834
  case "vector":
1790
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterVector, { field: field2, value, onChange: set, ...rest });
2835
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterVector, { field: field2, value, onChange: set, ...rest });
1791
2836
  case "image":
1792
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterImage, { field: field2, value, onChange: set, resolveFile, ...rest });
2837
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterImage, { field: field2, value, onChange: set, resolveFile, ...rest });
1793
2838
  case "text":
1794
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterText, { field: field2, value, onChange: set, ...rest });
2839
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ParameterText, { field: field2, value, onChange: set, ...rest });
1795
2840
  }
1796
2841
  }
1797
2842
 
1798
2843
  // src/effects/EffectParameters.tsx
1799
- var import_jsx_runtime13 = require("react/jsx-runtime");
2844
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1800
2845
  function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
1801
- const fields = (0, import_react15.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1802
- const idBase = (0, import_react15.useId)();
1803
- const gesture = import_react15.default.useRef(null);
1804
- const count = import_react15.default.useRef(0);
1805
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1806
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2846
+ const fields = (0, import_react18.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
2847
+ const idBase = (0, import_react18.useId)();
2848
+ const gesture = import_react18.default.useRef(null);
2849
+ const count = import_react18.default.useRef(0);
2850
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
2851
+ onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1807
2852
  "select",
1808
2853
  {
1809
2854
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -1815,8 +2860,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1815
2860
  if (preset) onPreset({ ...description.defaults, ...preset.values });
1816
2861
  },
1817
2862
  children: [
1818
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "Presets\u2026" }),
1819
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: p.name, children: p.name }, p.name))
2863
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "Presets\u2026" }),
2864
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: p.name, children: p.name }, p.name))
1820
2865
  ]
1821
2866
  }
1822
2867
  ),
@@ -1826,13 +2871,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1826
2871
  const keyed = keyframed?.has(field2.id) ?? false;
1827
2872
  const value = (0, import_effects3.effectFieldValue)(field2, values[field2.id]);
1828
2873
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field2.default);
1829
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", "data-effect-control": field2.id, children: [
1830
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1831
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field2.description, children: label }),
1832
- keyed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1833
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field2.id), children: "\u21BA" })
2874
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "space-y-1", "data-effect-control": field2.id, children: [
2875
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2876
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field2.description, children: label }),
2877
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
2878
+ 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(field2.id), children: "\u21BA" })
1834
2879
  ] }),
1835
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2880
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1836
2881
  ParameterFieldControl,
1837
2882
  {
1838
2883
  field: field2,
@@ -1846,14 +2891,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1846
2891
  )
1847
2892
  ] }, field2.id);
1848
2893
  }),
1849
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
2894
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1850
2895
  ] });
1851
2896
  }
1852
2897
 
1853
2898
  // src/video-editor/VideoEffectsPanel.tsx
1854
- var import_react16 = require("react");
2899
+ var import_react19 = require("react");
1855
2900
  var import_video_editor9 = require("@pixerate/editor/video-editor");
1856
- var import_jsx_runtime14 = require("react/jsx-runtime");
2901
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1857
2902
  var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
1858
2903
  var keyedOf = (values) => new Set(Object.entries(values ?? {}).filter(([, v]) => (0, import_video_editor9.isVideoKeyframes)(v)).map(([k]) => k));
1859
2904
  function EffectControls({
@@ -1866,21 +2911,21 @@ function EffectControls({
1866
2911
  onPreset
1867
2912
  }) {
1868
2913
  const { description, error } = useEffectDescription(provider, effect);
1869
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
2914
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
1870
2915
  'No effects provider: "',
1871
2916
  name ?? effect,
1872
2917
  '" is kept and shown as a placeholder.'
1873
2918
  ] });
1874
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
1875
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
1876
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectParameters, { description, values: values ?? {}, keyframed: keyedOf(values), disabled, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
2919
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
2920
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
2921
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectParameters, { description, values: values ?? {}, keyframed: keyedOf(values), disabled, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
1877
2922
  }
1878
2923
  function VideoEffectsPanel({ controller, className = "" }) {
1879
2924
  const state = useVideoEditorState(controller);
1880
2925
  const provider = state.effectsProvider;
1881
- const [browse, setBrowse] = (0, import_react16.useState)(null);
1882
- const [message, setMessage] = (0, import_react16.useState)(null);
1883
- const [open, setOpen] = (0, import_react16.useState)(null);
2926
+ const [browse, setBrowse] = (0, import_react19.useState)(null);
2927
+ const [message, setMessage] = (0, import_react19.useState)(null);
2928
+ const [open, setOpen] = (0, import_react19.useState)(null);
1884
2929
  const selected = state.selection[0];
1885
2930
  const at = selected ? (0, import_video_editor9.findVideoClip)(state.project, selected) : null;
1886
2931
  const clip = at?.clip ?? null;
@@ -1891,18 +2936,18 @@ function VideoEffectsPanel({ controller, className = "" }) {
1891
2936
  if (!track) return setMessage("Add a video track first.");
1892
2937
  report(controller.addEffectClip(track, effect, { start: Math.round(state.time), mode: "overwrite" }).then((r) => (r.ok && r.clip && controller.select([r.clip]), r)));
1893
2938
  };
1894
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: `flex flex-col gap-2 rounded-md border border-border p-2 text-xs ${className}`, "aria-label": "Effects", "data-video-effects": "", children: [
1895
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
1896
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "flex-1 font-semibold", children: "Effects" }),
1897
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, onClick: () => setBrowse(browse === "generator" ? null : "generator"), "aria-pressed": browse === "generator", children: "Add effect clip" })
2939
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("section", { className: `flex flex-col gap-2 rounded-md border border-border p-2 text-xs ${className}`, "aria-label": "Effects", "data-video-effects": "", children: [
2940
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2941
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { className: "flex-1 font-semibold", children: "Effects" }),
2942
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, onClick: () => setBrowse(browse === "generator" ? null : "generator"), "aria-pressed": browse === "generator", children: "Add effect clip" })
1898
2943
  ] }),
1899
- !provider && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the project are kept and drawn as placeholders." }),
1900
- browse === "generator" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["generator", "title", "overlay"], title: "Generators and titles", onPick: (e) => (setBrowse(null), addEffectClip(e.id)) }),
1901
- !clip && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a clip to see its effects." }),
1902
- clip && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
1903
- clip.type === "effect" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
1904
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "font-medium", children: clip.name ?? clip.effect }),
1905
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2944
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the project are kept and drawn as placeholders." }),
2945
+ browse === "generator" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectsBrowser, { provider, uses: ["generator", "title", "overlay"], title: "Generators and titles", onPick: (e) => (setBrowse(null), addEffectClip(e.id)) }),
2946
+ !clip && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a clip to see its effects." }),
2947
+ clip && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2948
+ clip.type === "effect" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
2949
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "font-medium", children: clip.name ?? clip.effect }),
2950
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1906
2951
  EffectControls,
1907
2952
  {
1908
2953
  provider,
@@ -1915,13 +2960,13 @@ function VideoEffectsPanel({ controller, className = "" }) {
1915
2960
  }
1916
2961
  )
1917
2962
  ] }),
1918
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1", "data-effect-part": "transition", children: [
1919
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 font-medium", children: "Transition in" }),
1921
- clip.transition?.type === "effect" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled, onClick: () => report(controller.apply({ op: "set_transition", clip: clip.id, transition: null }, "Remove transition")), children: "Remove" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Effect transition\u2026" })
2963
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1", "data-effect-part": "transition", children: [
2964
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2965
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex-1 font-medium", children: "Transition in" }),
2966
+ clip.transition?.type === "effect" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled, onClick: () => report(controller.apply({ op: "set_transition", clip: clip.id, transition: null }, "Remove transition")), children: "Remove" }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Effect transition\u2026" })
1922
2967
  ] }),
1923
- browse === "transition" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), report(controller.setEffectTransition(clip.id, e.id))) }),
1924
- clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2968
+ browse === "transition" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), report(controller.setEffectTransition(clip.id, e.id))) }),
2969
+ clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1925
2970
  EffectControls,
1926
2971
  {
1927
2972
  provider,
@@ -1934,24 +2979,24 @@ function VideoEffectsPanel({ controller, className = "" }) {
1934
2979
  }
1935
2980
  )
1936
2981
  ] }),
1937
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1", "data-effect-part": "stack", children: [
1938
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
1939
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 font-medium", children: "On this clip" }),
1940
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "clip", onClick: () => setBrowse(browse === "clip" ? null : "clip"), children: "Add effect\u2026" })
2982
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1", "data-effect-part": "stack", children: [
2983
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2984
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex-1 font-medium", children: "On this clip" }),
2985
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "clip", onClick: () => setBrowse(browse === "clip" ? null : "clip"), children: "Add effect\u2026" })
1941
2986
  ] }),
1942
- browse === "clip" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["filter", "overlay"], title: "Filters and overlays", onPick: (e) => (setBrowse(null), report(controller.applyClipEffect(clip.id, e.id))) }),
1943
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ol", { className: "space-y-1", children: (clip.effects ?? []).map((e, i, all) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { className: "rounded border border-border p-1", "data-clip-effect": e.id, children: [
1944
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
1945
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "checkbox", checked: e.enabled !== false, disabled, "aria-label": `${e.name ?? e.effect} on`, onChange: (ev) => report(controller.updateClipEffect(clip.id, e.id, { enabled: ev.currentTarget.checked })) }),
1946
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.id, onClick: () => setOpen(open === e.id ? null : e.id), children: e.name ?? e.effect }),
1947
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled: disabled || i === 0, "aria-label": "Move up", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i - 1 })), children: "\u2191" }),
1948
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled: disabled || i === all.length - 1, "aria-label": "Move down", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i + 1 })), children: "\u2193" }),
1949
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeClipEffect(clip.id, e.id)), children: "\u2715" })
2987
+ browse === "clip" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectsBrowser, { provider, uses: ["filter", "overlay"], title: "Filters and overlays", onPick: (e) => (setBrowse(null), report(controller.applyClipEffect(clip.id, e.id))) }),
2988
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ol", { className: "space-y-1", children: (clip.effects ?? []).map((e, i, all) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: "rounded border border-border p-1", "data-clip-effect": e.id, children: [
2989
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2990
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "checkbox", checked: e.enabled !== false, disabled, "aria-label": `${e.name ?? e.effect} on`, onChange: (ev) => report(controller.updateClipEffect(clip.id, e.id, { enabled: ev.currentTarget.checked })) }),
2991
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.id, onClick: () => setOpen(open === e.id ? null : e.id), children: e.name ?? e.effect }),
2992
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled: disabled || i === 0, "aria-label": "Move up", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i - 1 })), children: "\u2191" }),
2993
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled: disabled || i === all.length - 1, "aria-label": "Move down", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i + 1 })), children: "\u2193" }),
2994
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeClipEffect(clip.id, e.id)), children: "\u2715" })
1950
2995
  ] }),
1951
- open === e.id && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mt-1 space-y-2", children: [
1952
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
1953
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w-14 text-[11px]", children: "Opacity" }),
1954
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2996
+ open === e.id && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "mt-1 space-y-2", children: [
2997
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2998
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-14 text-[11px]", children: "Opacity" }),
2999
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1955
3000
  "input",
1956
3001
  {
1957
3002
  type: "range",
@@ -1966,7 +3011,7 @@ function VideoEffectsPanel({ controller, className = "" }) {
1966
3011
  }
1967
3012
  )
1968
3013
  ] }),
1969
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3014
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1970
3015
  EffectControls,
1971
3016
  {
1972
3017
  provider,
@@ -1980,42 +3025,42 @@ function VideoEffectsPanel({ controller, className = "" }) {
1980
3025
  )
1981
3026
  ] })
1982
3027
  ] }, e.id)) }),
1983
- !clip.effects?.length && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects on this clip." })
3028
+ !clip.effects?.length && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects on this clip." })
1984
3029
  ] })
1985
3030
  ] }),
1986
- message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
3031
+ message && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
1987
3032
  ] });
1988
3033
  }
1989
3034
 
1990
3035
  // src/video-editor/VideoEditor.tsx
1991
- var import_jsx_runtime15 = require("react/jsx-runtime");
3036
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1992
3037
  function VideoEditor({ controller: given, options, editable = true, pxPerSecond, onPxPerSecondChange, resolution, showIssues = true, showTranscript = true, showScopes = false, effects, showEffects, className = "", playback, onPlaybackReveal }) {
1993
3038
  const { controller, state } = useVideoEditor(given ?? options ?? {});
1994
3039
  useEffects(controller, effects);
1995
3040
  const effectsShown = showEffects ?? !!(state.effectsProvider || state.project.tracks.some((t) => t.clips.some((c) => c.type === "effect" || c.effects?.length || c.transition?.type === "effect")));
1996
- (0, import_react17.useEffect)(() => {
3041
+ (0, import_react20.useEffect)(() => {
1997
3042
  if (editable) return;
1998
3043
  const was = controller.getState().readOnly;
1999
3044
  controller.setReadOnly(true);
2000
3045
  return () => controller.setReadOnly(was);
2001
3046
  }, [controller, editable]);
2002
3047
  const { issues } = state;
2003
- const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Video issues", "data-video-issues": "", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", "data-issue": issue.code, children: issue.message }, i)) });
2004
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `flex flex-col gap-3 ${className}`, "data-video-editor": "", children: [
2005
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `grid gap-3 ${editable ? "lg:grid-cols-[16rem_minmax(0,1fr)_18rem]" : ""}`, children: [
2006
- editable && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MediaBin, { controller, className: "min-w-0" }),
2007
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
2008
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(VideoPreview, { controller, resolution, className: "rounded-md border border-border" }),
2009
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(VideoTransport, { controller, editable }),
2010
- showScopes && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(VideoScopes, { controller })
3048
+ const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Video issues", "data-video-issues": "", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", "data-issue": issue.code, children: issue.message }, i)) });
3049
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `flex flex-col gap-3 ${className}`, "data-video-editor": "", children: [
3050
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `grid gap-3 ${editable ? "lg:grid-cols-[16rem_minmax(0,1fr)_18rem]" : ""}`, children: [
3051
+ editable && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MediaBin, { controller, className: "min-w-0" }),
3052
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
3053
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoPreview, { controller, resolution, className: "rounded-md border border-border" }),
3054
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoTransport, { controller, editable }),
3055
+ showScopes && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoScopes, { controller })
2011
3056
  ] }),
2012
- editable && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
2013
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClipInspector, { controller, className: "min-w-0" }),
2014
- effectsShown && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(VideoEffectsPanel, { controller, className: "min-w-0" })
3057
+ editable && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
3058
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ClipInspector, { controller, className: "min-w-0" }),
3059
+ effectsShown && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoEffectsPanel, { controller, className: "min-w-0" })
2015
3060
  ] })
2016
3061
  ] }),
2017
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(VideoTimeline, { controller, editable, pxPerSecond, onPxPerSecondChange, playback, onPlaybackReveal }),
2018
- showTranscript && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TranscriptPanel, { controller, editable }),
3062
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoTimeline, { controller, editable, pxPerSecond, onPxPerSecondChange, playback, onPlaybackReveal }),
3063
+ showTranscript && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptPanel, { controller, editable }),
2019
3064
  issueList
2020
3065
  ] });
2021
3066
  }