@pixerate/editor-react 0.95.0 → 0.97.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 +2 -0
  2. package/dist/animation-editor/index.cjs +1261 -198
  3. package/dist/animation-editor/index.js +4 -2
  4. package/dist/canvas/index.cjs +1439 -376
  5. package/dist/canvas/index.js +4 -2
  6. package/dist/chunk-3I7FOSLF.js +988 -0
  7. package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
  8. package/dist/chunk-KIRIU53A.js +72 -0
  9. package/dist/{chunk-6YRSQW2V.js → chunk-NC4RLZTK.js} +1 -1
  10. package/dist/chunk-Q7LAFHGP.js +655 -0
  11. package/dist/color/ColorPicker.d.cts +30 -0
  12. package/dist/color/ColorPicker.d.ts +30 -0
  13. package/dist/color/DualColorPicker.d.cts +29 -0
  14. package/dist/color/DualColorPicker.d.ts +29 -0
  15. package/dist/color/index.cjs +1067 -0
  16. package/dist/color/index.d.cts +7 -0
  17. package/dist/color/index.d.ts +7 -0
  18. package/dist/color/index.js +14 -0
  19. package/dist/color/useColorScheme.d.cts +16 -0
  20. package/dist/color/useColorScheme.d.ts +16 -0
  21. package/dist/effects/EffectAuthoringEditor.d.cts +22 -0
  22. package/dist/effects/EffectAuthoringEditor.d.ts +22 -0
  23. package/dist/effects/EffectParameters.d.cts +5 -1
  24. package/dist/effects/EffectParameters.d.ts +5 -1
  25. package/dist/effects/index.cjs +1624 -127
  26. package/dist/effects/index.d.cts +2 -0
  27. package/dist/effects/index.d.ts +2 -0
  28. package/dist/effects/index.js +8 -2
  29. package/dist/effects/useEffectAuthoring.d.cts +6 -0
  30. package/dist/effects/useEffectAuthoring.d.ts +6 -0
  31. package/dist/gradient/FillPicker.d.cts +27 -0
  32. package/dist/gradient/FillPicker.d.ts +27 -0
  33. package/dist/gradient/GradientEditor.d.cts +21 -0
  34. package/dist/gradient/GradientEditor.d.ts +21 -0
  35. package/dist/gradient/index.cjs +1601 -0
  36. package/dist/gradient/index.d.cts +6 -0
  37. package/dist/gradient/index.d.ts +6 -0
  38. package/dist/gradient/index.js +617 -0
  39. package/dist/gradient/useGradientController.d.cts +10 -0
  40. package/dist/gradient/useGradientController.d.ts +10 -0
  41. package/dist/image-editor/index.cjs +1763 -700
  42. package/dist/image-editor/index.js +5 -3
  43. package/dist/index.cjs +2181 -1118
  44. package/dist/index.js +5 -3
  45. package/dist/paint-editor/index.cjs +1254 -191
  46. package/dist/paint-editor/index.js +4 -2
  47. package/dist/parameters/fields.d.cts +1 -1
  48. package/dist/parameters/fields.d.ts +1 -1
  49. package/dist/parameters/index.cjs +1218 -173
  50. package/dist/parameters/index.js +3 -1
  51. package/dist/vector/index.cjs +1240 -177
  52. package/dist/vector/index.js +4 -2
  53. package/dist/video-editor/index.cjs +1251 -188
  54. package/dist/video-editor/index.js +4 -2
  55. package/package.json +29 -3
  56. package/dist/chunk-5R67YSSD.js +0 -205
@@ -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-
@@ -218,7 +219,7 @@ function useImageEffectsTools(registry, controller, options = {}) {
218
219
  }
219
220
 
220
221
  // src/image-editor/ImageEditor.tsx
221
- var import_react24 = __toESM(require("react"), 1);
222
+ var import_react27 = __toESM(require("react"), 1);
222
223
 
223
224
  // src/playback/AgentPlaybackContext.tsx
224
225
  var import_react2 = require("react");
@@ -1358,7 +1359,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
1358
1359
  };
1359
1360
 
1360
1361
  // src/image-editor/ImageProviderEffectsPanel.tsx
1361
- var import_react15 = __toESM(require("react"), 1);
1362
+ var import_react18 = __toESM(require("react"), 1);
1362
1363
  var import_image_editor8 = require("@pixerate/editor/image-editor");
1363
1364
 
1364
1365
  // src/effects/useEffects.ts
@@ -1498,14 +1499,1055 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1498
1499
  }
1499
1500
 
1500
1501
  // src/effects/EffectParameters.tsx
1501
- var import_react14 = __toESM(require("react"), 1);
1502
+ var import_react17 = __toESM(require("react"), 1);
1502
1503
  var import_effects3 = require("@pixerate/editor/effects");
1503
1504
  var import_parameters2 = require("@pixerate/editor/parameters");
1504
1505
 
1505
1506
  // src/parameters/fields.tsx
1506
- var import_react13 = require("react");
1507
+ var import_react16 = require("react");
1507
1508
  var import_parameters = require("@pixerate/editor/parameters");
1509
+
1510
+ // src/color/index.ts
1511
+ var color_exports = {};
1512
+ __export(color_exports, {
1513
+ ColorPicker: () => ColorPicker,
1514
+ DualColorPicker: () => DualColorPicker,
1515
+ useColorScheme: () => useColorScheme,
1516
+ useResolvedColor: () => useResolvedColor
1517
+ });
1518
+
1519
+ // src/color/ColorPicker.tsx
1520
+ var import_react13 = require("react");
1521
+ var import_color = require("@pixerate/editor/color");
1508
1522
  var import_jsx_runtime11 = require("react/jsx-runtime");
1523
+ var LOCAL_STORAGE_KEY = "pixerate:color:recent";
1524
+ function readLocalRecents() {
1525
+ try {
1526
+ if (typeof localStorage === "undefined") return [];
1527
+ const raw = localStorage.getItem(LOCAL_STORAGE_KEY);
1528
+ if (!raw) return [];
1529
+ const parsed = JSON.parse(raw);
1530
+ return Array.isArray(parsed) ? parsed : [];
1531
+ } catch {
1532
+ return [];
1533
+ }
1534
+ }
1535
+ function writeLocalRecents(list) {
1536
+ try {
1537
+ if (typeof localStorage !== "undefined") {
1538
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(list));
1539
+ }
1540
+ } catch {
1541
+ }
1542
+ }
1543
+ var CHECKERBOARD_BG = "repeating-conic-gradient(var(--pixerate-checker-a, #d4d4d8) 0 25%, var(--pixerate-checker-b, #ffffff) 0 50%)";
1544
+ var DEFAULT_PICKER_STATE = { h: 0, s: 1, v: 1, alpha: 1 };
1545
+ var ColorPicker = ({
1546
+ value,
1547
+ onChange,
1548
+ onGestureStart,
1549
+ onGestureEnd,
1550
+ alpha = false,
1551
+ swatches,
1552
+ recent: controlledRecent,
1553
+ onRecentChange,
1554
+ contrastAgainst,
1555
+ disabled = false,
1556
+ className,
1557
+ id,
1558
+ "aria-label": ariaLabel = "Color picker"
1559
+ }) => {
1560
+ const generatedId = (0, import_react13.useId)();
1561
+ const pickerId = id || generatedId;
1562
+ const [pickerState, setPickerState] = (0, import_react13.useState)(
1563
+ () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
1564
+ );
1565
+ const stateRef = (0, import_react13.useRef)(pickerState);
1566
+ stateRef.current = pickerState;
1567
+ (0, import_react13.useEffect)(() => {
1568
+ const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
1569
+ if (next) {
1570
+ setPickerState(next);
1571
+ }
1572
+ }, [value]);
1573
+ const [internalRecent, setInternalRecent] = (0, import_react13.useState)(
1574
+ () => controlledRecent ? [] : readLocalRecents()
1575
+ );
1576
+ const activeRecent = controlledRecent ?? internalRecent;
1577
+ const recordRecent = (0, import_react13.useCallback)(
1578
+ (color) => {
1579
+ const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
1580
+ if (!controlledRecent) {
1581
+ setInternalRecent(updated);
1582
+ writeLocalRecents(updated);
1583
+ }
1584
+ onRecentChange?.(updated);
1585
+ },
1586
+ [activeRecent, controlledRecent, onRecentChange]
1587
+ );
1588
+ const [textDraft, setTextDraft] = (0, import_react13.useState)(value);
1589
+ const [isInvalid, setIsInvalid] = (0, import_react13.useState)(false);
1590
+ const [isClipped, setIsClipped] = (0, import_react13.useState)(false);
1591
+ const isTypingRef = (0, import_react13.useRef)(false);
1592
+ (0, import_react13.useEffect)(() => {
1593
+ if (!isTypingRef.current) {
1594
+ setTextDraft(value);
1595
+ setIsInvalid(false);
1596
+ const parsed = (0, import_color.parseColor)(value);
1597
+ setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
1598
+ }
1599
+ }, [value]);
1600
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react13.useState)(false);
1601
+ (0, import_react13.useEffect)(() => {
1602
+ setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
1603
+ }, []);
1604
+ const emitColorChange = (0, import_react13.useCallback)(
1605
+ (nextState) => {
1606
+ setPickerState(nextState);
1607
+ const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
1608
+ onChange(hex);
1609
+ },
1610
+ [alpha, onChange]
1611
+ );
1612
+ const latest = (0, import_react13.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
1613
+ latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
1614
+ const endDragRef = (0, import_react13.useRef)(null);
1615
+ (0, import_react13.useEffect)(() => () => endDragRef.current?.(), []);
1616
+ const startDrag = (e, next) => {
1617
+ if (disabled) return;
1618
+ e.preventDefault();
1619
+ endDragRef.current?.();
1620
+ onGestureStart?.();
1621
+ const rect = e.currentTarget.getBoundingClientRect();
1622
+ const update = (clientX, clientY) => {
1623
+ const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
1624
+ const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
1625
+ latest.current.emitColorChange(next(stateRef.current, x, y));
1626
+ };
1627
+ update(e.clientX, e.clientY);
1628
+ const onPointerMove = (ev) => update(ev.clientX, ev.clientY);
1629
+ const end = () => {
1630
+ window.removeEventListener("pointermove", onPointerMove);
1631
+ window.removeEventListener("pointerup", onPointerUp);
1632
+ window.removeEventListener("pointercancel", onPointerUp);
1633
+ endDragRef.current = null;
1634
+ latest.current.onGestureEnd?.();
1635
+ };
1636
+ const onPointerUp = () => {
1637
+ end();
1638
+ latest.current.recordRecent((0, import_color.pickerStateToHex)(stateRef.current, latest.current.alpha));
1639
+ };
1640
+ endDragRef.current = end;
1641
+ window.addEventListener("pointermove", onPointerMove);
1642
+ window.addEventListener("pointerup", onPointerUp);
1643
+ window.addEventListener("pointercancel", onPointerUp);
1644
+ };
1645
+ const handleAreaPointerDown = (e) => startDrag(e, (state, x, y) => (0, import_color.pickerStateFromArea)(state, x, y));
1646
+ const handleHuePointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromHue)(state, x));
1647
+ const handleAlphaPointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromAlpha)(state, x));
1648
+ const handleAreaKeyDown = (e) => {
1649
+ if (disabled) return;
1650
+ const next = (0, import_color.pickerKeyStep)(pickerState, "area", e.key, e.shiftKey);
1651
+ if (next) {
1652
+ e.preventDefault();
1653
+ emitColorChange(next);
1654
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1655
+ }
1656
+ };
1657
+ const handleHueKeyDown = (e) => {
1658
+ if (disabled) return;
1659
+ const next = (0, import_color.pickerKeyStep)(pickerState, "hue", e.key, e.shiftKey);
1660
+ if (next) {
1661
+ e.preventDefault();
1662
+ emitColorChange(next);
1663
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1664
+ }
1665
+ };
1666
+ const handleAlphaKeyDown = (e) => {
1667
+ if (disabled) return;
1668
+ const next = (0, import_color.pickerKeyStep)(pickerState, "alpha", e.key, e.shiftKey);
1669
+ if (next) {
1670
+ e.preventDefault();
1671
+ emitColorChange(next);
1672
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
1673
+ }
1674
+ };
1675
+ const commitTextInput = (inputElement) => {
1676
+ isTypingRef.current = false;
1677
+ const parsed = (0, import_color.parseColor)(textDraft);
1678
+ if (parsed) {
1679
+ setIsInvalid(false);
1680
+ setIsClipped(!(0, import_color.inSrgbGamut)(parsed));
1681
+ const formatted = (0, import_color.formatHex)(parsed);
1682
+ onChange(formatted);
1683
+ recordRecent(formatted);
1684
+ } else {
1685
+ setIsInvalid(true);
1686
+ setTextDraft(value);
1687
+ if (inputElement) {
1688
+ inputElement.value = value;
1689
+ }
1690
+ }
1691
+ };
1692
+ const handleTextKeyDown = (e) => {
1693
+ if (e.key === "Enter") {
1694
+ e.preventDefault();
1695
+ commitTextInput(e.currentTarget);
1696
+ } else if (e.key === "Escape") {
1697
+ e.preventDefault();
1698
+ isTypingRef.current = false;
1699
+ setIsInvalid(false);
1700
+ setTextDraft(value);
1701
+ e.currentTarget.value = value;
1702
+ }
1703
+ };
1704
+ const handleEyeDropper = async () => {
1705
+ if (disabled || !hasEyeDropper) return;
1706
+ try {
1707
+ const EyeDropperClass = window.EyeDropper;
1708
+ const eyeDropper = new EyeDropperClass();
1709
+ const res = await eyeDropper.open();
1710
+ if (res?.sRGBHex) {
1711
+ onChange(res.sRGBHex);
1712
+ recordRecent(res.sRGBHex);
1713
+ }
1714
+ } catch {
1715
+ }
1716
+ };
1717
+ const contrastResult = (0, import_react13.useMemo)(() => {
1718
+ if (!contrastAgainst) return null;
1719
+ const fg = (0, import_color.parseColor)(value);
1720
+ const bg = (0, import_color.parseColor)(contrastAgainst);
1721
+ if (!fg || !bg) return null;
1722
+ const ratio = (0, import_color.contrastRatio)(fg, bg);
1723
+ const aa = ratio >= 4.5;
1724
+ const aaa = ratio >= 7;
1725
+ return { ratio, aa, aaa };
1726
+ }, [value, contrastAgainst]);
1727
+ const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
1728
+ const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
1729
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1730
+ "div",
1731
+ {
1732
+ id: pickerId,
1733
+ role: "group",
1734
+ "aria-label": ariaLabel,
1735
+ className,
1736
+ style: {
1737
+ boxSizing: "border-box",
1738
+ width: "var(--pixerate-color-picker-width, 240px)",
1739
+ borderRadius: "var(--pixerate-color-picker-radius, 8px)",
1740
+ background: "var(--pixerate-color-picker-bg, #1f2430)",
1741
+ color: "var(--pixerate-color-picker-fg, #f0f2f5)",
1742
+ padding: "12px",
1743
+ display: "flex",
1744
+ flexDirection: "column",
1745
+ gap: "10px",
1746
+ fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
1747
+ fontSize: "12px",
1748
+ userSelect: "none",
1749
+ opacity: disabled ? 0.6 : 1,
1750
+ pointerEvents: disabled ? "none" : "auto"
1751
+ },
1752
+ children: [
1753
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1754
+ "span",
1755
+ {
1756
+ role: "status",
1757
+ "aria-live": "polite",
1758
+ style: {
1759
+ position: "absolute",
1760
+ width: "1px",
1761
+ height: "1px",
1762
+ padding: 0,
1763
+ margin: "-1px",
1764
+ overflow: "hidden",
1765
+ clip: "rect(0, 0, 0, 0)",
1766
+ whiteSpace: "nowrap",
1767
+ border: 0
1768
+ },
1769
+ children: liveDescription
1770
+ }
1771
+ ),
1772
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1773
+ "div",
1774
+ {
1775
+ role: "slider",
1776
+ tabIndex: disabled ? -1 : 0,
1777
+ "aria-label": "Saturation and brightness",
1778
+ "aria-valuetext": `Saturation ${Math.round(pickerState.s * 100)}%, Brightness ${Math.round(
1779
+ pickerState.v * 100
1780
+ )}%`,
1781
+ "aria-disabled": disabled,
1782
+ onPointerDown: handleAreaPointerDown,
1783
+ onKeyDown: handleAreaKeyDown,
1784
+ style: {
1785
+ position: "relative",
1786
+ width: "100%",
1787
+ height: "150px",
1788
+ borderRadius: "6px",
1789
+ background: (0, import_color.pickerAreaBackground)(pickerState),
1790
+ cursor: disabled ? "default" : "crosshair",
1791
+ touchAction: "none",
1792
+ outline: "none"
1793
+ },
1794
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1795
+ "div",
1796
+ {
1797
+ style: {
1798
+ position: "absolute",
1799
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1800
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1801
+ borderRadius: "50%",
1802
+ transform: "translate(-50%, -50%)",
1803
+ left: `${pickerState.s * 100}%`,
1804
+ top: `${(1 - pickerState.v) * 100}%`,
1805
+ border: "2px solid #ffffff",
1806
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1807
+ pointerEvents: "none",
1808
+ backgroundColor: currentHex
1809
+ }
1810
+ }
1811
+ )
1812
+ }
1813
+ ),
1814
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1815
+ "div",
1816
+ {
1817
+ role: "slider",
1818
+ tabIndex: disabled ? -1 : 0,
1819
+ "aria-label": "Hue",
1820
+ "aria-valuenow": Math.round(pickerState.h),
1821
+ "aria-valuemin": 0,
1822
+ "aria-valuemax": 360,
1823
+ "aria-valuetext": `${Math.round(pickerState.h)} degrees`,
1824
+ "aria-disabled": disabled,
1825
+ onPointerDown: handleHuePointerDown,
1826
+ onKeyDown: handleHueKeyDown,
1827
+ style: {
1828
+ position: "relative",
1829
+ width: "100%",
1830
+ height: "12px",
1831
+ borderRadius: "6px",
1832
+ background: import_color.PICKER_HUE_BACKGROUND,
1833
+ cursor: disabled ? "default" : "pointer",
1834
+ touchAction: "none",
1835
+ outline: "none"
1836
+ },
1837
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1838
+ "div",
1839
+ {
1840
+ style: {
1841
+ position: "absolute",
1842
+ top: "50%",
1843
+ transform: "translate(-50%, -50%)",
1844
+ left: `${pickerState.h / 360 * 100}%`,
1845
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1846
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1847
+ borderRadius: "50%",
1848
+ border: "2px solid #ffffff",
1849
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1850
+ pointerEvents: "none",
1851
+ backgroundColor: `hsl(${pickerState.h}, 100%, 50%)`
1852
+ }
1853
+ }
1854
+ )
1855
+ }
1856
+ ),
1857
+ alpha && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1858
+ "div",
1859
+ {
1860
+ role: "slider",
1861
+ tabIndex: disabled ? -1 : 0,
1862
+ "aria-label": "Alpha",
1863
+ "aria-valuenow": Math.round(pickerState.alpha * 100),
1864
+ "aria-valuemin": 0,
1865
+ "aria-valuemax": 100,
1866
+ "aria-valuetext": `${Math.round(pickerState.alpha * 100)}%`,
1867
+ "aria-disabled": disabled,
1868
+ onPointerDown: handleAlphaPointerDown,
1869
+ onKeyDown: handleAlphaKeyDown,
1870
+ style: {
1871
+ position: "relative",
1872
+ width: "100%",
1873
+ height: "12px",
1874
+ borderRadius: "6px",
1875
+ backgroundImage: CHECKERBOARD_BG,
1876
+ backgroundSize: "8px 8px",
1877
+ cursor: disabled ? "default" : "pointer",
1878
+ touchAction: "none",
1879
+ outline: "none",
1880
+ overflow: "hidden"
1881
+ },
1882
+ children: [
1883
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1884
+ "div",
1885
+ {
1886
+ style: {
1887
+ position: "absolute",
1888
+ inset: 0,
1889
+ background: (0, import_color.pickerAlphaBackground)(pickerState)
1890
+ }
1891
+ }
1892
+ ),
1893
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1894
+ "div",
1895
+ {
1896
+ style: {
1897
+ position: "absolute",
1898
+ top: "50%",
1899
+ transform: "translate(-50%, -50%)",
1900
+ left: `${pickerState.alpha * 100}%`,
1901
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
1902
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
1903
+ borderRadius: "50%",
1904
+ border: "2px solid #ffffff",
1905
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
1906
+ pointerEvents: "none",
1907
+ backgroundColor: currentHex
1908
+ }
1909
+ }
1910
+ )
1911
+ ]
1912
+ }
1913
+ ),
1914
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
1915
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1916
+ "div",
1917
+ {
1918
+ style: {
1919
+ position: "relative",
1920
+ width: "28px",
1921
+ height: "28px",
1922
+ borderRadius: "4px",
1923
+ backgroundImage: CHECKERBOARD_BG,
1924
+ backgroundSize: "8px 8px",
1925
+ overflow: "hidden",
1926
+ flexShrink: 0,
1927
+ border: "1px solid rgba(255,255,255,0.15)"
1928
+ },
1929
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1930
+ "div",
1931
+ {
1932
+ style: {
1933
+ width: "100%",
1934
+ height: "100%",
1935
+ backgroundColor: currentHex
1936
+ }
1937
+ }
1938
+ )
1939
+ }
1940
+ ),
1941
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1942
+ "input",
1943
+ {
1944
+ type: "text",
1945
+ value: textDraft,
1946
+ disabled,
1947
+ "aria-label": "Color hex or CSS string",
1948
+ "aria-invalid": isInvalid ? "true" : void 0,
1949
+ onChange: (e) => {
1950
+ isTypingRef.current = true;
1951
+ setTextDraft(e.target.value);
1952
+ setIsInvalid(false);
1953
+ },
1954
+ onKeyDown: handleTextKeyDown,
1955
+ onBlur: (e) => commitTextInput(e.currentTarget),
1956
+ style: {
1957
+ flex: 1,
1958
+ minWidth: 0,
1959
+ height: "28px",
1960
+ padding: "0 8px",
1961
+ fontSize: "12px",
1962
+ fontFamily: "monospace",
1963
+ borderRadius: "4px",
1964
+ border: isInvalid ? "1px solid #ef4444" : "1px solid rgba(255,255,255,0.2)",
1965
+ background: "rgba(0,0,0,0.2)",
1966
+ color: "inherit",
1967
+ outline: "none"
1968
+ }
1969
+ }
1970
+ ),
1971
+ hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1972
+ "button",
1973
+ {
1974
+ type: "button",
1975
+ disabled,
1976
+ "aria-label": "Pick color from screen",
1977
+ title: "Pick color from screen",
1978
+ onClick: handleEyeDropper,
1979
+ style: {
1980
+ display: "inline-flex",
1981
+ alignItems: "center",
1982
+ justifyContent: "center",
1983
+ width: "28px",
1984
+ height: "28px",
1985
+ borderRadius: "4px",
1986
+ border: "1px solid rgba(255,255,255,0.2)",
1987
+ background: "transparent",
1988
+ color: "inherit",
1989
+ cursor: disabled ? "default" : "pointer"
1990
+ },
1991
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1992
+ "svg",
1993
+ {
1994
+ width: "14",
1995
+ height: "14",
1996
+ viewBox: "0 0 24 24",
1997
+ fill: "none",
1998
+ stroke: "currentColor",
1999
+ strokeWidth: "2",
2000
+ strokeLinecap: "round",
2001
+ strokeLinejoin: "round",
2002
+ children: [
2003
+ /* @__PURE__ */ (0, import_jsx_runtime11.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" }),
2004
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
2005
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "m14 6 4 4" })
2006
+ ]
2007
+ }
2008
+ )
2009
+ }
2010
+ )
2011
+ ] }),
2012
+ isClipped && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2013
+ "div",
2014
+ {
2015
+ role: "note",
2016
+ title: "This colour was outside standard sRGB and clipped.",
2017
+ style: {
2018
+ display: "inline-flex",
2019
+ alignItems: "center",
2020
+ gap: "4px",
2021
+ fontSize: "10px",
2022
+ color: "#f59e0b",
2023
+ background: "rgba(245, 158, 11, 0.1)",
2024
+ padding: "2px 6px",
2025
+ borderRadius: "4px",
2026
+ alignSelf: "flex-start"
2027
+ },
2028
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
2029
+ }
2030
+ ),
2031
+ contrastResult && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2032
+ "div",
2033
+ {
2034
+ style: {
2035
+ display: "flex",
2036
+ alignItems: "center",
2037
+ justifyContent: "space-between",
2038
+ fontSize: "11px",
2039
+ padding: "4px 8px",
2040
+ borderRadius: "4px",
2041
+ background: "rgba(255,255,255,0.05)",
2042
+ border: "1px solid rgba(255,255,255,0.1)"
2043
+ },
2044
+ children: [
2045
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
2046
+ "Contrast: ",
2047
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("strong", { children: [
2048
+ contrastResult.ratio.toFixed(2),
2049
+ ":1"
2050
+ ] })
2051
+ ] }),
2052
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
2053
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2054
+ "span",
2055
+ {
2056
+ style: {
2057
+ color: contrastResult.aa ? "#10b981" : "#ef4444",
2058
+ fontWeight: 600
2059
+ },
2060
+ children: [
2061
+ "AA ",
2062
+ contrastResult.aa ? "\u2713" : "\u2717"
2063
+ ]
2064
+ }
2065
+ ),
2066
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2067
+ "span",
2068
+ {
2069
+ style: {
2070
+ color: contrastResult.aaa ? "#10b981" : "#ef4444",
2071
+ fontWeight: 600
2072
+ },
2073
+ children: [
2074
+ "AAA ",
2075
+ contrastResult.aaa ? "\u2713" : "\u2717"
2076
+ ]
2077
+ }
2078
+ )
2079
+ ] })
2080
+ ]
2081
+ }
2082
+ ),
2083
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2084
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
2085
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2086
+ "button",
2087
+ {
2088
+ type: "button",
2089
+ "data-testid": "color-picker-swatch",
2090
+ title: color,
2091
+ disabled,
2092
+ "aria-label": `Color ${color}`,
2093
+ onClick: () => {
2094
+ onChange(color);
2095
+ recordRecent(color);
2096
+ },
2097
+ style: {
2098
+ width: "18px",
2099
+ height: "18px",
2100
+ borderRadius: "3px",
2101
+ backgroundColor: color,
2102
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
2103
+ cursor: disabled ? "default" : "pointer",
2104
+ padding: 0,
2105
+ outline: "none"
2106
+ }
2107
+ },
2108
+ `${color}-${idx}`
2109
+ )) })
2110
+ ] }),
2111
+ activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2112
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
2113
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2114
+ "button",
2115
+ {
2116
+ type: "button",
2117
+ "data-testid": "color-picker-recent",
2118
+ disabled,
2119
+ "aria-label": `Color ${color}`,
2120
+ onClick: () => {
2121
+ onChange(color);
2122
+ recordRecent(color);
2123
+ },
2124
+ style: {
2125
+ width: "18px",
2126
+ height: "18px",
2127
+ borderRadius: "3px",
2128
+ backgroundColor: color,
2129
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
2130
+ cursor: disabled ? "default" : "pointer",
2131
+ padding: 0,
2132
+ outline: "none"
2133
+ }
2134
+ },
2135
+ `recent-${color}-${idx}`
2136
+ )) })
2137
+ ] })
2138
+ ]
2139
+ }
2140
+ );
2141
+ };
2142
+
2143
+ // src/color/DualColorPicker.tsx
2144
+ var import_react14 = require("react");
2145
+ var import_color2 = require("@pixerate/editor/color");
2146
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2147
+ function DualColorPicker({
2148
+ value,
2149
+ onChange,
2150
+ onGestureStart,
2151
+ onGestureEnd,
2152
+ scheme: controlledScheme,
2153
+ onSchemeChange,
2154
+ surfaces = import_color2.DEFAULT_SCHEME_SURFACES,
2155
+ contrastAgainst,
2156
+ alpha = false,
2157
+ swatches,
2158
+ disabled = false,
2159
+ className = ""
2160
+ }) {
2161
+ const sameId = (0, import_react14.useId)();
2162
+ const [internalScheme, setInternalScheme] = (0, import_react14.useState)("light");
2163
+ const activeScheme = controlledScheme ?? internalScheme;
2164
+ const handleSchemeSelect = (nextScheme) => {
2165
+ if (onSchemeChange) {
2166
+ onSchemeChange(nextScheme);
2167
+ } else {
2168
+ setInternalScheme(nextScheme);
2169
+ }
2170
+ };
2171
+ const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
2172
+ const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
2173
+ const [sameInBoth, setSameInBoth] = (0, import_react14.useState)(isSame);
2174
+ const handleSameToggle = (e) => {
2175
+ const nextSame = e.target.checked;
2176
+ setSameInBoth(nextSame);
2177
+ if (nextSame) {
2178
+ const activeVal = activeScheme === "dark" ? dual.dark : dual.light;
2179
+ onChange({ light: activeVal, dark: activeVal });
2180
+ }
2181
+ };
2182
+ const handleDerive = () => {
2183
+ if (disabled) return;
2184
+ onGestureStart?.();
2185
+ const currentActive = activeScheme === "dark" ? dual.dark : dual.light;
2186
+ const derived = (0, import_color2.deriveDualColor)(currentActive, {
2187
+ from: activeScheme,
2188
+ // An unreadable surfaces prop falls back to the defaults rather than throwing.
2189
+ surfaces: (0, import_color2.normalizeDualColor)(surfaces) ?? import_color2.DEFAULT_SCHEME_SURFACES
2190
+ });
2191
+ onChange(derived);
2192
+ onGestureEnd?.();
2193
+ };
2194
+ const handleInnerChange = (hex) => {
2195
+ if (sameInBoth) {
2196
+ onChange({ light: hex, dark: hex });
2197
+ } else {
2198
+ const updated = (0, import_color2.setDualColorSide)(dual, activeScheme, hex);
2199
+ onChange(updated);
2200
+ }
2201
+ };
2202
+ const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
2203
+ const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
2204
+ const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
2205
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2206
+ "div",
2207
+ {
2208
+ className: `pixerate-dual-color-picker ${className}`,
2209
+ style: {
2210
+ display: "flex",
2211
+ flexDirection: "column",
2212
+ gap: "12px",
2213
+ padding: "12px",
2214
+ background: "#1a1d24",
2215
+ color: "#e2e8f0",
2216
+ borderRadius: "10px",
2217
+ boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
2218
+ width: "260px",
2219
+ fontFamily: "system-ui, -apple-system, sans-serif",
2220
+ fontSize: "13px",
2221
+ boxSizing: "border-box"
2222
+ },
2223
+ children: [
2224
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2225
+ "div",
2226
+ {
2227
+ role: "tablist",
2228
+ "aria-label": "Color scheme mode",
2229
+ style: {
2230
+ display: "flex",
2231
+ background: "#111318",
2232
+ borderRadius: "6px",
2233
+ padding: "2px",
2234
+ gap: "2px"
2235
+ },
2236
+ children: [
2237
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2238
+ "button",
2239
+ {
2240
+ type: "button",
2241
+ role: "tab",
2242
+ "aria-selected": activeScheme === "light",
2243
+ onClick: () => handleSchemeSelect("light"),
2244
+ disabled,
2245
+ style: {
2246
+ flex: 1,
2247
+ padding: "6px 8px",
2248
+ border: "none",
2249
+ borderRadius: "4px",
2250
+ background: activeScheme === "light" ? "#2d3342" : "transparent",
2251
+ color: activeScheme === "light" ? "#ffffff" : "#8c95a6",
2252
+ fontWeight: activeScheme === "light" ? 600 : 400,
2253
+ cursor: disabled ? "not-allowed" : "pointer",
2254
+ fontSize: "12px",
2255
+ transition: "all 0.15s ease"
2256
+ },
2257
+ children: "Light"
2258
+ }
2259
+ ),
2260
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2261
+ "button",
2262
+ {
2263
+ type: "button",
2264
+ role: "tab",
2265
+ "aria-selected": activeScheme === "dark",
2266
+ onClick: () => handleSchemeSelect("dark"),
2267
+ disabled,
2268
+ style: {
2269
+ flex: 1,
2270
+ padding: "6px 8px",
2271
+ border: "none",
2272
+ borderRadius: "4px",
2273
+ background: activeScheme === "dark" ? "#2d3342" : "transparent",
2274
+ color: activeScheme === "dark" ? "#ffffff" : "#8c95a6",
2275
+ fontWeight: activeScheme === "dark" ? 600 : 400,
2276
+ cursor: disabled ? "not-allowed" : "pointer",
2277
+ fontSize: "12px",
2278
+ transition: "all 0.15s ease"
2279
+ },
2280
+ children: "Dark"
2281
+ }
2282
+ )
2283
+ ]
2284
+ }
2285
+ ),
2286
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
2287
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2288
+ "button",
2289
+ {
2290
+ type: "button",
2291
+ onClick: () => handleSchemeSelect("light"),
2292
+ disabled,
2293
+ title: "Edit light mode colour",
2294
+ style: {
2295
+ flex: 1,
2296
+ display: "flex",
2297
+ flexDirection: "column",
2298
+ alignItems: "center",
2299
+ gap: "6px",
2300
+ padding: "8px",
2301
+ background: surfaces.light,
2302
+ color: "#000000",
2303
+ border: activeScheme === "light" ? "2px solid #3b82f6" : "1px solid #333842",
2304
+ borderRadius: "6px",
2305
+ cursor: disabled ? "not-allowed" : "pointer",
2306
+ outline: "none"
2307
+ },
2308
+ children: [
2309
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2310
+ "span",
2311
+ {
2312
+ style: {
2313
+ width: "100%",
2314
+ height: "24px",
2315
+ borderRadius: "4px",
2316
+ background: dual.light,
2317
+ border: "1px solid rgba(0,0,0,0.15)"
2318
+ }
2319
+ }
2320
+ ),
2321
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
2322
+ ]
2323
+ }
2324
+ ),
2325
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2326
+ "button",
2327
+ {
2328
+ type: "button",
2329
+ onClick: () => handleSchemeSelect("dark"),
2330
+ disabled,
2331
+ title: "Edit dark mode colour",
2332
+ style: {
2333
+ flex: 1,
2334
+ display: "flex",
2335
+ flexDirection: "column",
2336
+ alignItems: "center",
2337
+ gap: "6px",
2338
+ padding: "8px",
2339
+ background: surfaces.dark,
2340
+ color: "#ffffff",
2341
+ border: activeScheme === "dark" ? "2px solid #3b82f6" : "1px solid #333842",
2342
+ borderRadius: "6px",
2343
+ cursor: disabled ? "not-allowed" : "pointer",
2344
+ outline: "none"
2345
+ },
2346
+ children: [
2347
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2348
+ "span",
2349
+ {
2350
+ style: {
2351
+ width: "100%",
2352
+ height: "24px",
2353
+ borderRadius: "4px",
2354
+ background: dual.dark,
2355
+ border: "1px solid rgba(255,255,255,0.15)"
2356
+ }
2357
+ }
2358
+ ),
2359
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
2360
+ ]
2361
+ }
2362
+ )
2363
+ ] }),
2364
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2365
+ "div",
2366
+ {
2367
+ style: {
2368
+ display: "flex",
2369
+ alignItems: "center",
2370
+ justifyContent: "space-between",
2371
+ gap: "8px",
2372
+ padding: "2px 0"
2373
+ },
2374
+ children: [
2375
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2376
+ "label",
2377
+ {
2378
+ htmlFor: sameId,
2379
+ style: {
2380
+ display: "flex",
2381
+ alignItems: "center",
2382
+ gap: "6px",
2383
+ cursor: disabled ? "not-allowed" : "pointer",
2384
+ userSelect: "none",
2385
+ fontSize: "12px",
2386
+ color: "#c4cad4"
2387
+ },
2388
+ children: [
2389
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2390
+ "input",
2391
+ {
2392
+ id: sameId,
2393
+ type: "checkbox",
2394
+ checked: sameInBoth,
2395
+ onChange: handleSameToggle,
2396
+ disabled,
2397
+ style: { cursor: disabled ? "not-allowed" : "pointer" }
2398
+ }
2399
+ ),
2400
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "Same in both" })
2401
+ ]
2402
+ }
2403
+ ),
2404
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2405
+ "button",
2406
+ {
2407
+ type: "button",
2408
+ onClick: handleDerive,
2409
+ disabled,
2410
+ style: {
2411
+ padding: "4px 10px",
2412
+ background: "#2d3342",
2413
+ color: "#e2e8f0",
2414
+ border: "1px solid #3b4252",
2415
+ borderRadius: "4px",
2416
+ fontSize: "11px",
2417
+ fontWeight: 500,
2418
+ cursor: disabled ? "not-allowed" : "pointer"
2419
+ },
2420
+ children: "Derive"
2421
+ }
2422
+ )
2423
+ ]
2424
+ }
2425
+ ),
2426
+ dualContrast && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2427
+ "div",
2428
+ {
2429
+ "data-testid": "dual-contrast-summary",
2430
+ style: {
2431
+ display: "flex",
2432
+ justifyContent: "space-between",
2433
+ background: "#111318",
2434
+ padding: "6px 8px",
2435
+ borderRadius: "6px",
2436
+ fontSize: "11px",
2437
+ color: "#8c95a6"
2438
+ },
2439
+ children: [
2440
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
2441
+ "Light:",
2442
+ " ",
2443
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2444
+ dualContrast.light.ratio.toFixed(2),
2445
+ " (",
2446
+ dualContrast.light.level,
2447
+ ")"
2448
+ ] })
2449
+ ] }),
2450
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
2451
+ "Dark:",
2452
+ " ",
2453
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2454
+ dualContrast.dark.ratio.toFixed(2),
2455
+ " (",
2456
+ dualContrast.dark.level,
2457
+ ")"
2458
+ ] })
2459
+ ] })
2460
+ ]
2461
+ }
2462
+ ),
2463
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2464
+ ColorPicker,
2465
+ {
2466
+ value: activeColor,
2467
+ onChange: handleInnerChange,
2468
+ onGestureStart,
2469
+ onGestureEnd,
2470
+ contrastAgainst: activeContrastTarget,
2471
+ alpha,
2472
+ swatches,
2473
+ disabled
2474
+ }
2475
+ )
2476
+ ]
2477
+ }
2478
+ );
2479
+ }
2480
+
2481
+ // src/color/useColorScheme.ts
2482
+ var import_react15 = require("react");
2483
+ var import_color3 = require("@pixerate/editor/color");
2484
+ function getSnapshot(attribute) {
2485
+ if (typeof window === "undefined" || typeof document === "undefined") {
2486
+ return "light";
2487
+ }
2488
+ if (attribute) {
2489
+ const el = document.documentElement;
2490
+ if (attribute === "class") {
2491
+ return el.classList.contains("dark") ? "dark" : "light";
2492
+ }
2493
+ const val = el.getAttribute(attribute);
2494
+ return val === "dark" ? "dark" : "light";
2495
+ }
2496
+ if (typeof window.matchMedia === "function") {
2497
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
2498
+ }
2499
+ return "light";
2500
+ }
2501
+ function getServerSnapshot() {
2502
+ return "light";
2503
+ }
2504
+ function useColorScheme(options) {
2505
+ const override = options?.override;
2506
+ const attribute = options?.attribute;
2507
+ const subscribe = (0, import_react15.useMemo)(() => {
2508
+ return (callback) => {
2509
+ if (typeof window === "undefined" || typeof document === "undefined") {
2510
+ return () => {
2511
+ };
2512
+ }
2513
+ if (attribute) {
2514
+ const observer = new MutationObserver(() => {
2515
+ callback();
2516
+ });
2517
+ observer.observe(document.documentElement, {
2518
+ attributes: true,
2519
+ attributeFilter: [attribute]
2520
+ });
2521
+ return () => observer.disconnect();
2522
+ }
2523
+ if (typeof window.matchMedia === "function") {
2524
+ const mql = window.matchMedia("(prefers-color-scheme: dark)");
2525
+ const handler = () => callback();
2526
+ mql.addEventListener("change", handler);
2527
+ return () => mql.removeEventListener("change", handler);
2528
+ }
2529
+ return () => {
2530
+ };
2531
+ };
2532
+ }, [attribute]);
2533
+ const detected = (0, import_react15.useSyncExternalStore)(
2534
+ subscribe,
2535
+ () => getSnapshot(attribute),
2536
+ getServerSnapshot
2537
+ );
2538
+ return override ?? detected;
2539
+ }
2540
+ function useResolvedColor(value, scheme) {
2541
+ const detectedScheme = useColorScheme();
2542
+ const activeScheme = scheme ?? detectedScheme;
2543
+ return (0, import_color3.resolveColor)(value, activeScheme);
2544
+ }
2545
+
2546
+ // src/color/index.ts
2547
+ __reExport(color_exports, require("@pixerate/editor/color"));
2548
+
2549
+ // src/parameters/fields.tsx
2550
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1509
2551
  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";
1510
2552
  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";
1511
2553
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
@@ -1529,7 +2571,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
1529
2571
  onKeyDown: keyDown,
1530
2572
  ...rest
1531
2573
  };
1532
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "text", ...props }, value);
2574
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "text", ...props }, value);
1533
2575
  }
1534
2576
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
1535
2577
  function ParameterNumberInput({
@@ -1540,8 +2582,8 @@ function ParameterNumberInput({
1540
2582
  id,
1541
2583
  "aria-label": ariaLabel
1542
2584
  }) {
1543
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1544
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2585
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2586
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1545
2587
  ParameterCommitInput,
1546
2588
  {
1547
2589
  id,
@@ -1563,21 +2605,21 @@ function ParameterNumberInput({
1563
2605
  }
1564
2606
  }
1565
2607
  ),
1566
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
2608
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1567
2609
  ] });
1568
2610
  }
1569
2611
  function ParameterSlider(props) {
1570
2612
  const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
1571
- const dragging = (0, import_react13.useRef)(false);
2613
+ const dragging = (0, import_react16.useRef)(false);
1572
2614
  const end = () => {
1573
2615
  if (!dragging.current) return;
1574
2616
  dragging.current = false;
1575
2617
  onGestureEnd?.();
1576
2618
  };
1577
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterNumberInput, { ...props });
2619
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterNumberInput, { ...props });
1578
2620
  const step = (0, import_parameters.parameterStep)(field);
1579
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
1580
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2621
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
2622
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1581
2623
  "input",
1582
2624
  {
1583
2625
  type: "range",
@@ -1600,11 +2642,11 @@ function ParameterSlider(props) {
1600
2642
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
1601
2643
  }
1602
2644
  ),
1603
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
2645
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
1604
2646
  ] });
1605
2647
  }
1606
2648
  function ParameterToggle({ field, value, onChange, disabled, id }) {
1607
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2649
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1608
2650
  "button",
1609
2651
  {
1610
2652
  type: "button",
@@ -1615,7 +2657,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
1615
2657
  disabled: disabled || field.readOnly,
1616
2658
  onClick: () => onChange(!value),
1617
2659
  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"}`,
1618
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2660
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1619
2661
  "span",
1620
2662
  {
1621
2663
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -1628,7 +2670,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1628
2670
  const options = (0, import_parameters.getChoiceOptions)(field);
1629
2671
  const off = disabled || field.readOnly;
1630
2672
  if (field.control === "segmented") {
1631
- return /* @__PURE__ */ (0, import_jsx_runtime11.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_runtime11.jsx)(
2673
+ return /* @__PURE__ */ (0, import_jsx_runtime13.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_runtime13.jsx)(
1632
2674
  "button",
1633
2675
  {
1634
2676
  type: "button",
@@ -1644,7 +2686,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1644
2686
  )) });
1645
2687
  }
1646
2688
  const index = options.findIndex((o) => o.value === value);
1647
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2689
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1648
2690
  "select",
1649
2691
  {
1650
2692
  id,
@@ -1656,53 +2698,64 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1656
2698
  if (option) onChange(option.value);
1657
2699
  },
1658
2700
  className: parameterInputClass,
1659
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
2701
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
1660
2702
  }
1661
2703
  );
1662
2704
  }
1663
2705
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
1664
- const picking = (0, import_react13.useRef)(false);
2706
+ const [open, setOpen] = (0, import_react16.useState)(false);
2707
+ const containerRef = (0, import_react16.useRef)(null);
2708
+ const buttonRef = (0, import_react16.useRef)(null);
2709
+ const popoverRef = (0, import_react16.useRef)(null);
1665
2710
  const alpha = !!field.alpha;
1666
2711
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
1667
2712
  const rgb = hex.slice(0, 7);
1668
- const a = hex.slice(7);
2713
+ const shown = alpha ? hex : rgb;
1669
2714
  const off = disabled || field.readOnly;
1670
- const start = () => {
1671
- if (picking.current) return;
1672
- picking.current = true;
1673
- onGestureStart?.();
1674
- };
1675
- const end = () => {
1676
- if (!picking.current) return;
1677
- picking.current = false;
1678
- onGestureEnd?.();
1679
- };
1680
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-1.5", children: [
1681
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
1682
- /* @__PURE__ */ (0, import_jsx_runtime11.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: [
1683
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
1684
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1685
- "input",
1686
- {
1687
- type: "color",
1688
- "aria-label": (0, import_parameters.parameterLabel)(field),
1689
- value: rgb,
1690
- disabled: off,
1691
- className: "absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
1692
- onChange: (e) => {
1693
- start();
1694
- onChange(alpha ? `${e.target.value}${a}` : e.target.value);
1695
- },
1696
- onBlur: end
1697
- }
1698
- )
1699
- ] }),
1700
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2715
+ const name = (0, import_parameters.parameterLabel)(field);
2716
+ (0, import_react16.useEffect)(() => {
2717
+ if (!open) return;
2718
+ const onPointerDown = (e) => {
2719
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
2720
+ setOpen(false);
2721
+ }
2722
+ };
2723
+ const onKeyDown = (e) => {
2724
+ if (e.key === "Escape") {
2725
+ e.stopPropagation();
2726
+ setOpen(false);
2727
+ buttonRef.current?.focus();
2728
+ }
2729
+ };
2730
+ window.addEventListener("pointerdown", onPointerDown, true);
2731
+ window.addEventListener("keydown", onKeyDown, true);
2732
+ return () => {
2733
+ window.removeEventListener("pointerdown", onPointerDown, true);
2734
+ window.removeEventListener("keydown", onKeyDown, true);
2735
+ };
2736
+ }, [open]);
2737
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2738
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
2739
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2740
+ "button",
2741
+ {
2742
+ ref: buttonRef,
2743
+ type: "button",
2744
+ "aria-label": name,
2745
+ "aria-expanded": open,
2746
+ "aria-haspopup": "dialog",
2747
+ disabled: off,
2748
+ onClick: () => setOpen((prev) => !prev),
2749
+ 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",
2750
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
2751
+ }
2752
+ ),
2753
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1701
2754
  ParameterCommitInput,
1702
2755
  {
1703
2756
  id,
1704
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} hex`,
1705
- value: alpha ? hex : rgb,
2757
+ "aria-label": `${name} hex`,
2758
+ value: shown,
1706
2759
  disabled: off,
1707
2760
  spellCheck: false,
1708
2761
  className: `${parameterInputClass} font-mono`,
@@ -1713,51 +2766,43 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1713
2766
  }
1714
2767
  )
1715
2768
  ] }),
1716
- alpha && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1717
- "input",
2769
+ open && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2770
+ "div",
1718
2771
  {
1719
- type: "range",
1720
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} opacity`,
1721
- min: 0,
1722
- max: 255,
1723
- step: 1,
1724
- value: parseInt(a, 16),
1725
- disabled: off,
1726
- className: rangeClass,
1727
- onPointerDown: start,
1728
- onPointerUp: end,
1729
- onPointerCancel: end,
1730
- onBlur: end,
1731
- onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
1732
- }
1733
- ),
1734
- field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
1735
- const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
1736
- if (!swatch) return null;
1737
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1738
- "button",
1739
- {
1740
- type: "button",
1741
- title: swatch,
1742
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${swatch}`,
1743
- "aria-pressed": swatch === (alpha ? hex : rgb),
1744
- disabled: off,
1745
- onClick: () => onChange(swatch),
1746
- className: "h-5 w-5 rounded border border-input aria-pressed:ring-1 aria-pressed:ring-primary",
1747
- style: { background: swatch }
2772
+ ref: popoverRef,
2773
+ role: "dialog",
2774
+ "aria-label": name,
2775
+ tabIndex: -1,
2776
+ onBlur: (e) => {
2777
+ if (popoverRef.current && !popoverRef.current.contains(e.relatedTarget)) {
2778
+ setOpen(false);
2779
+ }
1748
2780
  },
1749
- s
1750
- );
1751
- }) })
2781
+ 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",
2782
+ style: { background: "var(--popover, var(--background, #fff))" },
2783
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2784
+ ColorPicker,
2785
+ {
2786
+ value: shown,
2787
+ alpha,
2788
+ swatches: field.swatches,
2789
+ disabled: off,
2790
+ onChange,
2791
+ onGestureStart,
2792
+ onGestureEnd
2793
+ }
2794
+ )
2795
+ }
2796
+ )
1752
2797
  ] });
1753
2798
  }
1754
2799
  function ParameterVector({ field, value, onChange, disabled, id }) {
1755
2800
  const size = (0, import_parameters.vectorSize)(field);
1756
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1757
2802
  const component = (0, import_parameters.vectorComponentField)(field, i);
1758
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1759
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1760
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2803
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
2804
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
2805
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1761
2806
  ParameterNumberInput,
1762
2807
  {
1763
2808
  field: component,
@@ -1774,11 +2819,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
1774
2819
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1775
2820
  const off = disabled || field.readOnly;
1776
2821
  const name = (0, import_parameters.parameterLabel)(field);
1777
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-1.5", children: [
1778
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
1779
- /* @__PURE__ */ (0, import_jsx_runtime11.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_runtime11.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1780
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1781
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2822
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1.5", children: [
2823
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
2824
+ /* @__PURE__ */ (0, import_jsx_runtime13.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_runtime13.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
2825
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
2826
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1782
2827
  ParameterCommitInput,
1783
2828
  {
1784
2829
  id,
@@ -1789,10 +2834,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1789
2834
  onCommit: (text) => onChange(text.trim())
1790
2835
  }
1791
2836
  ),
1792
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex gap-1", children: [
1793
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
2837
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex gap-1", children: [
2838
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1794
2839
  "Choose file\u2026",
1795
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2840
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1796
2841
  "input",
1797
2842
  {
1798
2843
  type: "file",
@@ -1808,11 +2853,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1808
2853
  }
1809
2854
  )
1810
2855
  ] }),
1811
- value && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
2856
+ value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1812
2857
  ] })
1813
2858
  ] })
1814
2859
  ] }),
1815
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2860
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1816
2861
  "button",
1817
2862
  {
1818
2863
  type: "button",
@@ -1822,14 +2867,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1822
2867
  disabled: off,
1823
2868
  onClick: () => onChange(o.url),
1824
2869
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
1825
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
2870
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1826
2871
  },
1827
2872
  o.url
1828
2873
  )) })
1829
2874
  ] });
1830
2875
  }
1831
2876
  function ParameterText({ field, value, onChange, disabled, id }) {
1832
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2877
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1833
2878
  ParameterCommitInput,
1834
2879
  {
1835
2880
  id,
@@ -1848,31 +2893,42 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
1848
2893
  switch (field.type) {
1849
2894
  case "number":
1850
2895
  case "int":
1851
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
2896
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1852
2897
  case "boolean":
1853
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
2898
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1854
2899
  case "choice":
1855
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
2900
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1856
2901
  case "color":
1857
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
2902
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1858
2903
  case "vector":
1859
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
2904
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1860
2905
  case "image":
1861
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
2906
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1862
2907
  case "text":
1863
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterText, { field, value, onChange: set, ...rest });
2908
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1864
2909
  }
1865
2910
  }
1866
2911
 
1867
2912
  // src/effects/EffectParameters.tsx
1868
- var import_jsx_runtime12 = require("react/jsx-runtime");
1869
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
1870
- const fields = (0, import_react14.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1871
- const idBase = (0, import_react14.useId)();
1872
- const gesture = import_react14.default.useRef(null);
1873
- const count = import_react14.default.useRef(0);
1874
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1875
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2913
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2914
+ function EffectParameters({
2915
+ description,
2916
+ values,
2917
+ onChange,
2918
+ onReset,
2919
+ keyframed,
2920
+ onPreset,
2921
+ onPresetName,
2922
+ renderControlAddon,
2923
+ disabled = false,
2924
+ className = ""
2925
+ }) {
2926
+ const fields = (0, import_react17.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
2927
+ const idBase = (0, import_react17.useId)();
2928
+ const gesture = import_react17.default.useRef(null);
2929
+ const count = import_react17.default.useRef(0);
2930
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
2931
+ (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1876
2932
  "select",
1877
2933
  {
1878
2934
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -1880,12 +2936,18 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1880
2936
  value: "",
1881
2937
  disabled,
1882
2938
  onChange: (e) => {
1883
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
1884
- if (preset) onPreset({ ...description.defaults, ...preset.values });
2939
+ const name = e.currentTarget.value;
2940
+ if (!name) return;
2941
+ if (onPresetName) {
2942
+ onPresetName(name);
2943
+ } else if (onPreset) {
2944
+ const preset = description.presets.find((p) => p.name === name);
2945
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
2946
+ }
1885
2947
  },
1886
2948
  children: [
1887
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: "Presets\u2026" }),
1888
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: p.name, children: p.name }, p.name))
2949
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "Presets\u2026" }),
2950
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: p.name, children: p.name }, p.name))
1889
2951
  ]
1890
2952
  }
1891
2953
  ),
@@ -1895,13 +2957,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1895
2957
  const keyed = keyframed?.has(field.id) ?? false;
1896
2958
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
1897
2959
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
1898
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
1899
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1900
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
1901
- keyed && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1902
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime12.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" })
2960
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
2961
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2962
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
2963
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
2964
+ renderControlAddon?.(field.id),
2965
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1903
2966
  ] }),
1904
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2967
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1905
2968
  ParameterFieldControl,
1906
2969
  {
1907
2970
  field,
@@ -1915,12 +2978,12 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1915
2978
  )
1916
2979
  ] }, field.id);
1917
2980
  }),
1918
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
2981
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1919
2982
  ] });
1920
2983
  }
1921
2984
 
1922
2985
  // src/image-editor/ImageProviderEffectsPanel.tsx
1923
- var import_jsx_runtime13 = require("react/jsx-runtime");
2986
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1924
2987
  var btn = "rounded border border-slate-700 px-1.5 py-0.5 text-[11px] text-slate-300 hover:text-white disabled:opacity-40";
1925
2988
  function Controls({
1926
2989
  provider,
@@ -1931,21 +2994,21 @@ function Controls({
1931
2994
  onPreset
1932
2995
  }) {
1933
2996
  const { description, error } = useEffectDescription(provider, effect);
1934
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
2997
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
1935
2998
  'No effects provider: "',
1936
2999
  name ?? effect,
1937
3000
  '" is kept but not drawn.'
1938
3001
  ] });
1939
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
1940
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1941
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectParameters, { description, values, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
3002
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
3003
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
3004
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EffectParameters, { description, values, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
1942
3005
  }
1943
3006
  function ImageProviderEffectsPanel({ controller, className = "" }) {
1944
- const [, setTick] = (0, import_react15.useState)(0);
1945
- (0, import_react15.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
1946
- const [browse, setBrowse] = (0, import_react15.useState)(null);
1947
- const [message, setMessage] = (0, import_react15.useState)(null);
1948
- const [open, setOpen] = (0, import_react15.useState)(null);
3007
+ const [, setTick] = (0, import_react18.useState)(0);
3008
+ (0, import_react18.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
3009
+ const [browse, setBrowse] = (0, import_react18.useState)(null);
3010
+ const [message, setMessage] = (0, import_react18.useState)(null);
3011
+ const [open, setOpen] = (0, import_react18.useState)(null);
1949
3012
  const provider = controller.effectsProvider;
1950
3013
  const state = controller.getState();
1951
3014
  const layer = state.activeLayerId ? (0, import_image_editor8.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
@@ -1953,7 +3016,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
1953
3016
  setMessage(null);
1954
3017
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
1955
3018
  };
1956
- const drags = import_react15.default.useRef(/* @__PURE__ */ new Set());
3019
+ const drags = import_react18.default.useRef(/* @__PURE__ */ new Set());
1957
3020
  const commit = (gesture) => {
1958
3021
  if (gesture) {
1959
3022
  if (!drags.current.has(gesture)) {
@@ -1967,21 +3030,21 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
1967
3030
  const filters = layer?.type === "smart" ? (layer.smartFilters?.filters ?? []).filter((f) => f.kind === "effect") : [];
1968
3031
  const generator = layer?.type === "pixel" ? layer.generator : void 0;
1969
3032
  const canFilter = !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
1970
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Provider effects", "data-image-provider-effects": "", children: [
1971
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
1972
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-slate-200", children: "Effects" }),
1973
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: !provider || !canFilter, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Apply effect\u2026" }),
1974
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => setBrowse(browse === "layer" ? null : "layer"), children: "Effect layer\u2026" })
3033
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Provider effects", "data-image-provider-effects": "", children: [
3034
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
3035
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-slate-200", children: "Effects" }),
3036
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, disabled: !provider || !canFilter, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Apply effect\u2026" }),
3037
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => setBrowse(browse === "layer" ? null : "layer"), children: "Effect layer\u2026" })
1975
3038
  ] }),
1976
- !provider && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the document are kept." }),
1977
- browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
1978
- browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectsBrowser, { provider, uses: ["generator", "overlay", "title"], title: "Generators and overlays", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id))) }),
1979
- generator && layer && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
1980
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
1981
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex-1 font-medium text-slate-200", children: generator.name ?? generator.effect }),
1982
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, title: "Keep the pixels as a plain layer", onClick: () => run(() => controller.rasterizeEffectLayer(layer.id)), children: "Rasterize" })
3039
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the document are kept." }),
3040
+ browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
3041
+ browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EffectsBrowser, { provider, uses: ["generator", "overlay", "title"], title: "Generators and overlays", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id))) }),
3042
+ generator && layer && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
3043
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
3044
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex-1 font-medium text-slate-200", children: generator.name ?? generator.effect }),
3045
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, title: "Keep the pixels as a plain layer", onClick: () => run(() => controller.rasterizeEffectLayer(layer.id)), children: "Rasterize" })
1983
3046
  ] }),
1984
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3047
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1985
3048
  Controls,
1986
3049
  {
1987
3050
  provider,
@@ -1993,26 +3056,26 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
1993
3056
  }
1994
3057
  )
1995
3058
  ] }),
1996
- filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", children: filters.map((f) => {
3059
+ filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", children: filters.map((f) => {
1997
3060
  const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
1998
3061
  const all = layer.smartFilters.filters;
1999
3062
  const index = all.indexOf(f);
2000
3063
  if (f.kind !== "effect") return null;
2001
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: "rounded border border-slate-700 p-1", "data-smart-effect": f.id, children: [
2002
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
2003
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "checkbox", checked: f.enabled, "aria-label": `${label} on`, onChange: (e) => {
3064
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("li", { className: "rounded border border-slate-700 p-1", "data-smart-effect": f.id, children: [
3065
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1", children: [
3066
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { type: "checkbox", checked: f.enabled, "aria-label": `${label} on`, onChange: (e) => {
2004
3067
  const enabled = e.currentTarget.checked;
2005
3068
  run(() => controller.updateEffectFilter(layer.id, f.id, { enabled }));
2006
3069
  } }),
2007
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left text-slate-200", "aria-expanded": open === f.id, onClick: () => setOpen(open === f.id ? null : f.id), children: label }),
2008
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: index === all.length - 1, "aria-label": "Move up", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index + 1 })), children: "\u2191" }),
2009
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: index === 0, "aria-label": "Move down", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index - 1 })), children: "\u2193" }),
2010
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, "aria-label": `Remove ${label}`, onClick: () => run(() => controller.removeSmartFilter(layer.id, f.id)), children: "\u2715" })
3070
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left text-slate-200", "aria-expanded": open === f.id, onClick: () => setOpen(open === f.id ? null : f.id), children: label }),
3071
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, disabled: index === all.length - 1, "aria-label": "Move up", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index + 1 })), children: "\u2191" }),
3072
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, disabled: index === 0, "aria-label": "Move down", onClick: () => run(() => controller.updateEffectFilter(layer.id, f.id, { index: index - 1 })), children: "\u2193" }),
3073
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: btn, "aria-label": `Remove ${label}`, onClick: () => run(() => controller.removeSmartFilter(layer.id, f.id)), children: "\u2715" })
2011
3074
  ] }),
2012
- open === f.id && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "mt-1 space-y-2", children: [
2013
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-1", children: [
2014
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w-14 text-[11px] text-slate-300", children: "Opacity" }),
2015
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3075
+ open === f.id && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mt-1 space-y-2", children: [
3076
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-1", children: [
3077
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-14 text-[11px] text-slate-300", children: "Opacity" }),
3078
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2016
3079
  "input",
2017
3080
  {
2018
3081
  type: "range",
@@ -2029,7 +3092,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
2029
3092
  }
2030
3093
  )
2031
3094
  ] }),
2032
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3095
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2033
3096
  Controls,
2034
3097
  {
2035
3098
  provider,
@@ -2043,13 +3106,13 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
2043
3106
  ] })
2044
3107
  ] }, f.id);
2045
3108
  }) }),
2046
- !layer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-slate-400", children: "Select a layer to apply effects to it." }),
2047
- message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: message })
3109
+ !layer && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-slate-400", children: "Select a layer to apply effects to it." }),
3110
+ message && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: message })
2048
3111
  ] });
2049
3112
  }
2050
3113
 
2051
3114
  // src/image-editor/BrushOptionsBar.tsx
2052
- var import_react17 = require("react");
3115
+ var import_react20 = require("react");
2053
3116
  var import_image_editor10 = require("@pixerate/editor/image-editor");
2054
3117
  var import_image_editor11 = require("@pixerate/editor/image-editor");
2055
3118
 
@@ -2057,8 +3120,8 @@ var import_image_editor11 = require("@pixerate/editor/image-editor");
2057
3120
  var import_image_editor9 = require("@pixerate/editor/image-editor");
2058
3121
 
2059
3122
  // src/paint-editor/PaintGradientEditorView.tsx
2060
- var import_react16 = require("react");
2061
- var import_jsx_runtime14 = require("react/jsx-runtime");
3123
+ var import_react19 = require("react");
3124
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2062
3125
  var button2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
2063
3126
  var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
2064
3127
  var number = "w-16 rounded bg-slate-800 px-1 py-0.5 text-[11px]";
@@ -2079,7 +3142,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
2079
3142
  reversePaintGradient,
2080
3143
  updatePaintGradientStop
2081
3144
  } = kit;
2082
- const [selected, setSelected] = (0, import_react16.useState)(0);
3145
+ const [selected, setSelected] = (0, import_react19.useState)(0);
2083
3146
  const sel = Math.min(selected, value.stops.length - 1);
2084
3147
  const stop = value.stops[sel];
2085
3148
  const map = value.map;
@@ -2089,15 +3152,15 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
2089
3152
  setSelected(r.index);
2090
3153
  onChange(r.paint);
2091
3154
  };
2092
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "paint-gradient-editor", "aria-label": "Gradient paint", children: [
2093
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
2094
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { "aria-label": "Gradient preset", className: select, value: "", onChange: (e) => e.target.value && (setSelected(0), onChange(PAINT_GRADIENT_PRESETS[Number(e.target.value)].paint)), children: [
2095
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "Presets\u2026" }),
2096
- PAINT_GRADIENT_PRESETS.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: i, children: p.name }, p.name))
3155
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "paint-gradient-editor", "aria-label": "Gradient paint", children: [
3156
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
3157
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { "aria-label": "Gradient preset", className: select, value: "", onChange: (e) => e.target.value && (setSelected(0), onChange(PAINT_GRADIENT_PRESETS[Number(e.target.value)].paint)), children: [
3158
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "Presets\u2026" }),
3159
+ PAINT_GRADIENT_PRESETS.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: i, children: p.name }, p.name))
2097
3160
  ] }),
2098
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: button2, onClick: () => onChange(reversePaintGradient(value)), children: "Reverse" })
3161
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button2, onClick: () => onChange(reversePaintGradient(value)), children: "Reverse" })
2099
3162
  ] }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3163
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2101
3164
  "div",
2102
3165
  {
2103
3166
  role: "slider",
@@ -2119,7 +3182,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
2119
3182
  }
2120
3183
  }
2121
3184
  ),
2122
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "relative h-4", "aria-label": "Stops", children: value.stops.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3185
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "relative h-4", "aria-label": "Stops", children: value.stops.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2123
3186
  "button",
2124
3187
  {
2125
3188
  type: "button",
@@ -2131,64 +3194,64 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
2131
3194
  },
2132
3195
  i
2133
3196
  )) }),
2134
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-stop", children: [
2135
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { "aria-label": "Stop colour source", className: select, value: stop.color === "paint" || stop.color === "secondary" ? stop.color : "color", onChange: (e) => patchStop({ color: e.target.value === "color" ? stopHex(stop.color) : e.target.value }), children: [
2136
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "color", children: "Colour" }),
2137
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "paint", children: "Paint colour" }),
2138
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "secondary", children: "Second colour" })
3197
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-stop", children: [
3198
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { "aria-label": "Stop colour source", className: select, value: stop.color === "paint" || stop.color === "secondary" ? stop.color : "color", onChange: (e) => patchStop({ color: e.target.value === "color" ? stopHex(stop.color) : e.target.value }), children: [
3199
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "color", children: "Colour" }),
3200
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "paint", children: "Paint colour" }),
3201
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "secondary", children: "Second colour" })
2139
3202
  ] }),
2140
- stop.color !== "paint" && stop.color !== "secondary" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "color", "aria-label": "Stop colour", value: stop.color, onChange: (e) => patchStop({ color: e.target.value }), className: "h-6 w-8 rounded bg-transparent" }),
2141
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
3203
+ stop.color !== "paint" && stop.color !== "secondary" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "color", "aria-label": "Stop colour", value: stop.color, onChange: (e) => patchStop({ color: e.target.value }), className: "h-6 w-8 rounded bg-transparent" }),
3204
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2142
3205
  "At",
2143
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Stop position", min: 0, max: 100, step: 1, value: pct(stop.offset), onChange: (e) => patchStop({ offset: Number(e.target.value) / 100 }), className: number }),
3206
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Stop position", min: 0, max: 100, step: 1, value: pct(stop.offset), onChange: (e) => patchStop({ offset: Number(e.target.value) / 100 }), className: number }),
2144
3207
  "%"
2145
3208
  ] }),
2146
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
3209
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2147
3210
  "Opacity",
2148
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Stop opacity", min: 0, max: 100, step: 5, value: pct(stop.opacity ?? 1), onChange: (e) => patchStop({ opacity: Number(e.target.value) / 100 }), className: number }),
3211
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Stop opacity", min: 0, max: 100, step: 5, value: pct(stop.opacity ?? 1), onChange: (e) => patchStop({ opacity: Number(e.target.value) / 100 }), className: number }),
2149
3212
  "%"
2150
3213
  ] }),
2151
- sel < value.stops.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
3214
+ sel < value.stops.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2152
3215
  "Midpoint",
2153
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Stop midpoint", min: 5, max: 95, step: 1, value: pct(stop.midpoint ?? 0.5), onChange: (e) => patchStop({ midpoint: Number(e.target.value) / 100 }), className: number }),
3216
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Stop midpoint", min: 5, max: 95, step: 1, value: pct(stop.midpoint ?? 0.5), onChange: (e) => patchStop({ midpoint: Number(e.target.value) / 100 }), className: number }),
2154
3217
  "%"
2155
3218
  ] }),
2156
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: button2, disabled: value.stops.length <= 2, onClick: () => (setSelected(Math.max(0, sel - 1)), onChange(removePaintGradientStop(value, sel))), children: "Remove stop" })
3219
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: button2, disabled: value.stops.length <= 2, onClick: () => (setSelected(Math.max(0, sel - 1)), onChange(removePaintGradientStop(value, sel))), children: "Remove stop" })
2157
3220
  ] }),
2158
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-mapping", children: [
2159
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("select", { "aria-label": "Gradient follows", className: select, value: map.by, onChange: (e) => onChange({ ...value, map: paintGradientMappingFor(e.target.value, map) }), children: PAINT_GRADIENT_MAPPINGS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: m, children: PAINT_GRADIENT_MAPPING_LABELS[m] }, m)) }),
2160
- map.by === "distance" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
2161
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Gradient length", min: 1, max: 1e5, value: map.length, onChange: (e) => onChange({ ...value, map: { ...map, length: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
2162
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { "aria-label": "Gradient length unit", className: select, value: map.unit ?? "px", onChange: (e) => onChange({ ...value, map: { ...map, unit: e.target.value } }), children: [
2163
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "px", children: "px" }),
2164
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "dabs", children: "dabs" })
3221
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-mapping", children: [
3222
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("select", { "aria-label": "Gradient follows", className: select, value: map.by, onChange: (e) => onChange({ ...value, map: paintGradientMappingFor(e.target.value, map) }), children: PAINT_GRADIENT_MAPPINGS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: m, children: PAINT_GRADIENT_MAPPING_LABELS[m] }, m)) }),
3223
+ map.by === "distance" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3224
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Gradient length", min: 1, max: 1e5, value: map.length, onChange: (e) => onChange({ ...value, map: { ...map, length: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
3225
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { "aria-label": "Gradient length unit", className: select, value: map.unit ?? "px", onChange: (e) => onChange({ ...value, map: { ...map, unit: e.target.value } }), children: [
3226
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "px", children: "px" }),
3227
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "dabs", children: "dabs" })
2165
3228
  ] })
2166
3229
  ] }),
2167
- map.by === "time" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Gradient duration", min: 1, max: 6e5, value: map.duration, onChange: (e) => onChange({ ...value, map: { ...map, duration: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
2168
- map.by === "random" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "number", "aria-label": "Dabs per pick", min: 1, max: 500, value: map.every ?? 1, onChange: (e) => onChange({ ...value, map: { ...map, every: Math.max(1, Math.round(Number(e.target.value) || 1)) } }), className: number }),
2169
- (map.by === "distance" || map.by === "time") && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("select", { "aria-label": "Gradient repeat", className: select, value: map.repeat ?? "clamp", onChange: (e) => onChange({ ...value, map: { ...map, repeat: e.target.value } }), children: PAINT_GRADIENT_REPEATS.map((r) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: r, children: PAINT_GRADIENT_REPEAT_LABELS[r] }, r)) })
3230
+ map.by === "time" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Gradient duration", min: 1, max: 6e5, value: map.duration, onChange: (e) => onChange({ ...value, map: { ...map, duration: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
3231
+ map.by === "random" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "number", "aria-label": "Dabs per pick", min: 1, max: 500, value: map.every ?? 1, onChange: (e) => onChange({ ...value, map: { ...map, every: Math.max(1, Math.round(Number(e.target.value) || 1)) } }), className: number }),
3232
+ (map.by === "distance" || map.by === "time") && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("select", { "aria-label": "Gradient repeat", className: select, value: map.repeat ?? "clamp", onChange: (e) => onChange({ ...value, map: { ...map, repeat: e.target.value } }), children: PAINT_GRADIENT_REPEATS.map((r) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: r, children: PAINT_GRADIENT_REPEAT_LABELS[r] }, r)) })
2170
3233
  ] }),
2171
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
2172
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("select", { "aria-label": "Gradient mixing", className: select, value: value.space, onChange: (e) => onChange({ ...value, space: e.target.value }), children: PAINT_GRADIENT_SPACES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: s, children: PAINT_GRADIENT_SPACE_LABELS[s] }, s)) }),
2173
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex flex-1 items-center gap-1", children: [
3234
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
3235
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("select", { "aria-label": "Gradient mixing", className: select, value: value.space, onChange: (e) => onChange({ ...value, space: e.target.value }), children: PAINT_GRADIENT_SPACES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: s, children: PAINT_GRADIENT_SPACE_LABELS[s] }, s)) }),
3236
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex flex-1 items-center gap-1", children: [
2174
3237
  "Softness",
2175
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "range", "aria-label": "Gradient softness", min: 0, max: 1, step: 0.05, value: value.softness ?? 1, onChange: (e) => onChange({ ...value, softness: Number(e.target.value) }), className: "flex-1 accent-indigo-500" })
3238
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "range", "aria-label": "Gradient softness", min: 0, max: 1, step: 0.05, value: value.softness ?? 1, onChange: (e) => onChange({ ...value, softness: Number(e.target.value) }), className: "flex-1 accent-indigo-500" })
2176
3239
  ] })
2177
3240
  ] })
2178
3241
  ] });
2179
3242
  };
2180
3243
 
2181
3244
  // src/image-editor/PaintGradientEditor.tsx
2182
- var import_jsx_runtime15 = require("react/jsx-runtime");
2183
- var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PaintGradientEditorView, { ...props, kit: import_image_editor9.PAINT_GRADIENT_KIT });
3245
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3246
+ var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaintGradientEditorView, { ...props, kit: import_image_editor9.PAINT_GRADIENT_KIT });
2184
3247
 
2185
3248
  // src/image-editor/BrushOptionsBar.tsx
2186
- var import_jsx_runtime16 = require("react/jsx-runtime");
3249
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2187
3250
  var chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
2188
3251
  var BrushOptionsBar = ({ controller, className }) => {
2189
- const [, setTick] = (0, import_react17.useState)(0);
2190
- (0, import_react17.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
2191
- const [error, setError] = (0, import_react17.useState)(null);
3252
+ const [, setTick] = (0, import_react20.useState)(0);
3253
+ (0, import_react20.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
3254
+ const [error, setError] = (0, import_react20.useState)(null);
2192
3255
  const state = controller.getState();
2193
3256
  const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource, paint } = state.paint;
2194
3257
  const tool = state.activeTool;
@@ -2200,8 +3263,8 @@ var BrushOptionsBar = ({ controller, className }) => {
2200
3263
  setError(err instanceof Error ? err.message : String(err));
2201
3264
  }
2202
3265
  };
2203
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "brush-options", children: [
2204
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Paint tools", children: import_image_editor10.PAINT_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3266
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "brush-options", children: [
3267
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Paint tools", children: import_image_editor10.PAINT_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2205
3268
  "button",
2206
3269
  {
2207
3270
  type: "button",
@@ -2213,9 +3276,9 @@ var BrushOptionsBar = ({ controller, className }) => {
2213
3276
  },
2214
3277
  t.id
2215
3278
  )) }),
2216
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", role: "group", "aria-label": "Colours", children: [
2217
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2218
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3279
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", role: "group", "aria-label": "Colours", children: [
3280
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1", children: [
3281
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2219
3282
  "input",
2220
3283
  {
2221
3284
  type: "color",
@@ -2225,10 +3288,10 @@ var BrushOptionsBar = ({ controller, className }) => {
2225
3288
  className: "h-6 w-8 rounded border border-slate-700 bg-transparent"
2226
3289
  }
2227
3290
  ),
2228
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: "FG" })
3291
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "FG" })
2229
3292
  ] }),
2230
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1", children: [
2231
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3293
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1", children: [
3294
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2232
3295
  "input",
2233
3296
  {
2234
3297
  type: "color",
@@ -2238,11 +3301,11 @@ var BrushOptionsBar = ({ controller, className }) => {
2238
3301
  className: "h-6 w-8 rounded border border-slate-700 bg-transparent"
2239
3302
  }
2240
3303
  ),
2241
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: "BG" })
3304
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: "BG" })
2242
3305
  ] }),
2243
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Swap colours (X)", className: chip(false), onClick: () => controller.swapPaintColors(), children: "Swap" }),
2244
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Default colours (D)", className: chip(false), onClick: () => controller.resetPaintColors(), children: "Default" }),
2245
- state.activeTool === "brush" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3306
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Swap colours (X)", className: chip(false), onClick: () => controller.swapPaintColors(), children: "Swap" }),
3307
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Default colours (D)", className: chip(false), onClick: () => controller.resetPaintColors(), children: "Default" }),
3308
+ state.activeTool === "brush" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2246
3309
  "button",
2247
3310
  {
2248
3311
  type: "button",
@@ -2254,8 +3317,8 @@ var BrushOptionsBar = ({ controller, className }) => {
2254
3317
  }
2255
3318
  )
2256
3319
  ] }),
2257
- state.activeTool === "brush" && paint.type === "gradient" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaintGradientEditor, { value: paint, colors: { paint: foreground, secondary: background }, onChange: (g) => attempt(() => controller.setPaintOptions({ paint: g })) }),
2258
- import_image_editor10.BRUSH_OPTION_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3320
+ state.activeTool === "brush" && paint.type === "gradient" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PaintGradientEditor, { value: paint, colors: { paint: foreground, secondary: background }, onChange: (g) => attempt(() => controller.setPaintOptions({ paint: g })) }),
3321
+ import_image_editor10.BRUSH_OPTION_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2259
3322
  ControlSlider,
2260
3323
  {
2261
3324
  spec,
@@ -2264,9 +3327,9 @@ var BrushOptionsBar = ({ controller, className }) => {
2264
3327
  },
2265
3328
  spec.id
2266
3329
  )),
2267
- state.activeTool === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-2 border-t border-slate-800 pt-2", role: "group", "aria-label": "Mixer Brush", "data-testid": "mixer-options", children: [
2268
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
2269
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3330
+ state.activeTool === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2 border-t border-slate-800 pt-2", role: "group", "aria-label": "Mixer Brush", "data-testid": "mixer-options", children: [
3331
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
3332
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2270
3333
  "span",
2271
3334
  {
2272
3335
  "aria-label": "Brush load",
@@ -2275,10 +3338,10 @@ var BrushOptionsBar = ({ controller, className }) => {
2275
3338
  style: { background: mixerLoad.reservoir ? (0, import_image_editor10.rgbUnitToHex)(mixerLoad.reservoir) : "transparent" }
2276
3339
  }
2277
3340
  ),
2278
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Fill the reservoir with the foreground colour", className: chip(false), onClick: () => controller.loadMixerBrush(), children: "Load brush" }),
2279
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Empty the picked-up colour", className: chip(false), onClick: () => controller.cleanMixerBrush(), children: "Clean brush" })
3341
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Fill the reservoir with the foreground colour", className: chip(false), onClick: () => controller.loadMixerBrush(), children: "Load brush" }),
3342
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Empty the picked-up colour", className: chip(false), onClick: () => controller.cleanMixerBrush(), children: "Clean brush" })
2280
3343
  ] }),
2281
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Mixing", children: import_image_editor10.MIXER_MIXING_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3344
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Mixing", children: import_image_editor10.MIXER_MIXING_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2282
3345
  "button",
2283
3346
  {
2284
3347
  type: "button",
@@ -2290,10 +3353,10 @@ var BrushOptionsBar = ({ controller, className }) => {
2290
3353
  },
2291
3354
  m.id
2292
3355
  )) }),
2293
- import_image_editor10.MIXER_OPTION_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ControlSlider, { spec, value: mixer[spec.id], onChange: (v) => controller.setPaintOptions({ mixer: { [spec.id]: v } }) }, spec.id)),
2294
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-3 text-slate-300", children: [
2295
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1.5", children: [
2296
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3356
+ import_image_editor10.MIXER_OPTION_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ControlSlider, { spec, value: mixer[spec.id], onChange: (v) => controller.setPaintOptions({ mixer: { [spec.id]: v } }) }, spec.id)),
3357
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-3 text-slate-300", children: [
3358
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
3359
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2297
3360
  "input",
2298
3361
  {
2299
3362
  type: "checkbox",
@@ -2305,8 +3368,8 @@ var BrushOptionsBar = ({ controller, className }) => {
2305
3368
  ),
2306
3369
  "Load each stroke"
2307
3370
  ] }),
2308
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1.5", children: [
2309
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3371
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
3372
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2310
3373
  "input",
2311
3374
  {
2312
3375
  type: "checkbox",
@@ -2320,22 +3383,22 @@ var BrushOptionsBar = ({ controller, className }) => {
2320
3383
  ] })
2321
3384
  ] })
2322
3385
  ] }),
2323
- (0, import_image_editor10.isRetouchPaintTool)(tool) && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-2 border-t border-slate-800 pt-2", role: "group", "aria-label": "Retouch options", "data-testid": "retouch-options", children: [
2324
- (tool === "clone" || tool === "heal") && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
2325
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", "data-testid": "clone-source", children: (0, import_image_editor10.cloneSourceLabel)(controller) }),
2326
- cloneSource && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Forget the source point", className: chip(false), onClick: () => controller.setCloneSource(null), children: "Clear source" })
3386
+ (0, import_image_editor10.isRetouchPaintTool)(tool) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2 border-t border-slate-800 pt-2", role: "group", "aria-label": "Retouch options", "data-testid": "retouch-options", children: [
3387
+ (tool === "clone" || tool === "heal") && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
3388
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", "data-testid": "clone-source", children: (0, import_image_editor10.cloneSourceLabel)(controller) }),
3389
+ cloneSource && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Forget the source point", className: chip(false), onClick: () => controller.setCloneSource(null), children: "Clear source" })
2327
3390
  ] }),
2328
- (tool === "clone" || tool === "heal") && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": "Clone source transform", "data-testid": "clone-transform", children: [
2329
- import_image_editor10.CLONE_TRANSFORM_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ControlSlider, { spec, value: (0, import_image_editor10.cloneTransformView)(controller)[spec.id], onChange: (v) => (0, import_image_editor10.setCloneTransformValue)(controller, spec.id, v) }, spec.id)),
2330
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-1", children: [
2331
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-pressed": (0, import_image_editor10.cloneTransformView)(controller).flipH, title: "Mirror the source left to right", className: chip((0, import_image_editor10.cloneTransformView)(controller).flipH), onClick: () => (0, import_image_editor10.setCloneTransformValue)(controller, "flipH"), children: "Flip H" }),
2332
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-pressed": (0, import_image_editor10.cloneTransformView)(controller).flipV, title: "Mirror the source top to bottom", className: chip((0, import_image_editor10.cloneTransformView)(controller).flipV), onClick: () => (0, import_image_editor10.setCloneTransformValue)(controller, "flipV"), children: "Flip V" }),
2333
- !(0, import_image_editor10.cloneTransformView)(controller).identity && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", title: "Back to 100 %, no flip, 0\xB0", className: chip(false), onClick: () => controller.setCloneTransform(null), children: "Reset transform" })
3391
+ (tool === "clone" || tool === "heal") && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": "Clone source transform", "data-testid": "clone-transform", children: [
3392
+ import_image_editor10.CLONE_TRANSFORM_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ControlSlider, { spec, value: (0, import_image_editor10.cloneTransformView)(controller)[spec.id], onChange: (v) => (0, import_image_editor10.setCloneTransformValue)(controller, spec.id, v) }, spec.id)),
3393
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
3394
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-pressed": (0, import_image_editor10.cloneTransformView)(controller).flipH, title: "Mirror the source left to right", className: chip((0, import_image_editor10.cloneTransformView)(controller).flipH), onClick: () => (0, import_image_editor10.setCloneTransformValue)(controller, "flipH"), children: "Flip H" }),
3395
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-pressed": (0, import_image_editor10.cloneTransformView)(controller).flipV, title: "Mirror the source top to bottom", className: chip((0, import_image_editor10.cloneTransformView)(controller).flipV), onClick: () => (0, import_image_editor10.setCloneTransformValue)(controller, "flipV"), children: "Flip V" }),
3396
+ !(0, import_image_editor10.cloneTransformView)(controller).identity && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", title: "Back to 100 %, no flip, 0\xB0", className: chip(false), onClick: () => controller.setCloneTransform(null), children: "Reset transform" })
2334
3397
  ] })
2335
3398
  ] }),
2336
- import_image_editor10.RETOUCH_CHOICES.filter((c) => c.tools.includes(tool)).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": choice.label, children: [
2337
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: choice.label }),
2338
- choice.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3399
+ import_image_editor10.RETOUCH_CHOICES.filter((c) => c.tools.includes(tool)).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": choice.label, children: [
3400
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-slate-400", children: choice.label }),
3401
+ choice.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2339
3402
  "button",
2340
3403
  {
2341
3404
  type: "button",
@@ -2348,9 +3411,9 @@ var BrushOptionsBar = ({ controller, className }) => {
2348
3411
  o.id
2349
3412
  ))
2350
3413
  ] }, choice.id)),
2351
- import_image_editor10.RETOUCH_OPTION_CONTROLS.filter((c) => c.tools.includes(tool)).map((spec) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ControlSlider, { spec, value: retouch[spec.id], onChange: (v) => controller.setPaintOptions({ retouch: { [spec.id]: v } }) }, spec.id)),
2352
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-wrap gap-3 text-slate-300", children: import_image_editor10.RETOUCH_TOGGLES.filter((t) => t.tools.includes(tool)).map((t) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1.5", children: [
2353
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3414
+ import_image_editor10.RETOUCH_OPTION_CONTROLS.filter((c) => c.tools.includes(tool)).map((spec) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ControlSlider, { spec, value: retouch[spec.id], onChange: (v) => controller.setPaintOptions({ retouch: { [spec.id]: v } }) }, spec.id)),
3415
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-wrap gap-3 text-slate-300", children: import_image_editor10.RETOUCH_TOGGLES.filter((t) => t.tools.includes(tool)).map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
3416
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2354
3417
  "input",
2355
3418
  {
2356
3419
  type: "checkbox",
@@ -2363,9 +3426,9 @@ var BrushOptionsBar = ({ controller, className }) => {
2363
3426
  t.label
2364
3427
  ] }, t.id)) })
2365
3428
  ] }),
2366
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-3 text-slate-300", role: "group", "aria-label": "Pressure", children: [
2367
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1.5", children: [
2368
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3429
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-3 text-slate-300", role: "group", "aria-label": "Pressure", children: [
3430
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
3431
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2369
3432
  "input",
2370
3433
  {
2371
3434
  type: "checkbox",
@@ -2377,8 +3440,8 @@ var BrushOptionsBar = ({ controller, className }) => {
2377
3440
  ),
2378
3441
  "Pressure size"
2379
3442
  ] }),
2380
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-1.5", children: [
2381
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3443
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
3444
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2382
3445
  "input",
2383
3446
  {
2384
3447
  type: "checkbox",
@@ -2391,27 +3454,27 @@ var BrushOptionsBar = ({ controller, className }) => {
2391
3454
  "Pressure opacity"
2392
3455
  ] })
2393
3456
  ] }),
2394
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex gap-1", children: [
2395
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: chip(false), onClick: () => attempt(() => controller.fillPixels()), children: "Fill" }),
2396
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: chip(false), onClick: () => attempt(() => controller.clearPixels()), children: "Clear" })
3457
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
3458
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: chip(false), onClick: () => attempt(() => controller.fillPixels()), children: "Fill" }),
3459
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: chip(false), onClick: () => attempt(() => controller.clearPixels()), children: "Clear" })
2397
3460
  ] }),
2398
- error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
3461
+ error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
2399
3462
  ] });
2400
3463
  };
2401
3464
 
2402
3465
  // src/image-editor/ColorProfilePanel.tsx
2403
- var import_react18 = require("react");
3466
+ var import_react21 = require("react");
2404
3467
  var import_image_editor12 = require("@pixerate/editor/image-editor");
2405
- var import_jsx_runtime17 = require("react/jsx-runtime");
3468
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2406
3469
  var chip2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-300 hover:text-white";
2407
3470
  var select2 = "rounded bg-slate-800 px-1 py-0.5 text-[11px] text-slate-200";
2408
3471
  var ColorProfilePanel = ({ controller, className }) => {
2409
- const [, setTick] = (0, import_react18.useState)(0);
2410
- (0, import_react18.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
2411
- const [target, setTarget] = (0, import_react18.useState)("display-p3");
2412
- const [intent, setIntent] = (0, import_react18.useState)("relative");
2413
- const [bpc, setBpc] = (0, import_react18.useState)(true);
2414
- const [error, setError] = (0, import_react18.useState)(null);
3472
+ const [, setTick] = (0, import_react21.useState)(0);
3473
+ (0, import_react21.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
3474
+ const [target, setTarget] = (0, import_react21.useState)("display-p3");
3475
+ const [intent, setIntent] = (0, import_react21.useState)("relative");
3476
+ const [bpc, setBpc] = (0, import_react21.useState)(true);
3477
+ const [error, setError] = (0, import_react21.useState)(null);
2415
3478
  const view = (0, import_image_editor12.colorPanelView)(controller);
2416
3479
  const attempt = (fn) => {
2417
3480
  try {
@@ -2433,29 +3496,29 @@ var ColorProfilePanel = ({ controller, className }) => {
2433
3496
  })
2434
3497
  );
2435
3498
  };
2436
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "color-profile-panel", children: [
2437
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
2438
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Profile" }),
2439
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { "data-testid": "color-profile-name", children: view.profileName })
3499
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "color-profile-panel", children: [
3500
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
3501
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: "Profile" }),
3502
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { "data-testid": "color-profile-name", children: view.profileName })
2440
3503
  ] }),
2441
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Colour mode", children: [
2442
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Mode" }),
2443
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Colour mode", className: select2, value: view.mode, onChange: (e) => attempt(() => controller.setColorMode(e.target.value)), children: import_image_editor12.COLOR_MODE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.id, title: o.title, children: o.label }, o.id)) }),
2444
- view.cmykProfileName && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: view.cmykProfileName })
3504
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Colour mode", children: [
3505
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: "Mode" }),
3506
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("select", { "aria-label": "Colour mode", className: select2, value: view.mode, onChange: (e) => attempt(() => controller.setColorMode(e.target.value)), children: import_image_editor12.COLOR_MODE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: o.id, title: o.title, children: o.label }, o.id)) }),
3507
+ view.cmykProfileName && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: view.cmykProfileName })
2445
3508
  ] }),
2446
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Assign or convert", children: [
2447
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Target profile", className: select2, value: target, onChange: (e) => setTarget(e.target.value), children: import_image_editor12.WORKING_SPACE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.id, children: o.label }, o.id)) }),
2448
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Rendering intent", className: select2, value: intent, onChange: (e) => setIntent(e.target.value), children: import_image_editor12.INTENT_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.id, title: o.title, children: o.label }, o.id)) }),
2449
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-1", children: [
2450
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "checkbox", "aria-label": "Black point compensation", checked: bpc, onChange: (e) => setBpc(e.target.checked), className: "accent-indigo-500" }),
3509
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Assign or convert", children: [
3510
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("select", { "aria-label": "Target profile", className: select2, value: target, onChange: (e) => setTarget(e.target.value), children: import_image_editor12.WORKING_SPACE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: o.id, children: o.label }, o.id)) }),
3511
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("select", { "aria-label": "Rendering intent", className: select2, value: intent, onChange: (e) => setIntent(e.target.value), children: import_image_editor12.INTENT_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: o.id, title: o.title, children: o.label }, o.id)) }),
3512
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1", children: [
3513
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "checkbox", "aria-label": "Black point compensation", checked: bpc, onChange: (e) => setBpc(e.target.checked), className: "accent-indigo-500" }),
2451
3514
  "BPC"
2452
3515
  ] }),
2453
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: chip2, title: "Edit \u203A Assign Profile: keep the numbers", onClick: () => attempt(() => controller.assignProfile(target)), children: "Assign" }),
2454
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: chip2, title: "Edit \u203A Convert to Profile: keep the look", onClick: () => attempt(() => controller.convertToProfile(target, { intent, bpc })), children: "Convert" })
3516
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: chip2, title: "Edit \u203A Assign Profile: keep the numbers", onClick: () => attempt(() => controller.assignProfile(target)), children: "Assign" }),
3517
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: chip2, title: "Edit \u203A Convert to Profile: keep the look", onClick: () => attempt(() => controller.convertToProfile(target, { intent, bpc })), children: "Convert" })
2455
3518
  ] }),
2456
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Proof setup", children: [
2457
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-slate-400", children: "Proof" }),
2458
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
3519
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Proof setup", children: [
3520
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-slate-400", children: "Proof" }),
3521
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2459
3522
  "select",
2460
3523
  {
2461
3524
  "aria-label": "Proof profile",
@@ -2463,31 +3526,31 @@ var ColorProfilePanel = ({ controller, className }) => {
2463
3526
  value: view.proof?.id ?? "",
2464
3527
  onChange: (e) => e.target.value ? proofWith({ id: e.target.value }) : attempt(() => controller.setProofSetup(null)),
2465
3528
  children: [
2466
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "Off" }),
2467
- import_image_editor12.PROOF_PROFILE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.id, children: o.label }, o.id))
3529
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "Off" }),
3530
+ import_image_editor12.PROOF_PROFILE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: o.id, children: o.label }, o.id))
2468
3531
  ]
2469
3532
  }
2470
3533
  ),
2471
- view.proof && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
2472
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("select", { "aria-label": "Proof intent", className: select2, value: view.proof.intent, onChange: (e) => proofWith({ intent: e.target.value }), children: import_image_editor12.INTENT_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: o.id, children: o.label }, o.id)) }),
2473
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-1", children: [
2474
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "checkbox", "aria-label": "Simulate paper colour", checked: view.proof.simulatePaper, onChange: (e) => proofWith({ simulatePaper: e.target.checked }), className: "accent-indigo-500" }),
3534
+ view.proof && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
3535
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("select", { "aria-label": "Proof intent", className: select2, value: view.proof.intent, onChange: (e) => proofWith({ intent: e.target.value }), children: import_image_editor12.INTENT_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: o.id, children: o.label }, o.id)) }),
3536
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1", children: [
3537
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "checkbox", "aria-label": "Simulate paper colour", checked: view.proof.simulatePaper, onChange: (e) => proofWith({ simulatePaper: e.target.checked }), className: "accent-indigo-500" }),
2475
3538
  "Paper"
2476
3539
  ] }),
2477
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-1", children: [
2478
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "checkbox", "aria-label": "Gamut warning", checked: view.proof.gamutWarning, onChange: (e) => proofWith({ gamutWarning: e.target.checked }), className: "accent-indigo-500" }),
3540
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1", children: [
3541
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "checkbox", "aria-label": "Gamut warning", checked: view.proof.gamutWarning, onChange: (e) => proofWith({ gamutWarning: e.target.checked }), className: "accent-indigo-500" }),
2479
3542
  "Gamut warning"
2480
3543
  ] })
2481
3544
  ] })
2482
3545
  ] }),
2483
- error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
3546
+ error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
2484
3547
  ] });
2485
3548
  };
2486
3549
 
2487
3550
  // src/image-editor/SelectionOptionsBar.tsx
2488
- var import_react19 = require("react");
3551
+ var import_react22 = require("react");
2489
3552
  var import_image_editor13 = require("@pixerate/editor/image-editor");
2490
- var import_jsx_runtime18 = require("react/jsx-runtime");
3553
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2491
3554
  var MODIFY_OPS = [
2492
3555
  { op: "grow", label: "Grow" },
2493
3556
  { op: "shrink", label: "Shrink" },
@@ -2504,20 +3567,20 @@ var SelectionOptionsBar = ({
2504
3567
  quickMask,
2505
3568
  className = ""
2506
3569
  }) => {
2507
- const [radius, setRadius] = (0, import_react19.useState)(2);
3570
+ const [radius, setRadius] = (0, import_react22.useState)(2);
2508
3571
  const set = (patch) => onOptionsChange({ ...options, ...patch });
2509
3572
  const sel = selection === void 0 ? controller.getSelection() : selection;
2510
3573
  const qm = quickMask ?? Boolean(controller.getState().quickMask);
2511
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-testid": "selection-options-bar", className: `flex flex-col gap-3 text-xs ${className}`, children: [
2512
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "group", "aria-label": "Selection tool", className: "flex flex-wrap gap-1", children: import_image_editor13.SELECTION_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-pressed": options.tool === t.id, className: btn2(options.tool === t.id), onClick: () => set({ tool: t.id }), children: t.label }, t.id)) }),
2513
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "group", "aria-label": "Selection mode", className: "flex flex-wrap gap-1", children: import_image_editor13.SELECTION_MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-pressed": options.mode === m, className: btn2(options.mode === m), onClick: () => set({ mode: m }), children: import_image_editor13.SELECTION_MODE_LABELS[m] }, m)) }),
2514
- options.tool === "wand" && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2515
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex flex-col gap-1", children: [
2516
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
2517
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Tolerance" }),
2518
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "font-mono", children: options.tolerance })
3574
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { "data-testid": "selection-options-bar", className: `flex flex-col gap-3 text-xs ${className}`, children: [
3575
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { role: "group", "aria-label": "Selection tool", className: "flex flex-wrap gap-1", children: import_image_editor13.SELECTION_TOOLS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", "aria-pressed": options.tool === t.id, className: btn2(options.tool === t.id), onClick: () => set({ tool: t.id }), children: t.label }, t.id)) }),
3576
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { role: "group", "aria-label": "Selection mode", className: "flex flex-wrap gap-1", children: import_image_editor13.SELECTION_MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", "aria-pressed": options.mode === m, className: btn2(options.mode === m), onClick: () => set({ mode: m }), children: import_image_editor13.SELECTION_MODE_LABELS[m] }, m)) }),
3577
+ options.tool === "wand" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-2", children: [
3578
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex flex-col gap-1", children: [
3579
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
3580
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "Tolerance" }),
3581
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-mono", children: options.tolerance })
2519
3582
  ] }),
2520
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3583
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2521
3584
  "input",
2522
3585
  {
2523
3586
  type: "range",
@@ -2531,17 +3594,17 @@ var SelectionOptionsBar = ({
2531
3594
  }
2532
3595
  )
2533
3596
  ] }),
2534
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
2535
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "checkbox", checked: options.contiguous, onChange: (e) => set({ contiguous: e.target.checked }) }),
3597
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
3598
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "checkbox", checked: options.contiguous, onChange: (e) => set({ contiguous: e.target.checked }) }),
2536
3599
  "Contiguous"
2537
3600
  ] }),
2538
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
2539
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "checkbox", checked: options.sampleMerged, onChange: (e) => set({ sampleMerged: e.target.checked }) }),
3601
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
3602
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "checkbox", checked: options.sampleMerged, onChange: (e) => set({ sampleMerged: e.target.checked }) }),
2540
3603
  "Sample adjusted image"
2541
3604
  ] }),
2542
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
3605
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
2543
3606
  "Sample",
2544
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3607
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2545
3608
  "select",
2546
3609
  {
2547
3610
  "aria-label": "Sample from",
@@ -2549,27 +3612,27 @@ var SelectionOptionsBar = ({
2549
3612
  onChange: (e) => set({ sample: e.target.value }),
2550
3613
  className: "bg-slate-800 border border-slate-700 rounded px-1 py-0.5",
2551
3614
  children: [
2552
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "composite", children: "All layers" }),
2553
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "active-layer", children: "Active layer" })
3615
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "composite", children: "All layers" }),
3616
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "active-layer", children: "Active layer" })
2554
3617
  ]
2555
3618
  }
2556
3619
  )
2557
3620
  ] })
2558
3621
  ] }),
2559
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
2560
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "checkbox", checked: options.antiAlias, onChange: (e) => set({ antiAlias: e.target.checked }) }),
3622
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
3623
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "checkbox", checked: options.antiAlias, onChange: (e) => set({ antiAlias: e.target.checked }) }),
2561
3624
  "Anti-alias"
2562
3625
  ] }),
2563
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
2564
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2(false), onClick: () => controller.selectAll(), children: "Select All" }),
2565
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
2566
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
2567
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-pressed": qm, className: btn2(qm), onClick: () => controller.setQuickMask(!qm), children: "Quick Mask" })
3626
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
3627
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn2(false), onClick: () => controller.selectAll(), children: "Select All" }),
3628
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn2(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
3629
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn2(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
3630
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", "aria-pressed": qm, className: btn2(qm), onClick: () => controller.setQuickMask(!qm), children: "Quick Mask" })
2568
3631
  ] }),
2569
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
2570
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1 text-slate-400", children: [
3632
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3633
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1 text-slate-400", children: [
2571
3634
  "Radius",
2572
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3635
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2573
3636
  "input",
2574
3637
  {
2575
3638
  type: "number",
@@ -2583,24 +3646,24 @@ var SelectionOptionsBar = ({
2583
3646
  }
2584
3647
  )
2585
3648
  ] }),
2586
- MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
3649
+ MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn2(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
2587
3650
  ] }),
2588
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { "data-testid": "selection-status", className: "text-slate-400", children: (0, import_image_editor13.describeSelection)(sel) })
3651
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { "data-testid": "selection-status", className: "text-slate-400", children: (0, import_image_editor13.describeSelection)(sel) })
2589
3652
  ] });
2590
3653
  };
2591
3654
 
2592
3655
  // src/image-editor/RefineEdgePanel.tsx
2593
- var import_react20 = require("react");
3656
+ var import_react23 = require("react");
2594
3657
  var import_image_editor14 = require("@pixerate/editor/image-editor");
2595
- var import_jsx_runtime19 = require("react/jsx-runtime");
3658
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2596
3659
  var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
2597
3660
  var button3 = "px-2 py-1 rounded-md border border-slate-800 bg-slate-950 text-[11px] text-slate-200 hover:text-white disabled:opacity-40";
2598
3661
  var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2599
- const [params, setParams] = (0, import_react20.useState)(DEFAULT_PARAMS);
2600
- const [busy, setBusy] = (0, import_react20.useState)(false);
2601
- const [error, setError] = (0, import_react20.useState)(null);
2602
- const [layerId, setLayerId] = (0, import_react20.useState)("");
2603
- const [newKind, setNewKind] = (0, import_react20.useState)("hueSaturation");
3662
+ const [params, setParams] = (0, import_react23.useState)(DEFAULT_PARAMS);
3663
+ const [busy, setBusy] = (0, import_react23.useState)(false);
3664
+ const [error, setError] = (0, import_react23.useState)(null);
3665
+ const [layerId, setLayerId] = (0, import_react23.useState)("");
3666
+ const [newKind, setNewKind] = (0, import_react23.useState)("hueSaturation");
2604
3667
  const sel = selection === void 0 ? controller.getSelection() : selection;
2605
3668
  const list = layers ?? controller.getAdjustmentLayers();
2606
3669
  const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
@@ -2615,17 +3678,17 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2615
3678
  setBusy(false);
2616
3679
  }
2617
3680
  };
2618
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { "data-testid": "refine-edge-panel", className: `flex flex-col gap-3 text-xs ${className}`, children: [
2619
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Refine Edge" }),
2620
- import_image_editor14.REFINE_EDGE_CONTROLS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex flex-col gap-1", children: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
2622
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: c.label }),
2623
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "font-mono", children: [
3681
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { "data-testid": "refine-edge-panel", className: `flex flex-col gap-3 text-xs ${className}`, children: [
3682
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Refine Edge" }),
3683
+ import_image_editor14.REFINE_EDGE_CONTROLS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex flex-col gap-1", children: [
3684
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
3685
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: c.label }),
3686
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "font-mono", children: [
2624
3687
  params[c.id],
2625
3688
  c.unit
2626
3689
  ] })
2627
3690
  ] }),
2628
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3691
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2629
3692
  "input",
2630
3693
  {
2631
3694
  type: "range",
@@ -2639,28 +3702,28 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2639
3702
  }
2640
3703
  )
2641
3704
  ] }, c.id)),
2642
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
2643
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "checkbox", checked: params.smartRadius, onChange: (e) => setParams({ ...params, smartRadius: e.target.checked }) }),
3705
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-2 text-slate-300", children: [
3706
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", checked: params.smartRadius, onChange: (e) => setParams({ ...params, smartRadius: e.target.checked }) }),
2644
3707
  "Smart Radius"
2645
3708
  ] }),
2646
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1", children: [
2647
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button3, disabled: !sel || busy, onClick: refine, children: "Refine Edge" }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button3, onClick: () => setParams(DEFAULT_PARAMS), children: "Reset" })
3709
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-1", children: [
3710
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button3, disabled: !sel || busy, onClick: refine, children: "Refine Edge" }),
3711
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button3, onClick: () => setParams(DEFAULT_PARAMS), children: "Reset" })
2649
3712
  ] }),
2650
- error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-rose-400", children: error }),
2651
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] mt-2", children: "Layer Mask" }),
2652
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1 items-center", children: [
2653
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3713
+ error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { role: "alert", className: "text-rose-400", children: error }),
3714
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] mt-2", children: "Layer Mask" }),
3715
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-1 items-center", children: [
3716
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2654
3717
  "select",
2655
3718
  {
2656
3719
  "aria-label": "New masked layer kind",
2657
3720
  value: newKind,
2658
3721
  onChange: (e) => setNewKind(e.target.value),
2659
3722
  className: "flex-1 bg-slate-950 border border-slate-800 rounded px-1 py-1 text-slate-200",
2660
- children: import_image_editor14.ADJUSTMENT_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: k.kind, children: k.label }, k.kind))
3723
+ children: import_image_editor14.ADJUSTMENT_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: k.kind, children: k.label }, k.kind))
2661
3724
  }
2662
3725
  ),
2663
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3726
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2664
3727
  "button",
2665
3728
  {
2666
3729
  type: "button",
@@ -2671,35 +3734,35 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2671
3734
  }
2672
3735
  )
2673
3736
  ] }),
2674
- list.length > 0 && target && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col gap-2", children: [
2675
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3737
+ list.length > 0 && target && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-2", children: [
3738
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2676
3739
  "select",
2677
3740
  {
2678
3741
  "aria-label": "Mask layer",
2679
3742
  value: target.id,
2680
3743
  onChange: (e) => setLayerId(e.target.value),
2681
3744
  className: "bg-slate-950 border border-slate-800 rounded px-1 py-1 text-slate-200",
2682
- children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("option", { value: l.id, children: [
3745
+ children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: l.id, children: [
2683
3746
  l.name || (0, import_image_editor14.adjustmentKindLabel)(l.kind),
2684
3747
  l.mask ? " (masked)" : ""
2685
3748
  ] }, l.id))
2686
3749
  }
2687
3750
  ),
2688
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
2689
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button3, disabled: !sel, onClick: () => controller.applySelectionAsLayerMask(target.id), children: "Mask with Selection" }),
2690
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button3, disabled: !target.mask, onClick: () => controller.selectionFromLayerMask(target.id), children: "Load as Selection" }),
2691
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: button3, disabled: !target.mask, onClick: () => controller.setAdjustmentLayerMask(target.id, null), children: "Remove Mask" })
3751
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
3752
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button3, disabled: !sel, onClick: () => controller.applySelectionAsLayerMask(target.id), children: "Mask with Selection" }),
3753
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button3, disabled: !target.mask, onClick: () => controller.selectionFromLayerMask(target.id), children: "Load as Selection" }),
3754
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button3, disabled: !target.mask, onClick: () => controller.setAdjustmentLayerMask(target.id, null), children: "Remove Mask" })
2692
3755
  ] }),
2693
- target.mask && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
2694
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex flex-col gap-1", children: [
2695
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
2696
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Density" }),
2697
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "font-mono", children: [
3756
+ target.mask && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
3757
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex flex-col gap-1", children: [
3758
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
3759
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Density" }),
3760
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "font-mono", children: [
2698
3761
  Math.round((target.mask.density ?? 1) * 100),
2699
3762
  "%"
2700
3763
  ] })
2701
3764
  ] }),
2702
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3765
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2703
3766
  "input",
2704
3767
  {
2705
3768
  type: "range",
@@ -2713,15 +3776,15 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2713
3776
  }
2714
3777
  )
2715
3778
  ] }),
2716
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex flex-col gap-1", children: [
2717
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
2718
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Mask Feather" }),
2719
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "font-mono", children: [
3779
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex flex-col gap-1", children: [
3780
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex justify-between text-slate-400", children: [
3781
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Mask Feather" }),
3782
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "font-mono", children: [
2720
3783
  target.mask.feather ?? 0,
2721
3784
  "px"
2722
3785
  ] })
2723
3786
  ] }),
2724
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3787
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2725
3788
  "input",
2726
3789
  {
2727
3790
  type: "range",
@@ -2741,14 +3804,14 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
2741
3804
  };
2742
3805
 
2743
3806
  // src/image-editor/FreeTransformOptionsBar.tsx
2744
- var import_react21 = require("react");
3807
+ var import_react24 = require("react");
2745
3808
  var import_image_editor15 = require("@pixerate/editor/image-editor");
2746
- var import_jsx_runtime20 = require("react/jsx-runtime");
3809
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2747
3810
  var chip3 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
2748
3811
  var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
2749
3812
  var FreeTransformOptionsBar = ({ tool, className }) => {
2750
- const [, setTick] = (0, import_react21.useState)(0);
2751
- (0, import_react21.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
3813
+ const [, setTick] = (0, import_react24.useState)(0);
3814
+ (0, import_react24.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
2752
3815
  const bar = tool.bar();
2753
3816
  if (!tool.active || !bar) return null;
2754
3817
  const warp = tool.warpBar();
@@ -2760,17 +3823,17 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2760
3823
  const v = Number(raw);
2761
3824
  if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
2762
3825
  };
2763
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `flex flex-wrap items-center gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "free-transform-options", role: "toolbar", "aria-label": "Free Transform options", children: [
2764
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor15.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", title: m.title, "aria-pressed": tool.mode === m.id, className: chip3(tool.mode === m.id), onClick: () => tool.setMode(m.id), children: m.label }, m.id)) }),
2765
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor15.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", "aria-label": `Reference point ${a}`, title: `Reference point: ${a}`, className: "h-2.5 w-2.5 rounded-sm bg-slate-700 hover:bg-indigo-500", onClick: () => tool.setReference(a) }, a)) }),
2766
- tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
2767
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
2768
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-400", children: "Warp" }),
2769
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5", children: import_image_editor15.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: o.id, children: o.label }, o.id)) })
3826
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `flex flex-wrap items-center gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "free-transform-options", role: "toolbar", "aria-label": "Free Transform options", children: [
3827
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor15.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", title: m.title, "aria-pressed": tool.mode === m.id, className: chip3(tool.mode === m.id), onClick: () => tool.setMode(m.id), children: m.label }, m.id)) }),
3828
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor15.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", "aria-label": `Reference point ${a}`, title: `Reference point: ${a}`, className: "h-2.5 w-2.5 rounded-sm bg-slate-700 hover:bg-indigo-500", onClick: () => tool.setReference(a) }, a)) }),
3829
+ tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
3830
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3831
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "Warp" }),
3832
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5", children: import_image_editor15.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: o.id, children: o.label }, o.id)) })
2770
3833
  ] }),
2771
- ["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
2772
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-400", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
2773
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3834
+ ["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3835
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
3836
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2774
3837
  "input",
2775
3838
  {
2776
3839
  type: "number",
@@ -2791,9 +3854,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2791
3854
  },
2792
3855
  `${k}:${warp[k]}`
2793
3856
  ),
2794
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-500", children: "%" })
3857
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-500", children: "%" })
2795
3858
  ] }, k)),
2796
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3859
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2797
3860
  "button",
2798
3861
  {
2799
3862
  type: "button",
@@ -2805,9 +3868,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2805
3868
  children: "Vertical"
2806
3869
  }
2807
3870
  ),
2808
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
2809
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-400", children: "Grid" }),
2810
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3871
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3872
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "Grid" }),
3873
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2811
3874
  "select",
2812
3875
  {
2813
3876
  "aria-label": "Warp grid",
@@ -2817,14 +3880,14 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2817
3880
  tool.setWarp({ columns: g.columns, rows: g.rows });
2818
3881
  },
2819
3882
  className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5",
2820
- children: import_image_editor15.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: g.id, children: g.label }, g.id))
3883
+ children: import_image_editor15.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: g.id, children: g.label }, g.id))
2821
3884
  }
2822
3885
  )
2823
3886
  ] })
2824
3887
  ] }),
2825
- tool.mode !== "warp" && import_image_editor15.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
2826
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-400", children: f.label }),
2827
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3888
+ tool.mode !== "warp" && import_image_editor15.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
3889
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: f.label }),
3890
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2828
3891
  "input",
2829
3892
  {
2830
3893
  type: "number",
@@ -2844,8 +3907,8 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2844
3907
  },
2845
3908
  `${f.id}:${round(bar[f.id], f.unit)}`
2846
3909
  ),
2847
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-500", children: f.unit }),
2848
- f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3910
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-500", children: f.unit }),
3911
+ f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2849
3912
  "button",
2850
3913
  {
2851
3914
  type: "button",
@@ -2860,34 +3923,34 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
2860
3923
  }
2861
3924
  )
2862
3925
  ] }, f.id)),
2863
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
2864
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-slate-400", children: "Interpolation" }),
2865
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3926
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3927
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "Interpolation" }),
3928
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2866
3929
  "select",
2867
3930
  {
2868
3931
  "aria-label": "Interpolation",
2869
3932
  value: tool.interpolation,
2870
3933
  onChange: (e) => tool.setInterpolation(e.target.value),
2871
3934
  className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5",
2872
- children: import_image_editor15.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
3935
+ children: import_image_editor15.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
2873
3936
  }
2874
3937
  )
2875
3938
  ] }),
2876
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", title: "Commit (Enter)", className: "px-2 py-1 rounded bg-emerald-600 text-white hover:bg-emerald-500", onClick: () => tool.commit(), children: "Commit" }),
2877
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", title: "Cancel (Esc)", className: chip3(false), onClick: () => tool.cancel(), children: "Cancel" }),
2878
- tool.error && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { role: "alert", className: "text-rose-400", children: tool.error })
3939
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", title: "Commit (Enter)", className: "px-2 py-1 rounded bg-emerald-600 text-white hover:bg-emerald-500", onClick: () => tool.commit(), children: "Commit" }),
3940
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", title: "Cancel (Esc)", className: chip3(false), onClick: () => tool.cancel(), children: "Cancel" }),
3941
+ tool.error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { role: "alert", className: "text-rose-400", children: tool.error })
2879
3942
  ] });
2880
3943
  };
2881
3944
 
2882
3945
  // src/image-editor/ShapeOptionsBar.tsx
2883
- var import_react22 = require("react");
3946
+ var import_react25 = require("react");
2884
3947
  var import_image_editor16 = require("@pixerate/editor/image-editor");
2885
- var import_jsx_runtime21 = require("react/jsx-runtime");
3948
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2886
3949
  var chip4 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
2887
3950
  var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2888
- const [, setTick] = (0, import_react22.useState)(0);
2889
- (0, import_react22.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
2890
- const [error, setError] = (0, import_react22.useState)(null);
3951
+ const [, setTick] = (0, import_react25.useState)(0);
3952
+ (0, import_react25.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
3953
+ const [error, setError] = (0, import_react25.useState)(null);
2891
3954
  const active = controller.getActiveLayer();
2892
3955
  const shapeId = active?.type === "shape" ? active.id : null;
2893
3956
  const set = (change) => {
@@ -2901,13 +3964,13 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2901
3964
  }
2902
3965
  };
2903
3966
  const num = (v, min, max) => Math.max(min, Math.min(max, Number(v) || min));
2904
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "shape-options", children: [
2905
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor16.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: chip4(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor16.SHAPE_KIND_LABELS[k] }, k)) }),
2906
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
2907
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
2908
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", "aria-label": "Fill", checked: options.fill !== null, onChange: (e) => set({ fill: e.target.checked ? "#4f46e5" : null }) }),
3967
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "shape-options", children: [
3968
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor16.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: chip4(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor16.SHAPE_KIND_LABELS[k] }, k)) }),
3969
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
3970
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
3971
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "checkbox", "aria-label": "Fill", checked: options.fill !== null, onChange: (e) => set({ fill: e.target.checked ? "#4f46e5" : null }) }),
2909
3972
  "Fill",
2910
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3973
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2911
3974
  "input",
2912
3975
  {
2913
3976
  type: "color",
@@ -2919,10 +3982,10 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2919
3982
  }
2920
3983
  )
2921
3984
  ] }),
2922
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
2923
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", "aria-label": "Stroke", checked: options.stroke !== null, onChange: (e) => set({ stroke: e.target.checked ? "#000000" : null }) }),
3985
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
3986
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "checkbox", "aria-label": "Stroke", checked: options.stroke !== null, onChange: (e) => set({ stroke: e.target.checked ? "#000000" : null }) }),
2924
3987
  "Stroke",
2925
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3988
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2926
3989
  "input",
2927
3990
  {
2928
3991
  type: "color",
@@ -2934,9 +3997,9 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2934
3997
  }
2935
3998
  )
2936
3999
  ] }),
2937
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4000
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2938
4001
  "Width",
2939
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4002
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2940
4003
  "input",
2941
4004
  {
2942
4005
  type: "number",
@@ -2950,23 +4013,23 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2950
4013
  )
2951
4014
  ] })
2952
4015
  ] }),
2953
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
2954
- options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4016
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
4017
+ options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2955
4018
  "Radius",
2956
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "number", "aria-label": "Corner radius", min: 0, max: 1e3, value: options.radius, onChange: (e) => set({ radius: num(e.target.value, 0, 1e3) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
4019
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "number", "aria-label": "Corner radius", min: 0, max: 1e3, value: options.radius, onChange: (e) => set({ radius: num(e.target.value, 0, 1e3) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
2957
4020
  ] }),
2958
- options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4021
+ options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2959
4022
  "Sides",
2960
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "number", "aria-label": "Sides", min: 3, max: 100, value: options.sides, onChange: (e) => set({ sides: num(e.target.value, 3, 100) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
4023
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "number", "aria-label": "Sides", min: 3, max: 100, value: options.sides, onChange: (e) => set({ sides: num(e.target.value, 3, 100) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
2961
4024
  ] }),
2962
- options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2963
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4025
+ options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4026
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2964
4027
  "Points",
2965
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "number", "aria-label": "Points", min: 3, max: 100, value: options.points, onChange: (e) => set({ points: num(e.target.value, 3, 100) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
4028
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "number", "aria-label": "Points", min: 3, max: 100, value: options.points, onChange: (e) => set({ points: num(e.target.value, 3, 100) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
2966
4029
  ] }),
2967
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4030
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2968
4031
  "Inner",
2969
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4032
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2970
4033
  "input",
2971
4034
  {
2972
4035
  type: "range",
@@ -2981,33 +4044,33 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
2981
4044
  )
2982
4045
  ] })
2983
4046
  ] }),
2984
- options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2985
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
4047
+ options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4048
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
2986
4049
  "Weight",
2987
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "number", "aria-label": "Line weight", min: 1, max: 200, value: options.weight, onChange: (e) => set({ weight: num(e.target.value, 1, 200) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
4050
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "number", "aria-label": "Line weight", min: 1, max: 200, value: options.weight, onChange: (e) => set({ weight: num(e.target.value, 1, 200) }), className: "w-14 rounded border border-slate-700 bg-slate-950 px-1 py-0.5" })
2988
4051
  ] }),
2989
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
2990
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", "aria-label": "Arrowhead", checked: options.arrow, onChange: (e) => set({ arrow: e.target.checked }) }),
4052
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
4053
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "checkbox", "aria-label": "Arrowhead", checked: options.arrow, onChange: (e) => set({ arrow: e.target.checked }) }),
2991
4054
  "Arrowhead"
2992
4055
  ] })
2993
4056
  ] })
2994
4057
  ] }),
2995
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[10px] text-slate-500", children: "Drag on the image to draw. Shift: square, circle or 45\xB0 line. Alt: from the centre." }),
2996
- error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
4058
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-[10px] text-slate-500", children: "Drag on the image to draw. Shift: square, circle or 45\xB0 line. Alt: from the centre." }),
4059
+ error && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
2997
4060
  ] });
2998
4061
  };
2999
4062
 
3000
4063
  // src/image-editor/TypeOptionsBar.tsx
3001
- var import_react23 = require("react");
4064
+ var import_react26 = require("react");
3002
4065
  var import_image_editor17 = require("@pixerate/editor/image-editor");
3003
- var import_jsx_runtime22 = require("react/jsx-runtime");
4066
+ var import_jsx_runtime24 = require("react/jsx-runtime");
3004
4067
  var chip5 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
3005
4068
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
3006
4069
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
3007
- const [, setTick] = (0, import_react23.useState)(0);
3008
- (0, import_react23.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
3009
- (0, import_react23.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
3010
- const [error, setError] = (0, import_react23.useState)(null);
4070
+ const [, setTick] = (0, import_react26.useState)(0);
4071
+ (0, import_react26.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
4072
+ (0, import_react26.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
4073
+ const [error, setError] = (0, import_react26.useState)(null);
3011
4074
  const active = controller.getActiveLayer();
3012
4075
  const typeId = !session && active?.type === "type" ? active.id : null;
3013
4076
  const here = session?.alive ? session.styleHere() : {};
@@ -3039,11 +4102,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
3039
4102
  setError(e instanceof Error ? e.message : String(e));
3040
4103
  }
3041
4104
  };
3042
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "type-options", children: [
3043
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
3044
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
4105
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "type-options", children: [
4106
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
4107
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "flex items-center gap-1", children: [
3045
4108
  "Font",
3046
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4109
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3047
4110
  "input",
3048
4111
  {
3049
4112
  list: "pixerate-type-fonts",
@@ -3053,11 +4116,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
3053
4116
  className: "w-32 rounded border border-slate-700 bg-slate-950 px-1 py-0.5"
3054
4117
  }
3055
4118
  ),
3056
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: f }, f)) })
4119
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: f }, f)) })
3057
4120
  ] }),
3058
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
4121
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "flex items-center gap-1", children: [
3059
4122
  "Size",
3060
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4123
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3061
4124
  "input",
3062
4125
  {
3063
4126
  type: "number",
@@ -3070,24 +4133,24 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
3070
4133
  }
3071
4134
  )
3072
4135
  ] }),
3073
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${chip5(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
3074
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${chip5(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
3075
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "color", "aria-label": "Text colour", value: shown.color, onChange: (e) => style({ color: e.target.value }), className: "h-6 w-8 rounded border border-slate-700 bg-transparent" })
4136
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${chip5(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
4137
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${chip5(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
4138
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("input", { type: "color", "aria-label": "Text colour", value: shown.color, onChange: (e) => style({ color: e.target.value }), className: "h-6 w-8 rounded border border-slate-700 bg-transparent" })
3076
4139
  ] }),
3077
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor17.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: chip5(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
3078
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[10px] text-slate-500", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
3079
- missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { role: "status", className: "text-amber-400", "data-testid": "type-missing-fonts", children: [
4140
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor17.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: chip5(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
4141
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-[10px] text-slate-500", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
4142
+ missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { role: "status", className: "text-amber-400", "data-testid": "type-missing-fonts", children: [
3080
4143
  "Missing ",
3081
4144
  missing.length === 1 ? "font" : "fonts",
3082
4145
  ": ",
3083
4146
  missing.join(", ")
3084
4147
  ] }),
3085
- error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
4148
+ error && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { role: "alert", className: "text-rose-400", children: error })
3086
4149
  ] });
3087
4150
  };
3088
4151
 
3089
4152
  // src/image-editor/ImageEditor.tsx
3090
- var import_jsx_runtime23 = require("react/jsx-runtime");
4153
+ var import_jsx_runtime25 = require("react/jsx-runtime");
3091
4154
  var ImageEditor = ({
3092
4155
  editor: externalEditor,
3093
4156
  src,
@@ -3111,15 +4174,15 @@ var ImageEditor = ({
3111
4174
  return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
3112
4175
  });
3113
4176
  const legacyProcess = (0, import_image_editor18.normalizeProcessVersion)(state.adjustments.process) < import_image_editor18.LATEST_PROCESS_VERSION;
3114
- const canvasRef = (0, import_react24.useRef)(null);
3115
- const containerRef = (0, import_react24.useRef)(null);
3116
- const [activeTab, setActiveTab] = (0, import_react24.useState)("crop");
3117
- const rootRef = (0, import_react24.useRef)(null);
3118
- const activeTabRef = (0, import_react24.useRef)(activeTab);
4177
+ const canvasRef = (0, import_react27.useRef)(null);
4178
+ const containerRef = (0, import_react27.useRef)(null);
4179
+ const [activeTab, setActiveTab] = (0, import_react27.useState)("crop");
4180
+ const rootRef = (0, import_react27.useRef)(null);
4181
+ const activeTabRef = (0, import_react27.useRef)(activeTab);
3119
4182
  activeTabRef.current = activeTab;
3120
4183
  const ambientPlayback = useAgentPlayback();
3121
4184
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3122
- const [locateLayer] = (0, import_react24.useState)(() => (0, import_image_editor18.createImagePlaybackLocator)(controller));
4185
+ const [locateLayer] = (0, import_react27.useState)(() => (0, import_image_editor18.createImagePlaybackLocator)(controller));
3123
4186
  const docToRoot = (p) => {
3124
4187
  const canvas = canvasRef.current;
3125
4188
  const root = rootRef.current;
@@ -3176,26 +4239,26 @@ var ImageEditor = ({
3176
4239
  fromViewport: clientToDoc,
3177
4240
  reveal: () => onPlaybackReveal?.()
3178
4241
  });
3179
- const [activeCropRatio, setActiveCropRatio] = (0, import_react24.useState)(null);
3180
- const [selectionOptions, setSelectionOptions] = (0, import_react24.useState)(import_image_editor18.DEFAULT_SELECTION_TOOL_OPTIONS);
3181
- const selectionOptionsRef = (0, import_react24.useRef)(selectionOptions);
4242
+ const [activeCropRatio, setActiveCropRatio] = (0, import_react27.useState)(null);
4243
+ const [selectionOptions, setSelectionOptions] = (0, import_react27.useState)(import_image_editor18.DEFAULT_SELECTION_TOOL_OPTIONS);
4244
+ const selectionOptionsRef = (0, import_react27.useRef)(selectionOptions);
3182
4245
  selectionOptionsRef.current = selectionOptions;
3183
- const selectionGestureRef = (0, import_react24.useRef)(null);
4246
+ const selectionGestureRef = (0, import_react27.useRef)(null);
3184
4247
  if (!selectionGestureRef.current || selectionGestureRef.current.controller !== controller) {
3185
4248
  selectionGestureRef.current = new import_image_editor18.SelectionGesture(controller, () => selectionOptionsRef.current);
3186
4249
  }
3187
- const selectionDraftRef = (0, import_react24.useRef)(null);
3188
- const [selectionError, setSelectionError] = (0, import_react24.useState)(null);
3189
- const paintGestureRef = (0, import_react24.useRef)(null);
3190
- const paintControllerRef = (0, import_react24.useRef)(controller);
4250
+ const selectionDraftRef = (0, import_react27.useRef)(null);
4251
+ const [selectionError, setSelectionError] = (0, import_react27.useState)(null);
4252
+ const paintGestureRef = (0, import_react27.useRef)(null);
4253
+ const paintControllerRef = (0, import_react27.useRef)(controller);
3191
4254
  if (!paintGestureRef.current || paintControllerRef.current !== controller) {
3192
4255
  paintGestureRef.current = new import_image_editor18.PaintGesture(controller);
3193
4256
  paintControllerRef.current = controller;
3194
4257
  }
3195
- const brushCursorRef = (0, import_react24.useRef)(null);
3196
- const [paintError, setPaintError] = (0, import_react24.useState)(null);
3197
- const transformToolRef = (0, import_react24.useRef)(null);
3198
- const transformControllerRef = (0, import_react24.useRef)(controller);
4258
+ const brushCursorRef = (0, import_react27.useRef)(null);
4259
+ const [paintError, setPaintError] = (0, import_react27.useState)(null);
4260
+ const transformToolRef = (0, import_react27.useRef)(null);
4261
+ const transformControllerRef = (0, import_react27.useRef)(controller);
3199
4262
  if (!transformToolRef.current || transformControllerRef.current !== controller) {
3200
4263
  transformToolRef.current?.cancel();
3201
4264
  transformToolRef.current = new import_image_editor18.FreeTransformTool(controller, {
@@ -3204,33 +4267,33 @@ var ImageEditor = ({
3204
4267
  transformControllerRef.current = controller;
3205
4268
  }
3206
4269
  const transformTool = transformToolRef.current;
3207
- const [, setTransformTick] = (0, import_react24.useState)(0);
3208
- const [transformCursor, setTransformCursor] = (0, import_react24.useState)("default");
3209
- const [shapeOptions, setShapeOptions] = (0, import_react24.useState)(import_image_editor18.DEFAULT_SHAPE_TOOL_OPTIONS);
3210
- const shapeOptionsRef = (0, import_react24.useRef)(shapeOptions);
4270
+ const [, setTransformTick] = (0, import_react27.useState)(0);
4271
+ const [transformCursor, setTransformCursor] = (0, import_react27.useState)("default");
4272
+ const [shapeOptions, setShapeOptions] = (0, import_react27.useState)(import_image_editor18.DEFAULT_SHAPE_TOOL_OPTIONS);
4273
+ const shapeOptionsRef = (0, import_react27.useRef)(shapeOptions);
3211
4274
  shapeOptionsRef.current = shapeOptions;
3212
- const [typeOptions, setTypeOptions] = (0, import_react24.useState)(import_image_editor18.DEFAULT_TYPE_TOOL_OPTIONS);
3213
- const typeOptionsRef = (0, import_react24.useRef)(typeOptions);
4275
+ const [typeOptions, setTypeOptions] = (0, import_react27.useState)(import_image_editor18.DEFAULT_TYPE_TOOL_OPTIONS);
4276
+ const typeOptionsRef = (0, import_react27.useRef)(typeOptions);
3214
4277
  typeOptionsRef.current = typeOptions;
3215
- const shapeGestureRef = (0, import_react24.useRef)(null);
3216
- const typeToolRef = (0, import_react24.useRef)(null);
3217
- const shapeTypeControllerRef = (0, import_react24.useRef)(controller);
4278
+ const shapeGestureRef = (0, import_react27.useRef)(null);
4279
+ const typeToolRef = (0, import_react27.useRef)(null);
4280
+ const shapeTypeControllerRef = (0, import_react27.useRef)(controller);
3218
4281
  if (!shapeGestureRef.current || !typeToolRef.current || shapeTypeControllerRef.current !== controller) {
3219
4282
  typeToolRef.current?.finish();
3220
4283
  shapeGestureRef.current = new import_image_editor18.ShapeDrawGesture(controller, () => shapeOptionsRef.current);
3221
4284
  typeToolRef.current = new import_image_editor18.TypeToolGesture(controller, () => typeOptionsRef.current);
3222
4285
  shapeTypeControllerRef.current = controller;
3223
4286
  }
3224
- const typeInputRef = (0, import_react24.useRef)(null);
3225
- const [typeSession, setTypeSession] = (0, import_react24.useState)(typeToolRef.current.session);
3226
- const [shapeTypeError, setShapeTypeError] = (0, import_react24.useState)(null);
3227
- const [inpaintPrompt, setInpaintPrompt] = (0, import_react24.useState)("");
3228
- const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react24.useState)("annotations");
3229
- const [isRemovingBg, setIsRemovingBg] = (0, import_react24.useState)(false);
3230
- const [isInpainting, setIsInpainting] = (0, import_react24.useState)(false);
3231
- const [aiError, setAiError] = (0, import_react24.useState)(null);
3232
- const [aiSuccess, setAiSuccess] = (0, import_react24.useState)(null);
3233
- const [aiTarget, setAiTarget] = (0, import_react24.useState)("auto");
4287
+ const typeInputRef = (0, import_react27.useRef)(null);
4288
+ const [typeSession, setTypeSession] = (0, import_react27.useState)(typeToolRef.current.session);
4289
+ const [shapeTypeError, setShapeTypeError] = (0, import_react27.useState)(null);
4290
+ const [inpaintPrompt, setInpaintPrompt] = (0, import_react27.useState)("");
4291
+ const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react27.useState)("annotations");
4292
+ const [isRemovingBg, setIsRemovingBg] = (0, import_react27.useState)(false);
4293
+ const [isInpainting, setIsInpainting] = (0, import_react27.useState)(false);
4294
+ const [aiError, setAiError] = (0, import_react27.useState)(null);
4295
+ const [aiSuccess, setAiSuccess] = (0, import_react27.useState)(null);
4296
+ const [aiTarget, setAiTarget] = (0, import_react27.useState)("auto");
3234
4297
  const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
3235
4298
  const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
3236
4299
  const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
@@ -3293,18 +4356,18 @@ var ImageEditor = ({
3293
4356
  setIsInpainting(false);
3294
4357
  }
3295
4358
  };
3296
- const [activeColor, setActiveColor] = (0, import_react24.useState)("#ef4444");
3297
- const [strokeWidth, setStrokeWidth] = (0, import_react24.useState)(3);
3298
- const [fontSize, setFontSize] = (0, import_react24.useState)(24);
3299
- const [textInput, setTextInput] = (0, import_react24.useState)("");
3300
- const draftAnnotationRef = (0, import_react24.useRef)(null);
3301
- const draftCropRef = (0, import_react24.useRef)(null);
3302
- const cropDragInfoRef = (0, import_react24.useRef)(null);
3303
- const annotationDragInfoRef = (0, import_react24.useRef)(null);
3304
- const isDrawingRef = (0, import_react24.useRef)(false);
3305
- const currentPathRef = (0, import_react24.useRef)([]);
3306
- const dragStartPointRef = (0, import_react24.useRef)(null);
3307
- const renderCanvas = (0, import_react24.useCallback)(
4359
+ const [activeColor, setActiveColor] = (0, import_react27.useState)("#ef4444");
4360
+ const [strokeWidth, setStrokeWidth] = (0, import_react27.useState)(3);
4361
+ const [fontSize, setFontSize] = (0, import_react27.useState)(24);
4362
+ const [textInput, setTextInput] = (0, import_react27.useState)("");
4363
+ const draftAnnotationRef = (0, import_react27.useRef)(null);
4364
+ const draftCropRef = (0, import_react27.useRef)(null);
4365
+ const cropDragInfoRef = (0, import_react27.useRef)(null);
4366
+ const annotationDragInfoRef = (0, import_react27.useRef)(null);
4367
+ const isDrawingRef = (0, import_react27.useRef)(false);
4368
+ const currentPathRef = (0, import_react27.useRef)([]);
4369
+ const dragStartPointRef = (0, import_react27.useRef)(null);
4370
+ const renderCanvas = (0, import_react27.useCallback)(
3308
4371
  async (draftAnnotation, draftCrop) => {
3309
4372
  const canvas = canvasRef.current;
3310
4373
  const container = containerRef.current;
@@ -3327,8 +4390,8 @@ var ImageEditor = ({
3327
4390
  },
3328
4391
  [controller, activeTab, transformTool]
3329
4392
  );
3330
- (0, import_react24.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
3331
- (0, import_react24.useEffect)(() => {
4393
+ (0, import_react27.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4394
+ (0, import_react27.useEffect)(() => {
3332
4395
  if (activeTab === "annotate" && state.activeTool === "type") return;
3333
4396
  if (typeToolRef.current?.session) {
3334
4397
  typeToolRef.current.finish();
@@ -3363,7 +4426,7 @@ var ImageEditor = ({
3363
4426
  el.value = "";
3364
4427
  }
3365
4428
  };
3366
- (0, import_react24.useEffect)(() => transformTool.subscribe(() => {
4429
+ (0, import_react27.useEffect)(() => transformTool.subscribe(() => {
3367
4430
  setTransformTick((n) => n + 1);
3368
4431
  void renderCanvas();
3369
4432
  }), [transformTool, renderCanvas]);
@@ -3406,7 +4469,7 @@ var ImageEditor = ({
3406
4469
  transformTool.up();
3407
4470
  return true;
3408
4471
  };
3409
- (0, import_react24.useEffect)(() => {
4472
+ (0, import_react27.useEffect)(() => {
3410
4473
  if (typeof window === "undefined") return;
3411
4474
  const onKey = (e) => {
3412
4475
  if (transformTool.key(e)) e.preventDefault();
@@ -3414,7 +4477,7 @@ var ImageEditor = ({
3414
4477
  window.addEventListener("keydown", onKey);
3415
4478
  return () => window.removeEventListener("keydown", onKey);
3416
4479
  }, [transformTool]);
3417
- (0, import_react24.useEffect)(() => {
4480
+ (0, import_react27.useEffect)(() => {
3418
4481
  const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
3419
4482
  const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
3420
4483
  const animId = raf(() => {
@@ -3422,12 +4485,12 @@ var ImageEditor = ({
3422
4485
  });
3423
4486
  return () => caf(animId);
3424
4487
  }, [renderCanvas, state]);
3425
- (0, import_react24.useEffect)(() => {
4488
+ (0, import_react27.useEffect)(() => {
3426
4489
  if (activeTab === "crop" && editor.state.activeTool !== "crop") {
3427
4490
  editor.setTool("crop");
3428
4491
  }
3429
4492
  }, [activeTab, editor]);
3430
- (0, import_react24.useEffect)(() => {
4493
+ (0, import_react27.useEffect)(() => {
3431
4494
  const container = containerRef.current;
3432
4495
  if (!container) return;
3433
4496
  if (typeof ResizeObserver !== "undefined") {
@@ -3495,7 +4558,7 @@ var ImageEditor = ({
3495
4558
  if (g.error) setPaintError(g.error);
3496
4559
  }
3497
4560
  };
3498
- (0, import_react24.useEffect)(() => {
4561
+ (0, import_react27.useEffect)(() => {
3499
4562
  if (activeTab !== "paint" || typeof window === "undefined") return;
3500
4563
  const onKey = (e) => {
3501
4564
  if ((0, import_image_editor18.handlePaintShortcut)(controller, e)) e.preventDefault();
@@ -3890,17 +4953,17 @@ var ImageEditor = ({
3890
4953
  link.click();
3891
4954
  }
3892
4955
  };
3893
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4956
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3894
4957
  "div",
3895
4958
  {
3896
4959
  ref: rootRef,
3897
4960
  className: `relative flex flex-col bg-slate-900 border border-slate-800 rounded-xl overflow-hidden shadow-2xl text-slate-100 ${className}`,
3898
4961
  style,
3899
4962
  children: [
3900
- playing && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
3901
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-wrap items-center justify-between px-4 py-3 bg-slate-950/80 border-b border-slate-800 gap-3", children: [
3902
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-1 bg-slate-900 p-1 rounded-lg border border-slate-800 text-xs", children: [
3903
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4963
+ playing && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
4964
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center justify-between px-4 py-3 bg-slate-950/80 border-b border-slate-800 gap-3", children: [
4965
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-1 bg-slate-900 p-1 rounded-lg border border-slate-800 text-xs", children: [
4966
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3904
4967
  "button",
3905
4968
  {
3906
4969
  type: "button",
@@ -3913,7 +4976,7 @@ var ImageEditor = ({
3913
4976
  children: "Transform & Crop"
3914
4977
  }
3915
4978
  ),
3916
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4979
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3917
4980
  "button",
3918
4981
  {
3919
4982
  type: "button",
@@ -3926,7 +4989,7 @@ var ImageEditor = ({
3926
4989
  children: "Adjustments"
3927
4990
  }
3928
4991
  ),
3929
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4992
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3930
4993
  "button",
3931
4994
  {
3932
4995
  type: "button",
@@ -3939,7 +5002,7 @@ var ImageEditor = ({
3939
5002
  children: "Layers"
3940
5003
  }
3941
5004
  ),
3942
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5005
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3943
5006
  "button",
3944
5007
  {
3945
5008
  type: "button",
@@ -3952,7 +5015,7 @@ var ImageEditor = ({
3952
5015
  children: "Paint"
3953
5016
  }
3954
5017
  ),
3955
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5018
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3956
5019
  "button",
3957
5020
  {
3958
5021
  type: "button",
@@ -3965,7 +5028,7 @@ var ImageEditor = ({
3965
5028
  children: "Select & Mask"
3966
5029
  }
3967
5030
  ),
3968
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5031
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3969
5032
  "button",
3970
5033
  {
3971
5034
  type: "button",
@@ -3978,7 +5041,7 @@ var ImageEditor = ({
3978
5041
  children: "Annotations"
3979
5042
  }
3980
5043
  ),
3981
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5044
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3982
5045
  "button",
3983
5046
  {
3984
5047
  type: "button",
@@ -3991,7 +5054,7 @@ var ImageEditor = ({
3991
5054
  children: "Depth Mask"
3992
5055
  }
3993
5056
  ),
3994
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5057
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3995
5058
  "button",
3996
5059
  {
3997
5060
  type: "button",
@@ -4002,14 +5065,14 @@ var ImageEditor = ({
4002
5065
  },
4003
5066
  className: `px-3 py-1.5 rounded-md font-medium transition-colors flex items-center gap-1.5 ${activeTab === "ai" ? "bg-indigo-600 text-white shadow" : "text-slate-400 hover:text-slate-200"}`,
4004
5067
  children: [
4005
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
5068
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
4006
5069
  "AI Tools"
4007
5070
  ]
4008
5071
  }
4009
5072
  )
4010
5073
  ] }),
4011
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
4012
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5074
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
5075
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4013
5076
  "button",
4014
5077
  {
4015
5078
  type: "button",
@@ -4020,7 +5083,7 @@ var ImageEditor = ({
4020
5083
  children: "\u21A9"
4021
5084
  }
4022
5085
  ),
4023
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5086
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4024
5087
  "button",
4025
5088
  {
4026
5089
  type: "button",
@@ -4031,7 +5094,7 @@ var ImageEditor = ({
4031
5094
  children: "\u21AA"
4032
5095
  }
4033
5096
  ),
4034
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5097
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4035
5098
  "button",
4036
5099
  {
4037
5100
  type: "button",
@@ -4040,8 +5103,8 @@ var ImageEditor = ({
4040
5103
  children: "Reset"
4041
5104
  }
4042
5105
  ),
4043
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
4044
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5106
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
5107
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4045
5108
  "button",
4046
5109
  {
4047
5110
  type: "button",
@@ -4051,11 +5114,11 @@ var ImageEditor = ({
4051
5114
  children: "-"
4052
5115
  }
4053
5116
  ),
4054
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "font-mono text-slate-400 w-10 text-center", children: [
5117
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono text-slate-400 w-10 text-center", children: [
4055
5118
  Math.round(state.zoom * 100),
4056
5119
  "%"
4057
5120
  ] }),
4058
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5121
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4059
5122
  "button",
4060
5123
  {
4061
5124
  type: "button",
@@ -4065,8 +5128,8 @@ var ImageEditor = ({
4065
5128
  children: "+"
4066
5129
  }
4067
5130
  ),
4068
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
4069
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5131
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
5132
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4070
5133
  "button",
4071
5134
  {
4072
5135
  type: "button",
@@ -4077,7 +5140,7 @@ var ImageEditor = ({
4077
5140
  children: "Hold Compare"
4078
5141
  }
4079
5142
  ),
4080
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5143
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4081
5144
  "button",
4082
5145
  {
4083
5146
  type: "button",
@@ -4088,16 +5151,16 @@ var ImageEditor = ({
4088
5151
  )
4089
5152
  ] })
4090
5153
  ] }),
4091
- transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-slate-800 bg-slate-900/95 px-4 py-2" }),
4092
- !transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { role: "alert", className: "border-b border-rose-900 bg-rose-950/80 px-4 py-1.5 text-xs text-rose-200", children: transformTool.error }),
4093
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
4094
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5154
+ transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-slate-800 bg-slate-900/95 px-4 py-2" }),
5155
+ !transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { role: "alert", className: "border-b border-rose-900 bg-rose-950/80 px-4 py-1.5 text-xs text-rose-200", children: transformTool.error }),
5156
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
5157
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4095
5158
  "div",
4096
5159
  {
4097
5160
  ref: containerRef,
4098
5161
  className: "relative flex-1 h-[360px] md:h-full min-h-[320px] bg-slate-950 overflow-hidden select-none",
4099
5162
  children: [
4100
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5163
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4101
5164
  "canvas",
4102
5165
  {
4103
5166
  ref: canvasRef,
@@ -4114,7 +5177,7 @@ var ImageEditor = ({
4114
5177
  className: `absolute inset-0 w-full h-full block ${transformTool.active ? "touch-none" : activeTab === "paint" ? "touch-none cursor-crosshair" : activeTab === "annotate" && state.activeTool === "type" ? "cursor-text" : activeTab === "annotate" && state.activeTool === "shape" ? "cursor-crosshair" : ""}`
4115
5178
  }
4116
5179
  ),
4117
- typeSession && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5180
+ typeSession && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4118
5181
  "textarea",
4119
5182
  {
4120
5183
  ref: typeInputRef,
@@ -4136,11 +5199,11 @@ var ImageEditor = ({
4136
5199
  ]
4137
5200
  }
4138
5201
  ),
4139
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "w-full md:w-80 bg-slate-900/90 border-t md:border-t-0 md:border-l border-slate-800 p-4 overflow-y-auto h-auto md:h-full md:max-h-[560px]", children: [
4140
- activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
4141
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Aspect Ratio Presets" }),
4142
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
4143
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5202
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "w-full md:w-80 bg-slate-900/90 border-t md:border-t-0 md:border-l border-slate-800 p-4 overflow-y-auto h-auto md:h-full md:max-h-[560px]", children: [
5203
+ activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
5204
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Aspect Ratio Presets" }),
5205
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
5206
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4144
5207
  "button",
4145
5208
  {
4146
5209
  type: "button",
@@ -4152,7 +5215,7 @@ var ImageEditor = ({
4152
5215
  children: "Freeform"
4153
5216
  }
4154
5217
  ),
4155
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5218
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4156
5219
  "button",
4157
5220
  {
4158
5221
  type: "button",
@@ -4164,7 +5227,7 @@ var ImageEditor = ({
4164
5227
  children: "1:1 Square"
4165
5228
  }
4166
5229
  ),
4167
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5230
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4168
5231
  "button",
4169
5232
  {
4170
5233
  type: "button",
@@ -4176,7 +5239,7 @@ var ImageEditor = ({
4176
5239
  children: "4:3 Standard"
4177
5240
  }
4178
5241
  ),
4179
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5242
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4180
5243
  "button",
4181
5244
  {
4182
5245
  type: "button",
@@ -4188,7 +5251,7 @@ var ImageEditor = ({
4188
5251
  children: "16:9 Wide"
4189
5252
  }
4190
5253
  ),
4191
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5254
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4192
5255
  "button",
4193
5256
  {
4194
5257
  type: "button",
@@ -4200,7 +5263,7 @@ var ImageEditor = ({
4200
5263
  children: "3:2 Photo"
4201
5264
  }
4202
5265
  ),
4203
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5266
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4204
5267
  "button",
4205
5268
  {
4206
5269
  type: "button",
@@ -4213,10 +5276,10 @@ var ImageEditor = ({
4213
5276
  }
4214
5277
  )
4215
5278
  ] }),
4216
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
4217
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Orientation & Flips" }),
4218
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
4219
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5279
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
5280
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Orientation & Flips" }),
5281
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
5282
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4220
5283
  "button",
4221
5284
  {
4222
5285
  type: "button",
@@ -4225,7 +5288,7 @@ var ImageEditor = ({
4225
5288
  children: "Rotate -90\xB0"
4226
5289
  }
4227
5290
  ),
4228
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5291
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4229
5292
  "button",
4230
5293
  {
4231
5294
  type: "button",
@@ -4234,7 +5297,7 @@ var ImageEditor = ({
4234
5297
  children: "Rotate +90\xB0"
4235
5298
  }
4236
5299
  ),
4237
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5300
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4238
5301
  "button",
4239
5302
  {
4240
5303
  type: "button",
@@ -4243,7 +5306,7 @@ var ImageEditor = ({
4243
5306
  children: "Flip Horizontal"
4244
5307
  }
4245
5308
  ),
4246
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5309
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4247
5310
  "button",
4248
5311
  {
4249
5312
  type: "button",
@@ -4254,10 +5317,10 @@ var ImageEditor = ({
4254
5317
  )
4255
5318
  ] })
4256
5319
  ] }),
4257
- activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
4258
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between", children: [
4259
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Color Adjustments" }),
4260
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5320
+ activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
5321
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
5322
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Color Adjustments" }),
5323
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4261
5324
  "button",
4262
5325
  {
4263
5326
  type: "button",
@@ -4267,9 +5330,9 @@ var ImageEditor = ({
4267
5330
  }
4268
5331
  )
4269
5332
  ] }),
4270
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Histogram, { histogram: editor.histogram }),
4271
- import_image_editor18.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react24.default.Fragment, { children: [
4272
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5333
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Histogram, { histogram: editor.histogram }),
5334
+ import_image_editor18.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react27.default.Fragment, { children: [
5335
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4273
5336
  ControlSlider,
4274
5337
  {
4275
5338
  spec,
@@ -4278,14 +5341,14 @@ var ImageEditor = ({
4278
5341
  onChange: (v) => editor.setAdjustments({ [spec.id]: v })
4279
5342
  }
4280
5343
  ),
4281
- spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5344
+ spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4282
5345
  "div",
4283
5346
  {
4284
5347
  className: "flex items-center justify-between gap-2 rounded border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-200",
4285
5348
  "data-testid": "image-editor-process-notice",
4286
5349
  children: [
4287
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
4288
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5350
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
5351
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4289
5352
  "button",
4290
5353
  {
4291
5354
  type: "button",
@@ -4298,7 +5361,7 @@ var ImageEditor = ({
4298
5361
  }
4299
5362
  )
4300
5363
  ] }, spec.id)),
4301
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "border-t border-slate-700/60 pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5364
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "border-t border-slate-700/60 pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4302
5365
  AdjustmentLayersPanel,
4303
5366
  {
4304
5367
  controller,
@@ -4307,9 +5370,9 @@ var ImageEditor = ({
4307
5370
  }
4308
5371
  ) })
4309
5372
  ] }),
4310
- activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
4311
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Layers" }),
4312
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5373
+ activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
5374
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Layers" }),
5375
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4313
5376
  "button",
4314
5377
  {
4315
5378
  type: "button",
@@ -4320,15 +5383,15 @@ var ImageEditor = ({
4320
5383
  children: "Free Transform"
4321
5384
  }
4322
5385
  ),
4323
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersPanel, { controller }),
4324
- effectsShown && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ImageProviderEffectsPanel, { controller, className: "border-t border-slate-700/60 pt-3" }),
4325
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Colour" }),
4326
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColorProfilePanel, { controller })
5386
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(LayersPanel, { controller }),
5387
+ effectsShown && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageProviderEffectsPanel, { controller, className: "border-t border-slate-700/60 pt-3" }),
5388
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Colour" }),
5389
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ColorProfilePanel, { controller })
4327
5390
  ] }),
4328
- activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
4329
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Paint" }),
4330
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BrushOptionsBar, { controller }),
4331
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5391
+ activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
5392
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Paint" }),
5393
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BrushOptionsBar, { controller }),
5394
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4332
5395
  "button",
4333
5396
  {
4334
5397
  type: "button",
@@ -4339,12 +5402,12 @@ var ImageEditor = ({
4339
5402
  children: "Free Transform"
4340
5403
  }
4341
5404
  ),
4342
- paintError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "text-rose-400", "data-testid": "paint-error", children: paintError }),
4343
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "border-t border-slate-700/60 pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersPanel, { controller }) })
5405
+ paintError && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "alert", className: "text-rose-400", "data-testid": "paint-error", children: paintError }),
5406
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "border-t border-slate-700/60 pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(LayersPanel, { controller }) })
4344
5407
  ] }),
4345
- activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
4346
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Shape & Type Layers" }),
4347
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5408
+ activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
5409
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Shape & Type Layers" }),
5410
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4348
5411
  "button",
4349
5412
  {
4350
5413
  type: "button",
@@ -4355,13 +5418,13 @@ var ImageEditor = ({
4355
5418
  },
4356
5419
  t
4357
5420
  )) }),
4358
- state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
4359
- state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
4360
- state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", onClick: finishTyping, className: "self-start rounded bg-slate-800 px-2 py-1 text-[11px] text-slate-200 hover:bg-slate-700", children: "Done editing text" }),
4361
- shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "text-rose-400", "data-testid": "shape-type-error", children: shapeTypeError }),
4362
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
4363
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Draw & Annotate" }),
4364
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5421
+ state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
5422
+ state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
5423
+ state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", onClick: finishTyping, className: "self-start rounded bg-slate-800 px-2 py-1 text-[11px] text-slate-200 hover:bg-slate-700", children: "Done editing text" }),
5424
+ shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "alert", className: "text-rose-400", "data-testid": "shape-type-error", children: shapeTypeError }),
5425
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
5426
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Draw & Annotate" }),
5427
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4365
5428
  "button",
4366
5429
  {
4367
5430
  type: "button",
@@ -4371,9 +5434,9 @@ var ImageEditor = ({
4371
5434
  },
4372
5435
  t
4373
5436
  )) }),
4374
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
4375
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { className: "text-slate-400", children: "Color:" }),
4376
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5437
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
5438
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("label", { className: "text-slate-400", children: "Color:" }),
5439
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4377
5440
  "input",
4378
5441
  {
4379
5442
  type: "color",
@@ -4382,15 +5445,15 @@ var ImageEditor = ({
4382
5445
  className: "w-8 h-8 rounded border border-slate-700 cursor-pointer bg-transparent"
4383
5446
  }
4384
5447
  ),
4385
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex-1 ml-2", children: [
4386
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex justify-between text-slate-400 mb-0.5", children: [
4387
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Width:" }),
4388
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "font-mono", children: [
5448
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex-1 ml-2", children: [
5449
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between text-slate-400 mb-0.5", children: [
5450
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Width:" }),
5451
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono", children: [
4389
5452
  strokeWidth,
4390
5453
  "px"
4391
5454
  ] })
4392
5455
  ] }),
4393
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5456
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4394
5457
  "input",
4395
5458
  {
4396
5459
  type: "range",
@@ -4403,10 +5466,10 @@ var ImageEditor = ({
4403
5466
  )
4404
5467
  ] })
4405
5468
  ] }),
4406
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
4407
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Add Text" }),
4408
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-2", children: [
4409
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5469
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
5470
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Add Text" }),
5471
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-2", children: [
5472
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4410
5473
  "input",
4411
5474
  {
4412
5475
  type: "text",
@@ -4417,7 +5480,7 @@ var ImageEditor = ({
4417
5480
  className: "flex-1 bg-slate-950 border border-slate-700 rounded-lg px-2.5 py-1.5 text-xs text-slate-100 placeholder-slate-500 focus:outline-none focus:border-indigo-500"
4418
5481
  }
4419
5482
  ),
4420
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5483
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4421
5484
  "button",
4422
5485
  {
4423
5486
  type: "button",
@@ -4427,14 +5490,14 @@ var ImageEditor = ({
4427
5490
  }
4428
5491
  )
4429
5492
  ] }),
4430
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between text-slate-400", children: [
4431
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Font Size:" }),
4432
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "font-mono", children: [
5493
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between text-slate-400", children: [
5494
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Font Size:" }),
5495
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono", children: [
4433
5496
  fontSize,
4434
5497
  "px"
4435
5498
  ] })
4436
5499
  ] }),
4437
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5500
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4438
5501
  "input",
4439
5502
  {
4440
5503
  type: "range",
@@ -4445,14 +5508,14 @@ var ImageEditor = ({
4445
5508
  className: "w-full accent-indigo-500"
4446
5509
  }
4447
5510
  ),
4448
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
4449
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between", children: [
4450
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "text-slate-400", children: [
5511
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-px bg-slate-800 my-1" }),
5512
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
5513
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "text-slate-400", children: [
4451
5514
  "Layers (",
4452
5515
  state.annotations.length,
4453
5516
  ")"
4454
5517
  ] }),
4455
- state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5518
+ state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4456
5519
  "button",
4457
5520
  {
4458
5521
  type: "button",
@@ -4461,7 +5524,7 @@ var ImageEditor = ({
4461
5524
  children: "Delete Selected"
4462
5525
  }
4463
5526
  ),
4464
- state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5527
+ state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4465
5528
  "button",
4466
5529
  {
4467
5530
  type: "button",
@@ -4472,10 +5535,10 @@ var ImageEditor = ({
4472
5535
  )
4473
5536
  ] })
4474
5537
  ] }),
4475
- activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
4476
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between", children: [
4477
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Depth Masking" }),
4478
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5538
+ activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
5539
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
5540
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Depth Masking" }),
5541
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4479
5542
  "button",
4480
5543
  {
4481
5544
  type: "button",
@@ -4485,8 +5548,8 @@ var ImageEditor = ({
4485
5548
  }
4486
5549
  )
4487
5550
  ] }),
4488
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300", children: [
4489
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5551
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300", children: [
5552
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4490
5553
  "input",
4491
5554
  {
4492
5555
  type: "checkbox",
@@ -4495,12 +5558,12 @@ var ImageEditor = ({
4495
5558
  className: "rounded accent-indigo-500"
4496
5559
  }
4497
5560
  ),
4498
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Enable Depth / Alpha Mask" })
5561
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Enable Depth / Alpha Mask" })
4499
5562
  ] }),
4500
- state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4501
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4502
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { className: "text-slate-400 block mb-1", children: "Mask Image URL:" }),
4503
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5563
+ state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
5564
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
5565
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("label", { className: "text-slate-400 block mb-1", children: "Mask Image URL:" }),
5566
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4504
5567
  "input",
4505
5568
  {
4506
5569
  type: "text",
@@ -4511,8 +5574,8 @@ var ImageEditor = ({
4511
5574
  }
4512
5575
  )
4513
5576
  ] }),
4514
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-2", children: [
4515
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5577
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-2", children: [
5578
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4516
5579
  "button",
4517
5580
  {
4518
5581
  type: "button",
@@ -4521,7 +5584,7 @@ var ImageEditor = ({
4521
5584
  children: "Threshold Mode"
4522
5585
  }
4523
5586
  ),
4524
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5587
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4525
5588
  "button",
4526
5589
  {
4527
5590
  type: "button",
@@ -4531,12 +5594,12 @@ var ImageEditor = ({
4531
5594
  }
4532
5595
  )
4533
5596
  ] }),
4534
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4535
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
4536
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Depth Start (Lower):" }),
4537
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
5597
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
5598
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
5599
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Depth Start (Lower):" }),
5600
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
4538
5601
  ] }),
4539
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5602
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4540
5603
  "input",
4541
5604
  {
4542
5605
  type: "range",
@@ -4550,12 +5613,12 @@ var ImageEditor = ({
4550
5613
  }
4551
5614
  )
4552
5615
  ] }),
4553
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4554
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
4555
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Depth Stop (Upper):" }),
4556
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
5616
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
5617
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
5618
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Depth Stop (Upper):" }),
5619
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
4557
5620
  ] }),
4558
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5621
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4559
5622
  "input",
4560
5623
  {
4561
5624
  type: "range",
@@ -4569,12 +5632,12 @@ var ImageEditor = ({
4569
5632
  }
4570
5633
  )
4571
5634
  ] }),
4572
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4573
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
4574
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Softness:" }),
4575
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
5635
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
5636
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between text-slate-400 mb-1", children: [
5637
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Softness:" }),
5638
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
4576
5639
  ] }),
4577
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5640
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4578
5641
  "input",
4579
5642
  {
4580
5643
  type: "range",
@@ -4586,8 +5649,8 @@ var ImageEditor = ({
4586
5649
  }
4587
5650
  )
4588
5651
  ] }),
4589
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300 mt-1", children: [
4590
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5652
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300 mt-1", children: [
5653
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4591
5654
  "input",
4592
5655
  {
4593
5656
  type: "checkbox",
@@ -4596,12 +5659,12 @@ var ImageEditor = ({
4596
5659
  className: "rounded accent-indigo-500"
4597
5660
  }
4598
5661
  ),
4599
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Invert Mask" })
5662
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Invert Mask" })
4600
5663
  ] })
4601
5664
  ] })
4602
5665
  ] }),
4603
- activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
4604
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5666
+ activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
5667
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4605
5668
  SelectionOptionsBar,
4606
5669
  {
4607
5670
  controller,
@@ -4611,9 +5674,9 @@ var ImageEditor = ({
4611
5674
  quickMask: Boolean(state.quickMask)
4612
5675
  }
4613
5676
  ),
4614
- selectionError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "text-rose-400", children: selectionError }),
4615
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex gap-1", children: [
4616
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5677
+ selectionError && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "alert", className: "text-rose-400", children: selectionError }),
5678
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-1", children: [
5679
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4617
5680
  "button",
4618
5681
  {
4619
5682
  type: "button",
@@ -4624,7 +5687,7 @@ var ImageEditor = ({
4624
5687
  children: "Transform Selection"
4625
5688
  }
4626
5689
  ),
4627
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5690
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4628
5691
  "button",
4629
5692
  {
4630
5693
  type: "button",
@@ -4636,12 +5699,12 @@ var ImageEditor = ({
4636
5699
  }
4637
5700
  )
4638
5701
  ] }),
4639
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers })
5702
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers })
4640
5703
  ] }),
4641
- activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
4642
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center justify-between gap-2 text-slate-300", children: [
4643
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Results go to" }),
4644
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5704
+ activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
5705
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center justify-between gap-2 text-slate-300", children: [
5706
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Results go to" }),
5707
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4645
5708
  "select",
4646
5709
  {
4647
5710
  "aria-label": "AI result target",
@@ -4649,54 +5712,54 @@ var ImageEditor = ({
4649
5712
  onChange: (e) => setAiTarget(e.target.value),
4650
5713
  className: "bg-slate-800 border border-slate-700 rounded px-1.5 py-1",
4651
5714
  children: [
4652
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
4653
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
4654
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "replace", children: "Replace image" })
5715
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
5716
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
5717
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("option", { value: "replace", children: "Replace image" })
4655
5718
  ]
4656
5719
  }
4657
5720
  )
4658
5721
  ] }),
4659
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-3 rounded-lg bg-slate-950/60 border border-slate-800 flex flex-col gap-2.5", children: [
4660
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between", children: [
4661
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
4662
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { className: "w-3.5 h-3.5 text-indigo-400", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" }) }),
5722
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "p-3 rounded-lg bg-slate-950/60 border border-slate-800 flex flex-col gap-2.5", children: [
5723
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
5724
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
5725
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { className: "w-3.5 h-3.5 text-indigo-400", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" }) }),
4663
5726
  "Background Removal"
4664
5727
  ] }),
4665
- isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-indigo-900/60 text-indigo-300 animate-pulse", children: "Removing..." })
5728
+ isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-indigo-900/60 text-indigo-300 animate-pulse", children: "Removing..." })
4666
5729
  ] }),
4667
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-slate-400 text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
4668
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5730
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-slate-400 text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
5731
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4669
5732
  "button",
4670
5733
  {
4671
5734
  type: "button",
4672
5735
  onClick: handleRemoveBackground,
4673
5736
  disabled: isRemovingBg || isInpainting,
4674
5737
  className: "mt-1 px-3 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white font-medium shadow transition-colors flex items-center justify-center gap-2",
4675
- children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4676
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin" }),
5738
+ children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
5739
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin" }),
4677
5740
  "Removing Background..."
4678
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4679
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
5741
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
5742
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
4680
5743
  "Remove Background"
4681
5744
  ] })
4682
5745
  }
4683
5746
  )
4684
5747
  ] }),
4685
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "p-3 rounded-lg bg-slate-950/60 border border-slate-800 flex flex-col gap-2.5", children: [
4686
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between", children: [
4687
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
4688
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("svg", { className: "w-3.5 h-3.5 text-purple-400", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
4689
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "m21.64 3.64-1.28-1.28a1.2 1.2 0 0 0-1.7 0l-9.72 9.72-1.94 4.86 4.86-1.94 9.72-9.72a1.2 1.2 0 0 0 .06-1.64z" }),
4690
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "m14 7 3 3" })
5748
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "p-3 rounded-lg bg-slate-950/60 border border-slate-800 flex flex-col gap-2.5", children: [
5749
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
5750
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
5751
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { className: "w-3.5 h-3.5 text-purple-400", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
5752
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m21.64 3.64-1.28-1.28a1.2 1.2 0 0 0-1.7 0l-9.72 9.72-1.94 4.86 4.86-1.94 9.72-9.72a1.2 1.2 0 0 0 .06-1.64z" }),
5753
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m14 7 3 3" })
4691
5754
  ] }),
4692
5755
  "Generative Inpainting"
4693
5756
  ] }),
4694
- isInpainting && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-900/60 text-purple-300 animate-pulse", children: "Inpainting..." })
5757
+ isInpainting && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-900/60 text-purple-300 animate-pulse", children: "Inpainting..." })
4695
5758
  ] }),
4696
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-slate-400 text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
4697
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-1", children: [
4698
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-slate-300 text-[11px] font-medium", children: "Prompt" }),
4699
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5759
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-slate-400 text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
5760
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
5761
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-slate-300 text-[11px] font-medium", children: "Prompt" }),
5762
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4700
5763
  "textarea",
4701
5764
  {
4702
5765
  id: "ai-inpaint-prompt-react",
@@ -4708,10 +5771,10 @@ var ImageEditor = ({
4708
5771
  }
4709
5772
  )
4710
5773
  ] }),
4711
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-1", children: [
4712
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-slate-300 text-[11px] font-medium", children: "Target Mask Region" }),
4713
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
4714
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5774
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
5775
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-slate-300 text-[11px] font-medium", children: "Target Mask Region" }),
5776
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
5777
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4715
5778
  "button",
4716
5779
  {
4717
5780
  type: "button",
@@ -4724,7 +5787,7 @@ var ImageEditor = ({
4724
5787
  ]
4725
5788
  }
4726
5789
  ),
4727
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5790
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4728
5791
  "button",
4729
5792
  {
4730
5793
  type: "button",
@@ -4739,25 +5802,25 @@ var ImageEditor = ({
4739
5802
  )
4740
5803
  ] })
4741
5804
  ] }),
4742
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5805
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4743
5806
  "button",
4744
5807
  {
4745
5808
  type: "button",
4746
5809
  onClick: handleInpaint,
4747
5810
  disabled: isInpainting || isRemovingBg || !inpaintPrompt.trim(),
4748
5811
  className: "mt-1 px-3 py-2 rounded-lg bg-purple-600 hover:bg-purple-500 disabled:opacity-50 text-white font-medium shadow transition-colors flex items-center justify-center gap-2",
4749
- children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4750
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin" }),
5812
+ children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
5813
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin" }),
4751
5814
  "Generating Inpaint..."
4752
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
4753
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
5815
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
5816
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
4754
5817
  "Apply Inpainting"
4755
5818
  ] })
4756
5819
  }
4757
5820
  )
4758
5821
  ] }),
4759
- aiError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "p-2.5 rounded-lg bg-rose-950/60 border border-rose-800 text-rose-300 text-[11px]", children: aiError }),
4760
- aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-950/60 border border-emerald-800 text-emerald-300 text-[11px]", children: aiSuccess })
5822
+ aiError && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "p-2.5 rounded-lg bg-rose-950/60 border border-rose-800 text-rose-300 text-[11px]", children: aiError }),
5823
+ aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-950/60 border border-emerald-800 text-emerald-300 text-[11px]", children: aiSuccess })
4761
5824
  ] })
4762
5825
  ] })
4763
5826
  ] })