@pixerate/editor-react 0.101.0 → 0.102.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.
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ __export(src_exports, {
43
43
  CommentsPanel: () => CommentsPanel,
44
44
  ControlSlider: () => ControlSlider,
45
45
  CurvesEditor: () => CurvesEditor,
46
- DirtyTracker: () => import_editor21.DirtyTracker,
46
+ DirtyTracker: () => import_editor22.DirtyTracker,
47
47
  EditorContent: () => EditorContent,
48
48
  EditorSlotsProvider: () => EditorSlotsProvider,
49
49
  ExportDocxButton: () => ExportDocxButton,
@@ -53,7 +53,7 @@ __export(src_exports, {
53
53
  GenerationHistory: () => GenerationHistory,
54
54
  GenerationSettings: () => GenerationSettings,
55
55
  Histogram: () => Histogram,
56
- HistoryManager: () => import_editor21.HistoryManager,
56
+ HistoryManager: () => import_editor22.HistoryManager,
57
57
  ImageEditor: () => ImageEditor,
58
58
  ImageEditorCanvas: () => ImageEditorCanvas,
59
59
  ImageEffectControls: () => ImageEffectControls,
@@ -86,11 +86,11 @@ __export(src_exports, {
86
86
  TrackedChangesList: () => TrackedChangesList,
87
87
  TypeOptionsBar: () => TypeOptionsBar,
88
88
  VariableForm: () => VariableForm,
89
- bindDirtyToHistory: () => import_editor21.bindDirtyToHistory,
90
- createDirtyTracker: () => import_editor21.createDirtyTracker,
91
- createHistoryManager: () => import_editor21.createHistoryManager,
89
+ bindDirtyToHistory: () => import_editor22.bindDirtyToHistory,
90
+ createDirtyTracker: () => import_editor22.createDirtyTracker,
91
+ createHistoryManager: () => import_editor22.createHistoryManager,
92
92
  createReactChartNodeView: () => createReactChartNodeView,
93
- defaultIsEqual: () => import_editor21.defaultIsEqual,
93
+ defaultIsEqual: () => import_editor22.defaultIsEqual,
94
94
  useAgentPlayback: () => useAgentPlayback,
95
95
  useAgentToolProvider: () => useAgentToolProvider,
96
96
  useAutosave: () => useAutosave,
@@ -123,6 +123,7 @@ __export(src_exports, {
123
123
  usePlaybackSurface: () => usePlaybackSurface,
124
124
  usePromptEditor: () => usePromptEditor,
125
125
  useRegisterCommands: () => useRegisterCommands,
126
+ useRichTextEditorDocument: () => useRichTextEditorDocument,
126
127
  useSpreadsheetClipboard: () => useSpreadsheetClipboard,
127
128
  useSpreadsheetEditor: () => useSpreadsheetEditor,
128
129
  useSpreadsheetViewport: () => useSpreadsheetViewport,
@@ -130,7 +131,7 @@ __export(src_exports, {
130
131
  useToolBridge: () => useToolBridge,
131
132
  useToolRegistryView: () => useToolRegistryView,
132
133
  useTrackChanges: () => useTrackChanges,
133
- withoutDirty: () => import_editor21.withoutDirty
134
+ withoutDirty: () => import_editor22.withoutDirty
134
135
  });
135
136
  module.exports = __toCommonJS(src_exports);
136
137
 
@@ -748,11 +749,20 @@ function useAgentToolProvider(registry, provider, options = {}) {
748
749
  }, [registry, provider]);
749
750
  }
750
751
 
752
+ // src/hooks/useRichTextEditorDocument.ts
753
+ var import_react12 = require("react");
754
+ var import_editor6 = require("@pixerate/editor");
755
+ function useRichTextEditorDocument(editor) {
756
+ const doc = (0, import_react12.useMemo)(() => editor ? (0, import_editor6.createRichTextEditorDocument)(editor) : null, [editor]);
757
+ (0, import_react12.useEffect)(() => () => doc?.destroy(), [doc]);
758
+ return doc;
759
+ }
760
+
751
761
  // src/playback/PresenceLayer.tsx
752
- var import_react12 = __toESM(require("react"), 1);
762
+ var import_react13 = __toESM(require("react"), 1);
753
763
  var import_jsx_runtime2 = require("react/jsx-runtime");
754
764
  function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
755
- const { actors } = (0, import_react12.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
765
+ const { actors } = (0, import_react13.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
756
766
  if (!actors.length) return null;
757
767
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
758
768
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -769,7 +779,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
769
779
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
770
780
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
771
781
  })();
772
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react12.default.Fragment, { children: [
782
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react13.default.Fragment, { children: [
773
783
  ring && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
774
784
  "div",
775
785
  {
@@ -791,27 +801,27 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
791
801
  }
792
802
 
793
803
  // src/playback/AgentPlaybackContext.tsx
794
- var import_react13 = require("react");
804
+ var import_react14 = require("react");
795
805
  var import_jsx_runtime3 = require("react/jsx-runtime");
796
- var AgentPlaybackContext = (0, import_react13.createContext)(null);
806
+ var AgentPlaybackContext = (0, import_react14.createContext)(null);
797
807
  function AgentPlaybackProvider({ playback, children }) {
798
808
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AgentPlaybackContext.Provider, { value: playback ?? null, children });
799
809
  }
800
810
  function useAgentPlayback() {
801
- return (0, import_react13.useContext)(AgentPlaybackContext);
811
+ return (0, import_react14.useContext)(AgentPlaybackContext);
802
812
  }
803
813
 
804
814
  // src/playback/usePlaybackSurface.ts
805
- var import_react14 = require("react");
815
+ var import_react15 = require("react");
806
816
  var import_tools = require("@pixerate/editor/tools");
807
817
  function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
808
818
  const ambient = useAgentPlayback();
809
819
  const target = playback === void 0 ? ambient : playback;
810
- const [ownPresence] = (0, import_react14.useState)(() => new import_tools.PresenceStore());
820
+ const [ownPresence] = (0, import_react15.useState)(() => new import_tools.PresenceStore());
811
821
  const presence = sharedPresence ?? ownPresence;
812
- const latest = (0, import_react14.useRef)(options);
822
+ const latest = (0, import_react15.useRef)(options);
813
823
  latest.current = options;
814
- (0, import_react14.useEffect)(() => {
824
+ (0, import_react15.useEffect)(() => {
815
825
  if (!target || !id) return;
816
826
  const o = () => latest.current;
817
827
  const surface = {
@@ -843,10 +853,10 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
843
853
  }
844
854
 
845
855
  // src/playback/useElementPlaybackSurface.ts
846
- var import_react15 = require("react");
856
+ var import_react16 = require("react");
847
857
  var import_tools2 = require("@pixerate/editor/tools");
848
858
  function useElementPlaybackSurface(playback, id, element, options) {
849
- const latest = (0, import_react15.useRef)(options);
859
+ const latest = (0, import_react16.useRef)(options);
850
860
  latest.current = options;
851
861
  const box = () => element.current?.getBoundingClientRect() ?? null;
852
862
  const fromViewport = (p) => {
@@ -885,12 +895,12 @@ function useElementPlaybackSurface(playback, id, element, options) {
885
895
  }
886
896
 
887
897
  // src/hooks/useToolBridge.ts
888
- var import_react16 = require("react");
898
+ var import_react17 = require("react");
889
899
  var import_tools3 = require("@pixerate/editor/tools");
890
900
  function useToolBridge(registry, options) {
891
- const [state, setState] = (0, import_react16.useState)({ status: "off", editorId: null });
901
+ const [state, setState] = (0, import_react17.useState)({ status: "off", editorId: null });
892
902
  const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
893
- (0, import_react16.useEffect)(() => {
903
+ (0, import_react17.useEffect)(() => {
894
904
  if (!registry || !options) {
895
905
  setState({ status: "off", editorId: null });
896
906
  return;
@@ -910,36 +920,36 @@ function useToolBridge(registry, options) {
910
920
  }
911
921
 
912
922
  // src/hooks/useToolRegistryView.ts
913
- var import_react17 = require("react");
923
+ var import_react18 = require("react");
914
924
  function useToolRegistryView(registry, options = {}) {
915
925
  const { toolsets, readOnly, discovery } = options;
916
- const view = (0, import_react17.useMemo)(
926
+ const view = (0, import_react18.useMemo)(
917
927
  () => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
918
928
  // toolsets is applied below without making a new view, so enabled tools survive.
919
929
  // eslint-disable-next-line react-hooks/exhaustive-deps
920
930
  [registry, readOnly, discovery]
921
931
  );
922
932
  const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
923
- (0, import_react17.useEffect)(() => {
933
+ (0, import_react18.useEffect)(() => {
924
934
  view?.setToolsets(toolsets);
925
935
  }, [view, toolsetsKey]);
926
- (0, import_react17.useEffect)(() => () => view?.dispose(), [view]);
936
+ (0, import_react18.useEffect)(() => () => view?.dispose(), [view]);
927
937
  return view;
928
938
  }
929
939
 
930
940
  // src/components/EditorContent.tsx
931
- var import_react18 = require("@tiptap/react");
941
+ var import_react19 = require("@tiptap/react");
932
942
  var import_jsx_runtime4 = require("react/jsx-runtime");
933
943
  var EditorContent = ({
934
944
  className,
935
945
  editor,
936
946
  ...props
937
947
  }) => {
938
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react18.EditorContent, { editor, ...props }) });
948
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react19.EditorContent, { editor, ...props }) });
939
949
  };
940
950
 
941
951
  // src/components/BubbleMenu.tsx
942
- var import_react19 = require("react");
952
+ var import_react20 = require("react");
943
953
  var import_react_dom = require("react-dom");
944
954
  var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
945
955
  var BubbleMenu = ({
@@ -951,12 +961,12 @@ var BubbleMenu = ({
951
961
  pluginKey = "bubbleMenu",
952
962
  updateDelay
953
963
  }) => {
954
- const menuEl = (0, import_react19.useRef)(null);
955
- const [mounted, setMounted] = (0, import_react19.useState)(false);
964
+ const menuEl = (0, import_react20.useRef)(null);
965
+ const [mounted, setMounted] = (0, import_react20.useState)(false);
956
966
  if (!menuEl.current && typeof document !== "undefined") {
957
967
  menuEl.current = document.createElement("div");
958
968
  }
959
- (0, import_react19.useEffect)(() => {
969
+ (0, import_react20.useEffect)(() => {
960
970
  if (!editor || !menuEl.current || editor.isDestroyed) {
961
971
  return;
962
972
  }
@@ -987,8 +997,8 @@ var BubbleMenu = ({
987
997
  };
988
998
 
989
999
  // src/components/TemplateRenderer.tsx
990
- var import_react20 = require("react");
991
- var import_editor6 = require("@pixerate/editor");
1000
+ var import_react21 = require("react");
1001
+ var import_editor7 = require("@pixerate/editor");
992
1002
  var import_jsx_runtime5 = require("react/jsx-runtime");
993
1003
  var TemplateRenderer = ({
994
1004
  content,
@@ -1001,12 +1011,12 @@ var TemplateRenderer = ({
1001
1011
  onTemplateClick,
1002
1012
  onVariableClick
1003
1013
  }) => {
1004
- const displayText = (0, import_react20.useMemo)(() => {
1014
+ const displayText = (0, import_react21.useMemo)(() => {
1005
1015
  if (!resolve || templates.length === 0) return content;
1006
- return (0, import_editor6.resolveTemplates)(content, templates, { bindings });
1016
+ return (0, import_editor7.resolveTemplates)(content, templates, { bindings });
1007
1017
  }, [content, templates, resolve, bindings]);
1008
- const tokens = (0, import_react20.useMemo)(() => {
1009
- return (0, import_editor6.evaluatePromptTokens)(displayText, values);
1018
+ const tokens = (0, import_react21.useMemo)(() => {
1019
+ return (0, import_editor7.evaluatePromptTokens)(displayText, values);
1010
1020
  }, [displayText, values]);
1011
1021
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: tokens.map((token, index) => {
1012
1022
  if (token.type === "template") {
@@ -1072,8 +1082,8 @@ var TemplateRenderer = ({
1072
1082
  {
1073
1083
  "data-conditional": token.conditional,
1074
1084
  className: "inline-flex items-center px-1 py-0.5 mx-0.5 text-xs font-medium rounded-md border border-amber-400/40 bg-amber-400/15 text-amber-700 dark:text-amber-300",
1075
- title: (0, import_editor6.describeConditionalTag)(token),
1076
- children: (0, import_editor6.formatConditionalTag)(token)
1085
+ title: (0, import_editor7.describeConditionalTag)(token),
1086
+ children: (0, import_editor7.formatConditionalTag)(token)
1077
1087
  },
1078
1088
  index
1079
1089
  );
@@ -1094,8 +1104,8 @@ var TemplateRenderer = ({
1094
1104
  };
1095
1105
 
1096
1106
  // src/components/VariableForm.tsx
1097
- var import_react21 = require("react");
1098
- var import_editor7 = require("@pixerate/editor");
1107
+ var import_react22 = require("react");
1108
+ var import_editor8 = require("@pixerate/editor");
1099
1109
  var import_jsx_runtime6 = require("react/jsx-runtime");
1100
1110
  var VariableForm = ({
1101
1111
  content,
@@ -1106,19 +1116,19 @@ var VariableForm = ({
1106
1116
  onChange,
1107
1117
  className = "flex flex-col gap-3 text-sm"
1108
1118
  }) => {
1109
- const idPrefix = (0, import_react21.useId)();
1110
- const [internal, setInternal] = (0, import_react21.useState)(
1119
+ const idPrefix = (0, import_react22.useId)();
1120
+ const [internal, setInternal] = (0, import_react22.useState)(
1111
1121
  () => defaultValues ?? {}
1112
1122
  );
1113
1123
  const entered = values ?? internal;
1114
- const fields = (0, import_react21.useMemo)(
1115
- () => (0, import_editor7.getVariableFormFields)(content, { templates, bindings }),
1124
+ const fields = (0, import_react22.useMemo)(
1125
+ () => (0, import_editor8.getVariableFormFields)(content, { templates, bindings }),
1116
1126
  [content, templates, bindings]
1117
1127
  );
1118
1128
  const update = (name, value) => {
1119
1129
  const next = { ...entered, [name]: value };
1120
1130
  if (values === void 0) setInternal(next);
1121
- onChange?.((0, import_editor7.compactVariableValues)(next), next);
1131
+ onChange?.((0, import_editor8.compactVariableValues)(next), next);
1122
1132
  };
1123
1133
  if (fields.length === 0) return null;
1124
1134
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { className, onSubmit: (event) => event.preventDefault(), children: fields.map((field) => {
@@ -1179,28 +1189,28 @@ var VariableForm = ({
1179
1189
  };
1180
1190
 
1181
1191
  // src/components/MergePreview.tsx
1182
- var import_react23 = require("react");
1192
+ var import_react24 = require("react");
1183
1193
 
1184
1194
  // src/hooks/useMergePreview.ts
1185
- var import_react22 = require("react");
1186
- var import_editor8 = require("@pixerate/editor");
1195
+ var import_react23 = require("react");
1196
+ var import_editor9 = require("@pixerate/editor");
1187
1197
  function useMergePreview(options) {
1188
1198
  const { template, templates, bindings, parseOptions } = options;
1189
- const [sourceText, setSourceTextState] = (0, import_react22.useState)(options.initialSource ?? "");
1190
- const [overrides, setOverrides] = (0, import_react22.useState)({});
1191
- const [index, setIndexState] = (0, import_react22.useState)(0);
1192
- const [result, setResult] = (0, import_react22.useState)(null);
1193
- const source = (0, import_react22.useMemo)(
1194
- () => (0, import_editor8.parseDataSource)(sourceText, parseOptions),
1199
+ const [sourceText, setSourceTextState] = (0, import_react23.useState)(options.initialSource ?? "");
1200
+ const [overrides, setOverrides] = (0, import_react23.useState)({});
1201
+ const [index, setIndexState] = (0, import_react23.useState)(0);
1202
+ const [result, setResult] = (0, import_react23.useState)(null);
1203
+ const source = (0, import_react23.useMemo)(
1204
+ () => (0, import_editor9.parseDataSource)(sourceText, parseOptions),
1195
1205
  [sourceText, parseOptions]
1196
1206
  );
1197
- const variables = (0, import_react22.useMemo)(
1198
- () => (0, import_editor8.extractVariables)(template, { templates, bindings }).map((v) => v.name),
1207
+ const variables = (0, import_react23.useMemo)(
1208
+ () => (0, import_editor9.extractVariables)(template, { templates, bindings }).map((v) => v.name),
1199
1209
  [template, templates, bindings]
1200
1210
  );
1201
- const mapping = (0, import_react22.useMemo)(() => {
1211
+ const mapping = (0, import_react23.useMemo)(() => {
1202
1212
  const merged = {
1203
- ...(0, import_editor8.matchFields)(variables, source.fields).mapping
1213
+ ...(0, import_editor9.matchFields)(variables, source.fields).mapping
1204
1214
  };
1205
1215
  for (const [variable, field] of Object.entries(overrides)) {
1206
1216
  if (variables.includes(variable) && (field === null || source.fields.includes(field))) {
@@ -1212,30 +1222,30 @@ function useMergePreview(options) {
1212
1222
  const count = source.records.length;
1213
1223
  const current = count === 0 ? 0 : Math.min(index, count - 1);
1214
1224
  const record = source.records[current];
1215
- const values = (0, import_react22.useMemo)(
1216
- () => record ? (0, import_editor8.recordToValues)(record, mapping) : {},
1225
+ const values = (0, import_react23.useMemo)(
1226
+ () => record ? (0, import_editor9.recordToValues)(record, mapping) : {},
1217
1227
  [record, mapping]
1218
1228
  );
1219
- const setSourceText = (0, import_react22.useCallback)((text) => {
1229
+ const setSourceText = (0, import_react23.useCallback)((text) => {
1220
1230
  setSourceTextState(text);
1221
1231
  setIndexState(0);
1222
1232
  setResult(null);
1223
1233
  }, []);
1224
- const loadFile = (0, import_react22.useCallback)(
1234
+ const loadFile = (0, import_react23.useCallback)(
1225
1235
  async (file) => setSourceText(await file.text()),
1226
1236
  [setSourceText]
1227
1237
  );
1228
- const setIndex = (0, import_react22.useCallback)(
1238
+ const setIndex = (0, import_react23.useCallback)(
1229
1239
  (next) => setIndexState(Math.max(0, Math.min(next, count - 1))),
1230
1240
  [count]
1231
1241
  );
1232
- const setFieldMapping = (0, import_react22.useCallback)((variable, field) => {
1242
+ const setFieldMapping = (0, import_react23.useCallback)((variable, field) => {
1233
1243
  setOverrides((previous) => ({ ...previous, [variable]: field }));
1234
1244
  setResult(null);
1235
1245
  }, []);
1236
- const resetMapping = (0, import_react22.useCallback)(() => setOverrides({}), []);
1237
- const merge = (0, import_react22.useCallback)(() => {
1238
- const merged = (0, import_editor8.mergeRecords)(template, source, {
1246
+ const resetMapping = (0, import_react23.useCallback)(() => setOverrides({}), []);
1247
+ const merge = (0, import_react23.useCallback)(() => {
1248
+ const merged = (0, import_editor9.mergeRecords)(template, source, {
1239
1249
  templates,
1240
1250
  bindings,
1241
1251
  mapping,
@@ -1246,8 +1256,8 @@ function useMergePreview(options) {
1246
1256
  setResult(merged);
1247
1257
  return merged;
1248
1258
  }, [template, source, templates, bindings, mapping, options.skipIf, options.separator, options.maxOutputs]);
1249
- const serialize = (0, import_react22.useCallback)(
1250
- (format) => result ? (0, import_editor8.serializeMergeOutputs)(result.outputs, format, options.separator) : "",
1259
+ const serialize = (0, import_react23.useCallback)(
1260
+ (format) => result ? (0, import_editor9.serializeMergeOutputs)(result.outputs, format, options.separator) : "",
1251
1261
  [result, options.separator]
1252
1262
  );
1253
1263
  return {
@@ -1299,7 +1309,7 @@ var MergePreview = ({
1299
1309
  downloadName = "merged",
1300
1310
  className = "flex flex-col gap-3 text-sm"
1301
1311
  }) => {
1302
- const id = (0, import_react23.useId)();
1312
+ const id = (0, import_react24.useId)();
1303
1313
  const merge = useMergePreview({
1304
1314
  template: content,
1305
1315
  templates,
@@ -1310,7 +1320,7 @@ var MergePreview = ({
1310
1320
  separator,
1311
1321
  maxOutputs
1312
1322
  });
1313
- const [copied, setCopied] = (0, import_react23.useState)(false);
1323
+ const [copied, setCopied] = (0, import_react24.useState)(false);
1314
1324
  const { source, result } = merge;
1315
1325
  const copy = async () => {
1316
1326
  try {
@@ -1467,15 +1477,15 @@ var MergePreview = ({
1467
1477
  };
1468
1478
 
1469
1479
  // src/hooks/useOutline.ts
1470
- var import_react24 = require("react");
1471
- var import_editor9 = require("@pixerate/editor");
1480
+ var import_react25 = require("react");
1481
+ var import_editor10 = require("@pixerate/editor");
1472
1482
  function useOutline(editor) {
1473
- const store = (0, import_react24.useMemo)(() => (0, import_editor9.createOutlineStore)(editor), [editor]);
1474
- return (0, import_react24.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1483
+ const store = (0, import_react25.useMemo)(() => (0, import_editor10.createOutlineStore)(editor), [editor]);
1484
+ return (0, import_react25.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1475
1485
  }
1476
1486
 
1477
1487
  // src/components/OutlinePanel.tsx
1478
- var import_editor10 = require("@pixerate/editor");
1488
+ var import_editor11 = require("@pixerate/editor");
1479
1489
  var import_jsx_runtime8 = require("react/jsx-runtime");
1480
1490
  var OutlinePanel = ({
1481
1491
  editor,
@@ -1504,7 +1514,7 @@ var OutlinePanel = ({
1504
1514
  "data-heading-id": heading.id,
1505
1515
  onClick: () => {
1506
1516
  if (!editor) return;
1507
- if ((0, import_editor10.navigateToHeading)(editor, heading, { focus: focusOnNavigate })) {
1517
+ if ((0, import_editor11.navigateToHeading)(editor, heading, { focus: focusOnNavigate })) {
1508
1518
  onNavigate?.(heading);
1509
1519
  }
1510
1520
  },
@@ -1516,13 +1526,13 @@ var OutlinePanel = ({
1516
1526
  };
1517
1527
 
1518
1528
  // src/hooks/useParagraphStyles.ts
1519
- var import_react25 = require("react");
1520
- var import_editor11 = require("@pixerate/editor");
1529
+ var import_react26 = require("react");
1530
+ var import_editor12 = require("@pixerate/editor");
1521
1531
  function useParagraphStyles(editor) {
1522
- const store = (0, import_react25.useMemo)(() => (0, import_editor11.createParagraphStylesStore)(editor), [editor]);
1523
- const snapshot = (0, import_react25.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1524
- return (0, import_react25.useMemo)(() => {
1525
- const registry = (0, import_editor11.getStyleRegistry)(editor);
1532
+ const store = (0, import_react26.useMemo)(() => (0, import_editor12.createParagraphStylesStore)(editor), [editor]);
1533
+ const snapshot = (0, import_react26.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1534
+ return (0, import_react26.useMemo)(() => {
1535
+ const registry = (0, import_editor12.getStyleRegistry)(editor);
1526
1536
  const live = () => editor && !editor.isDestroyed ? editor : null;
1527
1537
  return {
1528
1538
  ...snapshot,
@@ -1544,7 +1554,7 @@ function useParagraphStyles(editor) {
1544
1554
  }
1545
1555
 
1546
1556
  // src/components/StylesGallery.tsx
1547
- var import_react26 = require("react");
1557
+ var import_react27 = require("react");
1548
1558
  var import_jsx_runtime9 = require("react/jsx-runtime");
1549
1559
  var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1550
1560
  var keepSelection = (event) => event.preventDefault();
@@ -1560,9 +1570,9 @@ var StylesGallery = ({
1560
1570
  onChange
1561
1571
  }) => {
1562
1572
  const styles = useParagraphStyles(editor);
1563
- const [open, setOpen] = (0, import_react26.useState)(false);
1564
- const [creating, setCreating] = (0, import_react26.useState)(false);
1565
- const [name, setName] = (0, import_react26.useState)("");
1573
+ const [open, setOpen] = (0, import_react27.useState)(false);
1574
+ const [creating, setCreating] = (0, import_react27.useState)(false);
1575
+ const [name, setName] = (0, import_react27.useState)("");
1566
1576
  const list = showAllStyles ? styles.styles : styles.gallery;
1567
1577
  const current = styles.currentStyle;
1568
1578
  const expanded = variant === "gallery" || open;
@@ -1675,16 +1685,16 @@ var StylesGallery = ({
1675
1685
  };
1676
1686
 
1677
1687
  // src/index.ts
1678
- var import_editor21 = require("@pixerate/editor");
1688
+ var import_editor22 = require("@pixerate/editor");
1679
1689
 
1680
1690
  // src/spreadsheet/useSpreadsheetEditor.ts
1681
- var import_react27 = require("react");
1691
+ var import_react28 = require("react");
1682
1692
  var import_spreadsheet = require("@pixerate/editor/spreadsheet");
1683
1693
  function useSpreadsheetEditor(options = {}) {
1684
- const optionsRef = (0, import_react27.useRef)(options);
1694
+ const optionsRef = (0, import_react28.useRef)(options);
1685
1695
  optionsRef.current = options;
1686
- const settersRef = (0, import_react27.useRef)({});
1687
- const [controller] = (0, import_react27.useState)(
1696
+ const settersRef = (0, import_react28.useRef)({});
1697
+ const [controller] = (0, import_react28.useState)(
1688
1698
  () => new import_spreadsheet.SpreadsheetController({
1689
1699
  ...options,
1690
1700
  onDocumentChange: (updated) => {
@@ -1701,37 +1711,37 @@ function useSpreadsheetEditor(options = {}) {
1701
1711
  }
1702
1712
  })
1703
1713
  );
1704
- const [doc, setDoc] = (0, import_react27.useState)(() => ({ ...controller.document }));
1705
- const [activeCell, setActiveCell] = (0, import_react27.useState)(controller.activeCell);
1706
- const [selectedRange, setSelectedRange] = (0, import_react27.useState)(controller.selectedRange);
1707
- const [editingCell, setEditingCell] = (0, import_react27.useState)(null);
1708
- const [draftValue, setDraftState] = (0, import_react27.useState)("");
1709
- const [validationPrompt, setValidationPrompt] = (0, import_react27.useState)(null);
1714
+ const [doc, setDoc] = (0, import_react28.useState)(() => ({ ...controller.document }));
1715
+ const [activeCell, setActiveCell] = (0, import_react28.useState)(controller.activeCell);
1716
+ const [selectedRange, setSelectedRange] = (0, import_react28.useState)(controller.selectedRange);
1717
+ const [editingCell, setEditingCell] = (0, import_react28.useState)(null);
1718
+ const [draftValue, setDraftState] = (0, import_react28.useState)("");
1719
+ const [validationPrompt, setValidationPrompt] = (0, import_react28.useState)(null);
1710
1720
  settersRef.current = { setDoc, setActiveCell, setSelectedRange };
1711
- const setDraftValue = (0, import_react27.useCallback)((value) => {
1721
+ const setDraftValue = (0, import_react28.useCallback)((value) => {
1712
1722
  controller.draftValue = value;
1713
1723
  setDraftState(value);
1714
1724
  }, [controller]);
1715
- const setCellValue = (0, import_react27.useCallback)((rowId, colId, raw) => {
1725
+ const setCellValue = (0, import_react28.useCallback)((rowId, colId, raw) => {
1716
1726
  controller.setCellValue(rowId, colId, raw);
1717
1727
  setDoc({ ...controller.document });
1718
1728
  }, [controller]);
1719
- const selectCell = (0, import_react27.useCallback)((row, col, extendSelection = false) => {
1729
+ const selectCell = (0, import_react28.useCallback)((row, col, extendSelection = false) => {
1720
1730
  controller.selectCell(row, col, extendSelection);
1721
1731
  setActiveCell(controller.activeCell);
1722
1732
  setSelectedRange(controller.selectedRange);
1723
1733
  }, [controller]);
1724
- const selectRange = (0, import_react27.useCallback)((range) => {
1734
+ const selectRange = (0, import_react28.useCallback)((range) => {
1725
1735
  controller.selectRange(range);
1726
1736
  setSelectedRange(controller.selectedRange);
1727
1737
  }, [controller]);
1728
- const startEditing = (0, import_react27.useCallback)((row, col, initialVal) => {
1738
+ const startEditing = (0, import_react28.useCallback)((row, col, initialVal) => {
1729
1739
  controller.startEditing(row, col, initialVal);
1730
1740
  setActiveCell(controller.activeCell);
1731
1741
  setEditingCell(controller.editingCell);
1732
1742
  setDraftValue(controller.draftValue);
1733
1743
  }, [controller]);
1734
- const syncEditing = (0, import_react27.useCallback)(() => {
1744
+ const syncEditing = (0, import_react28.useCallback)(() => {
1735
1745
  setEditingCell(controller.editingCell);
1736
1746
  setDraftValue(controller.draftValue);
1737
1747
  setValidationPrompt(controller.validationPrompt);
@@ -1739,90 +1749,90 @@ function useSpreadsheetEditor(options = {}) {
1739
1749
  setSelectedRange(controller.selectedRange);
1740
1750
  setDoc({ ...controller.document });
1741
1751
  }, [controller]);
1742
- const commitEditing = (0, import_react27.useCallback)((val) => {
1752
+ const commitEditing = (0, import_react28.useCallback)((val) => {
1743
1753
  const result = controller.commitEditing(val);
1744
1754
  syncEditing();
1745
1755
  return result;
1746
1756
  }, [controller, syncEditing]);
1747
- const commitCellInput = (0, import_react27.useCallback)((rowId, colId, raw) => {
1757
+ const commitCellInput = (0, import_react28.useCallback)((rowId, colId, raw) => {
1748
1758
  const result = controller.commitCellInput(rowId, colId, raw);
1749
1759
  syncEditing();
1750
1760
  return result;
1751
1761
  }, [controller, syncEditing]);
1752
- const resolveValidationPrompt = (0, import_react27.useCallback)((action) => {
1762
+ const resolveValidationPrompt = (0, import_react28.useCallback)((action) => {
1753
1763
  controller.resolveValidationPrompt(action);
1754
1764
  syncEditing();
1755
1765
  }, [controller, syncEditing]);
1756
- const cancelEditing = (0, import_react27.useCallback)(() => {
1766
+ const cancelEditing = (0, import_react28.useCallback)(() => {
1757
1767
  controller.cancelEditing();
1758
1768
  setEditingCell(null);
1759
1769
  setDraftValue("");
1760
1770
  }, [controller]);
1761
- const moveCursor = (0, import_react27.useCallback)((dir, extend = false) => {
1771
+ const moveCursor = (0, import_react28.useCallback)((dir, extend = false) => {
1762
1772
  controller.moveCursor(dir, extend);
1763
1773
  setActiveCell(controller.activeCell);
1764
1774
  setSelectedRange(controller.selectedRange);
1765
1775
  }, [controller]);
1766
- const insertColumn = (0, import_react27.useCallback)((index, config) => {
1776
+ const insertColumn = (0, import_react28.useCallback)((index, config) => {
1767
1777
  controller.insertColumn(index, config);
1768
1778
  setDoc({ ...controller.document });
1769
1779
  }, [controller]);
1770
- const deleteColumn = (0, import_react27.useCallback)((colId) => {
1780
+ const deleteColumn = (0, import_react28.useCallback)((colId) => {
1771
1781
  controller.deleteColumn(colId);
1772
1782
  setDoc({ ...controller.document });
1773
1783
  }, [controller]);
1774
- const insertRow = (0, import_react27.useCallback)((index, config) => {
1784
+ const insertRow = (0, import_react28.useCallback)((index, config) => {
1775
1785
  controller.insertRow(index, config);
1776
1786
  setDoc({ ...controller.document });
1777
1787
  }, [controller]);
1778
- const deleteRow = (0, import_react27.useCallback)((rowId) => {
1788
+ const deleteRow = (0, import_react28.useCallback)((rowId) => {
1779
1789
  controller.deleteRow(rowId);
1780
1790
  setDoc({ ...controller.document });
1781
1791
  }, [controller]);
1782
- const setColumnWidth = (0, import_react27.useCallback)((colId, width) => {
1792
+ const setColumnWidth = (0, import_react28.useCallback)((colId, width) => {
1783
1793
  controller.setColumnWidth(colId, width);
1784
1794
  setDoc({ ...controller.document });
1785
1795
  }, [controller]);
1786
- const autoFitColumnWidth = (0, import_react27.useCallback)((colId, customWidth) => {
1796
+ const autoFitColumnWidth = (0, import_react28.useCallback)((colId, customWidth) => {
1787
1797
  controller.autoFitColumnWidth(colId, customWidth);
1788
1798
  setDoc({ ...controller.document });
1789
1799
  }, [controller]);
1790
- const registerDataSource = (0, import_react27.useCallback)((ds) => {
1800
+ const registerDataSource = (0, import_react28.useCallback)((ds) => {
1791
1801
  controller.registerDataSource(ds);
1792
1802
  setDoc({ ...controller.document });
1793
1803
  }, [controller]);
1794
- const setPrimaryDataSource = (0, import_react27.useCallback)((id) => {
1804
+ const setPrimaryDataSource = (0, import_react28.useCallback)((id) => {
1795
1805
  controller.setPrimaryDataSource(id);
1796
1806
  setDoc({ ...controller.document });
1797
1807
  }, [controller]);
1798
- const recalculateAll = (0, import_react27.useCallback)(() => {
1808
+ const recalculateAll = (0, import_react28.useCallback)(() => {
1799
1809
  controller.recalculateAll();
1800
1810
  setDoc({ ...controller.document });
1801
1811
  }, [controller]);
1802
- const undo = (0, import_react27.useCallback)(() => {
1812
+ const undo = (0, import_react28.useCallback)(() => {
1803
1813
  controller.undo();
1804
1814
  setDoc({ ...controller.document });
1805
1815
  setActiveCell(controller.activeCell);
1806
1816
  setSelectedRange(controller.selectedRange);
1807
1817
  }, [controller]);
1808
- const redo = (0, import_react27.useCallback)(() => {
1818
+ const redo = (0, import_react28.useCallback)(() => {
1809
1819
  controller.redo();
1810
1820
  setDoc({ ...controller.document });
1811
1821
  setActiveCell(controller.activeCell);
1812
1822
  setSelectedRange(controller.selectedRange);
1813
1823
  }, [controller]);
1814
- const tableActions = (0, import_react27.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
1815
- const viewModel = (0, import_react27.useMemo)(() => controller.getViewModel(), [controller, doc]);
1816
- const sheets = (0, import_react27.useMemo)(() => controller.getSheets(), [controller, doc]);
1817
- const names = (0, import_react27.useMemo)(() => controller.getNames(), [controller, doc]);
1818
- const afterSheetSwitch = (0, import_react27.useCallback)(() => {
1824
+ const tableActions = (0, import_react28.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
1825
+ const viewModel = (0, import_react28.useMemo)(() => controller.getViewModel(), [controller, doc]);
1826
+ const sheets = (0, import_react28.useMemo)(() => controller.getSheets(), [controller, doc]);
1827
+ const names = (0, import_react28.useMemo)(() => controller.getNames(), [controller, doc]);
1828
+ const afterSheetSwitch = (0, import_react28.useCallback)(() => {
1819
1829
  setEditingCell(controller.editingCell);
1820
1830
  setDraftValue(controller.draftValue);
1821
1831
  setActiveCell(controller.activeCell);
1822
1832
  setSelectedRange(controller.selectedRange);
1823
1833
  setDoc({ ...controller.document });
1824
1834
  }, [controller, setDraftValue]);
1825
- const workbookActions = (0, import_react27.useMemo)(
1835
+ const workbookActions = (0, import_react28.useMemo)(
1826
1836
  () => ({
1827
1837
  setActiveSheet: (idOrName) => {
1828
1838
  const changed = controller.setActiveSheet(idOrName);
@@ -1852,7 +1862,9 @@ function useSpreadsheetEditor(options = {}) {
1852
1862
  }),
1853
1863
  [controller, afterSheetSwitch]
1854
1864
  );
1855
- const conditionalFormatOverlay = (0, import_react27.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
1865
+ const conditionalFormatOverlay = (0, import_react28.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
1866
+ const editorDocument = (0, import_react28.useMemo)(() => (0, import_spreadsheet.createSpreadsheetEditorDocument)(controller), [controller]);
1867
+ (0, import_react28.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
1856
1868
  return {
1857
1869
  document: doc,
1858
1870
  activeCell,
@@ -1864,6 +1876,8 @@ function useSpreadsheetEditor(options = {}) {
1864
1876
  resolveValidationPrompt,
1865
1877
  commitCellInput,
1866
1878
  controller,
1879
+ /** The save / load / undo contract (for `useEditorAutosave` or `createDocumentToolProvider`). */
1880
+ editorDocument,
1867
1881
  getCell: (rowId, colId) => controller.getCell(rowId, colId),
1868
1882
  setCellValue,
1869
1883
  selectCell,
@@ -1914,20 +1928,20 @@ function useSpreadsheetEditor(options = {}) {
1914
1928
  }
1915
1929
 
1916
1930
  // src/spreadsheet/SpreadsheetEditor.tsx
1917
- var import_react36 = require("react");
1931
+ var import_react37 = require("react");
1918
1932
  var import_spreadsheet8 = require("@pixerate/editor/spreadsheet");
1919
1933
 
1920
1934
  // src/spreadsheet/SpreadsheetContextMenu.tsx
1921
- var import_react28 = __toESM(require("react"), 1);
1935
+ var import_react29 = __toESM(require("react"), 1);
1922
1936
  var import_spreadsheet2 = require("@pixerate/editor/spreadsheet");
1923
1937
  var import_jsx_runtime10 = require("react/jsx-runtime");
1924
1938
  var VIEWPORT_MARGIN = 4;
1925
1939
  var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "Table actions" }) => {
1926
- const menuRef = (0, import_react28.useRef)(null);
1927
- const onCloseRef = (0, import_react28.useRef)(onClose);
1940
+ const menuRef = (0, import_react29.useRef)(null);
1941
+ const onCloseRef = (0, import_react29.useRef)(onClose);
1928
1942
  onCloseRef.current = onClose;
1929
- const [position, setPosition] = (0, import_react28.useState)({ x, y });
1930
- (0, import_react28.useLayoutEffect)(() => {
1943
+ const [position, setPosition] = (0, import_react29.useState)({ x, y });
1944
+ (0, import_react29.useLayoutEffect)(() => {
1931
1945
  const menu = menuRef.current;
1932
1946
  if (!menu || typeof window === "undefined") return;
1933
1947
  const { width, height } = menu.getBoundingClientRect();
@@ -1939,7 +1953,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1939
1953
  );
1940
1954
  setPosition((prev) => prev.x === next.x && prev.y === next.y ? prev : next);
1941
1955
  }, [x, y, items]);
1942
- (0, import_react28.useEffect)(() => {
1956
+ (0, import_react29.useEffect)(() => {
1943
1957
  const handlePointer = (e) => {
1944
1958
  if (!menuRef.current?.contains(e.target)) onCloseRef.current();
1945
1959
  };
@@ -1969,7 +1983,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1969
1983
  },
1970
1984
  onContextMenu: (e) => e.preventDefault(),
1971
1985
  onKeyDown: (e) => e.stopPropagation(),
1972
- children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react28.default.Fragment, { children: [
1986
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react29.default.Fragment, { children: [
1973
1987
  item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
1974
1988
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1975
1989
  "button",
@@ -1994,7 +2008,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1994
2008
  };
1995
2009
 
1996
2010
  // src/spreadsheet/SpreadsheetGroupRow.tsx
1997
- var import_react29 = __toESM(require("react"), 1);
2011
+ var import_react30 = __toESM(require("react"), 1);
1998
2012
  var import_jsx_runtime11 = require("react/jsx-runtime");
1999
2013
  var formatSummary = (value) => value === null ? "\u2013" : String(value);
2000
2014
  var SpreadsheetGroupRow = ({
@@ -2028,7 +2042,7 @@ var SpreadsheetGroupRow = ({
2028
2042
  columns.map(({ column }, i) => {
2029
2043
  const summary = group.summaries[column.id];
2030
2044
  const before = leadingColumns !== void 0 && i === leadingColumns && leftSpace > 0 ? spacer("space:left") : null;
2031
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react29.default.Fragment, { children: [
2045
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react30.default.Fragment, { children: [
2032
2046
  before,
2033
2047
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "border-r border-border px-2 py-1 truncate max-w-0 text-foreground", style: { maxWidth: 0, overflow: "hidden" }, children: column.id === labelColId ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "truncate", children: [
2034
2048
  group.label,
@@ -2048,7 +2062,7 @@ var SpreadsheetGroupRow = ({
2048
2062
  };
2049
2063
 
2050
2064
  // src/spreadsheet/useSpreadsheetTableInteractions.ts
2051
- var import_react30 = require("react");
2065
+ var import_react31 = require("react");
2052
2066
  var import_spreadsheet3 = require("@pixerate/editor/spreadsheet");
2053
2067
  function gridHasFocus(grid) {
2054
2068
  if (!grid || typeof document === "undefined") return false;
@@ -2057,12 +2071,12 @@ function gridHasFocus(grid) {
2057
2071
  return !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
2058
2072
  }
2059
2073
  function useSpreadsheetClipboard(gridRef, state, readOnly) {
2060
- const stateRef = (0, import_react30.useRef)(state);
2074
+ const stateRef = (0, import_react31.useRef)(state);
2061
2075
  stateRef.current = state;
2062
- const readOnlyRef = (0, import_react30.useRef)(readOnly);
2076
+ const readOnlyRef = (0, import_react31.useRef)(readOnly);
2063
2077
  readOnlyRef.current = readOnly;
2064
- const copiedRef = (0, import_react30.useRef)(false);
2065
- (0, import_react30.useEffect)(() => {
2078
+ const copiedRef = (0, import_react31.useRef)(false);
2079
+ (0, import_react31.useEffect)(() => {
2066
2080
  if (typeof document === "undefined") return;
2067
2081
  const handleCopy = (e) => {
2068
2082
  const s = stateRef.current;
@@ -2085,7 +2099,7 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
2085
2099
  document.removeEventListener("paste", handlePaste);
2086
2100
  };
2087
2101
  }, [gridRef]);
2088
- const copyShortcutFallback = (0, import_react30.useCallback)(() => {
2102
+ const copyShortcutFallback = (0, import_react31.useCallback)(() => {
2089
2103
  copiedRef.current = false;
2090
2104
  setTimeout(() => {
2091
2105
  if (copiedRef.current) return;
@@ -2097,13 +2111,13 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
2097
2111
  return { copyShortcutFallback };
2098
2112
  }
2099
2113
  function useFillHandle(state) {
2100
- const [drag, setDrag] = (0, import_react30.useState)(null);
2101
- const dragRef = (0, import_react30.useRef)(drag);
2114
+ const [drag, setDrag] = (0, import_react31.useState)(null);
2115
+ const dragRef = (0, import_react31.useRef)(drag);
2102
2116
  dragRef.current = drag;
2103
- const stateRef = (0, import_react30.useRef)(state);
2117
+ const stateRef = (0, import_react31.useRef)(state);
2104
2118
  stateRef.current = state;
2105
2119
  const dragging = drag !== null;
2106
- (0, import_react30.useEffect)(() => {
2120
+ (0, import_react31.useEffect)(() => {
2107
2121
  if (!dragging) return;
2108
2122
  const handleMouseUp = () => {
2109
2123
  const current = dragRef.current;
@@ -2113,13 +2127,13 @@ function useFillHandle(state) {
2113
2127
  window.addEventListener("mouseup", handleMouseUp);
2114
2128
  return () => window.removeEventListener("mouseup", handleMouseUp);
2115
2129
  }, [dragging]);
2116
- const startFill = (0, import_react30.useCallback)((e) => {
2130
+ const startFill = (0, import_react31.useCallback)((e) => {
2117
2131
  e.preventDefault();
2118
2132
  e.stopPropagation();
2119
2133
  const range = stateRef.current.selectedRange;
2120
2134
  if (range) setDrag({ source: (0, import_spreadsheet3.normalizeRange)(range), target: null });
2121
2135
  }, []);
2122
- const extendFill = (0, import_react30.useCallback)((row, col) => {
2136
+ const extendFill = (0, import_react31.useCallback)((row, col) => {
2123
2137
  const current = dragRef.current;
2124
2138
  if (!current) return;
2125
2139
  setDrag({ source: current.source, target: (0, import_spreadsheet3.computeFillTarget)(current.source, { row, col }) });
@@ -2128,12 +2142,12 @@ function useFillHandle(state) {
2128
2142
  }
2129
2143
 
2130
2144
  // src/spreadsheet/SpreadsheetValidationDialog.tsx
2131
- var import_react31 = require("react");
2145
+ var import_react32 = require("react");
2132
2146
  var import_jsx_runtime12 = require("react/jsx-runtime");
2133
2147
  var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2134
2148
  const style = prompt.result.errorStyle ?? "stop";
2135
- const firstButton = (0, import_react31.useRef)(null);
2136
- (0, import_react31.useEffect)(() => {
2149
+ const firstButton = (0, import_react32.useRef)(null);
2150
+ (0, import_react32.useEffect)(() => {
2137
2151
  firstButton.current?.focus();
2138
2152
  }, [prompt]);
2139
2153
  const buttons = style === "stop" ? [
@@ -2199,7 +2213,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2199
2213
  };
2200
2214
 
2201
2215
  // src/spreadsheet/SpreadsheetRulePanels.tsx
2202
- var import_react32 = require("react");
2216
+ var import_react33 = require("react");
2203
2217
  var import_spreadsheet4 = require("@pixerate/editor/spreadsheet");
2204
2218
  var import_jsx_runtime13 = require("react/jsx-runtime");
2205
2219
  var inputClass = "w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground";
@@ -2253,18 +2267,18 @@ function RuleSwatch({ rule }) {
2253
2267
  }
2254
2268
  var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2255
2269
  const rules = state.document.table?.conditionalFormats ?? [];
2256
- const [kind, setKind] = (0, import_react32.useState)("greaterThan");
2257
- const [appliesTo, setAppliesTo] = (0, import_react32.useState)(() => selectionText(state.selectedRange));
2258
- const [value, setValue] = (0, import_react32.useState)("");
2259
- const [value2, setValue2] = (0, import_react32.useState)("");
2260
- const [text, setText] = (0, import_react32.useState)("");
2261
- const [formula, setFormula] = (0, import_react32.useState)("=");
2262
- const [rank, setRank] = (0, import_react32.useState)("10");
2263
- const [period, setPeriod] = (0, import_react32.useState)("today");
2264
- const [iconSet, setIconSet] = (0, import_react32.useState)("3TrafficLights1");
2265
- const [color, setColor] = (0, import_react32.useState)("#638ec6");
2266
- const [styleId, setStyleId] = (0, import_react32.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
2267
- const preset = (0, import_react32.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
2270
+ const [kind, setKind] = (0, import_react33.useState)("greaterThan");
2271
+ const [appliesTo, setAppliesTo] = (0, import_react33.useState)(() => selectionText(state.selectedRange));
2272
+ const [value, setValue] = (0, import_react33.useState)("");
2273
+ const [value2, setValue2] = (0, import_react33.useState)("");
2274
+ const [text, setText] = (0, import_react33.useState)("");
2275
+ const [formula, setFormula] = (0, import_react33.useState)("=");
2276
+ const [rank, setRank] = (0, import_react33.useState)("10");
2277
+ const [period, setPeriod] = (0, import_react33.useState)("today");
2278
+ const [iconSet, setIconSet] = (0, import_react33.useState)("3TrafficLights1");
2279
+ const [color, setColor] = (0, import_react33.useState)("#638ec6");
2280
+ const [styleId, setStyleId] = (0, import_react33.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
2281
+ const preset = (0, import_react33.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
2268
2282
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2269
2283
  const add = () => {
2270
2284
  if (!ranges) return;
@@ -2348,15 +2362,15 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2348
2362
  };
2349
2363
  var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2350
2364
  const rules = state.document.table?.dataValidations ?? [];
2351
- const [type, setType] = (0, import_react32.useState)("list");
2352
- const [operator, setOperator] = (0, import_react32.useState)("between");
2353
- const [formula1, setFormula1] = (0, import_react32.useState)("");
2354
- const [formula2, setFormula2] = (0, import_react32.useState)("");
2355
- const [errorStyle, setErrorStyle] = (0, import_react32.useState)("stop");
2356
- const [errorMessage, setErrorMessage] = (0, import_react32.useState)("");
2357
- const [inputMessage, setInputMessage] = (0, import_react32.useState)("");
2358
- const [ignoreBlank, setIgnoreBlank] = (0, import_react32.useState)(true);
2359
- const [appliesTo, setAppliesTo] = (0, import_react32.useState)(() => selectionText(state.selectedRange));
2365
+ const [type, setType] = (0, import_react33.useState)("list");
2366
+ const [operator, setOperator] = (0, import_react33.useState)("between");
2367
+ const [formula1, setFormula1] = (0, import_react33.useState)("");
2368
+ const [formula2, setFormula2] = (0, import_react33.useState)("");
2369
+ const [errorStyle, setErrorStyle] = (0, import_react33.useState)("stop");
2370
+ const [errorMessage, setErrorMessage] = (0, import_react33.useState)("");
2371
+ const [inputMessage, setInputMessage] = (0, import_react33.useState)("");
2372
+ const [ignoreBlank, setIgnoreBlank] = (0, import_react33.useState)(true);
2373
+ const [appliesTo, setAppliesTo] = (0, import_react33.useState)(() => selectionText(state.selectedRange));
2360
2374
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2361
2375
  const usesOperator = type === "whole" || type === "decimal" || type === "date" || type === "time" || type === "textLength";
2362
2376
  const needsTwo = usesOperator && (operator === "between" || operator === "notBetween");
@@ -2430,29 +2444,29 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2430
2444
  };
2431
2445
 
2432
2446
  // src/spreadsheet/useSpreadsheetViewport.ts
2433
- var import_react33 = require("react");
2447
+ var import_react34 = require("react");
2434
2448
  var import_spreadsheet5 = require("@pixerate/editor/spreadsheet");
2435
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react33.useLayoutEffect : import_react33.useEffect;
2449
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react34.useLayoutEffect : import_react34.useEffect;
2436
2450
  function useSpreadsheetViewport(scrollRef, view, options = {}) {
2437
- const metrics = (0, import_react33.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2451
+ const metrics = (0, import_react34.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2438
2452
  const virtual = (0, import_spreadsheet5.shouldVirtualizeSpreadsheet)(view, options.virtualize ?? "auto");
2439
- const [viewport, setViewport] = (0, import_react33.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2440
- const windowOptions = (0, import_react33.useMemo)(
2453
+ const [viewport, setViewport] = (0, import_react34.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2454
+ const windowOptions = (0, import_react34.useMemo)(
2441
2455
  () => ({ merges: options.merges, overscanRows: options.overscanRows, overscanColumns: options.overscanColumns }),
2442
2456
  [options.merges, options.overscanRows, options.overscanColumns]
2443
2457
  );
2444
- const win = (0, import_react33.useMemo)(
2458
+ const win = (0, import_react34.useMemo)(
2445
2459
  () => virtual ? (0, import_spreadsheet5.getSpreadsheetViewWindow)(metrics, viewport, windowOptions) : (0, import_spreadsheet5.fullSpreadsheetViewWindow)(metrics),
2446
2460
  [virtual, metrics, viewport, windowOptions]
2447
2461
  );
2448
- const latest = (0, import_react33.useRef)({ metrics, viewport, virtual, windowOptions });
2462
+ const latest = (0, import_react34.useRef)({ metrics, viewport, virtual, windowOptions });
2449
2463
  latest.current = { metrics, viewport, virtual, windowOptions };
2450
- const readViewport = (0, import_react33.useCallback)(() => {
2464
+ const readViewport = (0, import_react34.useCallback)(() => {
2451
2465
  const el = scrollRef.current;
2452
2466
  if (!el) return null;
2453
2467
  return { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft, width: el.clientWidth, height: el.clientHeight };
2454
2468
  }, [scrollRef]);
2455
- const updateViewport = (0, import_react33.useCallback)((next) => {
2469
+ const updateViewport = (0, import_react34.useCallback)((next) => {
2456
2470
  setViewport((prev) => {
2457
2471
  const { metrics: m, virtual: v, windowOptions: o } = latest.current;
2458
2472
  if (!v) return prev;
@@ -2460,7 +2474,7 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2460
2474
  return same ? prev : next;
2461
2475
  });
2462
2476
  }, []);
2463
- const onScroll = (0, import_react33.useCallback)(() => {
2477
+ const onScroll = (0, import_react34.useCallback)(() => {
2464
2478
  const next = readViewport();
2465
2479
  if (next) updateViewport(next);
2466
2480
  }, [readViewport, updateViewport]);
@@ -2494,24 +2508,24 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2494
2508
  }
2495
2509
 
2496
2510
  // src/spreadsheet/FormulaHints.tsx
2497
- var import_react34 = require("react");
2511
+ var import_react35 = require("react");
2498
2512
  var import_spreadsheet6 = require("@pixerate/editor/spreadsheet");
2499
2513
  var import_jsx_runtime14 = require("react/jsx-runtime");
2500
2514
  var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2501
- const [caret, setCaret] = (0, import_react34.useState)(null);
2502
- const [focused, setFocused] = (0, import_react34.useState)(false);
2503
- const [selected, setSelected] = (0, import_react34.useState)(0);
2504
- const [dismissed, setDismissed] = (0, import_react34.useState)(false);
2505
- const [position, setPosition] = (0, import_react34.useState)(null);
2506
- const pendingCaret = (0, import_react34.useRef)(null);
2507
- const hints = (0, import_react34.useMemo)(
2515
+ const [caret, setCaret] = (0, import_react35.useState)(null);
2516
+ const [focused, setFocused] = (0, import_react35.useState)(false);
2517
+ const [selected, setSelected] = (0, import_react35.useState)(0);
2518
+ const [dismissed, setDismissed] = (0, import_react35.useState)(false);
2519
+ const [position, setPosition] = (0, import_react35.useState)(null);
2520
+ const pendingCaret = (0, import_react35.useRef)(null);
2521
+ const hints = (0, import_react35.useMemo)(
2508
2522
  () => (0, import_spreadsheet6.getFormulaHints)(value, caret ?? value.length, { limit, names }),
2509
2523
  [value, caret, limit, names]
2510
2524
  );
2511
2525
  const suggestions = dismissed ? [] : hints.suggestions;
2512
2526
  const selectedIndex = Math.max(0, Math.min(selected, suggestions.length - 1));
2513
2527
  const visible = focused && value.trimStart().startsWith("=") && (suggestions.length > 0 || !!hints.activeCall);
2514
- const latest = (0, import_react34.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2528
+ const latest = (0, import_react35.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2515
2529
  latest.current = { suggestions, selected: selectedIndex, value, caret, onAccept };
2516
2530
  const accept = (index) => {
2517
2531
  const { suggestions: list, value: current, caret: at, onAccept: commit } = latest.current;
@@ -2521,7 +2535,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2521
2535
  pendingCaret.current = next.caret;
2522
2536
  commit(next.value);
2523
2537
  };
2524
- (0, import_react34.useEffect)(() => {
2538
+ (0, import_react35.useEffect)(() => {
2525
2539
  const input = inputRef.current;
2526
2540
  if (!input) return;
2527
2541
  const syncCaret = () => setCaret(input.selectionStart ?? input.value.length);
@@ -2571,7 +2585,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2571
2585
  input.removeEventListener("keydown", onKeyDown);
2572
2586
  };
2573
2587
  }, [inputRef]);
2574
- (0, import_react34.useLayoutEffect)(() => {
2588
+ (0, import_react35.useLayoutEffect)(() => {
2575
2589
  const input = inputRef.current;
2576
2590
  const at = pendingCaret.current;
2577
2591
  if (!input || at === null || input.value !== value) return;
@@ -2580,7 +2594,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2580
2594
  setCaret(at);
2581
2595
  setSelected(0);
2582
2596
  }, [value, inputRef]);
2583
- (0, import_react34.useLayoutEffect)(() => {
2597
+ (0, import_react35.useLayoutEffect)(() => {
2584
2598
  const input = inputRef.current;
2585
2599
  if (!visible || !input) return;
2586
2600
  const rect = input.getBoundingClientRect();
@@ -2644,16 +2658,16 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2644
2658
  };
2645
2659
 
2646
2660
  // src/spreadsheet/SheetTabs.tsx
2647
- var import_react35 = require("react");
2661
+ var import_react36 = require("react");
2648
2662
  var import_spreadsheet7 = require("@pixerate/editor/spreadsheet");
2649
2663
  var import_jsx_runtime15 = require("react/jsx-runtime");
2650
2664
  var SheetTabs = ({ state, readOnly = false, className = "" }) => {
2651
2665
  const { controller, sheets } = state;
2652
- const [renaming, setRenaming] = (0, import_react35.useState)(null);
2653
- const [error, setError] = (0, import_react35.useState)(null);
2654
- const [menu, setMenu] = (0, import_react35.useState)(null);
2655
- const dragFrom = (0, import_react35.useRef)(null);
2656
- const [dropTarget, setDropTarget] = (0, import_react35.useState)(null);
2666
+ const [renaming, setRenaming] = (0, import_react36.useState)(null);
2667
+ const [error, setError] = (0, import_react36.useState)(null);
2668
+ const [menu, setMenu] = (0, import_react36.useState)(null);
2669
+ const dragFrom = (0, import_react36.useRef)(null);
2670
+ const [dropTarget, setDropTarget] = (0, import_react36.useState)(null);
2657
2671
  const commitRename = (cancelOnError) => {
2658
2672
  if (!renaming) return;
2659
2673
  const sheet = sheets.find((s) => s.id === renaming.id);
@@ -2858,7 +2872,7 @@ var SpreadsheetEditor = ({
2858
2872
  }) => {
2859
2873
  const defaultState = useSpreadsheetEditor();
2860
2874
  const state = externalState || defaultState;
2861
- const gridRef = (0, import_react36.useRef)(null);
2875
+ const gridRef = (0, import_react37.useRef)(null);
2862
2876
  const ambientPlayback = useAgentPlayback();
2863
2877
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
2864
2878
  const agentPresence = usePlaybackSurface(playing, playbackId, {
@@ -2898,20 +2912,20 @@ var SpreadsheetEditor = ({
2898
2912
  },
2899
2913
  reveal: () => onPlaybackReveal?.()
2900
2914
  });
2901
- const scrollRef = (0, import_react36.useRef)(null);
2902
- const formulaBarRef = (0, import_react36.useRef)(null);
2903
- const cellInputRef = (0, import_react36.useRef)(null);
2904
- const [resizingColId, setResizingColId] = (0, import_react36.useState)(null);
2905
- const [hoveredColId, setHoveredColId] = (0, import_react36.useState)(null);
2906
- const [resizeStartX, setResizeStartX] = (0, import_react36.useState)(0);
2907
- const [resizeStartWidth, setResizeStartWidth] = (0, import_react36.useState)(0);
2915
+ const scrollRef = (0, import_react37.useRef)(null);
2916
+ const formulaBarRef = (0, import_react37.useRef)(null);
2917
+ const cellInputRef = (0, import_react37.useRef)(null);
2918
+ const [resizingColId, setResizingColId] = (0, import_react37.useState)(null);
2919
+ const [hoveredColId, setHoveredColId] = (0, import_react37.useState)(null);
2920
+ const [resizeStartX, setResizeStartX] = (0, import_react37.useState)(0);
2921
+ const [resizeStartWidth, setResizeStartWidth] = (0, import_react37.useState)(0);
2908
2922
  const view = state.viewModel;
2909
2923
  const { window: viewWindow, onScroll: handleGridScroll } = useSpreadsheetViewport(scrollRef, view, {
2910
2924
  virtualize,
2911
2925
  merges: state.document.table?.merges,
2912
2926
  activeCell: state.activeCell
2913
2927
  });
2914
- const columnSlots = (0, import_react36.useMemo)(() => {
2928
+ const columnSlots = (0, import_react37.useMemo)(() => {
2915
2929
  const col = (viewCol) => ({ kind: "col", viewCol });
2916
2930
  if (!viewWindow.virtual) return view.columns.map(col);
2917
2931
  const slots = view.columns.slice(0, viewWindow.frozenColumns).map(col);
@@ -2920,11 +2934,11 @@ var SpreadsheetEditor = ({
2920
2934
  if (viewWindow.rightSpace > 0) slots.push({ kind: "space", key: "space:right", width: viewWindow.rightSpace });
2921
2935
  return slots;
2922
2936
  }, [view, viewWindow]);
2923
- const renderedColumns = (0, import_react36.useMemo)(
2937
+ const renderedColumns = (0, import_react37.useMemo)(
2924
2938
  () => columnSlots.flatMap((slot) => slot.kind === "col" ? [slot.viewCol] : []),
2925
2939
  [columnSlots]
2926
2940
  );
2927
- const rowSlots = (0, import_react36.useMemo)(() => {
2941
+ const rowSlots = (0, import_react37.useMemo)(() => {
2928
2942
  const row = (viewRow) => ({ kind: "row", viewRow });
2929
2943
  if (!viewWindow.virtual) return view.rows.map(row);
2930
2944
  const slots = view.rows.slice(0, viewWindow.frozenRows).map(row);
@@ -2935,16 +2949,16 @@ var SpreadsheetEditor = ({
2935
2949
  }, [view, viewWindow]);
2936
2950
  const { copyShortcutFallback } = useSpreadsheetClipboard(gridRef, state, readOnly);
2937
2951
  const { fillTarget, startFill, extendFill } = useFillHandle(state);
2938
- const [menu, setMenu] = (0, import_react36.useState)(null);
2939
- const [panel, setPanel] = (0, import_react36.useState)(null);
2940
- const [listMenu, setListMenu] = (0, import_react36.useState)(null);
2952
+ const [menu, setMenu] = (0, import_react37.useState)(null);
2953
+ const [panel, setPanel] = (0, import_react37.useState)(null);
2954
+ const [listMenu, setListMenu] = (0, import_react37.useState)(null);
2941
2955
  const overlay = state.conditionalFormatOverlay;
2942
2956
  const filter = state.document.table?.filter;
2943
- const filteredColIds = (0, import_react36.useMemo)(
2957
+ const filteredColIds = (0, import_react37.useMemo)(
2944
2958
  () => new Set(filter?.enabled ? filter.rules.map((r) => r.colId) : []),
2945
2959
  [filter]
2946
2960
  );
2947
- const handleCellContextMenu = (0, import_react36.useCallback)((rIdx, cIdx, e) => {
2961
+ const handleCellContextMenu = (0, import_react37.useCallback)((rIdx, cIdx, e) => {
2948
2962
  if (readOnly) return;
2949
2963
  e.preventDefault();
2950
2964
  if (state.editingCell) state.commitEditing();
@@ -2953,33 +2967,33 @@ var SpreadsheetEditor = ({
2953
2967
  }
2954
2968
  setMenu({ x: e.clientX, y: e.clientY, items: (0, import_spreadsheet8.getSpreadsheetMenuItems)(state.controller, { row: rIdx, col: cIdx }) });
2955
2969
  }, [readOnly, state]);
2956
- const nameSuggestions = (0, import_react36.useMemo)(
2970
+ const nameSuggestions = (0, import_react37.useMemo)(
2957
2971
  () => state.controller.getNameSuggestions(),
2958
2972
  // eslint-disable-next-line react-hooks/exhaustive-deps
2959
2973
  [state.controller, state.document]
2960
2974
  );
2961
- const activeRawValue = (0, import_react36.useMemo)(() => {
2975
+ const activeRawValue = (0, import_react37.useMemo)(() => {
2962
2976
  if (!state.activeCell) return "";
2963
2977
  const row = state.document.rows[state.activeCell.row];
2964
2978
  const col = state.document.columns[state.activeCell.col];
2965
2979
  if (!row || !col) return "";
2966
2980
  return state.getCell(row.id, col.id).raw;
2967
2981
  }, [state.activeCell, state.document]);
2968
- const activeSpill = (0, import_react36.useMemo)(
2982
+ const activeSpill = (0, import_react37.useMemo)(
2969
2983
  () => state.activeCell ? state.controller.getSpillAt(state.activeCell.row, state.activeCell.col) : null,
2970
2984
  // eslint-disable-next-line react-hooks/exhaustive-deps
2971
2985
  [state.controller, state.activeCell, state.document]
2972
2986
  );
2973
2987
  const spillFormula = activeSpill && !activeRawValue && activeSpill.key !== coordKey(state.activeCell) ? activeSpill.formula : "";
2974
- const coordLabel = (0, import_react36.useMemo)(() => {
2988
+ const coordLabel = (0, import_react37.useMemo)(() => {
2975
2989
  if (!state.activeCell) return "--";
2976
2990
  const colName = (0, import_spreadsheet8.indexToColName)(state.activeCell.col);
2977
2991
  return `${colName}${state.activeCell.row + 1}`;
2978
2992
  }, [state.activeCell]);
2979
- const [formulaDraft, setFormulaDraft] = (0, import_react36.useState)(null);
2993
+ const [formulaDraft, setFormulaDraft] = (0, import_react37.useState)(null);
2980
2994
  const activeColumn = state.activeCell ? state.document.columns[state.activeCell.col] : void 0;
2981
2995
  const formulaBarReadOnly = readOnly || !state.activeCell || !!activeColumn?.readOnly;
2982
- (0, import_react36.useEffect)(() => {
2996
+ (0, import_react37.useEffect)(() => {
2983
2997
  setFormulaDraft(null);
2984
2998
  }, [state.activeCell?.row, state.activeCell?.col]);
2985
2999
  const commitFormulaBar = () => {
@@ -2995,19 +3009,19 @@ var SpreadsheetEditor = ({
2995
3009
  }
2996
3010
  setFormulaDraft(null);
2997
3011
  };
2998
- const handleCellClick = (0, import_react36.useCallback)((rIdx, cIdx, e) => {
3012
+ const handleCellClick = (0, import_react37.useCallback)((rIdx, cIdx, e) => {
2999
3013
  if (state.editingCell && (state.editingCell.row !== rIdx || state.editingCell.col !== cIdx)) {
3000
3014
  state.commitEditing();
3001
3015
  }
3002
3016
  state.selectCell(rIdx, cIdx, e.shiftKey);
3003
3017
  }, [state]);
3004
- const handleCellDblClick = (0, import_react36.useCallback)((rIdx, cIdx) => {
3018
+ const handleCellDblClick = (0, import_react37.useCallback)((rIdx, cIdx) => {
3005
3019
  if (readOnly) return;
3006
3020
  const col = state.document.columns[cIdx];
3007
3021
  if (col?.readOnly) return;
3008
3022
  state.startEditing(rIdx, cIdx);
3009
3023
  }, [readOnly, state]);
3010
- const handleKeyDown = (0, import_react36.useCallback)((e) => {
3024
+ const handleKeyDown = (0, import_react37.useCallback)((e) => {
3011
3025
  if (state.editingCell) {
3012
3026
  if (e.key === "Enter") {
3013
3027
  e.preventDefault();
@@ -3079,12 +3093,12 @@ var SpreadsheetEditor = ({
3079
3093
  }
3080
3094
  }
3081
3095
  }, [readOnly, state, copyShortcutFallback]);
3082
- const activeListValues = (0, import_react36.useMemo)(
3096
+ const activeListValues = (0, import_react37.useMemo)(
3083
3097
  () => state.activeCell && !readOnly ? state.controller.getValidationListValues(state.activeCell.row, state.activeCell.col) : null,
3084
3098
  // eslint-disable-next-line react-hooks/exhaustive-deps
3085
3099
  [state.controller, state.activeCell, state.document, readOnly]
3086
3100
  );
3087
- const activeRule = (0, import_react36.useMemo)(
3101
+ const activeRule = (0, import_react37.useMemo)(
3088
3102
  () => state.activeCell ? state.controller.getDataValidationAt(state.activeCell.row, state.activeCell.col) : void 0,
3089
3103
  // eslint-disable-next-line react-hooks/exhaustive-deps
3090
3104
  [state.controller, state.activeCell, state.document]
@@ -3098,7 +3112,7 @@ var SpreadsheetEditor = ({
3098
3112
  const rect = td?.getBoundingClientRect();
3099
3113
  setListMenu({ x: rect ? rect.left : 0, y: rect ? rect.bottom : 0, row, col, values });
3100
3114
  }
3101
- (0, import_react36.useEffect)(() => {
3115
+ (0, import_react37.useEffect)(() => {
3102
3116
  if (!listMenu) return;
3103
3117
  const close = (e) => {
3104
3118
  if (!e.target?.closest?.('[aria-label="Allowed values"], .spreadsheet-list-arrow')) setListMenu(null);
@@ -3121,11 +3135,11 @@ var SpreadsheetEditor = ({
3121
3135
  else gridRef.current?.focus();
3122
3136
  });
3123
3137
  };
3124
- const stateRef = (0, import_react36.useRef)(state);
3138
+ const stateRef = (0, import_react37.useRef)(state);
3125
3139
  stateRef.current = state;
3126
- const onColumnResizeRef = (0, import_react36.useRef)(onColumnResize);
3140
+ const onColumnResizeRef = (0, import_react37.useRef)(onColumnResize);
3127
3141
  onColumnResizeRef.current = onColumnResize;
3128
- (0, import_react36.useEffect)(() => {
3142
+ (0, import_react37.useEffect)(() => {
3129
3143
  if (!resizingColId) return;
3130
3144
  if (typeof document !== "undefined") {
3131
3145
  document.body.style.cursor = "col-resize";
@@ -3176,7 +3190,7 @@ var SpreadsheetEditor = ({
3176
3190
  window.removeEventListener("mouseup", handleMouseUp);
3177
3191
  };
3178
3192
  }, [resizingColId, resizeStartX, resizeStartWidth]);
3179
- const measureElementContentWidth = (0, import_react36.useCallback)((el, container) => {
3193
+ const measureElementContentWidth = (0, import_react37.useCallback)((el, container) => {
3180
3194
  if (typeof document === "undefined") return 0;
3181
3195
  let maxW = el.scrollWidth || 0;
3182
3196
  const firstChild = el.firstElementChild;
@@ -3224,7 +3238,7 @@ var SpreadsheetEditor = ({
3224
3238
  }
3225
3239
  return maxW;
3226
3240
  }, []);
3227
- const autoFitColumn = (0, import_react36.useCallback)((colId, colIndex) => {
3241
+ const autoFitColumn = (0, import_react37.useCallback)((colId, colIndex) => {
3228
3242
  const col = state.document.columns.find((c) => c.id === colId);
3229
3243
  if (!col) return;
3230
3244
  let calculatedWidth = 0;
@@ -3260,12 +3274,12 @@ var SpreadsheetEditor = ({
3260
3274
  onColumnResize(updatedCol.id, updatedCol.width || 130);
3261
3275
  }
3262
3276
  }, [state, measureElementContentWidth, onColumnResize]);
3263
- const handleResizeDblClick = (0, import_react36.useCallback)((colId, colIndex, e) => {
3277
+ const handleResizeDblClick = (0, import_react37.useCallback)((colId, colIndex, e) => {
3264
3278
  e.preventDefault();
3265
3279
  e.stopPropagation();
3266
3280
  autoFitColumn(colId, colIndex);
3267
3281
  }, [autoFitColumn]);
3268
- const handleHeaderDblClick = (0, import_react36.useCallback)((colId, colIndex, e) => {
3282
+ const handleHeaderDblClick = (0, import_react37.useCallback)((colId, colIndex, e) => {
3269
3283
  const target = e.currentTarget;
3270
3284
  if (target) {
3271
3285
  const rect = target.getBoundingClientRect();
@@ -3657,19 +3671,19 @@ var SpreadsheetEditor = ({
3657
3671
  };
3658
3672
 
3659
3673
  // src/spreadsheet/NameManager.tsx
3660
- var import_react37 = require("react");
3674
+ var import_react38 = require("react");
3661
3675
  var import_spreadsheet9 = require("@pixerate/editor/spreadsheet");
3662
3676
  var import_jsx_runtime17 = require("react/jsx-runtime");
3663
3677
  var EMPTY_DRAFT = { original: null, name: "", refersTo: "=", scope: "", comment: "" };
3664
3678
  var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3665
3679
  const { controller, sheets } = state;
3666
- const rows = (0, import_react37.useMemo)(
3680
+ const rows = (0, import_react38.useMemo)(
3667
3681
  () => (0, import_spreadsheet9.getNameManagerRows)(controller),
3668
3682
  // eslint-disable-next-line react-hooks/exhaustive-deps
3669
3683
  [controller, state.document, state.names]
3670
3684
  );
3671
- const [draft, setDraft] = (0, import_react37.useState)(EMPTY_DRAFT);
3672
- const [error, setError] = (0, import_react37.useState)(null);
3685
+ const [draft, setDraft] = (0, import_react38.useState)(EMPTY_DRAFT);
3686
+ const [error, setError] = (0, import_react38.useState)(null);
3673
3687
  const edit = (row) => {
3674
3688
  setError(null);
3675
3689
  setDraft({
@@ -3812,7 +3826,7 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3812
3826
  };
3813
3827
 
3814
3828
  // src/slots.tsx
3815
- var import_react38 = require("react");
3829
+ var import_react39 = require("react");
3816
3830
  var import_jsx_runtime18 = require("react/jsx-runtime");
3817
3831
  var defaultSlots = {
3818
3832
  Button: (props) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
@@ -3834,119 +3848,119 @@ var defaultSlots = {
3834
3848
  props.onClose && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: props.onClose, className: "opacity-70 hover:opacity-100", children: "\xD7" })
3835
3849
  ] })
3836
3850
  };
3837
- var EditorSlotsContext = (0, import_react38.createContext)(defaultSlots);
3851
+ var EditorSlotsContext = (0, import_react39.createContext)(defaultSlots);
3838
3852
  function EditorSlotsProvider({ slots, children }) {
3839
- const mergedSlots = (0, import_react38.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3853
+ const mergedSlots = (0, import_react39.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3840
3854
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EditorSlotsContext.Provider, { value: mergedSlots, children });
3841
3855
  }
3842
3856
  function useEditorSlots() {
3843
- return (0, import_react38.useContext)(EditorSlotsContext);
3857
+ return (0, import_react39.useContext)(EditorSlotsContext);
3844
3858
  }
3845
3859
 
3846
3860
  // src/image-editor/useImageEditor.ts
3847
- var import_react39 = require("react");
3861
+ var import_react40 = require("react");
3848
3862
  var import_image_editor = require("@pixerate/editor/image-editor");
3849
3863
  function useImageEditor(options = {}) {
3850
- const controllerRef = (0, import_react39.useRef)(null);
3864
+ const controllerRef = (0, import_react40.useRef)(null);
3851
3865
  if (!controllerRef.current) {
3852
3866
  controllerRef.current = new import_image_editor.ImageEditorController(options);
3853
3867
  }
3854
3868
  const controller = controllerRef.current;
3855
- const [state, setState] = (0, import_react39.useState)(() => controller.getState());
3856
- const [historyTicks, setHistoryTicks] = (0, import_react39.useState)(0);
3857
- const [histogram, setHistogram] = (0, import_react39.useState)(() => controller.getHistogram());
3858
- (0, import_react39.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
3859
- (0, import_react39.useEffect)(() => {
3869
+ const [state, setState] = (0, import_react40.useState)(() => controller.getState());
3870
+ const [historyTicks, setHistoryTicks] = (0, import_react40.useState)(0);
3871
+ const [histogram, setHistogram] = (0, import_react40.useState)(() => controller.getHistogram());
3872
+ (0, import_react40.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
3873
+ (0, import_react40.useEffect)(() => {
3860
3874
  const unsub = controller.subscribe((next) => {
3861
3875
  setState(next);
3862
3876
  setHistoryTicks((t) => t + 1);
3863
3877
  });
3864
3878
  return unsub;
3865
3879
  }, [controller]);
3866
- const loadedImageRef = (0, import_react39.useRef)(options.image);
3867
- (0, import_react39.useEffect)(() => {
3880
+ const loadedImageRef = (0, import_react40.useRef)(options.image);
3881
+ (0, import_react40.useEffect)(() => {
3868
3882
  if (options.image === loadedImageRef.current) return;
3869
3883
  loadedImageRef.current = options.image;
3870
3884
  if (options.image) {
3871
3885
  controller.loadImage(options.image);
3872
3886
  }
3873
3887
  }, [options.image, controller]);
3874
- const setTool = (0, import_react39.useCallback)((tool) => controller.setTool(tool), [controller]);
3875
- const setCrop = (0, import_react39.useCallback)(
3888
+ const setTool = (0, import_react40.useCallback)((tool) => controller.setTool(tool), [controller]);
3889
+ const setCrop = (0, import_react40.useCallback)(
3876
3890
  (crop, addToHistory = true) => controller.setCrop(crop, addToHistory),
3877
3891
  [controller]
3878
3892
  );
3879
- const applyCropPreset = (0, import_react39.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
3880
- const resetCrop = (0, import_react39.useCallback)(() => controller.resetCrop(), [controller]);
3881
- const rotate = (0, import_react39.useCallback)((deg) => controller.rotate(deg), [controller]);
3882
- const setRotation = (0, import_react39.useCallback)((deg) => controller.setRotation(deg), [controller]);
3883
- const flipHorizontal = (0, import_react39.useCallback)(() => controller.flipHorizontal(), [controller]);
3884
- const flipVertical = (0, import_react39.useCallback)(() => controller.flipVertical(), [controller]);
3885
- const setAdjustments = (0, import_react39.useCallback)(
3893
+ const applyCropPreset = (0, import_react40.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
3894
+ const resetCrop = (0, import_react40.useCallback)(() => controller.resetCrop(), [controller]);
3895
+ const rotate = (0, import_react40.useCallback)((deg) => controller.rotate(deg), [controller]);
3896
+ const setRotation = (0, import_react40.useCallback)((deg) => controller.setRotation(deg), [controller]);
3897
+ const flipHorizontal = (0, import_react40.useCallback)(() => controller.flipHorizontal(), [controller]);
3898
+ const flipVertical = (0, import_react40.useCallback)(() => controller.flipVertical(), [controller]);
3899
+ const setAdjustments = (0, import_react40.useCallback)(
3886
3900
  (partial, commitToHistory = true) => controller.setAdjustments(partial, commitToHistory),
3887
3901
  [controller]
3888
3902
  );
3889
- const resetAdjustments = (0, import_react39.useCallback)(() => controller.resetAdjustments(), [controller]);
3890
- const upgradeProcess = (0, import_react39.useCallback)(() => controller.upgradeProcess(), [controller]);
3891
- const addAdjustmentLayer = (0, import_react39.useCallback)(
3903
+ const resetAdjustments = (0, import_react40.useCallback)(() => controller.resetAdjustments(), [controller]);
3904
+ const upgradeProcess = (0, import_react40.useCallback)(() => controller.upgradeProcess(), [controller]);
3905
+ const addAdjustmentLayer = (0, import_react40.useCallback)(
3892
3906
  (init, index) => controller.addAdjustmentLayer(init, index),
3893
3907
  [controller]
3894
3908
  );
3895
- const updateAdjustmentLayer = (0, import_react39.useCallback)(
3909
+ const updateAdjustmentLayer = (0, import_react40.useCallback)(
3896
3910
  (id, update, commitToHistory = true) => controller.updateAdjustmentLayer(id, update, commitToHistory),
3897
3911
  [controller]
3898
3912
  );
3899
- const removeAdjustmentLayer = (0, import_react39.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
3900
- const moveAdjustmentLayer = (0, import_react39.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
3901
- const toggleAdjustmentLayer = (0, import_react39.useCallback)(
3913
+ const removeAdjustmentLayer = (0, import_react40.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
3914
+ const moveAdjustmentLayer = (0, import_react40.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
3915
+ const toggleAdjustmentLayer = (0, import_react40.useCallback)(
3902
3916
  (id, enabled) => controller.toggleAdjustmentLayer(id, enabled),
3903
3917
  [controller]
3904
3918
  );
3905
- const setDepthMask = (0, import_react39.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
3906
- const resetDepthMask = (0, import_react39.useCallback)(() => controller.resetDepthMask(), [controller]);
3907
- const addAnnotation = (0, import_react39.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
3908
- const updateAnnotation = (0, import_react39.useCallback)(
3919
+ const setDepthMask = (0, import_react40.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
3920
+ const resetDepthMask = (0, import_react40.useCallback)(() => controller.resetDepthMask(), [controller]);
3921
+ const addAnnotation = (0, import_react40.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
3922
+ const updateAnnotation = (0, import_react40.useCallback)(
3909
3923
  (id, partial, commitToHistory = true) => controller.updateAnnotation(id, partial, commitToHistory),
3910
3924
  [controller]
3911
3925
  );
3912
- const removeAnnotation = (0, import_react39.useCallback)((id) => controller.removeAnnotation(id), [controller]);
3913
- const clearAnnotations = (0, import_react39.useCallback)(() => controller.clearAnnotations(), [controller]);
3914
- const selectAnnotation = (0, import_react39.useCallback)((id) => controller.selectAnnotation(id), [controller]);
3915
- const undo = (0, import_react39.useCallback)(() => controller.undo(), [controller]);
3916
- const redo = (0, import_react39.useCallback)(() => controller.redo(), [controller]);
3917
- const reset = (0, import_react39.useCallback)(() => controller.reset(), [controller]);
3918
- const zoomIn = (0, import_react39.useCallback)((factor) => controller.zoomIn(factor), [controller]);
3919
- const zoomOut = (0, import_react39.useCallback)((factor) => controller.zoomOut(factor), [controller]);
3920
- const resetZoom = (0, import_react39.useCallback)(() => controller.resetZoom(), [controller]);
3921
- const setZoom = (0, import_react39.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
3922
- const setPan = (0, import_react39.useCallback)((pan) => controller.setPan(pan), [controller]);
3923
- const setComparing = (0, import_react39.useCallback)((comp) => controller.setComparing(comp), [controller]);
3924
- const loadImage = (0, import_react39.useCallback)((src) => controller.loadImage(src), [controller]);
3925
- const toDataURL = (0, import_react39.useCallback)((opts) => controller.toDataURL(opts), [controller]);
3926
- const toBlob = (0, import_react39.useCallback)((opts) => controller.toBlob(opts), [controller]);
3927
- const toJSON = (0, import_react39.useCallback)(() => controller.toJSON(), [controller]);
3928
- const loadJSON = (0, import_react39.useCallback)((data) => controller.loadJSON(data), [controller]);
3929
- const renderMask = (0, import_react39.useCallback)(
3926
+ const removeAnnotation = (0, import_react40.useCallback)((id) => controller.removeAnnotation(id), [controller]);
3927
+ const clearAnnotations = (0, import_react40.useCallback)(() => controller.clearAnnotations(), [controller]);
3928
+ const selectAnnotation = (0, import_react40.useCallback)((id) => controller.selectAnnotation(id), [controller]);
3929
+ const undo = (0, import_react40.useCallback)(() => controller.undo(), [controller]);
3930
+ const redo = (0, import_react40.useCallback)(() => controller.redo(), [controller]);
3931
+ const reset = (0, import_react40.useCallback)(() => controller.reset(), [controller]);
3932
+ const zoomIn = (0, import_react40.useCallback)((factor) => controller.zoomIn(factor), [controller]);
3933
+ const zoomOut = (0, import_react40.useCallback)((factor) => controller.zoomOut(factor), [controller]);
3934
+ const resetZoom = (0, import_react40.useCallback)(() => controller.resetZoom(), [controller]);
3935
+ const setZoom = (0, import_react40.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
3936
+ const setPan = (0, import_react40.useCallback)((pan) => controller.setPan(pan), [controller]);
3937
+ const setComparing = (0, import_react40.useCallback)((comp) => controller.setComparing(comp), [controller]);
3938
+ const loadImage = (0, import_react40.useCallback)((src) => controller.loadImage(src), [controller]);
3939
+ const toDataURL = (0, import_react40.useCallback)((opts) => controller.toDataURL(opts), [controller]);
3940
+ const toBlob = (0, import_react40.useCallback)((opts) => controller.toBlob(opts), [controller]);
3941
+ const toJSON = (0, import_react40.useCallback)(() => controller.toJSON(), [controller]);
3942
+ const loadJSON = (0, import_react40.useCallback)((data) => controller.loadJSON(data), [controller]);
3943
+ const renderMask = (0, import_react40.useCallback)(
3930
3944
  (opts) => controller.renderMask(opts),
3931
3945
  [controller]
3932
3946
  );
3933
- const toMaskDataURL = (0, import_react39.useCallback)(
3947
+ const toMaskDataURL = (0, import_react40.useCallback)(
3934
3948
  (opts) => controller.toMaskDataURL(opts),
3935
3949
  [controller]
3936
3950
  );
3937
- const toSourceDataURL = (0, import_react39.useCallback)(
3951
+ const toSourceDataURL = (0, import_react40.useCallback)(
3938
3952
  (opts) => controller.toSourceDataURL(opts),
3939
3953
  [controller]
3940
3954
  );
3941
- const applyInpaintedImage = (0, import_react39.useCallback)(
3955
+ const applyInpaintedImage = (0, import_react40.useCallback)(
3942
3956
  (newDataUrl, options2) => controller.applyInpaintedImage(newDataUrl, options2),
3943
3957
  [controller]
3944
3958
  );
3945
- const applyBackgroundRemovedImage = (0, import_react39.useCallback)(
3959
+ const applyBackgroundRemovedImage = (0, import_react40.useCallback)(
3946
3960
  (newDataUrl, options2) => controller.applyBackgroundRemovedImage(newDataUrl, options2),
3947
3961
  [controller]
3948
3962
  );
3949
- return (0, import_react39.useMemo)(
3963
+ return (0, import_react40.useMemo)(
3950
3964
  () => ({
3951
3965
  controller,
3952
3966
  state,
@@ -4002,18 +4016,18 @@ function useImageEditor(options = {}) {
4002
4016
  }
4003
4017
  function useImageEffectsTools(registry, controller, options = {}) {
4004
4018
  const { id, namespace, readOnly, playbackSurface } = options;
4005
- (0, import_react39.useEffect)(() => {
4019
+ (0, import_react40.useEffect)(() => {
4006
4020
  if (!registry) return;
4007
4021
  return registry.register((0, import_image_editor.createImageEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
4008
4022
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
4009
4023
  }
4010
4024
 
4011
4025
  // src/image-editor/ImageEditor.tsx
4012
- var import_react63 = __toESM(require("react"), 1);
4026
+ var import_react64 = __toESM(require("react"), 1);
4013
4027
  var import_image_editor19 = require("@pixerate/editor/image-editor");
4014
4028
 
4015
4029
  // src/image-editor/ImageEditorCanvas.tsx
4016
- var import_react40 = require("react");
4030
+ var import_react41 = require("react");
4017
4031
  var import_image_editor2 = require("@pixerate/editor/image-editor");
4018
4032
  var import_tools4 = require("@pixerate/editor/tools");
4019
4033
  var import_jsx_runtime19 = require("react/jsx-runtime");
@@ -4042,18 +4056,18 @@ var ImageEditorCanvas = ({
4042
4056
  style
4043
4057
  }) => {
4044
4058
  const { state, controller } = editor;
4045
- const canvasRef = (0, import_react40.useRef)(null);
4046
- const containerRef = (0, import_react40.useRef)(null);
4047
- const rootRef = (0, import_react40.useRef)(null);
4048
- const viewRef = (0, import_react40.useRef)({ width: 0, height: 0 });
4049
- const modeRef = (0, import_react40.useRef)(mode);
4059
+ const canvasRef = (0, import_react41.useRef)(null);
4060
+ const containerRef = (0, import_react41.useRef)(null);
4061
+ const rootRef = (0, import_react41.useRef)(null);
4062
+ const viewRef = (0, import_react41.useRef)({ width: 0, height: 0 });
4063
+ const modeRef = (0, import_react41.useRef)(mode);
4050
4064
  modeRef.current = mode;
4051
- const latest = (0, import_react40.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
4065
+ const latest = (0, import_react41.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
4052
4066
  latest.current = { onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal };
4053
4067
  const report = (source, message) => latest.current.onError?.(source, message);
4054
4068
  const ambientPlayback = useAgentPlayback();
4055
4069
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
4056
- const locateLayer = (0, import_react40.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
4070
+ const locateLayer = (0, import_react41.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
4057
4071
  const docToRoot = (p) => {
4058
4072
  const canvas = canvasRef.current;
4059
4073
  const root = rootRef.current;
@@ -4110,22 +4124,22 @@ var ImageEditorCanvas = ({
4110
4124
  fromViewport: clientToDoc,
4111
4125
  reveal: () => latest.current.onPlaybackReveal?.()
4112
4126
  });
4113
- const selectionOptionsRef = (0, import_react40.useRef)(selectionOptions);
4127
+ const selectionOptionsRef = (0, import_react41.useRef)(selectionOptions);
4114
4128
  selectionOptionsRef.current = selectionOptions;
4115
- const selectionGestureRef = (0, import_react40.useRef)(null);
4129
+ const selectionGestureRef = (0, import_react41.useRef)(null);
4116
4130
  if (!selectionGestureRef.current || selectionGestureRef.current.controller !== controller) {
4117
4131
  selectionGestureRef.current = new import_image_editor2.SelectionGesture(controller, () => selectionOptionsRef.current);
4118
4132
  }
4119
- const selectionDraftRef = (0, import_react40.useRef)(null);
4120
- const paintGestureRef = (0, import_react40.useRef)(null);
4121
- const paintControllerRef = (0, import_react40.useRef)(controller);
4133
+ const selectionDraftRef = (0, import_react41.useRef)(null);
4134
+ const paintGestureRef = (0, import_react41.useRef)(null);
4135
+ const paintControllerRef = (0, import_react41.useRef)(controller);
4122
4136
  if (!paintGestureRef.current || paintControllerRef.current !== controller) {
4123
4137
  paintGestureRef.current = new import_image_editor2.PaintGesture(controller);
4124
4138
  paintControllerRef.current = controller;
4125
4139
  }
4126
- const brushCursorRef = (0, import_react40.useRef)(null);
4127
- const ownTransformRef = (0, import_react40.useRef)(null);
4128
- const ownTransformControllerRef = (0, import_react40.useRef)(controller);
4140
+ const brushCursorRef = (0, import_react41.useRef)(null);
4141
+ const ownTransformRef = (0, import_react41.useRef)(null);
4142
+ const ownTransformControllerRef = (0, import_react41.useRef)(controller);
4129
4143
  if (!hostTransformTool && (!ownTransformRef.current || ownTransformControllerRef.current !== controller)) {
4130
4144
  ownTransformRef.current?.cancel();
4131
4145
  ownTransformRef.current = new import_image_editor2.FreeTransformTool(controller, {
@@ -4134,36 +4148,36 @@ var ImageEditorCanvas = ({
4134
4148
  ownTransformControllerRef.current = controller;
4135
4149
  }
4136
4150
  const transformTool = hostTransformTool ?? ownTransformRef.current;
4137
- const [, setTransformTick] = (0, import_react40.useState)(0);
4138
- const [transformCursor, setTransformCursor] = (0, import_react40.useState)("default");
4139
- (0, import_react40.useEffect)(() => () => ownTransformRef.current?.cancel(), []);
4140
- const shapeOptionsRef = (0, import_react40.useRef)(shapeOptions);
4151
+ const [, setTransformTick] = (0, import_react41.useState)(0);
4152
+ const [transformCursor, setTransformCursor] = (0, import_react41.useState)("default");
4153
+ (0, import_react41.useEffect)(() => () => ownTransformRef.current?.cancel(), []);
4154
+ const shapeOptionsRef = (0, import_react41.useRef)(shapeOptions);
4141
4155
  shapeOptionsRef.current = shapeOptions;
4142
- const typeOptionsRef = (0, import_react40.useRef)(typeOptions);
4156
+ const typeOptionsRef = (0, import_react41.useRef)(typeOptions);
4143
4157
  typeOptionsRef.current = typeOptions;
4144
- const shapeGestureRef = (0, import_react40.useRef)(null);
4145
- const typeToolRef = (0, import_react40.useRef)(null);
4146
- const shapeTypeControllerRef = (0, import_react40.useRef)(controller);
4158
+ const shapeGestureRef = (0, import_react41.useRef)(null);
4159
+ const typeToolRef = (0, import_react41.useRef)(null);
4160
+ const shapeTypeControllerRef = (0, import_react41.useRef)(controller);
4147
4161
  if (!shapeGestureRef.current || !typeToolRef.current || shapeTypeControllerRef.current !== controller) {
4148
4162
  typeToolRef.current?.finish();
4149
4163
  shapeGestureRef.current = new import_image_editor2.ShapeDrawGesture(controller, () => shapeOptionsRef.current);
4150
4164
  typeToolRef.current = new import_image_editor2.TypeToolGesture(controller, () => typeOptionsRef.current);
4151
4165
  shapeTypeControllerRef.current = controller;
4152
4166
  }
4153
- const typeInputRef = (0, import_react40.useRef)(null);
4154
- const [typeSession, setTypeSessionState] = (0, import_react40.useState)(typeToolRef.current.session);
4167
+ const typeInputRef = (0, import_react41.useRef)(null);
4168
+ const [typeSession, setTypeSessionState] = (0, import_react41.useState)(typeToolRef.current.session);
4155
4169
  const setTypeSession = (session) => {
4156
4170
  setTypeSessionState(session);
4157
4171
  latest.current.onTypeSessionChange?.(session);
4158
4172
  };
4159
- const draftAnnotationRef = (0, import_react40.useRef)(null);
4160
- const draftCropRef = (0, import_react40.useRef)(null);
4161
- const cropDragInfoRef = (0, import_react40.useRef)(null);
4162
- const annotationDragInfoRef = (0, import_react40.useRef)(null);
4163
- const isDrawingRef = (0, import_react40.useRef)(false);
4164
- const currentPathRef = (0, import_react40.useRef)([]);
4165
- const dragStartPointRef = (0, import_react40.useRef)(null);
4166
- const renderCanvas = (0, import_react40.useCallback)(
4173
+ const draftAnnotationRef = (0, import_react41.useRef)(null);
4174
+ const draftCropRef = (0, import_react41.useRef)(null);
4175
+ const cropDragInfoRef = (0, import_react41.useRef)(null);
4176
+ const annotationDragInfoRef = (0, import_react41.useRef)(null);
4177
+ const isDrawingRef = (0, import_react41.useRef)(false);
4178
+ const currentPathRef = (0, import_react41.useRef)([]);
4179
+ const dragStartPointRef = (0, import_react41.useRef)(null);
4180
+ const renderCanvas = (0, import_react41.useCallback)(
4167
4181
  async (draftAnnotation, draftCrop) => {
4168
4182
  const canvas = canvasRef.current;
4169
4183
  const container = containerRef.current;
@@ -4188,7 +4202,7 @@ var ImageEditorCanvas = ({
4188
4202
  },
4189
4203
  [controller, mode, fit, transformTool]
4190
4204
  );
4191
- (0, import_react40.useEffect)(() => {
4205
+ (0, import_react41.useEffect)(() => {
4192
4206
  let drafting = false;
4193
4207
  return agentPresence.subscribe(
4194
4208
  (0, import_tools4.trackPresenceDrag)({
@@ -4211,18 +4225,18 @@ var ImageEditorCanvas = ({
4211
4225
  })
4212
4226
  );
4213
4227
  }, [agentPresence, controller, renderCanvas]);
4214
- (0, import_react40.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4228
+ (0, import_react41.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4215
4229
  const finishTyping = () => {
4216
4230
  typeToolRef.current?.finish();
4217
4231
  setTypeSession(null);
4218
4232
  void renderCanvas();
4219
4233
  };
4220
- (0, import_react40.useEffect)(() => {
4234
+ (0, import_react41.useEffect)(() => {
4221
4235
  if (mode === "annotate" && state.activeTool === "type") return;
4222
4236
  if (typeToolRef.current?.session) finishTyping();
4223
4237
  }, [mode, state.activeTool, renderCanvas]);
4224
- const prevTypeSessionProp = (0, import_react40.useRef)(typeSessionProp);
4225
- (0, import_react40.useEffect)(() => {
4238
+ const prevTypeSessionProp = (0, import_react41.useRef)(typeSessionProp);
4239
+ (0, import_react41.useEffect)(() => {
4226
4240
  const was = prevTypeSessionProp.current;
4227
4241
  prevTypeSessionProp.current = typeSessionProp;
4228
4242
  if (was && typeSessionProp === null && typeToolRef.current?.session) finishTyping();
@@ -4249,7 +4263,7 @@ var ImageEditorCanvas = ({
4249
4263
  el.value = "";
4250
4264
  }
4251
4265
  };
4252
- (0, import_react40.useEffect)(() => transformTool.subscribe(() => {
4266
+ (0, import_react41.useEffect)(() => transformTool.subscribe(() => {
4253
4267
  setTransformTick((n) => n + 1);
4254
4268
  void renderCanvas();
4255
4269
  }), [transformTool, renderCanvas]);
@@ -4292,7 +4306,7 @@ var ImageEditorCanvas = ({
4292
4306
  transformTool.up();
4293
4307
  return true;
4294
4308
  };
4295
- (0, import_react40.useEffect)(() => {
4309
+ (0, import_react41.useEffect)(() => {
4296
4310
  if (typeof window === "undefined") return;
4297
4311
  const onKey = (e) => {
4298
4312
  if (transformTool.key(e)) e.preventDefault();
@@ -4300,7 +4314,7 @@ var ImageEditorCanvas = ({
4300
4314
  window.addEventListener("keydown", onKey);
4301
4315
  return () => window.removeEventListener("keydown", onKey);
4302
4316
  }, [transformTool]);
4303
- (0, import_react40.useEffect)(() => {
4317
+ (0, import_react41.useEffect)(() => {
4304
4318
  const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
4305
4319
  const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
4306
4320
  const animId = raf(() => {
@@ -4308,7 +4322,7 @@ var ImageEditorCanvas = ({
4308
4322
  });
4309
4323
  return () => caf(animId);
4310
4324
  }, [renderCanvas, state]);
4311
- (0, import_react40.useEffect)(() => {
4325
+ (0, import_react41.useEffect)(() => {
4312
4326
  const container = containerRef.current;
4313
4327
  if (!container) return;
4314
4328
  const { width, height } = (0, import_image_editor2.measureCanvasViewport)(container);
@@ -4368,7 +4382,7 @@ var ImageEditorCanvas = ({
4368
4382
  if (g.error) report("paint", g.error);
4369
4383
  }
4370
4384
  };
4371
- (0, import_react40.useEffect)(() => {
4385
+ (0, import_react41.useEffect)(() => {
4372
4386
  if (mode !== "paint" || typeof window === "undefined") return;
4373
4387
  const onKey = (e) => {
4374
4388
  if ((0, import_image_editor2.handlePaintShortcut)(controller, e)) e.preventDefault();
@@ -4769,7 +4783,7 @@ var ControlSlider = ({ spec, value, onChange, disabled, label, className }) => {
4769
4783
  };
4770
4784
 
4771
4785
  // src/image-editor/Histogram.tsx
4772
- var import_react41 = require("react");
4786
+ var import_react42 = require("react");
4773
4787
  var import_image_editor4 = require("@pixerate/editor/image-editor");
4774
4788
  var import_jsx_runtime21 = require("react/jsx-runtime");
4775
4789
  var FILL = {
@@ -4781,7 +4795,7 @@ var FILL = {
4781
4795
  var W = 256;
4782
4796
  var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", style }) => {
4783
4797
  const channels = channel === "rgb" ? ["luminance", "red", "green", "blue"] : [channel];
4784
- const paths = (0, import_react41.useMemo)(
4798
+ const paths = (0, import_react42.useMemo)(
4785
4799
  () => histogram && histogram.samples > 0 ? channels.map((c) => ({ c, d: (0, import_image_editor4.histogramPath)(histogram, c, W, height) })) : [],
4786
4800
  // eslint-disable-next-line react-hooks/exhaustive-deps
4787
4801
  [histogram, channel, height]
@@ -4807,24 +4821,24 @@ var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", styl
4807
4821
  );
4808
4822
  };
4809
4823
  function useImageHistogram(controller) {
4810
- const [histogram, setHistogram] = (0, import_react41.useState)(() => controller.getHistogram());
4811
- (0, import_react41.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4824
+ const [histogram, setHistogram] = (0, import_react42.useState)(() => controller.getHistogram());
4825
+ (0, import_react42.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4812
4826
  return histogram;
4813
4827
  }
4814
4828
 
4815
4829
  // src/image-editor/AdjustmentLayersPanel.tsx
4816
- var import_react43 = require("react");
4830
+ var import_react44 = require("react");
4817
4831
  var import_image_editor6 = require("@pixerate/editor/image-editor");
4818
4832
 
4819
4833
  // src/image-editor/CurvesEditor.tsx
4820
- var import_react42 = require("react");
4834
+ var import_react43 = require("react");
4821
4835
  var import_image_editor5 = require("@pixerate/editor/image-editor");
4822
4836
  var import_jsx_runtime22 = require("react/jsx-runtime");
4823
4837
  var BOX = 256;
4824
4838
  var STROKE = { master: "var(--foreground, #e2e8f0)", red: "#ef4444", green: "#22c55e", blue: "#3b82f6" };
4825
4839
  var CurvesEditor = ({ points, onChange, histogram, channel = "master", size = 200, className = "" }) => {
4826
- const svgRef = (0, import_react42.useRef)(null);
4827
- const [drag, setDrag] = (0, import_react42.useState)(null);
4840
+ const svgRef = (0, import_react43.useRef)(null);
4841
+ const [drag, setDrag] = (0, import_react43.useState)(null);
4828
4842
  const toBox = (e) => {
4829
4843
  const rect = svgRef.current?.getBoundingClientRect();
4830
4844
  if (!rect || !rect.width || !rect.height) return { x: 0, y: 0 };
@@ -4944,14 +4958,14 @@ var HueRangeStrip = ({ bounds }) => {
4944
4958
  };
4945
4959
  var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, className = "" }) => {
4946
4960
  const follow = layersProp === void 0;
4947
- const [, setTick] = (0, import_react43.useState)(0);
4948
- (0, import_react43.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
4961
+ const [, setTick] = (0, import_react44.useState)(0);
4962
+ (0, import_react44.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
4949
4963
  const layers = layersProp ?? controller.getAdjustmentLayers();
4950
- const [newKind, setNewKind] = (0, import_react43.useState)("curves");
4951
- const [selectedId, setSelectedId] = (0, import_react43.useState)(null);
4952
- const [channel, setChannel] = (0, import_react43.useState)("master");
4953
- const [range, setRange] = (0, import_react43.useState)(-1);
4954
- const [tone, setTone] = (0, import_react43.useState)("midtones");
4964
+ const [newKind, setNewKind] = (0, import_react44.useState)("curves");
4965
+ const [selectedId, setSelectedId] = (0, import_react44.useState)(null);
4966
+ const [channel, setChannel] = (0, import_react44.useState)("master");
4967
+ const [range, setRange] = (0, import_react44.useState)(-1);
4968
+ const [tone, setTone] = (0, import_react44.useState)("midtones");
4955
4969
  const selected = layers.find((l) => l.id === selectedId) ?? null;
4956
4970
  const topFirst = [...layers].reverse();
4957
4971
  const setParam = (layer, path, value, commit = true) => controller.updateAdjustmentLayer(layer.id, { params: (0, import_image_editor6.setControlPath)(layer.params, path, value) }, commit);
@@ -5190,18 +5204,18 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
5190
5204
  };
5191
5205
 
5192
5206
  // src/image-editor/LayersPanel.tsx
5193
- var import_react45 = require("react");
5207
+ var import_react46 = require("react");
5194
5208
 
5195
5209
  // src/image-editor/LayerEffectsPanel.tsx
5196
- var import_react44 = require("react");
5210
+ var import_react45 = require("react");
5197
5211
  var import_image_editor7 = require("@pixerate/editor/image-editor");
5198
5212
  var import_jsx_runtime24 = require("react/jsx-runtime");
5199
5213
  var LayerEffectsPanel = ({ controller, layerId, className }) => {
5200
- const [, setTick] = (0, import_react44.useState)(0);
5201
- (0, import_react44.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5202
- const [open, setOpen] = (0, import_react44.useState)(null);
5203
- const [error, setError] = (0, import_react44.useState)(null);
5204
- const commitNext = (0, import_react44.useRef)(true);
5214
+ const [, setTick] = (0, import_react45.useState)(0);
5215
+ (0, import_react45.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5216
+ const [open, setOpen] = (0, import_react45.useState)(null);
5217
+ const [error, setError] = (0, import_react45.useState)(null);
5218
+ const commitNext = (0, import_react45.useRef)(true);
5205
5219
  const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
5206
5220
  const model = (0, import_image_editor7.layerEffectsPanel)(layer);
5207
5221
  const id = layer?.id;
@@ -5390,8 +5404,8 @@ var Thumbnail = ({
5390
5404
  selected,
5391
5405
  testId
5392
5406
  }) => {
5393
- const ref = (0, import_react45.useRef)(null);
5394
- (0, import_react45.useEffect)(() => {
5407
+ const ref = (0, import_react46.useRef)(null);
5408
+ (0, import_react46.useEffect)(() => {
5395
5409
  const canvas = ref.current;
5396
5410
  const ctx = canvas?.getContext("2d");
5397
5411
  if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
@@ -5415,14 +5429,14 @@ var Thumbnail = ({
5415
5429
  );
5416
5430
  };
5417
5431
  var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "image", effects = true, className }) => {
5418
- const [, setTick] = (0, import_react45.useState)(0);
5419
- (0, import_react45.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5420
- const [error, setError] = (0, import_react45.useState)(null);
5421
- const [renaming, setRenaming] = (0, import_react45.useState)(null);
5422
- const [menu, setMenu] = (0, import_react45.useState)(null);
5423
- const [drag, setDrag] = (0, import_react45.useState)(null);
5424
- const [psdNotes, setPsdNotes] = (0, import_react45.useState)([]);
5425
- const fileInput = (0, import_react45.useRef)(null);
5432
+ const [, setTick] = (0, import_react46.useState)(0);
5433
+ (0, import_react46.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5434
+ const [error, setError] = (0, import_react46.useState)(null);
5435
+ const [renaming, setRenaming] = (0, import_react46.useState)(null);
5436
+ const [menu, setMenu] = (0, import_react46.useState)(null);
5437
+ const [drag, setDrag] = (0, import_react46.useState)(null);
5438
+ const [psdNotes, setPsdNotes] = (0, import_react46.useState)([]);
5439
+ const fileInput = (0, import_react46.useRef)(null);
5426
5440
  const psdTask = async (fn) => {
5427
5441
  try {
5428
5442
  setError(null);
@@ -5431,7 +5445,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5431
5445
  setError(err instanceof Error ? err.message : String(err));
5432
5446
  }
5433
5447
  };
5434
- const commitNext = (0, import_react45.useRef)(true);
5448
+ const commitNext = (0, import_react46.useRef)(true);
5435
5449
  const state = controller.getState();
5436
5450
  const rows = (0, import_image_editor8.layerPanelRows)(state.layers, state.activeLayerId);
5437
5451
  const active = controller.getActiveLayer();
@@ -5806,21 +5820,21 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5806
5820
  };
5807
5821
 
5808
5822
  // src/image-editor/ImageProviderEffectsPanel.tsx
5809
- var import_react54 = __toESM(require("react"), 1);
5823
+ var import_react55 = __toESM(require("react"), 1);
5810
5824
  var import_image_editor9 = require("@pixerate/editor/image-editor");
5811
5825
 
5812
5826
  // src/effects/useEffects.ts
5813
- var import_react46 = require("react");
5827
+ var import_react47 = require("react");
5814
5828
  function useEffects(host, provider) {
5815
- (0, import_react46.useEffect)(() => {
5829
+ (0, import_react47.useEffect)(() => {
5816
5830
  if (!host || !provider) return;
5817
5831
  return host.useEffects(provider);
5818
5832
  }, [host, provider]);
5819
5833
  }
5820
5834
  function useEffectDescription(provider, effect) {
5821
- const [state, setState] = (0, import_react46.useState)({ key: "", description: null, error: null });
5835
+ const [state, setState] = (0, import_react47.useState)({ key: "", description: null, error: null });
5822
5836
  const key = provider && effect ? `${provider.id}:${effect}` : "";
5823
- (0, import_react46.useEffect)(() => {
5837
+ (0, import_react47.useEffect)(() => {
5824
5838
  if (!provider || !effect) return;
5825
5839
  let live = true;
5826
5840
  Promise.resolve().then(() => provider.describe(effect)).then(
@@ -5835,13 +5849,13 @@ function useEffectDescription(provider, effect) {
5835
5849
  }
5836
5850
 
5837
5851
  // src/effects/EffectThumbnail.tsx
5838
- var import_react47 = require("react");
5852
+ var import_react48 = require("react");
5839
5853
  var import_effects = require("@pixerate/editor/effects");
5840
5854
  var import_jsx_runtime26 = require("react/jsx-runtime");
5841
5855
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
5842
- const ref = (0, import_react47.useRef)(null);
5843
- const [failed, setFailed] = (0, import_react47.useState)(effect.kind === "motion");
5844
- (0, import_react47.useEffect)(() => {
5856
+ const ref = (0, import_react48.useRef)(null);
5857
+ const [failed, setFailed] = (0, import_react48.useState)(effect.kind === "motion");
5858
+ (0, import_react48.useEffect)(() => {
5845
5859
  if (effect.kind === "motion") return;
5846
5860
  let live = true;
5847
5861
  (0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
@@ -5868,16 +5882,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
5868
5882
  }
5869
5883
 
5870
5884
  // src/effects/EffectsBrowser.tsx
5871
- var import_react48 = require("react");
5885
+ var import_react49 = require("react");
5872
5886
  var import_effects2 = require("@pixerate/editor/effects");
5873
5887
  var import_jsx_runtime27 = require("react/jsx-runtime");
5874
5888
  function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
5875
- const [all, setAll] = (0, import_react48.useState)([]);
5876
- const [query, setQuery] = (0, import_react48.useState)("");
5877
- const [category, setCategory] = (0, import_react48.useState)("");
5878
- const [use, setUse] = (0, import_react48.useState)("");
5879
- const [error, setError] = (0, import_react48.useState)(null);
5880
- (0, import_react48.useEffect)(() => {
5889
+ const [all, setAll] = (0, import_react49.useState)([]);
5890
+ const [query, setQuery] = (0, import_react49.useState)("");
5891
+ const [category, setCategory] = (0, import_react49.useState)("");
5892
+ const [use, setUse] = (0, import_react49.useState)("");
5893
+ const [error, setError] = (0, import_react49.useState)(null);
5894
+ (0, import_react49.useEffect)(() => {
5881
5895
  if (!provider) return setAll([]);
5882
5896
  let live = true;
5883
5897
  Promise.resolve().then(() => provider.list()).then(
@@ -5888,8 +5902,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
5888
5902
  live = false;
5889
5903
  };
5890
5904
  }, [provider]);
5891
- const [found, setFound] = (0, import_react48.useState)([]);
5892
- (0, import_react48.useEffect)(() => {
5905
+ const [found, setFound] = (0, import_react49.useState)([]);
5906
+ (0, import_react49.useEffect)(() => {
5893
5907
  if (!provider) return setFound([]);
5894
5908
  let live = true;
5895
5909
  Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
@@ -5898,7 +5912,7 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
5898
5912
  };
5899
5913
  }, [provider, query, category, use]);
5900
5914
  const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
5901
- const categories = (0, import_react48.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
5915
+ const categories = (0, import_react49.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
5902
5916
  const shown = found.filter(allowed);
5903
5917
  if (!provider)
5904
5918
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
@@ -5946,12 +5960,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
5946
5960
  }
5947
5961
 
5948
5962
  // src/effects/EffectParameters.tsx
5949
- var import_react53 = __toESM(require("react"), 1);
5963
+ var import_react54 = __toESM(require("react"), 1);
5950
5964
  var import_effects3 = require("@pixerate/editor/effects");
5951
5965
  var import_parameters2 = require("@pixerate/editor/parameters");
5952
5966
 
5953
5967
  // src/parameters/fields.tsx
5954
- var import_react52 = require("react");
5968
+ var import_react53 = require("react");
5955
5969
  var import_parameters = require("@pixerate/editor/parameters");
5956
5970
 
5957
5971
  // src/color/index.ts
@@ -5964,7 +5978,7 @@ __export(color_exports, {
5964
5978
  });
5965
5979
 
5966
5980
  // src/color/ColorPicker.tsx
5967
- var import_react49 = require("react");
5981
+ var import_react50 = require("react");
5968
5982
  var import_color = require("@pixerate/editor/color");
5969
5983
  var import_jsx_runtime28 = require("react/jsx-runtime");
5970
5984
  var LOCAL_STORAGE_KEY = "pixerate:color:recent";
@@ -6004,24 +6018,24 @@ var ColorPicker = ({
6004
6018
  id,
6005
6019
  "aria-label": ariaLabel = "Color picker"
6006
6020
  }) => {
6007
- const generatedId = (0, import_react49.useId)();
6021
+ const generatedId = (0, import_react50.useId)();
6008
6022
  const pickerId = id || generatedId;
6009
- const [pickerState, setPickerState] = (0, import_react49.useState)(
6023
+ const [pickerState, setPickerState] = (0, import_react50.useState)(
6010
6024
  () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
6011
6025
  );
6012
- const stateRef = (0, import_react49.useRef)(pickerState);
6026
+ const stateRef = (0, import_react50.useRef)(pickerState);
6013
6027
  stateRef.current = pickerState;
6014
- (0, import_react49.useEffect)(() => {
6028
+ (0, import_react50.useEffect)(() => {
6015
6029
  const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
6016
6030
  if (next) {
6017
6031
  setPickerState(next);
6018
6032
  }
6019
6033
  }, [value]);
6020
- const [internalRecent, setInternalRecent] = (0, import_react49.useState)(
6034
+ const [internalRecent, setInternalRecent] = (0, import_react50.useState)(
6021
6035
  () => controlledRecent ? [] : readLocalRecents()
6022
6036
  );
6023
6037
  const activeRecent = controlledRecent ?? internalRecent;
6024
- const recordRecent = (0, import_react49.useCallback)(
6038
+ const recordRecent = (0, import_react50.useCallback)(
6025
6039
  (color) => {
6026
6040
  const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
6027
6041
  if (!controlledRecent) {
@@ -6032,11 +6046,11 @@ var ColorPicker = ({
6032
6046
  },
6033
6047
  [activeRecent, controlledRecent, onRecentChange]
6034
6048
  );
6035
- const [textDraft, setTextDraft] = (0, import_react49.useState)(value);
6036
- const [isInvalid, setIsInvalid] = (0, import_react49.useState)(false);
6037
- const [isClipped, setIsClipped] = (0, import_react49.useState)(false);
6038
- const isTypingRef = (0, import_react49.useRef)(false);
6039
- (0, import_react49.useEffect)(() => {
6049
+ const [textDraft, setTextDraft] = (0, import_react50.useState)(value);
6050
+ const [isInvalid, setIsInvalid] = (0, import_react50.useState)(false);
6051
+ const [isClipped, setIsClipped] = (0, import_react50.useState)(false);
6052
+ const isTypingRef = (0, import_react50.useRef)(false);
6053
+ (0, import_react50.useEffect)(() => {
6040
6054
  if (!isTypingRef.current) {
6041
6055
  setTextDraft(value);
6042
6056
  setIsInvalid(false);
@@ -6044,11 +6058,11 @@ var ColorPicker = ({
6044
6058
  setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
6045
6059
  }
6046
6060
  }, [value]);
6047
- const [hasEyeDropper, setHasEyeDropper] = (0, import_react49.useState)(false);
6048
- (0, import_react49.useEffect)(() => {
6061
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react50.useState)(false);
6062
+ (0, import_react50.useEffect)(() => {
6049
6063
  setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
6050
6064
  }, []);
6051
- const emitColorChange = (0, import_react49.useCallback)(
6065
+ const emitColorChange = (0, import_react50.useCallback)(
6052
6066
  (nextState) => {
6053
6067
  setPickerState(nextState);
6054
6068
  const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
@@ -6056,10 +6070,10 @@ var ColorPicker = ({
6056
6070
  },
6057
6071
  [alpha, onChange]
6058
6072
  );
6059
- const latest = (0, import_react49.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6073
+ const latest = (0, import_react50.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6060
6074
  latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
6061
- const endDragRef = (0, import_react49.useRef)(null);
6062
- (0, import_react49.useEffect)(() => () => endDragRef.current?.(), []);
6075
+ const endDragRef = (0, import_react50.useRef)(null);
6076
+ (0, import_react50.useEffect)(() => () => endDragRef.current?.(), []);
6063
6077
  const startDrag = (e, next) => {
6064
6078
  if (disabled) return;
6065
6079
  e.preventDefault();
@@ -6161,7 +6175,7 @@ var ColorPicker = ({
6161
6175
  } catch {
6162
6176
  }
6163
6177
  };
6164
- const contrastResult = (0, import_react49.useMemo)(() => {
6178
+ const contrastResult = (0, import_react50.useMemo)(() => {
6165
6179
  if (!contrastAgainst) return null;
6166
6180
  const fg = (0, import_color.parseColor)(value);
6167
6181
  const bg = (0, import_color.parseColor)(contrastAgainst);
@@ -6588,7 +6602,7 @@ var ColorPicker = ({
6588
6602
  };
6589
6603
 
6590
6604
  // src/color/DualColorPicker.tsx
6591
- var import_react50 = require("react");
6605
+ var import_react51 = require("react");
6592
6606
  var import_color2 = require("@pixerate/editor/color");
6593
6607
  var import_jsx_runtime29 = require("react/jsx-runtime");
6594
6608
  function DualColorPicker({
@@ -6605,8 +6619,8 @@ function DualColorPicker({
6605
6619
  disabled = false,
6606
6620
  className = ""
6607
6621
  }) {
6608
- const sameId = (0, import_react50.useId)();
6609
- const [internalScheme, setInternalScheme] = (0, import_react50.useState)("light");
6622
+ const sameId = (0, import_react51.useId)();
6623
+ const [internalScheme, setInternalScheme] = (0, import_react51.useState)("light");
6610
6624
  const activeScheme = controlledScheme ?? internalScheme;
6611
6625
  const handleSchemeSelect = (nextScheme) => {
6612
6626
  if (onSchemeChange) {
@@ -6617,7 +6631,7 @@ function DualColorPicker({
6617
6631
  };
6618
6632
  const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
6619
6633
  const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
6620
- const [sameInBoth, setSameInBoth] = (0, import_react50.useState)(isSame);
6634
+ const [sameInBoth, setSameInBoth] = (0, import_react51.useState)(isSame);
6621
6635
  const handleSameToggle = (e) => {
6622
6636
  const nextSame = e.target.checked;
6623
6637
  setSameInBoth(nextSame);
@@ -6926,7 +6940,7 @@ function DualColorPicker({
6926
6940
  }
6927
6941
 
6928
6942
  // src/color/useColorScheme.ts
6929
- var import_react51 = require("react");
6943
+ var import_react52 = require("react");
6930
6944
  var import_color3 = require("@pixerate/editor/color");
6931
6945
  function getSnapshot(attribute) {
6932
6946
  if (typeof window === "undefined" || typeof document === "undefined") {
@@ -6951,7 +6965,7 @@ function getServerSnapshot() {
6951
6965
  function useColorScheme(options) {
6952
6966
  const override = options?.override;
6953
6967
  const attribute = options?.attribute;
6954
- const subscribe = (0, import_react51.useMemo)(() => {
6968
+ const subscribe = (0, import_react52.useMemo)(() => {
6955
6969
  return (callback) => {
6956
6970
  if (typeof window === "undefined" || typeof document === "undefined") {
6957
6971
  return () => {
@@ -6977,7 +6991,7 @@ function useColorScheme(options) {
6977
6991
  };
6978
6992
  };
6979
6993
  }, [attribute]);
6980
- const detected = (0, import_react51.useSyncExternalStore)(
6994
+ const detected = (0, import_react52.useSyncExternalStore)(
6981
6995
  subscribe,
6982
6996
  () => getSnapshot(attribute),
6983
6997
  getServerSnapshot
@@ -7057,7 +7071,7 @@ function ParameterNumberInput({
7057
7071
  }
7058
7072
  function ParameterSlider(props) {
7059
7073
  const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
7060
- const dragging = (0, import_react52.useRef)(false);
7074
+ const dragging = (0, import_react53.useRef)(false);
7061
7075
  const end = () => {
7062
7076
  if (!dragging.current) return;
7063
7077
  dragging.current = false;
@@ -7150,17 +7164,17 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
7150
7164
  );
7151
7165
  }
7152
7166
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
7153
- const [open, setOpen] = (0, import_react52.useState)(false);
7154
- const containerRef = (0, import_react52.useRef)(null);
7155
- const buttonRef = (0, import_react52.useRef)(null);
7156
- const popoverRef = (0, import_react52.useRef)(null);
7167
+ const [open, setOpen] = (0, import_react53.useState)(false);
7168
+ const containerRef = (0, import_react53.useRef)(null);
7169
+ const buttonRef = (0, import_react53.useRef)(null);
7170
+ const popoverRef = (0, import_react53.useRef)(null);
7157
7171
  const alpha = !!field.alpha;
7158
7172
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
7159
7173
  const rgb = hex.slice(0, 7);
7160
7174
  const shown = alpha ? hex : rgb;
7161
7175
  const off = disabled || field.readOnly;
7162
7176
  const name = (0, import_parameters.parameterLabel)(field);
7163
- (0, import_react52.useEffect)(() => {
7177
+ (0, import_react53.useEffect)(() => {
7164
7178
  if (!open) return;
7165
7179
  const onPointerDown = (e) => {
7166
7180
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -7370,10 +7384,10 @@ function EffectParameters({
7370
7384
  disabled = false,
7371
7385
  className = ""
7372
7386
  }) {
7373
- const fields = (0, import_react53.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
7374
- const idBase = (0, import_react53.useId)();
7375
- const gesture = import_react53.default.useRef(null);
7376
- const count = import_react53.default.useRef(0);
7387
+ const fields = (0, import_react54.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
7388
+ const idBase = (0, import_react54.useId)();
7389
+ const gesture = import_react54.default.useRef(null);
7390
+ const count = import_react54.default.useRef(0);
7377
7391
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
7378
7392
  (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
7379
7393
  "select",
@@ -7448,11 +7462,11 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
7448
7462
  // src/image-editor/ImageProviderEffectsPanel.tsx
7449
7463
  var import_jsx_runtime33 = require("react/jsx-runtime");
7450
7464
  function ImageProviderEffectsPanel({ controller, className = "" }) {
7451
- const [, setTick] = (0, import_react54.useState)(0);
7452
- (0, import_react54.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7453
- const [browse, setBrowse] = (0, import_react54.useState)(null);
7454
- const [message, setMessage] = (0, import_react54.useState)(null);
7455
- const [open, setOpen] = (0, import_react54.useState)(null);
7465
+ const [, setTick] = (0, import_react55.useState)(0);
7466
+ (0, import_react55.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7467
+ const [browse, setBrowse] = (0, import_react55.useState)(null);
7468
+ const [message, setMessage] = (0, import_react55.useState)(null);
7469
+ const [open, setOpen] = (0, import_react55.useState)(null);
7456
7470
  const provider = controller.effectsProvider;
7457
7471
  const state = controller.getState();
7458
7472
  const layer = state.activeLayerId ? (0, import_image_editor9.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
@@ -7460,7 +7474,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
7460
7474
  setMessage(null);
7461
7475
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
7462
7476
  };
7463
- const drags = import_react54.default.useRef(/* @__PURE__ */ new Set());
7477
+ const drags = import_react55.default.useRef(/* @__PURE__ */ new Set());
7464
7478
  const commit = (gesture) => {
7465
7479
  if (gesture) {
7466
7480
  if (!drags.current.has(gesture)) {
@@ -7556,7 +7570,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
7556
7570
  }
7557
7571
 
7558
7572
  // src/image-editor/BrushOptionsBar.tsx
7559
- var import_react56 = require("react");
7573
+ var import_react57 = require("react");
7560
7574
  var import_image_editor11 = require("@pixerate/editor/image-editor");
7561
7575
  var import_image_editor12 = require("@pixerate/editor/image-editor");
7562
7576
 
@@ -7564,7 +7578,7 @@ var import_image_editor12 = require("@pixerate/editor/image-editor");
7564
7578
  var import_image_editor10 = require("@pixerate/editor/image-editor");
7565
7579
 
7566
7580
  // src/paint-editor/PaintGradientEditorView.tsx
7567
- var import_react55 = require("react");
7581
+ var import_react56 = require("react");
7568
7582
  var import_jsx_runtime34 = require("react/jsx-runtime");
7569
7583
  var button = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
7570
7584
  var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
@@ -7586,7 +7600,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
7586
7600
  reversePaintGradient,
7587
7601
  updatePaintGradientStop
7588
7602
  } = kit;
7589
- const [selected, setSelected] = (0, import_react55.useState)(0);
7603
+ const [selected, setSelected] = (0, import_react56.useState)(0);
7590
7604
  const sel = Math.min(selected, value.stops.length - 1);
7591
7605
  const stop = value.stops[sel];
7592
7606
  const map = value.map;
@@ -7692,9 +7706,9 @@ var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime35.js
7692
7706
  // src/image-editor/BrushOptionsBar.tsx
7693
7707
  var import_jsx_runtime36 = require("react/jsx-runtime");
7694
7708
  var BrushOptionsBar = ({ controller, className }) => {
7695
- const [, setTick] = (0, import_react56.useState)(0);
7696
- (0, import_react56.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7697
- const [error, setError] = (0, import_react56.useState)(null);
7709
+ const [, setTick] = (0, import_react57.useState)(0);
7710
+ (0, import_react57.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7711
+ const [error, setError] = (0, import_react57.useState)(null);
7698
7712
  const state = controller.getState();
7699
7713
  const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource, paint } = state.paint;
7700
7714
  const tool = state.activeTool;
@@ -7906,18 +7920,18 @@ var BrushOptionsBar = ({ controller, className }) => {
7906
7920
  };
7907
7921
 
7908
7922
  // src/image-editor/ColorProfilePanel.tsx
7909
- var import_react57 = require("react");
7923
+ var import_react58 = require("react");
7910
7924
  var import_image_editor13 = require("@pixerate/editor/image-editor");
7911
7925
  var import_jsx_runtime37 = require("react/jsx-runtime");
7912
7926
  var chip = imageChipClass(false);
7913
7927
  var select2 = "rounded bg-muted px-1 py-0.5 text-[11px] text-foreground";
7914
7928
  var ColorProfilePanel = ({ controller, className }) => {
7915
- const [, setTick] = (0, import_react57.useState)(0);
7916
- (0, import_react57.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7917
- const [target, setTarget] = (0, import_react57.useState)("display-p3");
7918
- const [intent, setIntent] = (0, import_react57.useState)("relative");
7919
- const [bpc, setBpc] = (0, import_react57.useState)(true);
7920
- const [error, setError] = (0, import_react57.useState)(null);
7929
+ const [, setTick] = (0, import_react58.useState)(0);
7930
+ (0, import_react58.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
7931
+ const [target, setTarget] = (0, import_react58.useState)("display-p3");
7932
+ const [intent, setIntent] = (0, import_react58.useState)("relative");
7933
+ const [bpc, setBpc] = (0, import_react58.useState)(true);
7934
+ const [error, setError] = (0, import_react58.useState)(null);
7921
7935
  const view = (0, import_image_editor13.colorPanelView)(controller);
7922
7936
  const attempt = (fn) => {
7923
7937
  try {
@@ -7991,7 +8005,7 @@ var ColorProfilePanel = ({ controller, className }) => {
7991
8005
  };
7992
8006
 
7993
8007
  // src/image-editor/SelectionOptionsBar.tsx
7994
- var import_react58 = require("react");
8008
+ var import_react59 = require("react");
7995
8009
  var import_image_editor14 = require("@pixerate/editor/image-editor");
7996
8010
  var import_jsx_runtime38 = require("react/jsx-runtime");
7997
8011
  var MODIFY_OPS = [
@@ -8010,7 +8024,7 @@ var SelectionOptionsBar = ({
8010
8024
  quickMask,
8011
8025
  className = ""
8012
8026
  }) => {
8013
- const [radius, setRadius] = (0, import_react58.useState)(2);
8027
+ const [radius, setRadius] = (0, import_react59.useState)(2);
8014
8028
  const set = (patch) => onOptionsChange({ ...options, ...patch });
8015
8029
  const sel = selection === void 0 ? controller.getSelection() : selection;
8016
8030
  const qm = quickMask ?? Boolean(controller.getState().quickMask);
@@ -8096,17 +8110,17 @@ var SelectionOptionsBar = ({
8096
8110
  };
8097
8111
 
8098
8112
  // src/image-editor/RefineEdgePanel.tsx
8099
- var import_react59 = require("react");
8113
+ var import_react60 = require("react");
8100
8114
  var import_image_editor15 = require("@pixerate/editor/image-editor");
8101
8115
  var import_jsx_runtime39 = require("react/jsx-runtime");
8102
8116
  var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
8103
8117
  var button2 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
8104
8118
  var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
8105
- const [params, setParams] = (0, import_react59.useState)(DEFAULT_PARAMS);
8106
- const [busy, setBusy] = (0, import_react59.useState)(false);
8107
- const [error, setError] = (0, import_react59.useState)(null);
8108
- const [layerId, setLayerId] = (0, import_react59.useState)("");
8109
- const [newKind, setNewKind] = (0, import_react59.useState)("hueSaturation");
8119
+ const [params, setParams] = (0, import_react60.useState)(DEFAULT_PARAMS);
8120
+ const [busy, setBusy] = (0, import_react60.useState)(false);
8121
+ const [error, setError] = (0, import_react60.useState)(null);
8122
+ const [layerId, setLayerId] = (0, import_react60.useState)("");
8123
+ const [newKind, setNewKind] = (0, import_react60.useState)("hueSaturation");
8110
8124
  const sel = selection === void 0 ? controller.getSelection() : selection;
8111
8125
  const list = layers ?? controller.getAdjustmentLayers();
8112
8126
  const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
@@ -8247,13 +8261,13 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
8247
8261
  };
8248
8262
 
8249
8263
  // src/image-editor/FreeTransformOptionsBar.tsx
8250
- var import_react60 = require("react");
8264
+ var import_react61 = require("react");
8251
8265
  var import_image_editor16 = require("@pixerate/editor/image-editor");
8252
8266
  var import_jsx_runtime40 = require("react/jsx-runtime");
8253
8267
  var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
8254
8268
  var FreeTransformOptionsBar = ({ tool, className }) => {
8255
- const [, setTick] = (0, import_react60.useState)(0);
8256
- (0, import_react60.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
8269
+ const [, setTick] = (0, import_react61.useState)(0);
8270
+ (0, import_react61.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
8257
8271
  const bar = tool.bar();
8258
8272
  if (!tool.active || !bar) return null;
8259
8273
  const warp = tool.warpBar();
@@ -8385,13 +8399,13 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
8385
8399
  };
8386
8400
 
8387
8401
  // src/image-editor/ShapeOptionsBar.tsx
8388
- var import_react61 = require("react");
8402
+ var import_react62 = require("react");
8389
8403
  var import_image_editor17 = require("@pixerate/editor/image-editor");
8390
8404
  var import_jsx_runtime41 = require("react/jsx-runtime");
8391
8405
  var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
8392
- const [, setTick] = (0, import_react61.useState)(0);
8393
- (0, import_react61.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8394
- const [error, setError] = (0, import_react61.useState)(null);
8406
+ const [, setTick] = (0, import_react62.useState)(0);
8407
+ (0, import_react62.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8408
+ const [error, setError] = (0, import_react62.useState)(null);
8395
8409
  const active = controller.getActiveLayer();
8396
8410
  const shapeId = active?.type === "shape" ? active.id : null;
8397
8411
  const set = (change) => {
@@ -8502,15 +8516,15 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
8502
8516
  };
8503
8517
 
8504
8518
  // src/image-editor/TypeOptionsBar.tsx
8505
- var import_react62 = require("react");
8519
+ var import_react63 = require("react");
8506
8520
  var import_image_editor18 = require("@pixerate/editor/image-editor");
8507
8521
  var import_jsx_runtime42 = require("react/jsx-runtime");
8508
8522
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
8509
8523
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
8510
- const [, setTick] = (0, import_react62.useState)(0);
8511
- (0, import_react62.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8512
- (0, import_react62.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
8513
- const [error, setError] = (0, import_react62.useState)(null);
8524
+ const [, setTick] = (0, import_react63.useState)(0);
8525
+ (0, import_react63.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8526
+ (0, import_react63.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
8527
+ const [error, setError] = (0, import_react63.useState)(null);
8514
8528
  const active = controller.getActiveLayer();
8515
8529
  const typeId = !session && active?.type === "type" ? active.id : null;
8516
8530
  const here = session?.alive ? session.styleHere() : {};
@@ -8615,32 +8629,32 @@ var ImageEditor = ({
8615
8629
  return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
8616
8630
  });
8617
8631
  const legacyProcess = (0, import_image_editor19.normalizeProcessVersion)(state.adjustments.process) < import_image_editor19.LATEST_PROCESS_VERSION;
8618
- const [activeTab, setActiveTab] = (0, import_react63.useState)("crop");
8619
- const rootRef = (0, import_react63.useRef)(null);
8632
+ const [activeTab, setActiveTab] = (0, import_react64.useState)("crop");
8633
+ const rootRef = (0, import_react64.useRef)(null);
8620
8634
  const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
8621
- const activeTabRef = (0, import_react63.useRef)(activeTab);
8635
+ const activeTabRef = (0, import_react64.useRef)(activeTab);
8622
8636
  activeTabRef.current = activeTab;
8623
8637
  const openPanel = async (ref) => {
8624
8638
  if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
8625
8639
  rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
8626
8640
  await new Promise((resolve) => setTimeout(resolve, 60));
8627
8641
  };
8628
- const [activeCropRatio, setActiveCropRatio] = (0, import_react63.useState)(null);
8629
- const [selectionOptions, setSelectionOptions] = (0, import_react63.useState)(import_image_editor19.DEFAULT_SELECTION_TOOL_OPTIONS);
8630
- const [shapeOptions, setShapeOptions] = (0, import_react63.useState)(import_image_editor19.DEFAULT_SHAPE_TOOL_OPTIONS);
8631
- const [typeOptions, setTypeOptions] = (0, import_react63.useState)(import_image_editor19.DEFAULT_TYPE_TOOL_OPTIONS);
8632
- const [typeSession, setTypeSession] = (0, import_react63.useState)(null);
8633
- const [selectionError, setSelectionError] = (0, import_react63.useState)(null);
8634
- const [paintError, setPaintError] = (0, import_react63.useState)(null);
8635
- const [shapeTypeError, setShapeTypeError] = (0, import_react63.useState)(null);
8642
+ const [activeCropRatio, setActiveCropRatio] = (0, import_react64.useState)(null);
8643
+ const [selectionOptions, setSelectionOptions] = (0, import_react64.useState)(import_image_editor19.DEFAULT_SELECTION_TOOL_OPTIONS);
8644
+ const [shapeOptions, setShapeOptions] = (0, import_react64.useState)(import_image_editor19.DEFAULT_SHAPE_TOOL_OPTIONS);
8645
+ const [typeOptions, setTypeOptions] = (0, import_react64.useState)(import_image_editor19.DEFAULT_TYPE_TOOL_OPTIONS);
8646
+ const [typeSession, setTypeSession] = (0, import_react64.useState)(null);
8647
+ const [selectionError, setSelectionError] = (0, import_react64.useState)(null);
8648
+ const [paintError, setPaintError] = (0, import_react64.useState)(null);
8649
+ const [shapeTypeError, setShapeTypeError] = (0, import_react64.useState)(null);
8636
8650
  const handleCanvasError = (source, message) => {
8637
8651
  if (source === "paint") setPaintError(message);
8638
8652
  else if (source === "select") setSelectionError(message);
8639
8653
  else setShapeTypeError(message);
8640
8654
  };
8641
8655
  const finishTyping = () => setTypeSession(null);
8642
- const transformToolRef = (0, import_react63.useRef)(null);
8643
- const transformControllerRef = (0, import_react63.useRef)(controller);
8656
+ const transformToolRef = (0, import_react64.useRef)(null);
8657
+ const transformControllerRef = (0, import_react64.useRef)(controller);
8644
8658
  if (!transformToolRef.current || transformControllerRef.current !== controller) {
8645
8659
  transformToolRef.current?.cancel();
8646
8660
  transformToolRef.current = new import_image_editor19.FreeTransformTool(controller, {
@@ -8649,16 +8663,16 @@ var ImageEditor = ({
8649
8663
  transformControllerRef.current = controller;
8650
8664
  }
8651
8665
  const transformTool = transformToolRef.current;
8652
- const [, setTransformTick] = (0, import_react63.useState)(0);
8653
- (0, import_react63.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
8654
- (0, import_react63.useEffect)(() => () => transformToolRef.current?.cancel(), []);
8655
- const [inpaintPrompt, setInpaintPrompt] = (0, import_react63.useState)("");
8656
- const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react63.useState)("annotations");
8657
- const [isRemovingBg, setIsRemovingBg] = (0, import_react63.useState)(false);
8658
- const [isInpainting, setIsInpainting] = (0, import_react63.useState)(false);
8659
- const [aiError, setAiError] = (0, import_react63.useState)(null);
8660
- const [aiSuccess, setAiSuccess] = (0, import_react63.useState)(null);
8661
- const [aiTarget, setAiTarget] = (0, import_react63.useState)("auto");
8666
+ const [, setTransformTick] = (0, import_react64.useState)(0);
8667
+ (0, import_react64.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
8668
+ (0, import_react64.useEffect)(() => () => transformToolRef.current?.cancel(), []);
8669
+ const [inpaintPrompt, setInpaintPrompt] = (0, import_react64.useState)("");
8670
+ const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react64.useState)("annotations");
8671
+ const [isRemovingBg, setIsRemovingBg] = (0, import_react64.useState)(false);
8672
+ const [isInpainting, setIsInpainting] = (0, import_react64.useState)(false);
8673
+ const [aiError, setAiError] = (0, import_react64.useState)(null);
8674
+ const [aiSuccess, setAiSuccess] = (0, import_react64.useState)(null);
8675
+ const [aiTarget, setAiTarget] = (0, import_react64.useState)("auto");
8662
8676
  const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
8663
8677
  const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
8664
8678
  const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
@@ -8721,11 +8735,11 @@ var ImageEditor = ({
8721
8735
  setIsInpainting(false);
8722
8736
  }
8723
8737
  };
8724
- const [activeColor, setActiveColor] = (0, import_react63.useState)("#ef4444");
8725
- const [strokeWidth, setStrokeWidth] = (0, import_react63.useState)(3);
8726
- const [fontSize, setFontSize] = (0, import_react63.useState)(24);
8727
- const [textInput, setTextInput] = (0, import_react63.useState)("");
8728
- (0, import_react63.useEffect)(() => {
8738
+ const [activeColor, setActiveColor] = (0, import_react64.useState)("#ef4444");
8739
+ const [strokeWidth, setStrokeWidth] = (0, import_react64.useState)(3);
8740
+ const [fontSize, setFontSize] = (0, import_react64.useState)(24);
8741
+ const [textInput, setTextInput] = (0, import_react64.useState)("");
8742
+ (0, import_react64.useEffect)(() => {
8729
8743
  if (activeTab === "crop" && editor.state.activeTool !== "crop") {
8730
8744
  editor.setTool("crop");
8731
8745
  }
@@ -9125,7 +9139,7 @@ var ImageEditor = ({
9125
9139
  )
9126
9140
  ] }),
9127
9141
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Histogram, { histogram: editor.histogram }),
9128
- import_image_editor19.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react63.default.Fragment, { children: [
9142
+ import_image_editor19.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react64.default.Fragment, { children: [
9129
9143
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9130
9144
  ControlSlider,
9131
9145
  {
@@ -9624,8 +9638,8 @@ var ImageEditor = ({
9624
9638
  };
9625
9639
 
9626
9640
  // src/review/useReview.ts
9627
- var import_react64 = require("react");
9628
- var import_editor12 = require("@pixerate/editor");
9641
+ var import_react65 = require("react");
9642
+ var import_editor13 = require("@pixerate/editor");
9629
9643
  var EMPTY_COMMENTS = Object.freeze({
9630
9644
  threads: [],
9631
9645
  activeThreadId: null
@@ -9642,24 +9656,24 @@ function isCommentStore(value) {
9642
9656
  return !!value && typeof value.getSnapshot === "function" && typeof value.createThread === "function";
9643
9657
  }
9644
9658
  function useComments(source) {
9645
- const store = isCommentStore(source) ? source : (0, import_editor12.getCommentStore)(source);
9646
- const subscribe = (0, import_react64.useCallback)(
9659
+ const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
9660
+ const subscribe = (0, import_react65.useCallback)(
9647
9661
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
9648
9662
  [store]
9649
9663
  );
9650
9664
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
9651
- const snapshot = (0, import_react64.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
9652
- return (0, import_react64.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
9665
+ const snapshot = (0, import_react65.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
9666
+ return (0, import_react65.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
9653
9667
  }
9654
9668
  function useTrackChanges(editor) {
9655
- const store = (0, import_editor12.getTrackChangesStore)(editor ?? null);
9656
- const subscribe = (0, import_react64.useCallback)(
9669
+ const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
9670
+ const subscribe = (0, import_react65.useCallback)(
9657
9671
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
9658
9672
  [store]
9659
9673
  );
9660
9674
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
9661
- const snapshot = (0, import_react64.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
9662
- return (0, import_react64.useMemo)(() => {
9675
+ const snapshot = (0, import_react65.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
9676
+ return (0, import_react65.useMemo)(() => {
9663
9677
  const run = (fn) => () => {
9664
9678
  if (editor && !editor.isDestroyed) fn(editor);
9665
9679
  };
@@ -9682,8 +9696,8 @@ function useTrackChanges(editor) {
9682
9696
  }
9683
9697
 
9684
9698
  // src/review/CommentsPanel.tsx
9685
- var import_react65 = require("react");
9686
- var import_editor13 = require("@pixerate/editor");
9699
+ var import_react66 = require("react");
9700
+ var import_editor14 = require("@pixerate/editor");
9687
9701
  var import_jsx_runtime44 = require("react/jsx-runtime");
9688
9702
  var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
9689
9703
  var primaryButtonClass = "rounded px-2 py-1 text-xs bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50";
@@ -9694,12 +9708,12 @@ var CommentsPanel = ({
9694
9708
  author: authorProp,
9695
9709
  showResolved: showResolvedInitial = false,
9696
9710
  className = "flex flex-col gap-2 text-sm text-foreground",
9697
- formatTime = (t) => (0, import_editor13.formatReviewTime)(t),
9711
+ formatTime = (t) => (0, import_editor14.formatReviewTime)(t),
9698
9712
  emptyMessage = "No comments yet. Select text and add a comment."
9699
9713
  }) => {
9700
9714
  const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
9701
- const [showResolved, setShowResolved] = (0, import_react65.useState)(showResolvedInitial);
9702
- const author = authorProp ?? (0, import_editor13.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
9715
+ const [showResolved, setShowResolved] = (0, import_react66.useState)(showResolvedInitial);
9716
+ const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
9703
9717
  const visible = threads.filter((t) => showResolved || !t.resolved);
9704
9718
  const resolvedCount = threads.filter((t) => t.resolved).length;
9705
9719
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("aside", { className, "aria-label": "Comments", children: [
@@ -9742,7 +9756,7 @@ var CommentThreadCard = ({
9742
9756
  author,
9743
9757
  formatTime
9744
9758
  }) => {
9745
- const [draft, setDraft] = (0, import_react65.useState)("");
9759
+ const [draft, setDraft] = (0, import_react66.useState)("");
9746
9760
  const isDraft = thread.body === "";
9747
9761
  const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
9748
9762
  const live = editor && !editor.isDestroyed ? editor : null;
@@ -9956,16 +9970,16 @@ var CommentButton = ({
9956
9970
  );
9957
9971
 
9958
9972
  // src/review/useDocumentCompare.ts
9959
- var import_react66 = require("react");
9960
- var import_editor14 = require("@pixerate/editor");
9973
+ var import_react67 = require("react");
9974
+ var import_editor15 = require("@pixerate/editor");
9961
9975
  function useDocumentCompare(editor, options) {
9962
- const [summary, setSummary] = (0, import_react66.useState)(null);
9963
- const defaults = (0, import_react66.useRef)(options);
9976
+ const [summary, setSummary] = (0, import_react67.useState)(null);
9977
+ const defaults = (0, import_react67.useRef)(options);
9964
9978
  defaults.current = options;
9965
- const compare = (0, import_react66.useCallback)(
9979
+ const compare = (0, import_react67.useCallback)(
9966
9980
  (original, revised, overrides) => {
9967
9981
  if (!editor || editor.isDestroyed) return null;
9968
- const result = (0, import_editor14.applyDocumentComparison)(editor, original, revised, {
9982
+ const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
9969
9983
  ...defaults.current,
9970
9984
  ...overrides
9971
9985
  });
@@ -9974,12 +9988,12 @@ function useDocumentCompare(editor, options) {
9974
9988
  },
9975
9989
  [editor]
9976
9990
  );
9977
- const clear = (0, import_react66.useCallback)(() => setSummary(null), []);
9978
- return (0, import_react66.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
9991
+ const clear = (0, import_react67.useCallback)(() => setSummary(null), []);
9992
+ return (0, import_react67.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
9979
9993
  }
9980
9994
 
9981
9995
  // src/review/TrackedChangesList.tsx
9982
- var import_editor15 = require("@pixerate/editor");
9996
+ var import_editor16 = require("@pixerate/editor");
9983
9997
  var import_jsx_runtime47 = require("react/jsx-runtime");
9984
9998
  var buttonClass4 = "rounded px-1.5 py-0.5 text-xs text-foreground hover:bg-muted disabled:opacity-40";
9985
9999
  var TrackedChangesList = ({
@@ -10010,7 +10024,7 @@ var TrackedChangesList = ({
10010
10024
  title: `${change.author.name}: ${change.description}`,
10011
10025
  onClick: () => review.select(change.id),
10012
10026
  children: [
10013
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-medium", children: (0, import_editor15.trackedChangeLabel)(change) }),
10027
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-medium", children: (0, import_editor16.trackedChangeLabel)(change) }),
10014
10028
  change.author.name ? ` \xB7 ${change.author.name}` : "",
10015
10029
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "block truncate text-muted-foreground", children: change.description })
10016
10030
  ]
@@ -10026,12 +10040,12 @@ var TrackedChangesList = ({
10026
10040
  };
10027
10041
 
10028
10042
  // src/commands/useCommandPalette.ts
10029
- var import_react67 = require("react");
10043
+ var import_react68 = require("react");
10030
10044
  var import_commands2 = require("@pixerate/editor/commands");
10031
10045
  function useCommandPalette(registry, options = {}) {
10032
- const optionsRef = (0, import_react67.useRef)(options);
10046
+ const optionsRef = (0, import_react68.useRef)(options);
10033
10047
  optionsRef.current = options;
10034
- const controller = (0, import_react67.useMemo)(
10048
+ const controller = (0, import_react68.useMemo)(
10035
10049
  () => (0, import_commands2.createCommandPaletteController)(registry, {
10036
10050
  context: () => {
10037
10051
  const c = optionsRef.current.context;
@@ -10052,9 +10066,9 @@ function useCommandPalette(registry, options = {}) {
10052
10066
  // eslint-disable-next-line react-hooks/exhaustive-deps
10053
10067
  [registry]
10054
10068
  );
10055
- const state = (0, import_react67.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
10069
+ const state = (0, import_react68.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
10056
10070
  const { hotkey, hotkeyTarget } = options;
10057
- (0, import_react67.useEffect)(() => {
10071
+ (0, import_react68.useEffect)(() => {
10058
10072
  if (!hotkey) return;
10059
10073
  const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
10060
10074
  if (!target) return;
@@ -10082,13 +10096,13 @@ function useCommandPalette(registry, options = {}) {
10082
10096
  }
10083
10097
 
10084
10098
  // src/commands/CommandPalette.tsx
10085
- var import_react68 = __toESM(require("react"), 1);
10099
+ var import_react69 = __toESM(require("react"), 1);
10086
10100
  var import_jsx_runtime48 = require("react/jsx-runtime");
10087
10101
  function HighlightedLabel({ item }) {
10088
10102
  if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_jsx_runtime48.Fragment, { children: item.label });
10089
10103
  const marked = new Set(item.labelIndices);
10090
10104
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_jsx_runtime48.Fragment, { children: Array.from(item.label).map(
10091
- (ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react68.default.Fragment, { children: ch }, i)
10105
+ (ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react69.default.Fragment, { children: ch }, i)
10092
10106
  ) });
10093
10107
  }
10094
10108
  var CommandPalette = ({
@@ -10097,16 +10111,16 @@ var CommandPalette = ({
10097
10111
  emptyMessage = "No matching commands",
10098
10112
  className = ""
10099
10113
  }) => {
10100
- const inputRef = (0, import_react68.useRef)(null);
10101
- const listRef = (0, import_react68.useRef)(null);
10102
- const baseId = (0, import_react68.useId)();
10114
+ const inputRef = (0, import_react69.useRef)(null);
10115
+ const listRef = (0, import_react69.useRef)(null);
10116
+ const baseId = (0, import_react69.useId)();
10103
10117
  const listId = `${baseId}-list`;
10104
10118
  const optionId = (index) => `${baseId}-option-${index}`;
10105
10119
  const { open, query, items, activeIndex } = palette;
10106
- (0, import_react68.useEffect)(() => {
10120
+ (0, import_react69.useEffect)(() => {
10107
10121
  if (open) inputRef.current?.focus();
10108
10122
  }, [open]);
10109
- (0, import_react68.useEffect)(() => {
10123
+ (0, import_react69.useEffect)(() => {
10110
10124
  if (!open) return;
10111
10125
  const active = listRef.current?.querySelector('[aria-selected="true"]');
10112
10126
  active?.scrollIntoView?.({ block: "nearest" });
@@ -10182,12 +10196,12 @@ var CommandPalette = ({
10182
10196
  };
10183
10197
 
10184
10198
  // src/commands/useCommandShortcuts.ts
10185
- var import_react69 = require("react");
10199
+ var import_react70 = require("react");
10186
10200
  function useCommandShortcuts(registry, options = {}) {
10187
- const optionsRef = (0, import_react69.useRef)(options);
10201
+ const optionsRef = (0, import_react70.useRef)(options);
10188
10202
  optionsRef.current = options;
10189
10203
  const { enabled = true, target } = options;
10190
- (0, import_react69.useEffect)(() => {
10204
+ (0, import_react70.useEffect)(() => {
10191
10205
  if (!registry || !enabled) return;
10192
10206
  const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
10193
10207
  if (!eventTarget) return;
@@ -10205,14 +10219,14 @@ function useCommandShortcuts(registry, options = {}) {
10205
10219
  }, [registry, enabled, target]);
10206
10220
  }
10207
10221
  function useRegisterCommands(registry, specs) {
10208
- (0, import_react69.useEffect)(() => {
10222
+ (0, import_react70.useEffect)(() => {
10209
10223
  if (!registry || !specs || specs.length === 0) return;
10210
10224
  return registry.register(specs);
10211
10225
  }, [registry, specs]);
10212
10226
  }
10213
10227
 
10214
10228
  // src/persistence/useAutosave.ts
10215
- var import_react70 = require("react");
10229
+ var import_react71 = require("react");
10216
10230
  var import_persistence = require("@pixerate/editor/persistence");
10217
10231
  var IDLE = {
10218
10232
  status: "idle",
@@ -10223,18 +10237,18 @@ var IDLE = {
10223
10237
  ready: false
10224
10238
  };
10225
10239
  function useAutosave(options) {
10226
- const optionsRef = (0, import_react70.useRef)(options);
10240
+ const optionsRef = (0, import_react71.useRef)(options);
10227
10241
  optionsRef.current = options;
10228
10242
  const { storage, key, history, dirty } = options;
10229
10243
  const recover = options.recover !== false;
10230
10244
  const flushOnHide = options.flushOnHide !== false;
10231
10245
  const ready = options.ready !== false;
10232
- const [controller, setController] = (0, import_react70.useState)(null);
10233
- const [status, setStatus] = (0, import_react70.useState)(IDLE);
10234
- const [recovery, setRecovery] = (0, import_react70.useState)(null);
10235
- const [pendingRecovery, setPendingRecovery] = (0, import_react70.useState)(recover);
10236
- const revisionsRef = (0, import_react70.useRef)(null);
10237
- (0, import_react70.useEffect)(() => {
10246
+ const [controller, setController] = (0, import_react71.useState)(null);
10247
+ const [status, setStatus] = (0, import_react71.useState)(IDLE);
10248
+ const [recovery, setRecovery] = (0, import_react71.useState)(null);
10249
+ const [pendingRecovery, setPendingRecovery] = (0, import_react71.useState)(recover);
10250
+ const revisionsRef = (0, import_react71.useRef)(null);
10251
+ (0, import_react71.useEffect)(() => {
10238
10252
  const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
10239
10253
  const o = optionsRef.current;
10240
10254
  const instance = (0, import_persistence.createAutosaveController)({
@@ -10277,10 +10291,10 @@ function useAutosave(options) {
10277
10291
  if (revisionsRef.current === revisions) revisionsRef.current = null;
10278
10292
  };
10279
10293
  }, [storage, key, history, dirty, recover]);
10280
- (0, import_react70.useEffect)(() => {
10294
+ (0, import_react71.useEffect)(() => {
10281
10295
  if (controller && ready && !pendingRecovery) controller.ready();
10282
10296
  }, [controller, ready, pendingRecovery]);
10283
- (0, import_react70.useEffect)(() => {
10297
+ (0, import_react71.useEffect)(() => {
10284
10298
  if (!controller || !flushOnHide || typeof window === "undefined") return;
10285
10299
  const flush = () => void controller.flushNow();
10286
10300
  const onVisibility = () => {
@@ -10293,30 +10307,30 @@ function useAutosave(options) {
10293
10307
  document.removeEventListener("visibilitychange", onVisibility);
10294
10308
  };
10295
10309
  }, [controller, flushOnHide]);
10296
- const restore = (0, import_react70.useCallback)(() => {
10310
+ const restore = (0, import_react71.useCallback)(() => {
10297
10311
  const snapshot = recovery?.snapshot;
10298
10312
  setRecovery(null);
10299
10313
  setPendingRecovery(false);
10300
10314
  return snapshot;
10301
10315
  }, [recovery]);
10302
- const discard = (0, import_react70.useCallback)(async () => {
10316
+ const discard = (0, import_react71.useCallback)(async () => {
10303
10317
  if (controller) await controller.discardRecovery();
10304
10318
  setRecovery(null);
10305
10319
  setPendingRecovery(false);
10306
10320
  }, [controller]);
10307
- const flushNow = (0, import_react70.useCallback)(async () => {
10321
+ const flushNow = (0, import_react71.useCallback)(async () => {
10308
10322
  await controller?.flushNow();
10309
10323
  }, [controller]);
10310
- const markClean = (0, import_react70.useCallback)(async () => {
10324
+ const markClean = (0, import_react71.useCallback)(async () => {
10311
10325
  revisionsRef.current?.markSaved();
10312
10326
  await controller?.markClean();
10313
10327
  }, [controller]);
10314
- const notifyChange = (0, import_react70.useCallback)(() => revisionsRef.current?.bump(), []);
10328
+ const notifyChange = (0, import_react71.useCallback)(() => revisionsRef.current?.bump(), []);
10315
10329
  return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
10316
10330
  }
10317
10331
 
10318
10332
  // src/persistence/useEditorAutosave.ts
10319
- var import_react71 = require("react");
10333
+ var import_react72 = require("react");
10320
10334
  var import_persistence2 = require("@pixerate/editor/persistence");
10321
10335
  function useEditorAutosave(doc, options) {
10322
10336
  const autosave = useAutosave({
@@ -10327,7 +10341,7 @@ function useEditorAutosave(doc, options) {
10327
10341
  history: doc
10328
10342
  });
10329
10343
  const take = autosave.restore;
10330
- const restore = (0, import_react71.useCallback)(() => {
10344
+ const restore = (0, import_react72.useCallback)(() => {
10331
10345
  const snapshot = take();
10332
10346
  return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
10333
10347
  }, [take, doc]);
@@ -10390,17 +10404,17 @@ var RecoveryPrompt = ({
10390
10404
  };
10391
10405
 
10392
10406
  // src/generation/useGenerationPlan.ts
10393
- var import_react72 = require("react");
10407
+ var import_react73 = require("react");
10394
10408
  var import_generation = require("@pixerate/editor/generation");
10395
10409
  function useGenerationPlan(request, capabilities, options = {}) {
10396
10410
  const key = JSON.stringify([request, capabilities, options]);
10397
- return (0, import_react72.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
10411
+ return (0, import_react73.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
10398
10412
  }
10399
10413
  function useJobProgress(options) {
10400
10414
  const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
10401
- const [tick, setTick] = (0, import_react72.useState)(() => Date.now());
10415
+ const [tick, setTick] = (0, import_react73.useState)(() => Date.now());
10402
10416
  const ticking = !done && now === void 0;
10403
- (0, import_react72.useEffect)(() => {
10417
+ (0, import_react73.useEffect)(() => {
10404
10418
  if (!ticking) return;
10405
10419
  setTick(Date.now());
10406
10420
  const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
@@ -10410,7 +10424,7 @@ function useJobProgress(options) {
10410
10424
  }
10411
10425
 
10412
10426
  // src/generation/GenerationSettings.tsx
10413
- var import_react73 = require("react");
10427
+ var import_react74 = require("react");
10414
10428
  var import_generation2 = require("@pixerate/editor/generation");
10415
10429
  var import_jsx_runtime50 = require("react/jsx-runtime");
10416
10430
  var inputClass2 = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
@@ -10493,8 +10507,8 @@ var GenerationSettings = ({
10493
10507
  renderReference,
10494
10508
  className = ""
10495
10509
  }) => {
10496
- const baseId = (0, import_react73.useId)();
10497
- const controls = (0, import_react73.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
10510
+ const baseId = (0, import_react74.useId)();
10511
+ const controls = (0, import_react74.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
10498
10512
  const computed = useGenerationPlan(value, capabilities, { strategy });
10499
10513
  const plan = planProp ?? computed;
10500
10514
  const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
@@ -10589,7 +10603,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
10589
10603
  };
10590
10604
 
10591
10605
  // src/generation/AssetMentionChips.tsx
10592
- var import_react74 = require("react");
10606
+ var import_react75 = require("react");
10593
10607
  var import_generation3 = require("@pixerate/editor/generation");
10594
10608
  var import_jsx_runtime52 = require("react/jsx-runtime");
10595
10609
  var AssetMentionChips = ({
@@ -10601,14 +10615,14 @@ var AssetMentionChips = ({
10601
10615
  renderAsset,
10602
10616
  className = ""
10603
10617
  }) => {
10604
- const [open, setOpen] = (0, import_react74.useState)(null);
10605
- const rootRef = (0, import_react74.useRef)(null);
10606
- const chips = (0, import_react74.useMemo)(
10618
+ const [open, setOpen] = (0, import_react75.useState)(null);
10619
+ const rootRef = (0, import_react75.useRef)(null);
10620
+ const chips = (0, import_react75.useMemo)(
10607
10621
  () => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
10608
10622
  [content, assets, capabilities]
10609
10623
  );
10610
10624
  const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
10611
- (0, import_react74.useEffect)(() => {
10625
+ (0, import_react75.useEffect)(() => {
10612
10626
  if (open === null) return;
10613
10627
  const onPointer = (event) => {
10614
10628
  if (!rootRef.current?.contains(event.target)) setOpen(null);
@@ -10703,15 +10717,15 @@ var AssetMentionChips = ({
10703
10717
  };
10704
10718
 
10705
10719
  // src/generation/GenerationHistory.tsx
10706
- var import_react75 = require("react");
10720
+ var import_react76 = require("react");
10707
10721
  var import_generation4 = require("@pixerate/editor/generation");
10708
10722
  var import_jsx_runtime53 = require("react/jsx-runtime");
10709
10723
  function useGenerationRecords(store, filter) {
10710
- const [records, setRecords] = (0, import_react75.useState)([]);
10711
- const [loading, setLoading] = (0, import_react75.useState)(!!store);
10712
- const [error, setError] = (0, import_react75.useState)(null);
10724
+ const [records, setRecords] = (0, import_react76.useState)([]);
10725
+ const [loading, setLoading] = (0, import_react76.useState)(!!store);
10726
+ const [error, setError] = (0, import_react76.useState)(null);
10713
10727
  const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
10714
- const refresh = (0, import_react75.useCallback)(async () => {
10728
+ const refresh = (0, import_react76.useCallback)(async () => {
10715
10729
  if (!store) {
10716
10730
  setRecords([]);
10717
10731
  setLoading(false);
@@ -10728,7 +10742,7 @@ function useGenerationRecords(store, filter) {
10728
10742
  setLoading(false);
10729
10743
  }
10730
10744
  }, [store, filterKey]);
10731
- (0, import_react75.useEffect)(() => {
10745
+ (0, import_react76.useEffect)(() => {
10732
10746
  void refresh();
10733
10747
  if (!store) return;
10734
10748
  return store.subscribe(() => void refresh());
@@ -10754,15 +10768,15 @@ var GenerationHistory = ({
10754
10768
  emptyText = "No generations yet.",
10755
10769
  className = ""
10756
10770
  }) => {
10757
- const [innerMode, setInnerMode] = (0, import_react75.useState)("exact");
10771
+ const [innerMode, setInnerMode] = (0, import_react76.useState)("exact");
10758
10772
  const mode = modeProp ?? innerMode;
10759
10773
  const setMode = (next) => {
10760
10774
  if (modeProp === void 0) setInnerMode(next);
10761
10775
  onModeChange?.(next);
10762
10776
  };
10763
- const options = (0, import_react75.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
10764
- const results = (0, import_react75.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
10765
- const models = (0, import_react75.useMemo)(
10777
+ const options = (0, import_react76.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
10778
+ const results = (0, import_react76.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
10779
+ const models = (0, import_react76.useMemo)(
10766
10780
  () => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
10767
10781
  [capabilities]
10768
10782
  );
@@ -10873,19 +10887,19 @@ var GenerationHistory = ({
10873
10887
  };
10874
10888
 
10875
10889
  // src/find-replace/useFindReplace.ts
10876
- var import_react76 = require("react");
10877
- var import_editor16 = require("@pixerate/editor");
10890
+ var import_react77 = require("react");
10891
+ var import_editor17 = require("@pixerate/editor");
10878
10892
  var noopUnsubscribe2 = () => {
10879
10893
  };
10880
10894
  function useFindReplace(editor) {
10881
- const store = (0, import_editor16.getFindReplaceStore)(editor ?? null);
10882
- const subscribe = (0, import_react76.useCallback)(
10895
+ const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
10896
+ const subscribe = (0, import_react77.useCallback)(
10883
10897
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
10884
10898
  [store]
10885
10899
  );
10886
- const getSnapshot2 = () => store?.getSnapshot() ?? import_editor16.EMPTY_FIND_REPLACE_SNAPSHOT;
10887
- const snapshot = (0, import_react76.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
10888
- return (0, import_react76.useMemo)(() => {
10900
+ const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
10901
+ const snapshot = (0, import_react77.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
10902
+ return (0, import_react77.useMemo)(() => {
10889
10903
  const run = (fn) => {
10890
10904
  if (editor && !editor.isDestroyed && store) fn(editor);
10891
10905
  };
@@ -10909,8 +10923,8 @@ function useFindReplace(editor) {
10909
10923
  }
10910
10924
 
10911
10925
  // src/find-replace/FindReplaceBar.tsx
10912
- var import_react77 = require("react");
10913
- var import_editor17 = require("@pixerate/editor");
10926
+ var import_react78 = require("react");
10927
+ var import_editor18 = require("@pixerate/editor");
10914
10928
  var import_jsx_runtime54 = require("react/jsx-runtime");
10915
10929
  var inputClass3 = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
10916
10930
  var buttonClass5 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
@@ -10924,17 +10938,17 @@ var FindReplaceBar = ({
10924
10938
  onClose
10925
10939
  }) => {
10926
10940
  const find = useFindReplace(editor);
10927
- const findInput = (0, import_react77.useRef)(null);
10928
- const [moreOpen, setMoreOpen] = (0, import_react77.useState)(false);
10941
+ const findInput = (0, import_react78.useRef)(null);
10942
+ const [moreOpen, setMoreOpen] = (0, import_react78.useState)(false);
10929
10943
  const visible = find.available && (alwaysOpen || find.open);
10930
- (0, import_react77.useEffect)(() => {
10944
+ (0, import_react78.useEffect)(() => {
10931
10945
  if (!visible || find.focusRequest === 0) return;
10932
10946
  findInput.current?.focus();
10933
10947
  findInput.current?.select();
10934
10948
  }, [visible, find.focusRequest]);
10935
10949
  if (!visible) return null;
10936
10950
  const showReplace = find.mode === "replace";
10937
- const status = (0, import_editor17.formatFindStatus)(find);
10951
+ const status = (0, import_editor18.formatFindStatus)(find);
10938
10952
  const hasMatches = find.matchCount > 0;
10939
10953
  const close = () => {
10940
10954
  find.close();
@@ -10992,7 +11006,7 @@ var FindReplaceBar = ({
10992
11006
  onKeyDown: onFindKeyDown
10993
11007
  }
10994
11008
  ),
10995
- import_editor17.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11009
+ import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
10996
11010
  "button",
10997
11011
  {
10998
11012
  type: "button",
@@ -11056,7 +11070,7 @@ var FindReplaceBar = ({
11056
11070
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("button", { type: "button", className: buttonClass5, disabled: !hasMatches, onClick: find.replaceAll, children: "Replace all" }),
11057
11071
  find.lastReplaceCount !== null && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "px-1 text-xs text-muted-foreground", "aria-live": "polite", children: find.lastReplaceCount === 1 ? "1 replaced" : `${find.lastReplaceCount} replaced` })
11058
11072
  ] }),
11059
- showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-xs text-muted-foreground", children: import_editor17.FIND_OPTION_TOGGLES.filter((t) => t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("label", { className: "flex items-center gap-1", children: [
11073
+ showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-xs text-muted-foreground", children: import_editor18.FIND_OPTION_TOGGLES.filter((t) => t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("label", { className: "flex items-center gap-1", children: [
11060
11074
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11061
11075
  "input",
11062
11076
  {
@@ -11071,29 +11085,29 @@ var FindReplaceBar = ({
11071
11085
  };
11072
11086
 
11073
11087
  // src/tables/useTableMenu.ts
11074
- var import_react78 = require("react");
11075
- var import_editor18 = require("@pixerate/editor");
11088
+ var import_react79 = require("react");
11089
+ var import_editor19 = require("@pixerate/editor");
11076
11090
  function useTableMenu(editor) {
11077
- const store = (0, import_react78.useMemo)(() => (0, import_editor18.createTableStore)(editor), [editor]);
11078
- const snapshot = (0, import_react78.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
11079
- return (0, import_react78.useMemo)(
11091
+ const store = (0, import_react79.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
11092
+ const snapshot = (0, import_react79.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
11093
+ return (0, import_react79.useMemo)(
11080
11094
  () => ({
11081
11095
  ...snapshot,
11082
- run: (action, params) => (0, import_editor18.runTableAction)(editor, action, params, { focus: true }),
11083
- check: (action, params) => (0, import_editor18.getTableActionState)(editor, action, params)
11096
+ run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
11097
+ check: (action, params) => (0, import_editor19.getTableActionState)(editor, action, params)
11084
11098
  }),
11085
11099
  [snapshot, editor]
11086
11100
  );
11087
11101
  }
11088
11102
 
11089
11103
  // src/tables/TableToolbar.tsx
11090
- var import_react79 = __toESM(require("react"), 1);
11091
- var import_editor19 = require("@pixerate/editor");
11104
+ var import_react80 = __toESM(require("react"), 1);
11105
+ var import_editor20 = require("@pixerate/editor");
11092
11106
  var import_jsx_runtime55 = require("react/jsx-runtime");
11093
11107
  var keepSelection2 = (event) => event.preventDefault();
11094
11108
  var TableToolbar = ({
11095
11109
  editor,
11096
- items = import_editor19.DEFAULT_TABLE_TOOLBAR,
11110
+ items = import_editor20.DEFAULT_TABLE_TOOLBAR,
11097
11111
  showWhenOutside = false,
11098
11112
  className = "flex flex-wrap items-center gap-1 text-xs",
11099
11113
  buttonClassName = "rounded px-2 py-1 text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent",
@@ -11108,7 +11122,7 @@ var TableToolbar = ({
11108
11122
  const enabled = status === true;
11109
11123
  const active = item.active?.(table);
11110
11124
  const separator = index > 0 && items[index - 1].group !== item.group;
11111
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_react79.default.Fragment, { children: [
11125
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_react80.default.Fragment, { children: [
11112
11126
  separator && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
11113
11127
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11114
11128
  "button",
@@ -11132,7 +11146,7 @@ var TableToolbar = ({
11132
11146
  };
11133
11147
 
11134
11148
  // src/tables/InsertTableGrid.tsx
11135
- var import_react80 = require("react");
11149
+ var import_react81 = require("react");
11136
11150
  var import_jsx_runtime56 = require("react/jsx-runtime");
11137
11151
  var keepSelection3 = (event) => event.preventDefault();
11138
11152
  var InsertTableGrid = ({
@@ -11146,7 +11160,7 @@ var InsertTableGrid = ({
11146
11160
  onInsert
11147
11161
  }) => {
11148
11162
  const table = useTableMenu(editor);
11149
- const [hover, setHover] = (0, import_react80.useState)(null);
11163
+ const [hover, setHover] = (0, import_react81.useState)(null);
11150
11164
  const status = table.actions.insertTable;
11151
11165
  const disabled = !editor || !status.enabled;
11152
11166
  const insert = (size) => {
@@ -11199,7 +11213,7 @@ var InsertTableGrid = ({
11199
11213
  };
11200
11214
 
11201
11215
  // src/tables/TableBubbleMenu.tsx
11202
- var import_editor20 = require("@pixerate/editor");
11216
+ var import_editor21 = require("@pixerate/editor");
11203
11217
  var import_jsx_runtime57 = require("react/jsx-runtime");
11204
11218
  var TableBubbleMenu = ({
11205
11219
  editor,
@@ -11207,20 +11221,20 @@ var TableBubbleMenu = ({
11207
11221
  toolbarProps,
11208
11222
  pluginKey = "tableBubbleMenu",
11209
11223
  ...rest
11210
- }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor20.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TableToolbar, { editor, ...toolbarProps }) });
11224
+ }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor21.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TableToolbar, { editor, ...toolbarProps }) });
11211
11225
 
11212
11226
  // src/chart-node/ChartNodeView.tsx
11213
11227
  var import_client = require("react-dom/client");
11214
11228
 
11215
11229
  // src/chart/ChartCanvas.tsx
11216
- var import_react82 = require("react");
11230
+ var import_react83 = require("react");
11217
11231
  var import_chart2 = require("@pixerate/editor/chart");
11218
11232
 
11219
11233
  // src/chart/useChartEditor.ts
11220
- var import_react81 = require("react");
11234
+ var import_react82 = require("react");
11221
11235
  var import_chart = require("@pixerate/editor/chart");
11222
11236
  function useChartState(controller) {
11223
- return (0, import_react81.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
11237
+ return (0, import_react82.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
11224
11238
  }
11225
11239
 
11226
11240
  // src/chart/ChartCanvas.tsx
@@ -11272,7 +11286,7 @@ function renderChartMark(mark, fontFamily, interactive) {
11272
11286
  }
11273
11287
  }
11274
11288
  function ChartPresenceLayer({ presence }) {
11275
- const { actors } = (0, import_react82.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
11289
+ const { actors } = (0, import_react83.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
11276
11290
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
11277
11291
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 }, transform: a.pressed ? "scale(0.9)" : void 0 }),
11278
11292
  /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("g", { transform: "translate(13 16)", children: [
@@ -11283,12 +11297,12 @@ function ChartPresenceLayer({ presence }) {
11283
11297
  }
11284
11298
  function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef }) {
11285
11299
  const state = useChartState(controller);
11286
- const wrapper = (0, import_react82.useRef)(null);
11287
- const svg = (0, import_react82.useRef)(null);
11288
- const drag = (0, import_react82.useRef)(null);
11289
- const [measured, setMeasured] = (0, import_react82.useState)(null);
11290
- const [frozen, setFrozen] = (0, import_react82.useState)(null);
11291
- (0, import_react82.useEffect)(() => {
11300
+ const wrapper = (0, import_react83.useRef)(null);
11301
+ const svg = (0, import_react83.useRef)(null);
11302
+ const drag = (0, import_react83.useRef)(null);
11303
+ const [measured, setMeasured] = (0, import_react83.useState)(null);
11304
+ const [frozen, setFrozen] = (0, import_react83.useState)(null);
11305
+ (0, import_react83.useEffect)(() => {
11292
11306
  const el = wrapper.current;
11293
11307
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
11294
11308
  const observer = new ResizeObserver(([entry]) => {
@@ -11299,8 +11313,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
11299
11313
  return () => observer.disconnect();
11300
11314
  }, [responsive]);
11301
11315
  const sceneWidth = responsive && measured || width;
11302
- const fullTheme = (0, import_react82.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
11303
- const scene = (0, import_react82.useMemo)(
11316
+ const fullTheme = (0, import_react83.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
11317
+ const scene = (0, import_react83.useMemo)(
11304
11318
  () => (0, import_chart2.layoutChart)(state.spec, {
11305
11319
  width: sceneWidth,
11306
11320
  height,
@@ -11316,8 +11330,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
11316
11330
  [state.spec, state.selection, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
11317
11331
  );
11318
11332
  if (sceneRef) sceneRef.current = scene;
11319
- const byKey = (0, import_react82.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
11320
- (0, import_react82.useEffect)(() => () => drag.current?.end(), []);
11333
+ const byKey = (0, import_react83.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
11334
+ (0, import_react83.useEffect)(() => () => drag.current?.end(), []);
11321
11335
  const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
11322
11336
  const onPointerDown = (e) => {
11323
11337
  if (!editable || e.button !== 0) return;
@@ -11375,7 +11389,7 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
11375
11389
  }
11376
11390
 
11377
11391
  // src/chart/ChartDataGrid.tsx
11378
- var import_react83 = require("react");
11392
+ var import_react84 = require("react");
11379
11393
  var import_chart3 = require("@pixerate/editor/chart");
11380
11394
 
11381
11395
  // src/chart/styles.ts
@@ -11390,9 +11404,9 @@ var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right t
11390
11404
  // src/chart/ChartDataGrid.tsx
11391
11405
  var import_jsx_runtime59 = require("react/jsx-runtime");
11392
11406
  function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
11393
- const [draft, setDraft] = (0, import_react83.useState)(value);
11394
- const typing = (0, import_react83.useRef)(false);
11395
- (0, import_react83.useEffect)(() => {
11407
+ const [draft, setDraft] = (0, import_react84.useState)(value);
11408
+ const typing = (0, import_react84.useRef)(false);
11409
+ (0, import_react84.useEffect)(() => {
11396
11410
  if (!typing.current) setDraft(value);
11397
11411
  }, [value]);
11398
11412
  const commit = () => {
@@ -11528,7 +11542,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
11528
11542
  }
11529
11543
 
11530
11544
  // src/chart/ChartInspector.tsx
11531
- var import_react84 = require("react");
11545
+ var import_react85 = require("react");
11532
11546
  var import_chart4 = require("@pixerate/editor/chart");
11533
11547
  var import_jsx_runtime60 = require("react/jsx-runtime");
11534
11548
  var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -11693,7 +11707,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
11693
11707
  }
11694
11708
  function ChartInspector({ controller, sections, className }) {
11695
11709
  const { spec, selectedSeries } = useChartState(controller);
11696
- const idBase = (0, import_react84.useId)();
11710
+ const idBase = (0, import_react85.useId)();
11697
11711
  const show = (section) => !sections || sections.includes(section);
11698
11712
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
11699
11713
  const family = (0, import_chart4.chartFamily)(spec);
@@ -12026,6 +12040,7 @@ function createReactChartNodeView(options = {}) {
12026
12040
  usePlaybackSurface,
12027
12041
  usePromptEditor,
12028
12042
  useRegisterCommands,
12043
+ useRichTextEditorDocument,
12029
12044
  useSpreadsheetClipboard,
12030
12045
  useSpreadsheetEditor,
12031
12046
  useSpreadsheetViewport,