@gridsheet/preact-core 3.2.0 → 3.3.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.js CHANGED
@@ -1,11 +1,9 @@
1
1
  import { h, render } from "preact";
2
- import { calcSideStyle, clampPopup, clampLeft, zoneToArea, focus, Lexer, getFunctionHelps, expandInput, y2r, x2c, resetInput, handleFormulaQuoteAutoClose, areaToZone, insertTextAtCursor, operations, isRefInsertable, COLOR_PALETTE, DEFAULT_WIDTH, DEFAULT_HEIGHT, between, makeSequence, p2a, MIN_HEIGHT, MIN_WIDTH, zoneShape, getLabel, FormulaError, Pending, insertRef, areaToRange, calcBelowPosition, hAlignTransform, among, getAreaInTabular, isFocus, Autofill, getCellRectPositions, a2p, virtualize, stripAddressAbsolute, stripSheetName, preventSafariBounce, smartScroll, isZoneNotSelected, Sheet, embedStyle, getMaxSizesFromCells, HEADER_HEIGHT, DEFAULT_ROW_KEY, SHEET_HEIGHT, HEADER_WIDTH, DEFAULT_COL_KEY, SHEET_WIDTH } from "@gridsheet/core";
3
- import { BaseFunction, BaseFunctionAsync, DEFAULT_HISTORY_LIMIT, FormulaError as FormulaError2, FormulaParser, Lexer as Lexer2, Pending as Pending2, PercentagePolicyMixin, Policy, RangeEntity, RefEntity, Registry, Sheet as Sheet2, Spilling, ThousandSeparatorPolicyMixin, Time, ValueEntity, a2p as a2p2, aa2oa, addressesToAreas, addressesToCols, addressesToRows, areaToRange as areaToRange2, areaToZone as areaToZone2, buildInitialCells, buildInitialCellsFromOrigin, c2x, ch, check, conditionArg, createBook, createBooleanMask, createRegistry, eachMatrix, ensureBoolean, ensureDate, ensureNumber, ensureString, matrixShape, oa2aa, operations as operations2, p2a as p2a2, r2y, rh, stripMatrix, toCellCols, toCellMatrix, toCellObject, toCellRows, toValueCols, toValueMatrix, toValueObject, toValueRows, x2c as x2c2, y2r as y2r2, zoneToArea as zoneToArea2 } from "@gridsheet/core";
2
+ import { Z, e as ee, K, R as Rs, j, $ as $t, y as yn, u as useBrowser, s as setEditingAddress, N, W, w as write, a as setInputting, b as updateSheet, E as Et, _, V, r as redo, c as undo, d as cut, f as Ee, g as setSearchQuery, h as setEntering, i as copy, k as select, l as arrow, m as escape, n as clear, v, o as walk, p as pn, X, q as paste, t as setEditorHovering, x as _n, z as setStore, A as submitAutofill, B as setDragging, C as setAutofillDraggingTo, D as drag, F as jt, J, G as setResizingPositionY, H as setResizingPositionX, I as Vr, L as jr, M as D, P as Pr, O as kr, Q as filterRows, S as sortRows, T as Xr, U as removeCols, Y as removeRows, a0 as insertColsRight, a1 as insertColsLeft, a2 as insertRowsBelow, a3 as insertRowsAbove, a4 as setContextMenuPosition, a5 as Rn, a6 as setColumnMenu, a7 as setRowMenu, a8 as isXSheetFocused, a9 as setEditorRect, aa as x, ab as k, ac as choose, ad as Y, ae as zr, af as J$1, ag as oe, ah as Wr, ai as Q, aj as U, ak as selectCols, al as useDebounceCallback, am as selectRows, an as En, ao as O, ap as N$1, aq as q, ar as Br, as as on, at as $, au as G, av as search, aw as setSearchCaseSensitive, ax as setSearchRegex, ay as rn, az as setSearchRange, aA as useBook, aB as $$1, aC as reducer, aD as re, aE as isMutationAction, aF as Cs, aG as Re, aH as vt, aI as Dr, aJ as _e, aK as Dt, aL as vr } from "./hooks-DroLjp9H.mjs";
3
+ import { b8, b9, bq, ba, bp, bn, bd, bb, aZ, br, bo, aU, bc, aN, aR, aS, aT, aO, aP, aV, aY, bi, bl, a_, bk, a$, bj, bg, bh, bf, be, aQ, aM, aW, aX, bm, b7, b4, b5, b6, b3, b0, b1, b2, bs } from "./hooks-DroLjp9H.mjs";
4
4
  import { jsxs, jsx, Fragment } from "preact/compat/jsx-runtime";
5
5
  import React, { createContext, useRef, useContext, useLayoutEffect, useState, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
6
6
  import { Children, Component, Fragment as Fragment2, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, render as render2, createContext as createContext2, createElement, createFactory, createPortal as createPortal2, createRef as createRef2, findDOMNode, forwardRef, hydrate, isValidElement, lazy, memo as memo2, unmountComponentAtNode, unstable_batchedUpdates, useCallback as useCallback2, useContext as useContext2, useDebugValue, useEffect as useEffect2, useImperativeHandle, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useReducer as useReducer2, useRef as useRef2, useState as useState2, version } from "preact/compat";
7
- import { u as useBrowser, s as setEditingAddress, w as write, a as setInputting, b as updateSheet, r as redo, c as undo, d as cut, e as setSearchQuery, f as setEntering, g as copy, h as select, i as arrow, j as escape, k as clear, l as walk, p as paste, m as setEditorHovering, n as setStore, o as setResizingPositionY, q as setResizingPositionX, t as filterRows, v as sortRows, x as removeCols, y as removeRows, z as insertColsRight, A as insertColsLeft, B as insertRowsBelow, C as insertRowsAbove, D as setContextMenuPosition, E as setColumnMenu, F as setRowMenu, G as isXSheetFocused, H as setEditorRect, I as choose, J as drag, K as setDragging, L as submitAutofill, M as setAutofillDraggingTo, N as selectCols, O as useDebounceCallback, P as selectRows, Q as search, R as setSearchCaseSensitive, S as setSearchRegex, T as setSearchRange, U as useBook, V as reducer, W as isMutationAction } from "./hooks-ykrgAwg5.mjs";
8
- import { X } from "./hooks-ykrgAwg5.mjs";
9
7
  const Context = createContext(
10
8
  {}
11
9
  );
@@ -25,14 +23,14 @@ const FunctionGuide = ({
25
23
  if (!el) {
26
24
  return;
27
25
  }
28
- calcSideStyle(el);
26
+ Z(el);
29
27
  });
30
28
  useLayoutEffect(() => {
31
29
  const el = ref.current;
32
30
  if (!el || left === void 0) {
33
31
  return;
34
32
  }
35
- clampPopup(el);
33
+ ee(el);
36
34
  });
37
35
  if (option) {
38
36
  return /* @__PURE__ */ jsxs(
@@ -50,7 +48,7 @@ const FunctionGuide = ({
50
48
  option.isFunction && /* @__PURE__ */ jsxs(Fragment, { children: [
51
49
  /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-example", children: option.example }),
52
50
  option.description && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-desc", style: { whiteSpace: "pre-line" }, children: option.description }),
53
- option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j) => {
51
+ option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j2) => {
54
52
  var _a;
55
53
  return /* @__PURE__ */ jsxs("div", { className: "gs-fn-guide1-arg", children: [
56
54
  /* @__PURE__ */ jsx("span", { className: "gs-fn-guide1-arg-name", children: arg.name }),
@@ -61,7 +59,7 @@ const FunctionGuide = ({
61
59
  " — ",
62
60
  arg.description
63
61
  ] })
64
- ] }, j);
62
+ ] }, j2);
65
63
  }) })
66
64
  ] })
67
65
  ]
@@ -82,25 +80,25 @@ const FunctionGuide = ({
82
80
  const args = activeFunctionGuide.defs ?? [];
83
81
  const numIterable = args.filter((a) => a.variadic).length;
84
82
  const variadicStart = args.length - numIterable;
85
- return args.map((arg, j) => {
83
+ return args.map((arg, j2) => {
86
84
  let isActive;
87
85
  if (activeArgIndex < variadicStart) {
88
- isActive = activeArgIndex === j;
89
- } else if (numIterable > 0 && j >= variadicStart) {
86
+ isActive = activeArgIndex === j2;
87
+ } else if (numIterable > 0 && j2 >= variadicStart) {
90
88
  const offset = (activeArgIndex - variadicStart) % numIterable;
91
- isActive = j === variadicStart + offset;
89
+ isActive = j2 === variadicStart + offset;
92
90
  } else {
93
91
  isActive = false;
94
92
  }
95
93
  return /* @__PURE__ */ jsxs(React.Fragment, { children: [
96
- j > 0 ? ", " : "",
94
+ j2 > 0 ? ", " : "",
97
95
  /* @__PURE__ */ jsxs("span", { className: isActive ? "gs-active-arg" : "", children: [
98
96
  arg.optional ? "[" : "",
99
97
  arg.name,
100
98
  arg.variadic ? ", ..." : "",
101
99
  arg.optional ? "]" : ""
102
100
  ] })
103
- ] }, j);
101
+ ] }, j2);
104
102
  });
105
103
  })() }),
106
104
  (() => {
@@ -150,7 +148,7 @@ const EditorOptions = ({
150
148
  return;
151
149
  }
152
150
  const width = ulRef.current.getBoundingClientRect().width;
153
- setAdjustedLeft(clampLeft(left, width));
151
+ setAdjustedLeft(K(left, width));
154
152
  }, [left, filteredOptions]);
155
153
  if (filteredOptions.length === 0) {
156
154
  return null;
@@ -177,11 +175,11 @@ const clip = (store) => {
177
175
  if (!sheet) {
178
176
  return { top: 0, left: 0, bottom: 0, right: 0 };
179
177
  }
180
- const { y, x } = choosing;
181
- const selectingArea = zoneToArea(selectingZone);
178
+ const { y, x: x2 } = choosing;
179
+ const selectingArea = Rs(selectingZone);
182
180
  let area = selectingArea;
183
181
  if (area.left === -1) {
184
- area = { top: y, left: x, bottom: y, right: x };
182
+ area = { top: y, left: x2, bottom: y, right: x2 };
185
183
  }
186
184
  const input = editorRef.current;
187
185
  const trimmed = sheet.trim(area);
@@ -208,7 +206,7 @@ const clip = (store) => {
208
206
  ]);
209
207
  } else if (input != null) {
210
208
  input.value = tsv;
211
- focus(input);
209
+ j(input);
212
210
  input.select();
213
211
  document.execCommand("copy");
214
212
  input.value = "";
@@ -233,8 +231,8 @@ const sheet2csv = (sheet, {
233
231
  }
234
232
  const cols = [];
235
233
  let rowIsEmpty = true;
236
- for (let x = sheet.left; x <= sheet.right; x++) {
237
- const point = { y, x };
234
+ for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
235
+ const point = { y, x: x2 };
238
236
  const value = getter(sheet, point);
239
237
  if (value !== "") {
240
238
  rowIsEmpty = false;
@@ -269,8 +267,8 @@ const sheet2html = (sheet, {
269
267
  }
270
268
  const cols = [];
271
269
  let rowIsEmpty = true;
272
- for (let x = sheet.left; x <= sheet.right; x++) {
273
- const point = { y, x };
270
+ for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
271
+ const point = { y, x: x2 };
274
272
  const value = getter(sheet, point);
275
273
  if (value !== "") {
276
274
  rowIsEmpty = false;
@@ -299,7 +297,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
299
297
  if (isFormula && textBeforeCursor.length > 1) {
300
298
  try {
301
299
  const textToCursor = textBeforeCursor.slice(1);
302
- const lexer = new Lexer(textToCursor);
300
+ const lexer = new $t(textToCursor);
303
301
  lexer.tokenize();
304
302
  const functionStack = [];
305
303
  for (let i = 0; i < lexer.tokens.length; i++) {
@@ -326,7 +324,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
326
324
  }
327
325
  if (functionStack.length > 0) {
328
326
  const activeItem = functionStack[functionStack.length - 1];
329
- const helps = getFunctionHelps(functions);
327
+ const helps = yn(functions);
330
328
  activeArgIndex2 = activeItem.argIndex;
331
329
  activeFunctionHelp2 = helps.find((h2) => h2.name === activeItem.name.toUpperCase()) || null;
332
330
  }
@@ -341,7 +339,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
341
339
  let isOnAddress = false;
342
340
  if (isFormula) {
343
341
  try {
344
- const fullLexer = new Lexer(inputting.slice(1));
342
+ const fullLexer = new $t(inputting.slice(1));
345
343
  fullLexer.tokenize();
346
344
  let currentIndex = 1;
347
345
  for (const token of fullLexer.tokens) {
@@ -367,7 +365,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
367
365
  }
368
366
  if (isFormula && !isOnAddress) {
369
367
  if (currentWord.length > 0 && !hasOpenParenAssigned) {
370
- filtered = getFunctionHelps(functions).map((help) => {
368
+ filtered = yn(functions).map((help) => {
371
369
  const keywordLower = help.name.toLowerCase();
372
370
  const startsWith = keywordLower.startsWith(currentWord);
373
371
  const index = startsWith ? 0 : -1;
@@ -517,7 +515,7 @@ const parseHTML = (html, onlyValue = false) => {
517
515
  }
518
516
  const cells = Array.from(row.querySelectorAll("td, th"));
519
517
  const result = [];
520
- let j = 0;
518
+ let j2 = 0;
521
519
  for (const cell of cells) {
522
520
  const value = ((_b = cell.textContent) == null ? void 0 : _b.trim()) ?? "";
523
521
  const style = onlyValue ? void 0 : (() => {
@@ -525,7 +523,7 @@ const parseHTML = (html, onlyValue = false) => {
525
523
  const parentStyle = parseStyleString(cell);
526
524
  return { ...parentStyle, ...childStyle };
527
525
  })();
528
- while (spans.has(`${i}-${++j}`)) {
526
+ while (spans.has(`${i}-${++j2}`)) {
529
527
  result.push({ value: "", style, skip: true });
530
528
  }
531
529
  result.push({ value, style });
@@ -533,7 +531,7 @@ const parseHTML = (html, onlyValue = false) => {
533
531
  const colSpan = parseInt(cell.getAttribute("colspan") ?? "1", 10);
534
532
  for (let r = 0; r < rowSpan; r++) {
535
533
  for (let c = 0; c < colSpan; c++) {
536
- spans.add(`${i + r}-${j + c}`);
534
+ spans.add(`${i + r}-${j2 + c}`);
537
535
  }
538
536
  }
539
537
  }
@@ -599,7 +597,7 @@ function parseStyleString(element) {
599
597
  if (rawKey === "height" || rawKey === "width") {
600
598
  return;
601
599
  }
602
- const key = rawKey.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
600
+ const key = rawKey.trim().replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
603
601
  if (key === "float" || key === "display" || key.startsWith("padding")) {
604
602
  return;
605
603
  }
@@ -754,7 +752,10 @@ const Editor = ({ mode }) => {
754
752
  }
755
753
  const { bottom: top2, left: left2 } = rect;
756
754
  return createPortal(
757
- /* @__PURE__ */ jsxs(Fragment, { children: [
755
+ // Portaled to <body>, outside .gs-root1 / .gs-editor, so carry data-mode
756
+ // here too — otherwise the theme-specific styles (e.g. the dark function
757
+ // guide) never match and the help renders with the light palette.
758
+ /* @__PURE__ */ jsxs("div", { className: "gs-editor-portal", "data-mode": mode, children: [
758
759
  activeFunctionHelp && filteredOptions.length === 0 && (!selectingZone || selectingZone.endY === -1 && selectingZone.endX === -1) && /* @__PURE__ */ jsx(
759
760
  FunctionGuide,
760
761
  {
@@ -799,7 +800,7 @@ const Editor = ({ mode }) => {
799
800
  functions: sheet == null ? void 0 : sheet.registry.functions
800
801
  });
801
802
  useEffect(() => {
802
- focus(editorRef == null ? void 0 : editorRef.current);
803
+ j(editorRef == null ? void 0 : editorRef.current);
803
804
  }, [editorRef]);
804
805
  useEffect(() => {
805
806
  if (!sheet) {
@@ -824,14 +825,14 @@ const Editor = ({ mode }) => {
824
825
  sheet.registry.editingAddress = editingAddress;
825
826
  }, [editingAddress, sheet, sheetId]);
826
827
  useEffect(() => {
827
- expandInput(editorRef.current);
828
+ N(editorRef.current);
828
829
  }, [inputting, editingAddress, editorRef]);
829
- const { y, x } = choosing;
830
- const rowId = `${y2r(y)}`;
831
- const colId = x2c(x);
830
+ const { y, x: x2 } = choosing;
831
+ const rowId = `${Et(y)}`;
832
+ const colId = W(x2);
832
833
  const address = `${colId}${rowId}`;
833
834
  const editing = editingAddress === address;
834
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "RAW" });
835
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x2 }, { resolution: "RAW" });
835
836
  const currentString = sheet ? sheet.getSerializedValue({ point: choosing, cell, resolution: "RAW" }) : "";
836
837
  const [before, setBefore] = useState(currentString);
837
838
  const writeCell = useCallback(
@@ -855,7 +856,7 @@ const Editor = ({ mode }) => {
855
856
  dispatch(setInputting(newValue));
856
857
  setTimeout(() => {
857
858
  if (editorRef.current) {
858
- focus(editorRef.current);
859
+ j(editorRef.current);
859
860
  editorRef.current.setSelectionRange(newCursor, newCursor);
860
861
  }
861
862
  }, 0);
@@ -879,14 +880,14 @@ const Editor = ({ mode }) => {
879
880
  }
880
881
  setBefore(currentString);
881
882
  dispatch(setInputting(currentString));
882
- resetInput(editorRef.current, sheet, choosing);
883
+ _(editorRef.current, sheet, choosing);
883
884
  }, [choosing, currentString, dispatch, editorRef, sheet]);
884
885
  const { y: top, x: left, height, width } = editorRect;
885
886
  const numLines = currentString.split("\n").length;
886
887
  const [isKeyDown, setIsKeyDown] = useState(false);
887
888
  const handleKeyDown = useCallback(
888
889
  (e) => {
889
- var _a2, _b2, _c, _d, _e, _f;
890
+ var _a2, _b2, _c, _d, _e2, _f;
890
891
  if (!sheet) {
891
892
  return;
892
893
  }
@@ -903,7 +904,7 @@ const Editor = ({ mode }) => {
903
904
  });
904
905
  }
905
906
  const input = e.currentTarget;
906
- if (handleFormulaQuoteAutoClose(e, inputting)) {
907
+ if (V(e, inputting)) {
907
908
  dispatch(setInputting(input.value));
908
909
  return false;
909
910
  }
@@ -944,7 +945,7 @@ const Editor = ({ mode }) => {
944
945
  return false;
945
946
  }
946
947
  } else if (e.altKey) {
947
- insertTextAtCursor(input, "\n");
948
+ v(input, "\n");
948
949
  dispatch(setInputting(input.value));
949
950
  e.preventDefault();
950
951
  return false;
@@ -975,7 +976,7 @@ const Editor = ({ mode }) => {
975
976
  return false;
976
977
  case "Backspace":
977
978
  if (!editing) {
978
- if (((_c = sheet.getSystem({ y, x })) == null ? void 0 : _c.spilledFrom) != null) {
979
+ if (((_c = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _c.spilledFrom) != null) {
979
980
  e.preventDefault();
980
981
  return false;
981
982
  }
@@ -986,7 +987,7 @@ const Editor = ({ mode }) => {
986
987
  break;
987
988
  case "Delete":
988
989
  if (!editing) {
989
- if (((_d = sheet.getSystem({ y, x })) == null ? void 0 : _d.spilledFrom) != null) {
990
+ if (((_d = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _d.spilledFrom) != null) {
990
991
  e.preventDefault();
991
992
  return false;
992
993
  }
@@ -1094,8 +1095,8 @@ const Editor = ({ mode }) => {
1094
1095
  if (!editing) {
1095
1096
  e.preventDefault();
1096
1097
  const area = clip(store);
1097
- dispatch(copy(areaToZone(area)));
1098
- focus(input);
1098
+ dispatch(copy(Ee(area)));
1099
+ j(input);
1099
1100
  return false;
1100
1101
  }
1101
1102
  return true;
@@ -1109,7 +1110,7 @@ const Editor = ({ mode }) => {
1109
1110
  dispatch(setSearchQuery(""));
1110
1111
  }
1111
1112
  dispatch(setEntering(false));
1112
- requestAnimationFrame(() => focus(searchInputRef.current));
1113
+ requestAnimationFrame(() => j(searchInputRef.current));
1113
1114
  return false;
1114
1115
  }
1115
1116
  }
@@ -1130,7 +1131,7 @@ const Editor = ({ mode }) => {
1130
1131
  if (e.ctrlKey || e.metaKey) {
1131
1132
  if (!editing) {
1132
1133
  e.preventDefault();
1133
- (_f = (_e = sheet.registry).onSave) == null ? void 0 : _f.call(_e, {
1134
+ (_f = (_e2 = sheet.registry).onSave) == null ? void 0 : _f.call(_e2, {
1134
1135
  sheet,
1135
1136
  points: {
1136
1137
  pointing: choosing,
@@ -1159,8 +1160,8 @@ const Editor = ({ mode }) => {
1159
1160
  if (!editing) {
1160
1161
  e.preventDefault();
1161
1162
  const area = clip(store);
1162
- dispatch(cut(areaToZone(area)));
1163
- focus(input);
1163
+ dispatch(cut(Ee(area)));
1164
+ j(input);
1164
1165
  return false;
1165
1166
  }
1166
1167
  }
@@ -1190,7 +1191,7 @@ const Editor = ({ mode }) => {
1190
1191
  if (e.ctrlKey || e.metaKey) {
1191
1192
  return false;
1192
1193
  }
1193
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1194
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1194
1195
  console.warn("This cell is protected from writing.");
1195
1196
  return false;
1196
1197
  }
@@ -1231,7 +1232,7 @@ const Editor = ({ mode }) => {
1231
1232
  );
1232
1233
  const handleDoubleClick = useCallback(
1233
1234
  (e) => {
1234
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1235
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1235
1236
  console.warn("This cell is protected from writing.");
1236
1237
  return;
1237
1238
  }
@@ -1252,7 +1253,7 @@ const Editor = ({ mode }) => {
1252
1253
  const handleBlur = useCallback(
1253
1254
  (e) => {
1254
1255
  setIsFocused(false);
1255
- if (isRefInsertable(e.currentTarget)) {
1256
+ if (X(e.currentTarget)) {
1256
1257
  return true;
1257
1258
  } else {
1258
1259
  if (editing) {
@@ -1265,7 +1266,7 @@ const Editor = ({ mode }) => {
1265
1266
  );
1266
1267
  const handleChange = useCallback(
1267
1268
  (e) => {
1268
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1269
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1269
1270
  return;
1270
1271
  }
1271
1272
  dispatch(setInputting(e.currentTarget.value));
@@ -1302,7 +1303,7 @@ const Editor = ({ mode }) => {
1302
1303
  (e) => {
1303
1304
  var _a2, _b2;
1304
1305
  setShiftKey(false);
1305
- const selectingArea = zoneToArea(store.selectingZone);
1306
+ const selectingArea = Rs(store.selectingZone);
1306
1307
  (_b2 = sheet == null ? void 0 : (_a2 = sheet.registry).onKeyUp) == null ? void 0 : _b2.call(_a2, {
1307
1308
  e,
1308
1309
  points: {
@@ -1408,7 +1409,7 @@ const editorStyle = (text) => {
1408
1409
  if (text[0] !== "=") {
1409
1410
  return /* @__PURE__ */ jsx(Fragment, { children: text });
1410
1411
  }
1411
- const lexer = new Lexer(text.substring(1));
1412
+ const lexer = new $t(text.substring(1));
1412
1413
  lexer.tokenize();
1413
1414
  let palletIndex = 0;
1414
1415
  const exists = {};
@@ -1431,12 +1432,12 @@ const editorStyle = (text) => {
1431
1432
  {
1432
1433
  token,
1433
1434
  tokenKey,
1434
- color: COLOR_PALETTE[existsIndex % COLOR_PALETTE.length]
1435
+ color: _n[existsIndex % _n.length]
1435
1436
  },
1436
1437
  tokenKey
1437
1438
  );
1438
1439
  }
1439
- const color = COLOR_PALETTE[palletIndex % COLOR_PALETTE.length];
1440
+ const color = _n[palletIndex % _n.length];
1440
1441
  exists[normalizedToken] = palletIndex++;
1441
1442
  return /* @__PURE__ */ jsx(
1442
1443
  TokenSpan,
@@ -1501,6 +1502,116 @@ const StoreObserver = ({
1501
1502
  const { store, dispatch } = useContext(Context);
1502
1503
  const { sheetReactive } = store;
1503
1504
  const sheet = sheetReactive.current;
1505
+ const dragRef = useRef({ store, dispatch });
1506
+ dragRef.current = { store, dispatch };
1507
+ useEffect(() => {
1508
+ let raf = 0;
1509
+ let running = false;
1510
+ let dead = false;
1511
+ let cx = 0;
1512
+ let cy = 0;
1513
+ let lastCell = "";
1514
+ let lastExtend = 0;
1515
+ const EDGE = 0;
1516
+ const SPEED = 18;
1517
+ const stop = () => {
1518
+ running = false;
1519
+ cancelAnimationFrame(raf);
1520
+ };
1521
+ const finish = () => {
1522
+ if (dead) {
1523
+ return;
1524
+ }
1525
+ dead = true;
1526
+ stop();
1527
+ const { store: s, dispatch: d } = dragRef.current;
1528
+ if (s.autofillDraggingTo) {
1529
+ d(submitAutofill(s.autofillDraggingTo));
1530
+ }
1531
+ if (s.dragging) {
1532
+ d(setDragging(false));
1533
+ }
1534
+ };
1535
+ const tick = () => {
1536
+ var _a, _b;
1537
+ if (dead || !running) {
1538
+ return;
1539
+ }
1540
+ const { store: s, dispatch: d } = dragRef.current;
1541
+ const el = (_a = s.tabularRef) == null ? void 0 : _a.current;
1542
+ if (!el || !(s.dragging || s.autofillDraggingTo)) {
1543
+ running = false;
1544
+ return;
1545
+ }
1546
+ const r = el.getBoundingClientRect();
1547
+ const dy = cy > r.bottom - EDGE ? SPEED : cy < r.top + EDGE ? -18 : 0;
1548
+ const dx = cx > r.right - EDGE ? SPEED : cx < r.left + EDGE ? -18 : 0;
1549
+ if (dy || dx) {
1550
+ el.scrollTop += dy;
1551
+ el.scrollLeft += dx;
1552
+ const px = Math.min(Math.max(cx, r.left + 1), r.right - 1);
1553
+ const py = Math.min(Math.max(cy, r.top + 1), r.bottom - 1);
1554
+ const cell = (_b = document.elementFromPoint(px, py)) == null ? void 0 : _b.closest(".gs-cell");
1555
+ if (cell) {
1556
+ const y = Number(cell.dataset.y);
1557
+ const x2 = Number(cell.dataset.x);
1558
+ const key = y + ":" + x2;
1559
+ const now = performance.now();
1560
+ if (!Number.isNaN(y) && !Number.isNaN(x2) && key !== lastCell && now - lastExtend > 80) {
1561
+ lastCell = key;
1562
+ lastExtend = now;
1563
+ d(s.autofillDraggingTo ? setAutofillDraggingTo({ x: x2, y }) : drag({ y, x: x2 }));
1564
+ }
1565
+ }
1566
+ }
1567
+ raf = requestAnimationFrame(tick);
1568
+ };
1569
+ const onMove = (e) => {
1570
+ if (e.buttons === 0) {
1571
+ const { store: s2 } = dragRef.current;
1572
+ if (!dead && (running || s2.autofillDraggingTo != null || s2.dragging)) {
1573
+ finish();
1574
+ }
1575
+ return;
1576
+ }
1577
+ cx = e.clientX;
1578
+ cy = e.clientY;
1579
+ const { store: s } = dragRef.current;
1580
+ if (!dead && !running && (s.dragging || s.autofillDraggingTo)) {
1581
+ running = true;
1582
+ lastCell = "";
1583
+ raf = requestAnimationFrame(tick);
1584
+ }
1585
+ };
1586
+ const onDown = () => {
1587
+ dead = false;
1588
+ };
1589
+ const onUp = () => {
1590
+ dead = true;
1591
+ stop();
1592
+ const { store: s, dispatch: d } = dragRef.current;
1593
+ if (s.autofillDraggingTo) {
1594
+ d(submitAutofill(s.autofillDraggingTo));
1595
+ }
1596
+ if (s.dragging) {
1597
+ d(setDragging(false));
1598
+ }
1599
+ };
1600
+ const onLeaveWindow = () => finish();
1601
+ window.addEventListener("mousedown", onDown, true);
1602
+ window.addEventListener("mousemove", onMove, true);
1603
+ window.addEventListener("mouseup", onUp, true);
1604
+ window.addEventListener("blur", onLeaveWindow);
1605
+ document.addEventListener("mouseleave", onLeaveWindow);
1606
+ return () => {
1607
+ window.removeEventListener("mousedown", onDown, true);
1608
+ window.removeEventListener("mousemove", onMove, true);
1609
+ window.removeEventListener("mouseup", onUp, true);
1610
+ window.removeEventListener("blur", onLeaveWindow);
1611
+ document.removeEventListener("mouseleave", onLeaveWindow);
1612
+ cancelAnimationFrame(raf);
1613
+ };
1614
+ }, []);
1504
1615
  useEffect(() => {
1505
1616
  if (!sheet) {
1506
1617
  return;
@@ -1585,36 +1696,36 @@ const Resizer = () => {
1585
1696
  } = store;
1586
1697
  const sheet = sheetRef.current;
1587
1698
  const [y, startY, endY] = posY;
1588
- const [x, startX, endX] = posX;
1699
+ const [x2, startX, endX] = posX;
1589
1700
  if (mainRef.current == null || editorRef.current == null || !sheet) {
1590
1701
  return /* @__PURE__ */ jsx("div", { className: "gs-resizing gs-hidden" });
1591
1702
  }
1592
- const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x === -1 ? 0 : x }, { resolution: "SYSTEM" });
1703
+ const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x2 === -1 ? 0 : x2 }, { resolution: "SYSTEM" });
1593
1704
  const { y: offsetY, x: offsetX } = mainRef.current.getBoundingClientRect();
1594
- const baseWidth = (cell == null ? void 0 : cell.width) || DEFAULT_WIDTH;
1595
- const baseHeight = (cell == null ? void 0 : cell.height) || DEFAULT_HEIGHT;
1705
+ const baseWidth = (cell == null ? void 0 : cell.width) || jt;
1706
+ const baseHeight = (cell == null ? void 0 : cell.height) || J;
1596
1707
  const width = baseWidth + (endX - startX);
1597
1708
  const height = baseHeight + (endY - startY);
1598
1709
  const handleResizeEnd = () => {
1599
- const selectingArea = zoneToArea(selectingZone);
1710
+ const selectingArea = Rs(selectingZone);
1600
1711
  const { top, left, bottom, right } = selectingArea;
1601
1712
  const diff = {};
1602
- if (x !== -1) {
1603
- let xs = [x];
1604
- if (topHeaderSelecting && between({ start: left, end: right }, x)) {
1605
- xs = makeSequence(left, right + 1);
1713
+ if (x2 !== -1) {
1714
+ let xs = [x2];
1715
+ if (topHeaderSelecting && Vr({ start: left, end: right }, x2)) {
1716
+ xs = jr(left, right + 1);
1606
1717
  }
1607
- xs.forEach((x2) => {
1608
- diff[p2a({ y: 0, x: x2 })] = { width };
1718
+ xs.forEach((x22) => {
1719
+ diff[D({ y: 0, x: x22 })] = { width };
1609
1720
  });
1610
1721
  }
1611
1722
  if (y !== -1) {
1612
1723
  let ys = [y];
1613
- if (leftHeaderSelecting && between({ start: top, end: bottom }, y)) {
1614
- ys = makeSequence(top, bottom + 1);
1724
+ if (leftHeaderSelecting && Vr({ start: top, end: bottom }, y)) {
1725
+ ys = jr(top, bottom + 1);
1615
1726
  }
1616
1727
  ys.forEach((y2) => {
1617
- diff[p2a({ y: y2, x: 0 })] = { height };
1728
+ diff[D({ y: y2, x: 0 })] = { height };
1618
1729
  });
1619
1730
  }
1620
1731
  sheet.update({
@@ -1630,33 +1741,33 @@ const Resizer = () => {
1630
1741
  );
1631
1742
  dispatch(setResizingPositionY([-1, -1, -1]));
1632
1743
  dispatch(setResizingPositionX([-1, -1, -1]));
1633
- focus(editorRef.current);
1744
+ j(editorRef.current);
1634
1745
  };
1635
1746
  const handleResizeMove = (e) => {
1636
1747
  if (y !== -1) {
1637
1748
  let endY2 = e.clientY;
1638
1749
  const height2 = baseHeight + (endY2 - startY);
1639
- if (height2 < MIN_HEIGHT) {
1640
- endY2 += MIN_HEIGHT - height2;
1750
+ if (height2 < Pr) {
1751
+ endY2 += Pr - height2;
1641
1752
  }
1642
1753
  dispatch(setResizingPositionY([y, startY, endY2]));
1643
- } else if (x !== -1) {
1754
+ } else if (x2 !== -1) {
1644
1755
  let endX2 = e.clientX;
1645
1756
  const width2 = baseWidth + (endX2 - startX);
1646
- if (width2 < MIN_WIDTH) {
1647
- endX2 += MIN_WIDTH - width2;
1757
+ if (width2 < kr) {
1758
+ endX2 += kr - width2;
1648
1759
  }
1649
- dispatch(setResizingPositionX([x, startX, endX2]));
1760
+ dispatch(setResizingPositionX([x2, startX, endX2]));
1650
1761
  }
1651
1762
  };
1652
1763
  return /* @__PURE__ */ jsxs(
1653
1764
  "div",
1654
1765
  {
1655
- className: `gs-resizing ${y === -1 && x === -1 ? "gs-hidden" : ""}`,
1766
+ className: `gs-resizing ${y === -1 && x2 === -1 ? "gs-hidden" : ""}`,
1656
1767
  onMouseUp: handleResizeEnd,
1657
1768
  onMouseMove: handleResizeMove,
1658
1769
  children: [
1659
- /* @__PURE__ */ jsx("div", { className: `gs-line-vertical ${x === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "gs-line", style: { width: 1, height: "100%", left: endX - offsetX }, children: /* @__PURE__ */ jsxs("span", { style: { left: "-50%" }, children: [
1770
+ /* @__PURE__ */ jsx("div", { className: `gs-line-vertical ${x2 === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "gs-line", style: { width: 1, height: "100%", left: endX - offsetX }, children: /* @__PURE__ */ jsxs("span", { style: { left: "-50%" }, children: [
1660
1771
  width,
1661
1772
  "px"
1662
1773
  ] }) }) }),
@@ -1701,14 +1812,14 @@ const Emitter = () => {
1701
1812
  const copier = async ({ store, dispatch }) => {
1702
1813
  const { editorRef } = store;
1703
1814
  const area = clip(store);
1704
- dispatch(copy(areaToZone(area)));
1705
- focus(editorRef.current);
1815
+ dispatch(copy(Ee(area)));
1816
+ j(editorRef.current);
1706
1817
  };
1707
1818
  const cutter = async ({ store, dispatch }) => {
1708
1819
  const { editorRef } = store;
1709
1820
  const area = clip(store);
1710
- dispatch(cut(areaToZone(area)));
1711
- focus(editorRef.current);
1821
+ dispatch(cut(Ee(area)));
1822
+ j(editorRef.current);
1712
1823
  };
1713
1824
  const paster = async ({ store, dispatch }, onlyValue = false) => {
1714
1825
  const { editorRef } = store;
@@ -1733,118 +1844,118 @@ const paster = async ({ store, dispatch }, onlyValue = false) => {
1733
1844
  }
1734
1845
  }
1735
1846
  dispatch(paste({ matrix: cells, onlyValue }));
1736
- focus(editorRef.current);
1847
+ j(editorRef.current);
1737
1848
  };
1738
1849
  const undoer = async ({ store, dispatch }) => {
1739
1850
  const { editorRef } = store;
1740
1851
  dispatch(undo(null));
1741
- focus(editorRef.current);
1852
+ j(editorRef.current);
1742
1853
  };
1743
1854
  const redoer = async ({ store, dispatch }) => {
1744
1855
  const { editorRef } = store;
1745
1856
  dispatch(redo(null));
1746
- focus(editorRef.current);
1857
+ j(editorRef.current);
1747
1858
  };
1748
1859
  const rowsInserterAbove = async ({ store, dispatch }) => {
1749
1860
  const { selectingZone, editorRef } = store;
1750
- const { top } = zoneToArea(selectingZone);
1751
- const numRows = zoneShape(selectingZone).rows;
1861
+ const { top } = Rs(selectingZone);
1862
+ const numRows = Xr(selectingZone).rows;
1752
1863
  dispatch(insertRowsAbove({ numRows, y: top, operator: "USER" }));
1753
- focus(editorRef.current);
1864
+ j(editorRef.current);
1754
1865
  };
1755
1866
  const rowsInserterBelow = async ({ store, dispatch }) => {
1756
1867
  const { selectingZone, editorRef } = store;
1757
- const { bottom } = zoneToArea(selectingZone);
1758
- const numRows = zoneShape(selectingZone).rows;
1868
+ const { bottom } = Rs(selectingZone);
1869
+ const numRows = Xr(selectingZone).rows;
1759
1870
  dispatch(insertRowsBelow({ numRows, y: bottom, operator: "USER" }));
1760
- focus(editorRef.current);
1871
+ j(editorRef.current);
1761
1872
  };
1762
1873
  const colsInserterLeft = async ({ store, dispatch }) => {
1763
1874
  const { selectingZone, editorRef } = store;
1764
- const { left } = zoneToArea(selectingZone);
1765
- const numCols = zoneShape(selectingZone).cols;
1875
+ const { left } = Rs(selectingZone);
1876
+ const numCols = Xr(selectingZone).cols;
1766
1877
  dispatch(insertColsLeft({ numCols, x: left, operator: "USER" }));
1767
- focus(editorRef.current);
1878
+ j(editorRef.current);
1768
1879
  };
1769
1880
  const colsInserterRight = async ({ store, dispatch }) => {
1770
1881
  const { selectingZone, editorRef } = store;
1771
- const { right } = zoneToArea(selectingZone);
1772
- const numCols = zoneShape(selectingZone).cols;
1882
+ const { right } = Rs(selectingZone);
1883
+ const numCols = Xr(selectingZone).cols;
1773
1884
  dispatch(insertColsRight({ numCols, x: right, operator: "USER" }));
1774
- focus(editorRef.current);
1885
+ j(editorRef.current);
1775
1886
  };
1776
1887
  const rowsRemover = async ({ store, dispatch }) => {
1777
1888
  const { selectingZone, editorRef } = store;
1778
- const { top } = zoneToArea(selectingZone);
1779
- const numRows = zoneShape(selectingZone).rows;
1889
+ const { top } = Rs(selectingZone);
1890
+ const numRows = Xr(selectingZone).rows;
1780
1891
  dispatch(removeRows({ numRows, y: top, operator: "USER" }));
1781
- focus(editorRef.current);
1892
+ j(editorRef.current);
1782
1893
  };
1783
1894
  const colsRemover = async ({ store, dispatch }) => {
1784
1895
  const { selectingZone, editorRef } = store;
1785
- const { left } = zoneToArea(selectingZone);
1786
- const numCols = zoneShape(selectingZone).cols;
1896
+ const { left } = Rs(selectingZone);
1897
+ const numCols = Xr(selectingZone).cols;
1787
1898
  dispatch(removeCols({ numCols, x: left, operator: "USER" }));
1788
- focus(editorRef.current);
1899
+ j(editorRef.current);
1789
1900
  };
1790
- const rowsSorterAsc = async ({ store, dispatch }, x) => {
1901
+ const rowsSorterAsc = async ({ store, dispatch }, x2) => {
1791
1902
  const sheet = store.sheetReactive.current;
1792
1903
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1793
1904
  await sheet.waitForPending();
1794
1905
  }
1795
- dispatch(sortRows({ x, direction: "asc" }));
1796
- focus(store.editorRef.current);
1906
+ dispatch(sortRows({ x: x2, direction: "asc" }));
1907
+ j(store.editorRef.current);
1797
1908
  };
1798
- const rowsSorterDesc = async ({ store, dispatch }, x) => {
1909
+ const rowsSorterDesc = async ({ store, dispatch }, x2) => {
1799
1910
  const sheet = store.sheetReactive.current;
1800
1911
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1801
1912
  await sheet.waitForPending();
1802
1913
  }
1803
- dispatch(sortRows({ x, direction: "desc" }));
1804
- focus(store.editorRef.current);
1914
+ dispatch(sortRows({ x: x2, direction: "desc" }));
1915
+ j(store.editorRef.current);
1805
1916
  };
1806
- const rowsFilterer = async ({ store, dispatch }, x, filter) => {
1917
+ const rowsFilterer = async ({ store, dispatch }, x2, filter) => {
1807
1918
  const sheet = store.sheetReactive.current;
1808
1919
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1809
1920
  await sheet.waitForPending();
1810
1921
  }
1811
- dispatch(filterRows({ x, filter }));
1812
- focus(store.editorRef.current);
1922
+ dispatch(filterRows({ x: x2, filter }));
1923
+ j(store.editorRef.current);
1813
1924
  };
1814
- const rowsFilterClearer = async ({ store, dispatch }, x) => {
1815
- dispatch(filterRows({ x }));
1816
- focus(store.editorRef.current);
1925
+ const rowsFilterClearer = async ({ store, dispatch }, x2) => {
1926
+ dispatch(filterRows({ x: x2 }));
1927
+ j(store.editorRef.current);
1817
1928
  };
1818
1929
  const rowSortFixedToggler = ({ store, dispatch }, y) => {
1819
1930
  const sheet = store.sheetReactive.current;
1820
1931
  if (!sheet) {
1821
1932
  return;
1822
1933
  }
1823
- const addr = p2a({ y, x: 0 });
1934
+ const addr = D({ y, x: 0 });
1824
1935
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1825
1936
  const next = !(rowCell == null ? void 0 : rowCell.sortFixed) || void 0;
1826
1937
  sheet.update({ diff: { [addr]: { sortFixed: next } }, partial: true });
1827
1938
  dispatch(updateSheet(sheet));
1828
- focus(store.editorRef.current);
1939
+ j(store.editorRef.current);
1829
1940
  };
1830
1941
  const rowFilterFixedToggler = ({ store, dispatch }, y) => {
1831
1942
  const sheet = store.sheetReactive.current;
1832
1943
  if (!sheet) {
1833
1944
  return;
1834
1945
  }
1835
- const addr = p2a({ y, x: 0 });
1946
+ const addr = D({ y, x: 0 });
1836
1947
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1837
1948
  const next = !(rowCell == null ? void 0 : rowCell.filterFixed) || void 0;
1838
1949
  sheet.update({ diff: { [addr]: { filterFixed: next } }, partial: true });
1839
1950
  dispatch(updateSheet(sheet));
1840
- focus(store.editorRef.current);
1951
+ j(store.editorRef.current);
1841
1952
  };
1842
1953
  const searcher = async ({ store, dispatch }) => {
1843
1954
  if (typeof store.searchQuery === "undefined") {
1844
1955
  dispatch(setSearchQuery(""));
1845
1956
  }
1846
1957
  dispatch(setEntering(false));
1847
- requestAnimationFrame(() => focus(store.searchInputRef.current));
1958
+ requestAnimationFrame(() => j(store.searchInputRef.current));
1848
1959
  };
1849
1960
  const applyers = {
1850
1961
  copy: copier,
@@ -1873,12 +1984,12 @@ const rowInsertCount = (ctx, y) => {
1873
1984
  const isFullRow = selectingZone.startX === 1 && selectingZone.endX === ctx.sheet.numCols;
1874
1985
  return isFullRow && y >= selStart && y <= selEnd ? selEnd - selStart + 1 : 1;
1875
1986
  };
1876
- const colInsertCount = (ctx, x) => {
1987
+ const colInsertCount = (ctx, x2) => {
1877
1988
  const { selectingZone } = ctx;
1878
1989
  const selStart = Math.min(selectingZone.startX, selectingZone.endX);
1879
1990
  const selEnd = Math.max(selectingZone.startX, selectingZone.endX);
1880
1991
  const isFullCol = selectingZone.startY === 1 && selectingZone.endY === ctx.sheet.numRows;
1881
- return isFullCol && x >= selStart && x <= selEnd ? selEnd - selStart + 1 : 1;
1992
+ return isFullCol && x2 >= selStart && x2 <= selEnd ? selEnd - selStart + 1 : 1;
1882
1993
  };
1883
1994
  const defaultContextMenuDescriptors = [
1884
1995
  {
@@ -1909,92 +2020,92 @@ const defaultContextMenuDescriptors = [
1909
2020
  {
1910
2021
  id: "insert-rows-above",
1911
2022
  label: (ctx) => {
1912
- const n = zoneShape(ctx.selectingZone).rows;
2023
+ const n = Xr(ctx.selectingZone).rows;
1913
2024
  return `Insert ${n} row${n > 1 ? "s" : ""} above`;
1914
2025
  },
1915
2026
  visible: (ctx) => ctx.leftHeaderSelecting,
1916
2027
  disabled: (ctx) => {
1917
- const n = zoneShape(ctx.selectingZone).rows;
2028
+ const n = Xr(ctx.selectingZone).rows;
1918
2029
  const sheet = ctx.sheet;
1919
2030
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1920
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
2031
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
1921
2032
  },
1922
- onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2033
+ onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1923
2034
  },
1924
2035
  {
1925
2036
  id: "insert-rows-below",
1926
2037
  label: (ctx) => {
1927
- const n = zoneShape(ctx.selectingZone).rows;
2038
+ const n = Xr(ctx.selectingZone).rows;
1928
2039
  return `Insert ${n} row${n > 1 ? "s" : ""} below`;
1929
2040
  },
1930
2041
  visible: (ctx) => ctx.leftHeaderSelecting,
1931
2042
  disabled: (ctx) => {
1932
- const n = zoneShape(ctx.selectingZone).rows;
2043
+ const n = Xr(ctx.selectingZone).rows;
1933
2044
  const sheet = ctx.sheet;
1934
2045
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1935
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
2046
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
1936
2047
  },
1937
- onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2048
+ onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1938
2049
  },
1939
2050
  {
1940
2051
  id: "insert-cols-left",
1941
2052
  label: (ctx) => {
1942
- const n = zoneShape(ctx.selectingZone).cols;
2053
+ const n = Xr(ctx.selectingZone).cols;
1943
2054
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
1944
2055
  },
1945
2056
  visible: (ctx) => ctx.topHeaderSelecting,
1946
2057
  disabled: (ctx) => {
1947
- const n = zoneShape(ctx.selectingZone).cols;
2058
+ const n = Xr(ctx.selectingZone).cols;
1948
2059
  const sheet = ctx.sheet;
1949
2060
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1950
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
2061
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsLeft);
1951
2062
  },
1952
- onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2063
+ onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1953
2064
  },
1954
2065
  {
1955
2066
  id: "insert-cols-right",
1956
2067
  label: (ctx) => {
1957
- const n = zoneShape(ctx.selectingZone).cols;
2068
+ const n = Xr(ctx.selectingZone).cols;
1958
2069
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
1959
2070
  },
1960
2071
  visible: (ctx) => ctx.topHeaderSelecting,
1961
2072
  disabled: (ctx) => {
1962
- const n = zoneShape(ctx.selectingZone).cols;
2073
+ const n = Xr(ctx.selectingZone).cols;
1963
2074
  const sheet = ctx.sheet;
1964
2075
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1965
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
2076
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsRight);
1966
2077
  },
1967
- onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2078
+ onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1968
2079
  },
1969
2080
  {
1970
2081
  id: "remove-rows",
1971
2082
  label: (ctx) => {
1972
- const n = zoneShape(ctx.selectingZone).rows;
2083
+ const n = Xr(ctx.selectingZone).rows;
1973
2084
  return `Remove ${n} row${n > 1 ? "s" : ""}`;
1974
2085
  },
1975
2086
  visible: (ctx) => ctx.leftHeaderSelecting,
1976
2087
  disabled: (ctx) => {
1977
- const n = zoneShape(ctx.selectingZone).rows;
2088
+ const n = Xr(ctx.selectingZone).rows;
1978
2089
  const sheet = ctx.sheet;
1979
2090
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1980
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
2091
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
1981
2092
  },
1982
- onClick: (ctx) => ctx.removeRows(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2093
+ onClick: (ctx) => ctx.removeRows(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1983
2094
  },
1984
2095
  {
1985
2096
  id: "remove-cols",
1986
2097
  label: (ctx) => {
1987
- const n = zoneShape(ctx.selectingZone).cols;
2098
+ const n = Xr(ctx.selectingZone).cols;
1988
2099
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
1989
2100
  },
1990
2101
  visible: (ctx) => ctx.topHeaderSelecting,
1991
2102
  disabled: (ctx) => {
1992
- const n = zoneShape(ctx.selectingZone).cols;
2103
+ const n = Xr(ctx.selectingZone).cols;
1993
2104
  const sheet = ctx.sheet;
1994
2105
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1995
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
2106
+ return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.RemoveCols);
1996
2107
  },
1997
- onClick: (ctx) => ctx.removeCols(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2108
+ onClick: (ctx) => ctx.removeCols(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1998
2109
  },
1999
2110
  { type: "divider" },
2000
2111
  {
@@ -2055,7 +2166,7 @@ const defaultRowMenuDescriptors = [
2055
2166
  const n = rowInsertCount(ctx, y);
2056
2167
  const sheet = ctx.sheet;
2057
2168
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2058
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
2169
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
2059
2170
  },
2060
2171
  onClick: (ctx, y) => ctx.insertRowsAbove(y, rowInsertCount(ctx, y))
2061
2172
  },
@@ -2069,7 +2180,7 @@ const defaultRowMenuDescriptors = [
2069
2180
  const n = rowInsertCount(ctx, y);
2070
2181
  const sheet = ctx.sheet;
2071
2182
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2072
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
2183
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
2073
2184
  },
2074
2185
  onClick: (ctx, y) => ctx.insertRowsBelow(y, rowInsertCount(ctx, y))
2075
2186
  },
@@ -2083,7 +2194,7 @@ const defaultRowMenuDescriptors = [
2083
2194
  const n = rowInsertCount(ctx, y);
2084
2195
  const sheet = ctx.sheet;
2085
2196
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2086
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
2197
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
2087
2198
  },
2088
2199
  onClick: (ctx, y) => ctx.removeRows(y, rowInsertCount(ctx, y))
2089
2200
  },
@@ -2115,6 +2226,8 @@ const defaultRowMenuDescriptors = [
2115
2226
  }
2116
2227
  ];
2117
2228
  const defaultColMenuDescriptors = [
2229
+ { type: "component", componentId: "col-label" },
2230
+ { type: "divider" },
2118
2231
  { type: "component", componentId: "col-filter" },
2119
2232
  { type: "divider" },
2120
2233
  { type: "component", componentId: "col-sort" },
@@ -2146,45 +2259,45 @@ const defaultColMenuDescriptors = [
2146
2259
  { type: "divider" },
2147
2260
  {
2148
2261
  id: "insert-cols-left",
2149
- label: (ctx, x) => {
2150
- const n = colInsertCount(ctx, x);
2262
+ label: (ctx, x2) => {
2263
+ const n = colInsertCount(ctx, x2);
2151
2264
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
2152
2265
  },
2153
- disabled: (ctx, x) => {
2154
- const n = colInsertCount(ctx, x);
2266
+ disabled: (ctx, x2) => {
2267
+ const n = colInsertCount(ctx, x2);
2155
2268
  const sheet = ctx.sheet;
2156
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2157
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
2269
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2270
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsLeft);
2158
2271
  },
2159
- onClick: (ctx, x) => ctx.insertColsLeft(x, colInsertCount(ctx, x))
2272
+ onClick: (ctx, x2) => ctx.insertColsLeft(x2, colInsertCount(ctx, x2))
2160
2273
  },
2161
2274
  {
2162
2275
  id: "insert-cols-right",
2163
- label: (ctx, x) => {
2164
- const n = colInsertCount(ctx, x);
2276
+ label: (ctx, x2) => {
2277
+ const n = colInsertCount(ctx, x2);
2165
2278
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
2166
2279
  },
2167
- disabled: (ctx, x) => {
2168
- const n = colInsertCount(ctx, x);
2280
+ disabled: (ctx, x2) => {
2281
+ const n = colInsertCount(ctx, x2);
2169
2282
  const sheet = ctx.sheet;
2170
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2171
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
2283
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2284
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsRight);
2172
2285
  },
2173
- onClick: (ctx, x) => ctx.insertColsRight(x, colInsertCount(ctx, x))
2286
+ onClick: (ctx, x2) => ctx.insertColsRight(x2, colInsertCount(ctx, x2))
2174
2287
  },
2175
2288
  {
2176
2289
  id: "remove-cols",
2177
- label: (ctx, x) => {
2178
- const n = colInsertCount(ctx, x);
2290
+ label: (ctx, x2) => {
2291
+ const n = colInsertCount(ctx, x2);
2179
2292
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
2180
2293
  },
2181
- disabled: (ctx, x) => {
2182
- const n = colInsertCount(ctx, x);
2294
+ disabled: (ctx, x2) => {
2295
+ const n = colInsertCount(ctx, x2);
2183
2296
  const sheet = ctx.sheet;
2184
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2185
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
2297
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2298
+ return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.RemoveCols);
2186
2299
  },
2187
- onClick: (ctx, x) => ctx.removeCols(x, colInsertCount(ctx, x))
2300
+ onClick: (ctx, x2) => ctx.removeCols(x2, colInsertCount(ctx, x2))
2188
2301
  },
2189
2302
  { type: "divider" },
2190
2303
  {
@@ -2192,9 +2305,7 @@ const defaultColMenuDescriptors = [
2192
2305
  label: "Search",
2193
2306
  shortcuts: ["F"],
2194
2307
  onClick: (ctx) => ctx.search()
2195
- },
2196
- { type: "divider" },
2197
- { type: "component", componentId: "col-label" }
2308
+ }
2198
2309
  ];
2199
2310
  function buildMenuContext(store, dispatch, close) {
2200
2311
  const props = { store, dispatch };
@@ -2219,38 +2330,38 @@ function buildMenuContext(store, dispatch, close) {
2219
2330
  removeRows: (y, numRows) => {
2220
2331
  dispatch(removeRows({ numRows, y, operator: "USER" }));
2221
2332
  },
2222
- insertColsLeft: (x, numCols) => {
2223
- dispatch(insertColsLeft({ numCols, x, operator: "USER" }));
2333
+ insertColsLeft: (x2, numCols) => {
2334
+ dispatch(insertColsLeft({ numCols, x: x2, operator: "USER" }));
2224
2335
  },
2225
- insertColsRight: (x, numCols) => {
2226
- dispatch(insertColsRight({ numCols, x, operator: "USER" }));
2336
+ insertColsRight: (x2, numCols) => {
2337
+ dispatch(insertColsRight({ numCols, x: x2, operator: "USER" }));
2227
2338
  },
2228
- removeCols: (x, numCols) => {
2229
- dispatch(removeCols({ numCols, x, operator: "USER" }));
2339
+ removeCols: (x2, numCols) => {
2340
+ dispatch(removeCols({ numCols, x: x2, operator: "USER" }));
2230
2341
  },
2231
- sortRows: async (x, direction) => {
2342
+ sortRows: async (x2, direction) => {
2232
2343
  if (direction === "asc") {
2233
- await rowsSorterAsc(props, x);
2344
+ await rowsSorterAsc(props, x2);
2234
2345
  } else {
2235
- await rowsSorterDesc(props, x);
2346
+ await rowsSorterDesc(props, x2);
2236
2347
  }
2237
2348
  },
2238
- filterRows: async (x, filter) => {
2349
+ filterRows: async (x2, filter) => {
2239
2350
  if (filter) {
2240
- await rowsFilterer(props, x, filter);
2351
+ await rowsFilterer(props, x2, filter);
2241
2352
  } else {
2242
- rowsFilterClearer(props, x);
2353
+ rowsFilterClearer(props, x2);
2243
2354
  }
2244
2355
  },
2245
- clearFilter: (x) => rowsFilterClearer(props, x),
2356
+ clearFilter: (x2) => rowsFilterClearer(props, x2),
2246
2357
  toggleSortFixed: (y) => rowSortFixedToggler(props, y),
2247
2358
  toggleFilterFixed: (y) => rowFilterFixedToggler(props, y),
2248
2359
  search: () => searcher(props),
2249
- updateColLabel: (x, label) => {
2360
+ updateColLabel: (x2, label) => {
2250
2361
  if (!sheet) {
2251
2362
  return;
2252
2363
  }
2253
- const addr = p2a({ y: 0, x });
2364
+ const addr = D({ y: 0, x: x2 });
2254
2365
  sheet.update({
2255
2366
  diff: { [addr]: { label: label || void 0 } },
2256
2367
  partial: true,
@@ -2301,10 +2412,10 @@ const MenuItem = ({
2301
2412
  shortcuts != null && shortcuts.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-menu-shortcut", children: shortcuts.map((shortcut, i) => /* @__PURE__ */ jsxs("span", { children: [
2302
2413
  i > 0 && /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-sep", children: ", " }),
2303
2414
  /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-badge", children: shortcut.split("+").map(
2304
- (part, j, arr) => j < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2415
+ (part, j2, arr) => j2 < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2305
2416
  part,
2306
2417
  "+"
2307
- ] }, j) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j)
2418
+ ] }, j2) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j2)
2308
2419
  ) })
2309
2420
  ] }, i)) })
2310
2421
  ]
@@ -2319,7 +2430,7 @@ const ContextMenu = () => {
2319
2430
  const menuRef = useRef(null);
2320
2431
  useEffect(() => {
2321
2432
  if (menuRef.current) {
2322
- clampPopup(menuRef.current);
2433
+ ee(menuRef.current);
2323
2434
  }
2324
2435
  });
2325
2436
  if (top === -1) {
@@ -2385,7 +2496,7 @@ const METHOD_LABELS = {
2385
2496
  };
2386
2497
  const NO_VALUE_METHODS = ["blank", "nonblank"];
2387
2498
  const DEFAULT_CONDITION = { method: "eq", value: [""] };
2388
- const FilterSection = ({ x, close, onWaiting }) => {
2499
+ const FilterSection = ({ x: x2, close, onWaiting }) => {
2389
2500
  const { store, dispatch } = useContext(Context);
2390
2501
  const { sheetReactive: sheetRef } = store;
2391
2502
  const sheet = sheetRef.current;
@@ -2399,11 +2510,11 @@ const FilterSection = ({ x, close, onWaiting }) => {
2399
2510
  }
2400
2511
  },
2401
2512
  // eslint-disable-next-line react-hooks/exhaustive-deps
2402
- [x]
2513
+ [x2]
2403
2514
  );
2404
2515
  useEffect(() => {
2405
2516
  if (sheet) {
2406
- const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2517
+ const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2407
2518
  const existing = colCell2 == null ? void 0 : colCell2.filter;
2408
2519
  if (existing && existing.conditions.length > 0) {
2409
2520
  setConditions(existing.conditions.map((c) => ({ ...c, value: [...c.value] })));
@@ -2413,7 +2524,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2413
2524
  setMode("or");
2414
2525
  }
2415
2526
  }
2416
- }, [x, sheet]);
2527
+ }, [x2, sheet]);
2417
2528
  const handleCancel = useCallback(() => {
2418
2529
  setPending(null);
2419
2530
  onWaiting == null ? void 0 : onWaiting(null);
@@ -2472,7 +2583,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2472
2583
  if (prev.length <= 1) {
2473
2584
  return [{ ...DEFAULT_CONDITION, value: [""] }];
2474
2585
  }
2475
- return prev.filter((_, i) => i !== index);
2586
+ return prev.filter((_2, i) => i !== index);
2476
2587
  });
2477
2588
  }, []);
2478
2589
  const handleApplyFilter = useCallback(() => {
@@ -2480,15 +2591,15 @@ const FilterSection = ({ x, close, onWaiting }) => {
2480
2591
  if (NO_VALUE_METHODS.includes(c.method)) {
2481
2592
  return true;
2482
2593
  }
2483
- return c.value.some((v) => v.trim() !== "");
2594
+ return c.value.some((v2) => v2.trim() !== "");
2484
2595
  });
2485
- setPending({ x, conditions: valid, mode });
2486
- }, [x, conditions, mode]);
2596
+ setPending({ x: x2, conditions: valid, mode });
2597
+ }, [x2, conditions, mode]);
2487
2598
  const handleResetColumn = useCallback(() => {
2488
2599
  setPending(null);
2489
- dispatch(filterRows({ x }));
2600
+ dispatch(filterRows({ x: x2 }));
2490
2601
  close();
2491
- }, [dispatch, x, close]);
2602
+ }, [dispatch, x2, close]);
2492
2603
  const handleResetAll = useCallback(() => {
2493
2604
  setPending(null);
2494
2605
  dispatch(filterRows({}));
@@ -2497,8 +2608,8 @@ const FilterSection = ({ x, close, onWaiting }) => {
2497
2608
  if (!sheet) {
2498
2609
  return null;
2499
2610
  }
2500
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2501
- const filterDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Filter);
2611
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2612
+ const filterDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Filter);
2502
2613
  const hasAnyFilter = sheet.hasActiveFilters();
2503
2614
  return /* @__PURE__ */ jsx("li", { className: `gs-column-menu-filter${filterDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs(Fragment, { children: [
2504
2615
  /* @__PURE__ */ jsxs("div", { className: "gs-filter-header", children: [
@@ -2590,7 +2701,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2590
2701
  ] }) });
2591
2702
  };
2592
2703
  registerMenuComponent("col-filter", FilterSection);
2593
- const SortSection = ({ x, close, onWaiting }) => {
2704
+ const SortSection = ({ x: x2, close, onWaiting }) => {
2594
2705
  const { store, dispatch } = useContext(Context);
2595
2706
  const { sheetReactive: sheetRef } = store;
2596
2707
  const sheet = sheetRef.current;
@@ -2636,8 +2747,8 @@ const SortSection = ({ x, close, onWaiting }) => {
2636
2747
  if (!sheet) {
2637
2748
  return null;
2638
2749
  }
2639
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2640
- const sortDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Sort);
2750
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2751
+ const sortDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Sort);
2641
2752
  return /* @__PURE__ */ jsxs("li", { className: `gs-menu-item gs-column-menu-sort${sortDisabled ? " gs-disabled" : ""}`, children: [
2642
2753
  /* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: "Sort:" }),
2643
2754
  /* @__PURE__ */ jsxs("div", { className: "gs-sort-buttons", children: [
@@ -2648,7 +2759,7 @@ const SortSection = ({ x, close, onWaiting }) => {
2648
2759
  onClick: (e) => {
2649
2760
  e.stopPropagation();
2650
2761
  if (!sortDisabled) {
2651
- setPending({ x, direction: "asc" });
2762
+ setPending({ x: x2, direction: "asc" });
2652
2763
  }
2653
2764
  },
2654
2765
  disabled: sortDisabled,
@@ -2662,7 +2773,7 @@ const SortSection = ({ x, close, onWaiting }) => {
2662
2773
  onClick: (e) => {
2663
2774
  e.stopPropagation();
2664
2775
  if (!sortDisabled) {
2665
- setPending({ x, direction: "desc" });
2776
+ setPending({ x: x2, direction: "desc" });
2666
2777
  }
2667
2778
  },
2668
2779
  disabled: sortDisabled,
@@ -2673,23 +2784,35 @@ const SortSection = ({ x, close, onWaiting }) => {
2673
2784
  ] });
2674
2785
  };
2675
2786
  registerMenuComponent("col-sort", SortSection);
2676
- const LabelSection = ({ x, close }) => {
2787
+ const LabelSection = ({ x: x2, close }) => {
2677
2788
  const { store, dispatch } = useContext(Context);
2678
2789
  const { sheetReactive: sheetRef } = store;
2679
2790
  const sheet = sheetRef.current;
2680
2791
  const labelInputRef = useRef(null);
2681
2792
  const [label, setLabel] = useState("");
2682
2793
  useEffect(() => {
2794
+ var _a;
2683
2795
  if (sheet) {
2684
- const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2796
+ const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2685
2797
  setLabel((colCell2 == null ? void 0 : colCell2.label) ?? "");
2686
2798
  }
2687
- }, [x, sheet]);
2799
+ if ((_a = store.columnMenuState) == null ? void 0 : _a.focusLabel) {
2800
+ requestAnimationFrame(
2801
+ () => requestAnimationFrame(() => {
2802
+ const input = labelInputRef.current;
2803
+ if (input) {
2804
+ input.focus();
2805
+ input.setSelectionRange(0, input.value.length);
2806
+ }
2807
+ })
2808
+ );
2809
+ }
2810
+ }, [x2, sheet]);
2688
2811
  const handleApplyLabel = useCallback(() => {
2689
2812
  if (!sheet) {
2690
2813
  return;
2691
2814
  }
2692
- const address = p2a({ y: 0, x });
2815
+ const address = D({ y: 0, x: x2 });
2693
2816
  sheet.update({
2694
2817
  diff: { [address]: { label: label || void 0 } },
2695
2818
  partial: true,
@@ -2707,13 +2830,13 @@ const LabelSection = ({ x, close }) => {
2707
2830
  });
2708
2831
  dispatch(setStore({ sheetReactive: { current: sheet } }));
2709
2832
  close();
2710
- }, [dispatch, x, label, close, sheet, store.selectingZone, store.choosing]);
2833
+ }, [dispatch, x2, label, close, sheet, store.selectingZone, store.choosing]);
2711
2834
  if (!sheet) {
2712
2835
  return null;
2713
2836
  }
2714
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2715
- const labelDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.SetLabel);
2716
- const labelPlaceholder = getLabel(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ?? x2c(x);
2837
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2838
+ const labelDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.SetLabel);
2839
+ const labelPlaceholder = Rn(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x: x2 }, x2) ?? W(x2);
2717
2840
  return /* @__PURE__ */ jsx("li", { className: `gs-menu-item gs-column-menu-label${labelDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs("label", { className: "gs-label-input-row", children: [
2718
2841
  /* @__PURE__ */ jsx("div", { className: "gs-label-input-label", children: "Label:" }),
2719
2842
  /* @__PURE__ */ jsx(
@@ -2747,12 +2870,12 @@ const ColumnMenu = () => {
2747
2870
  const { store, dispatch } = useContext(Context);
2748
2871
  const { columnMenuState, editorRef, colMenu } = store;
2749
2872
  const sheet = store.sheetReactive.current;
2750
- const x = columnMenuState == null ? void 0 : columnMenuState.x;
2873
+ const x2 = columnMenuState == null ? void 0 : columnMenuState.x;
2751
2874
  const position = columnMenuState == null ? void 0 : columnMenuState.position;
2752
2875
  const [waitingState, setWaitingState] = useState(null);
2753
2876
  const handleClose = useCallback(() => {
2754
2877
  dispatch(setColumnMenu(null));
2755
- focus(editorRef.current);
2878
+ j(editorRef.current);
2756
2879
  }, [dispatch, editorRef]);
2757
2880
  const handleWaiting = useCallback(
2758
2881
  (message, cancel) => {
@@ -2764,7 +2887,7 @@ const ColumnMenu = () => {
2764
2887
  },
2765
2888
  [handleClose]
2766
2889
  );
2767
- if (!columnMenuState || !sheet || x == null || !position) {
2890
+ if (!columnMenuState || !sheet || x2 == null || !position) {
2768
2891
  return null;
2769
2892
  }
2770
2893
  const ctx = buildMenuContext(store, dispatch, handleClose);
@@ -2789,7 +2912,7 @@ const ColumnMenu = () => {
2789
2912
  children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: colMenu.map((descriptor, index) => {
2790
2913
  var _a;
2791
2914
  if (descriptor.type === "component") {
2792
- const visible2 = !descriptor.visible || descriptor.visible(ctx, x);
2915
+ const visible2 = !descriptor.visible || descriptor.visible(ctx, x2);
2793
2916
  if (!visible2) {
2794
2917
  return null;
2795
2918
  }
@@ -2797,7 +2920,7 @@ const ColumnMenu = () => {
2797
2920
  if (!Section) {
2798
2921
  return null;
2799
2922
  }
2800
- return /* @__PURE__ */ jsx(Section, { x, close: handleClose, onWaiting: handleWaiting }, index);
2923
+ return /* @__PURE__ */ jsx(Section, { x: x2, close: handleClose, onWaiting: handleWaiting }, index);
2801
2924
  }
2802
2925
  if (descriptor.type === "divider") {
2803
2926
  if (descriptor.visible && !descriptor.visible(ctx)) {
@@ -2805,13 +2928,13 @@ const ColumnMenu = () => {
2805
2928
  }
2806
2929
  return /* @__PURE__ */ jsx(MenuDivider, {}, index);
2807
2930
  }
2808
- const visible = !descriptor.visible || descriptor.visible(ctx, x);
2931
+ const visible = !descriptor.visible || descriptor.visible(ctx, x2);
2809
2932
  if (!visible) {
2810
2933
  return null;
2811
2934
  }
2812
- const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, x)) ?? false;
2813
- const label = typeof descriptor.label === "function" ? descriptor.label(ctx, x) : descriptor.label;
2814
- const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, x) : descriptor.shortcuts;
2935
+ const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, x2)) ?? false;
2936
+ const label = typeof descriptor.label === "function" ? descriptor.label(ctx, x2) : descriptor.label;
2937
+ const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, x2) : descriptor.shortcuts;
2815
2938
  return /* @__PURE__ */ jsx(
2816
2939
  MenuItem,
2817
2940
  {
@@ -2820,7 +2943,7 @@ const ColumnMenu = () => {
2820
2943
  disabled,
2821
2944
  testId: descriptor.id ? `${descriptor.id}-item` : void 0,
2822
2945
  onClick: () => {
2823
- descriptor.onClick(ctx, x);
2946
+ descriptor.onClick(ctx, x2);
2824
2947
  dispatch(setColumnMenu(null));
2825
2948
  }
2826
2949
  },
@@ -2886,7 +3009,7 @@ const RowMenu = () => {
2886
3009
  const position = rowMenuState == null ? void 0 : rowMenuState.position;
2887
3010
  const handleClose = () => {
2888
3011
  dispatch(setRowMenu(null));
2889
- focus(editorRef.current);
3012
+ j(editorRef.current);
2890
3013
  };
2891
3014
  if (!rowMenuState || !sheet || y == null || !position) {
2892
3015
  return null;
@@ -2920,10 +3043,10 @@ const safePreventDefault = (e) => {
2920
3043
  e.preventDefault();
2921
3044
  }
2922
3045
  };
2923
- const Cell = memo(({ y, x }) => {
3046
+ const Cell = memo(({ y, x: x$1 }) => {
2924
3047
  var _a;
2925
- const rowId = y2r(y);
2926
- const colId = x2c(x);
3048
+ const rowId = Et(y);
3049
+ const colId = W(x$1);
2927
3050
  const address = `${colId}${rowId}`;
2928
3051
  const { store, dispatch } = useContext(Context);
2929
3052
  const isFirstPointed = useRef(true);
@@ -2943,9 +3066,9 @@ const Cell = memo(({ y, x }) => {
2943
3066
  const sheet = sheetReactive.current;
2944
3067
  const xSheetFocused = isXSheetFocused(store);
2945
3068
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
2946
- const selectingArea = zoneToArea(selectingZone);
3069
+ const selectingArea = Rs(selectingZone);
2947
3070
  const editing = editingAddress === address;
2948
- const pointed = choosing.y === y && choosing.x === x;
3071
+ const pointed = choosing.y === y && choosing.x === x$1;
2949
3072
  const _setEditorRect = useCallback(() => {
2950
3073
  var _a2;
2951
3074
  const rect = (_a2 = cellRef.current) == null ? void 0 : _a2.getBoundingClientRect();
@@ -2968,7 +3091,7 @@ const Cell = memo(({ y, x }) => {
2968
3091
  }
2969
3092
  isFirstPointed.current = false;
2970
3093
  }, [pointed, editing, _setEditorRect]);
2971
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "SYSTEM" });
3094
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x$1 }, { resolution: "SYSTEM" });
2972
3095
  const writeCell = useCallback(
2973
3096
  (value) => {
2974
3097
  dispatch(write({ value }));
@@ -2985,10 +3108,10 @@ const Cell = memo(({ y, x }) => {
2985
3108
  let rendered;
2986
3109
  try {
2987
3110
  if (sheet) {
2988
- rendered = sheet.render({ sheet, point: { y, x }, apply, value: void 0 });
3111
+ rendered = sheet.render({ sheet, point: { y, x: x$1 }, apply, value: void 0 });
2989
3112
  }
2990
3113
  } catch (e) {
2991
- if (FormulaError.is(e)) {
3114
+ if (x.is(e)) {
2992
3115
  errorMessage = e.message;
2993
3116
  rendered = e.code;
2994
3117
  } else {
@@ -2996,8 +3119,8 @@ const Cell = memo(({ y, x }) => {
2996
3119
  rendered = "#UNKNOWN";
2997
3120
  }
2998
3121
  }
2999
- const [, v] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x })) ?? [void 0, void 0];
3000
- const isPendingCell = Pending.is(v);
3122
+ const [, v2] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x: x$1 })) ?? [void 0, void 0];
3123
+ const isPendingCell = k.is(v2);
3001
3124
  const input = editorRef.current;
3002
3125
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
3003
3126
  const handleDragStart = useCallback(
@@ -3017,25 +3140,25 @@ const Cell = memo(({ y, x }) => {
3017
3140
  if (editingAnywhere && input) {
3018
3141
  input.blur();
3019
3142
  }
3020
- dispatch(choose({ y, x }));
3021
- dispatch(select({ startY: y, startX: x, endY: y, endX: x }));
3143
+ dispatch(choose({ y, x: x$1 }));
3144
+ dispatch(select({ startY: y, startX: x$1, endY: y, endX: x$1 }));
3022
3145
  return true;
3023
3146
  }
3024
3147
  if (e.shiftKey) {
3025
- dispatch(drag({ y, x }));
3148
+ dispatch(drag({ y, x: x$1 }));
3026
3149
  } else {
3027
- dispatch(select({ startY: y, startX: x, endY: -1, endX: -1 }));
3150
+ dispatch(select({ startY: y, startX: x$1, endY: -1, endX: -1 }));
3028
3151
  }
3029
3152
  dispatch(setDragging(true));
3030
3153
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${address}`;
3031
3154
  if (editingAnywhere) {
3032
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3155
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3033
3156
  if (inserted) {
3034
3157
  return false;
3035
3158
  }
3036
3159
  }
3037
3160
  sheet.registry.lastFocused = input;
3038
- focus(input);
3161
+ j(input);
3039
3162
  dispatch(setEditingAddress(""));
3040
3163
  if (autofillDraggingTo) {
3041
3164
  return false;
@@ -3044,7 +3167,7 @@ const Cell = memo(({ y, x }) => {
3044
3167
  writeCell(input.value);
3045
3168
  }
3046
3169
  if (!e.shiftKey) {
3047
- dispatch(choose({ y, x }));
3170
+ dispatch(choose({ y, x: x$1 }));
3048
3171
  }
3049
3172
  return true;
3050
3173
  },
@@ -3058,16 +3181,11 @@ const Cell = memo(({ y, x }) => {
3058
3181
  }
3059
3182
  safePreventDefault(e);
3060
3183
  dispatch(setDragging(false));
3061
- if (autofillDraggingTo) {
3062
- dispatch(submitAutofill(autofillDraggingTo));
3063
- focus(input);
3064
- return false;
3065
- }
3066
3184
  if (editingAnywhere) {
3067
3185
  dispatch(drag({ y: -1, x: -1 }));
3068
3186
  }
3069
3187
  },
3070
- [autofillDraggingTo, editingAnywhere, input]
3188
+ [editingAnywhere]
3071
3189
  );
3072
3190
  const handleDragging = useCallback(
3073
3191
  (e) => {
@@ -3083,7 +3201,7 @@ const Cell = memo(({ y, x }) => {
3083
3201
  safePreventDefault(e);
3084
3202
  e.stopPropagation();
3085
3203
  if (autofillDraggingTo) {
3086
- dispatch(setAutofillDraggingTo({ x, y }));
3204
+ dispatch(setAutofillDraggingTo({ x: x$1, y }));
3087
3205
  return false;
3088
3206
  }
3089
3207
  if (leftHeaderSelecting) {
@@ -3091,17 +3209,17 @@ const Cell = memo(({ y, x }) => {
3091
3209
  return false;
3092
3210
  }
3093
3211
  if (topHeaderSelecting) {
3094
- dispatch(drag({ y: sheet.numRows, x }));
3212
+ dispatch(drag({ y: sheet.numRows, x: x$1 }));
3095
3213
  return false;
3096
3214
  }
3097
- if (editingAnywhere && !isRefInsertable(lastFocused || null)) {
3215
+ if (editingAnywhere && !X(lastFocused || null)) {
3098
3216
  return false;
3099
3217
  }
3100
- dispatch(drag({ y, x }));
3218
+ dispatch(drag({ y, x: x$1 }));
3101
3219
  if (editingAnywhere) {
3102
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
3103
- const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${areaToRange(newArea)}`;
3104
- insertRef({ input: lastFocused || null, ref: fullRange });
3220
+ const newArea = Rs({ ...selectingZone, endY: y, endX: x$1 });
3221
+ const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${zr(newArea)}`;
3222
+ Y({ input: lastFocused || null, ref: fullRange });
3105
3223
  }
3106
3224
  return true;
3107
3225
  },
@@ -3118,11 +3236,11 @@ const Cell = memo(({ y, x }) => {
3118
3236
  );
3119
3237
  const handleAutofillMouseDown = useCallback(
3120
3238
  (e) => {
3121
- dispatch(setAutofillDraggingTo({ x, y }));
3239
+ dispatch(setAutofillDraggingTo({ x: x$1, y }));
3122
3240
  dispatch(setDragging(true));
3123
3241
  e.stopPropagation();
3124
3242
  },
3125
- [dispatch, x, y]
3243
+ [dispatch, x$1, y]
3126
3244
  );
3127
3245
  const handleErrorTriangleEnter = useCallback(() => {
3128
3246
  var _a2;
@@ -3130,7 +3248,7 @@ const Cell = memo(({ y, x }) => {
3130
3248
  if (!rect) {
3131
3249
  return;
3132
3250
  }
3133
- setErrorTooltipPos(calcBelowPosition(rect));
3251
+ setErrorTooltipPos(J$1(rect));
3134
3252
  }, []);
3135
3253
  const handleErrorTriangleLeave = useCallback(() => {
3136
3254
  setErrorTooltipPos(null);
@@ -3163,7 +3281,7 @@ const Cell = memo(({ y, x }) => {
3163
3281
  if (!editing && pointed && selectingArea.bottom === -1) {
3164
3282
  return "gs-autofill-drag";
3165
3283
  }
3166
- if (selectingArea.bottom === y && selectingArea.right === x) {
3284
+ if (selectingArea.bottom === y && selectingArea.right === x$1) {
3167
3285
  return "gs-autofill-drag";
3168
3286
  }
3169
3287
  return "gs-autofill-drag gs-hidden";
@@ -3172,19 +3290,19 @@ const Cell = memo(({ y, x }) => {
3172
3290
  return null;
3173
3291
  }
3174
3292
  if (!input) {
3175
- return /* @__PURE__ */ jsx("td", { "data-x": x, "data-y": y, "data-address": address, className: "gs-cell gs-hidden", children: /* @__PURE__ */ jsxs("div", { className: "gs-cell-inner-wrap", children: [
3293
+ return /* @__PURE__ */ jsx("td", { "data-x": x$1, "data-y": y, "data-address": address, className: "gs-cell gs-hidden", children: /* @__PURE__ */ jsxs("div", { className: "gs-cell-inner-wrap", children: [
3176
3294
  /* @__PURE__ */ jsx("div", { className: "gs-cell-inner", children: /* @__PURE__ */ jsx("div", { className: "gs-cell-rendered" }) }),
3177
3295
  /* @__PURE__ */ jsx("div", { className: "gs-autofill-drag" })
3178
- ] }) }, x);
3296
+ ] }) }, x$1);
3179
3297
  }
3180
3298
  return /* @__PURE__ */ jsx(
3181
3299
  "td",
3182
3300
  {
3183
3301
  ref: cellRef,
3184
- "data-x": x,
3302
+ "data-x": x$1,
3185
3303
  "data-y": y,
3186
3304
  "data-address": address,
3187
- className: `gs-cell ${among(selectingArea, { y, x }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3305
+ className: `gs-cell ${Wr(selectingArea, { y, x: x$1 }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3188
3306
  style: {
3189
3307
  ...cell == null ? void 0 : cell.style
3190
3308
  },
@@ -3239,7 +3357,7 @@ const Cell = memo(({ y, x }) => {
3239
3357
  style: {
3240
3358
  top: errorTooltipPos.y + 4,
3241
3359
  left: errorTooltipPos.x,
3242
- transform: hAlignTransform(errorTooltipPos.hAlign)
3360
+ transform: oe(errorTooltipPos.hAlign)
3243
3361
  },
3244
3362
  children: errorMessage
3245
3363
  }
@@ -3249,7 +3367,7 @@ const Cell = memo(({ y, x }) => {
3249
3367
  }
3250
3368
  )
3251
3369
  },
3252
- x
3370
+ x$1
3253
3371
  );
3254
3372
  });
3255
3373
  const acceleration = 0.4;
@@ -3270,6 +3388,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3270
3388
  editingAddress
3271
3389
  } = store;
3272
3390
  const sheet = sheetRef.current;
3391
+ const storeRef = useRef(store);
3392
+ storeRef.current = store;
3273
3393
  let isScrolling = false;
3274
3394
  const xSheetFocused = isXSheetFocused(store);
3275
3395
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
@@ -3286,14 +3406,14 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3286
3406
  vertical = e.pageY > bottom ? 1 : e.pageY < top ? -1 : 0;
3287
3407
  }
3288
3408
  }
3289
- const area = getAreaInTabular(tabularRef.current);
3290
- let { endX: x, endY: y } = selectingZone;
3409
+ const area = Q(tabularRef.current);
3410
+ let { endX: x2, endY: y } = selectingZone;
3291
3411
  if (horizontal) {
3292
- x = horizontal > 0 ? area.right : area.left;
3412
+ x2 = horizontal > 0 ? area.right : area.left;
3293
3413
  } else if (vertical) {
3294
3414
  y = vertical > 0 ? area.bottom : area.top;
3295
3415
  }
3296
- return { x, y };
3416
+ return { x: x2, y };
3297
3417
  },
3298
3418
  [sheet, horizontal, vertical, selectingZone]
3299
3419
  );
@@ -3302,6 +3422,15 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3302
3422
  if (!isScrolling || tabularRef.current === null || !sheet) {
3303
3423
  return;
3304
3424
  }
3425
+ const live = storeRef.current;
3426
+ if (!live.dragging && !live.autofillDraggingTo) {
3427
+ if (scrollRef.current !== null) {
3428
+ cancelAnimationFrame(scrollRef.current);
3429
+ scrollRef.current = null;
3430
+ }
3431
+ isScrolling = false;
3432
+ return;
3433
+ }
3305
3434
  const now = (/* @__PURE__ */ new Date()).getTime();
3306
3435
  if (now - lastScrollTime > 1e3) {
3307
3436
  currentSpeed = 0;
@@ -3311,20 +3440,20 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3311
3440
  left: currentSpeed * horizontal,
3312
3441
  top: currentSpeed * vertical
3313
3442
  });
3314
- focus(editorRef.current);
3315
- const { x, y } = getDestEdge(e);
3316
- if (autofillDraggingTo) {
3317
- const { y: curY, x: curX } = autofillDraggingTo;
3318
- dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3443
+ j(editorRef.current);
3444
+ const { x: x2, y } = getDestEdge(e);
3445
+ if (live.autofillDraggingTo) {
3446
+ const { y: curY, x: curX } = live.autofillDraggingTo;
3447
+ dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3319
3448
  } else {
3320
3449
  if (editingAnywhere) {
3321
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
3450
+ const newArea = Rs({ ...selectingZone, endY: y, endX: x2 });
3322
3451
  const sheetPrefix = sheet.sheetPrefix(!xSheetFocused);
3323
- const sheetRange = areaToRange(newArea);
3452
+ const sheetRange = zr(newArea);
3324
3453
  const fullRange = `${sheetPrefix}${sheetRange}`;
3325
- insertRef({ input: editorRef.current, ref: fullRange });
3454
+ Y({ input: editorRef.current, ref: fullRange });
3326
3455
  }
3327
- dispatch(drag({ y, x }));
3456
+ dispatch(drag({ y, x: x2 }));
3328
3457
  }
3329
3458
  currentSpeed = Math.min(currentSpeed + acceleration, maxSpeed);
3330
3459
  scrollRef.current = requestAnimationFrame(() => scrollStep(e));
@@ -3367,23 +3496,23 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3367
3496
  scrollRef.current = null;
3368
3497
  }
3369
3498
  isScrolling = false;
3370
- if (!isFocus(searchInputRef.current)) {
3371
- focus(editorRef.current);
3499
+ if (!U(searchInputRef.current)) {
3500
+ j(editorRef.current);
3372
3501
  }
3373
3502
  }, []);
3374
3503
  const handleMouseUp = useCallback(
3375
3504
  (e) => {
3376
3505
  e.preventDefault();
3377
3506
  e.stopPropagation();
3378
- const area = getAreaInTabular(tabularRef.current);
3507
+ const area = Q(tabularRef.current);
3379
3508
  if (area.bottom === -1 || area.right === -1) {
3380
3509
  return;
3381
3510
  }
3382
- const { x, y } = getDestEdge(e);
3511
+ const { x: x2, y } = getDestEdge(e);
3383
3512
  if (autofillDraggingTo) {
3384
3513
  const { y: curY, x: curX } = autofillDraggingTo;
3385
- dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3386
- focus(editorRef.current);
3514
+ dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3515
+ j(editorRef.current);
3387
3516
  } else {
3388
3517
  if (editingAnywhere) {
3389
3518
  dispatch(drag({ y: -1, x: -1 }));
@@ -3424,8 +3553,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3424
3553
  }
3425
3554
  );
3426
3555
  }
3427
- const HeaderCellTop = memo(({ x }) => {
3428
- const colId = x2c(x);
3556
+ const HeaderCellTop = memo(({ x: x2 }) => {
3557
+ const colId = W(x2);
3429
3558
  const { store, dispatch } = useContext(Context);
3430
3559
  const {
3431
3560
  sheetReactive: sheetRef,
@@ -3440,8 +3569,8 @@ const HeaderCellTop = memo(({ x }) => {
3440
3569
  columnMenuState
3441
3570
  } = store;
3442
3571
  const sheet = sheetRef.current;
3443
- const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
3444
- const width = (col == null ? void 0 : col.width) || DEFAULT_WIDTH;
3572
+ const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
3573
+ const width = (col == null ? void 0 : col.width) || jt;
3445
3574
  const hasFilter = !!((col == null ? void 0 : col.filter) && col.filter.conditions.length > 0);
3446
3575
  const xSheetFocused = isXSheetFocused(store);
3447
3576
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
@@ -3453,7 +3582,7 @@ const HeaderCellTop = memo(({ x }) => {
3453
3582
  [choosing]
3454
3583
  );
3455
3584
  const handleResizeMouseDown = useCallback((e) => {
3456
- dispatch(setResizingPositionX([x, e.clientX, e.clientX]));
3585
+ dispatch(setResizingPositionX([x2, e.clientX, e.clientX]));
3457
3586
  e.stopPropagation();
3458
3587
  safePreventDefault(e);
3459
3588
  }, []);
@@ -3471,26 +3600,26 @@ const HeaderCellTop = memo(({ x }) => {
3471
3600
  if (editingAnywhere && editorRef.current) {
3472
3601
  editorRef.current.blur();
3473
3602
  }
3474
- dispatch(choose({ y: 1, x }));
3475
- dispatch(select({ startY: 1, startX: x, endY: sheet.numRows, endX: x }));
3603
+ dispatch(choose({ y: 1, x: x2 }));
3604
+ dispatch(select({ startY: 1, startX: x2, endY: sheet.numRows, endX: x2 }));
3476
3605
  return true;
3477
3606
  }
3478
- dispatch(select({ startY: 1, startX: x, endY: -1, endX: x }));
3607
+ dispatch(select({ startY: 1, startX: x2, endY: -1, endX: x2 }));
3479
3608
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${colId}:${colId}`;
3480
3609
  if (editingAnywhere) {
3481
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3610
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3482
3611
  if (inserted) {
3483
- dispatch(select({ startY: sheet.numRows, startX: x, endY: 0, endX: x }));
3612
+ dispatch(select({ startY: sheet.numRows, startX: x2, endY: 0, endX: x2 }));
3484
3613
  return false;
3485
3614
  }
3486
3615
  }
3487
- let startX = e.shiftKey ? selectingZone.startX : x;
3616
+ let startX = e.shiftKey ? selectingZone.startX : x2;
3488
3617
  if (startX === -1) {
3489
3618
  startX = choosing.x;
3490
3619
  }
3491
3620
  dispatch(
3492
3621
  selectCols({
3493
- range: { start: startX, end: x },
3622
+ range: { start: startX, end: x2 },
3494
3623
  numRows: sheet.numRows
3495
3624
  })
3496
3625
  );
@@ -3499,7 +3628,7 @@ const HeaderCellTop = memo(({ x }) => {
3499
3628
  }
3500
3629
  dispatch(setEditingAddress(""));
3501
3630
  dispatch(setDragging(true));
3502
- focus(editorRef.current);
3631
+ j(editorRef.current);
3503
3632
  if (autofillDraggingTo) {
3504
3633
  return false;
3505
3634
  }
@@ -3526,7 +3655,7 @@ const HeaderCellTop = memo(({ x }) => {
3526
3655
  safePreventDefault(e);
3527
3656
  dispatch(setDragging(false));
3528
3657
  if (autofillDraggingTo) {
3529
- focus(editorRef.current);
3658
+ j(editorRef.current);
3530
3659
  return false;
3531
3660
  }
3532
3661
  },
@@ -3542,27 +3671,27 @@ const HeaderCellTop = memo(({ x }) => {
3542
3671
  safePreventDefault(e);
3543
3672
  e.stopPropagation();
3544
3673
  if (autofillDraggingTo) {
3545
- dispatch(setAutofillDraggingTo({ y: 1, x }));
3674
+ dispatch(setAutofillDraggingTo({ y: 1, x: x2 }));
3546
3675
  return false;
3547
3676
  }
3548
3677
  if (editingAnywhere) {
3549
- const newArea = zoneToArea({ ...selectingZone, endY: 1, endX: x });
3550
- const [left, right] = [x2c(newArea.left), x2c(newArea.right)];
3678
+ const newArea = Rs({ ...selectingZone, endY: 1, endX: x2 });
3679
+ const [left, right] = [W(newArea.left), W(newArea.right)];
3551
3680
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${left}:${right}`;
3552
- insertRef({ input: lastFocused || null, ref: fullRange });
3681
+ Y({ input: lastFocused || null, ref: fullRange });
3553
3682
  }
3554
3683
  if (autofillDraggingTo == null) {
3555
3684
  const { startY } = selectingZone;
3556
3685
  if (startY === 1) {
3557
- dispatch(drag({ y: sheet.numRows, x }));
3686
+ dispatch(drag({ y: sheet.numRows, x: x2 }));
3558
3687
  } else {
3559
- dispatch(drag({ y: 1, x }));
3688
+ dispatch(drag({ y: 1, x: x2 }));
3560
3689
  }
3561
3690
  }
3562
3691
  return false;
3563
3692
  }, 100);
3564
3693
  if (!sheet) {
3565
- return /* @__PURE__ */ jsx("th", { "data-x": x, className: "gs-th gs-th-top gs-hidden", children: /* @__PURE__ */ jsx("div", { className: "gs-th-inner-wrap", children: /* @__PURE__ */ jsxs("div", { className: "gs-th-inner", children: [
3694
+ return /* @__PURE__ */ jsx("th", { "data-x": x2, className: "gs-th gs-th-top gs-hidden", children: /* @__PURE__ */ jsx("div", { className: "gs-th-inner-wrap", children: /* @__PURE__ */ jsxs("div", { className: "gs-th-inner", children: [
3566
3695
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute" }, vertical: -1 }),
3567
3696
  /* @__PURE__ */ jsx("div", { className: "gs-resizer" })
3568
3697
  ] }) }) });
@@ -3570,9 +3699,26 @@ const HeaderCellTop = memo(({ x }) => {
3570
3699
  return /* @__PURE__ */ jsx(
3571
3700
  "th",
3572
3701
  {
3573
- "data-x": x,
3574
- className: `gs-th gs-th-top ${choosing.x === x ? "gs-choosing" : ""} ${between({ start: selectingZone.startX, end: selectingZone.endX }, x) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
3702
+ "data-x": x2,
3703
+ className: `gs-th gs-th-top ${choosing.x === x2 ? "gs-choosing" : ""} ${Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
3575
3704
  style: { ...col == null ? void 0 : col.style, width, minWidth: width, maxWidth: width },
3705
+ onDoubleClick: (e) => {
3706
+ const target = e.target;
3707
+ if (target.closest(".gs-resizer, .gs-menu-btn")) {
3708
+ return;
3709
+ }
3710
+ if (pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu)) {
3711
+ return;
3712
+ }
3713
+ e.stopPropagation();
3714
+ const inner = e.currentTarget.querySelector(".gs-th-inner");
3715
+ const rect = (inner ?? e.currentTarget).getBoundingClientRect();
3716
+ const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3717
+ if (!alreadySelected) {
3718
+ dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3719
+ }
3720
+ dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left }, focusLabel: true }));
3721
+ },
3576
3722
  onContextMenu: (e) => {
3577
3723
  if (contextMenu.length > 0) {
3578
3724
  e.stopPropagation();
@@ -3602,7 +3748,7 @@ const HeaderCellTop = memo(({ x }) => {
3602
3748
  }
3603
3749
  ),
3604
3750
  (() => {
3605
- const displayedLabel = getLabel(sheet, col == null ? void 0 : col.label, { y: 0, x }, x) ?? colId;
3751
+ const displayedLabel = Rn(sheet, col == null ? void 0 : col.label, { y: 0, x: x2 }, x2) ?? colId;
3606
3752
  if (displayedLabel !== colId) {
3607
3753
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3608
3754
  /* @__PURE__ */ jsx("span", { className: "gs-col-addr", children: colId }),
@@ -3611,10 +3757,10 @@ const HeaderCellTop = memo(({ x }) => {
3611
3757
  }
3612
3758
  return displayedLabel;
3613
3759
  })(),
3614
- !operations.hasOperation(col == null ? void 0 : col.prevention, operations.ColumnMenu) && /* @__PURE__ */ jsx(
3760
+ !pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu) && /* @__PURE__ */ jsx(
3615
3761
  "button",
3616
3762
  {
3617
- className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x ? "gs-active" : ""}`,
3763
+ className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x2 ? "gs-active" : ""}`,
3618
3764
  onMouseDown: (e) => {
3619
3765
  e.stopPropagation();
3620
3766
  e.preventDefault();
@@ -3631,14 +3777,14 @@ const HeaderCellTop = memo(({ x }) => {
3631
3777
  return;
3632
3778
  }
3633
3779
  const rect = btn.getBoundingClientRect();
3634
- if ((columnMenuState == null ? void 0 : columnMenuState.x) === x) {
3780
+ if ((columnMenuState == null ? void 0 : columnMenuState.x) === x2) {
3635
3781
  dispatch(setColumnMenu(null));
3636
3782
  } else {
3637
- const alreadySelected = between({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3783
+ const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3638
3784
  if (!alreadySelected) {
3639
- dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
3785
+ dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3640
3786
  }
3641
- dispatch(setColumnMenu({ x, position: { y: rect.bottom, x: rect.left } }));
3787
+ dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left } }));
3642
3788
  }
3643
3789
  },
3644
3790
  children: "⋮"
@@ -3649,7 +3795,7 @@ const HeaderCellTop = memo(({ x }) => {
3649
3795
  {
3650
3796
  className: `
3651
3797
  gs-resizer
3652
- ${operations.hasOperation(col == null ? void 0 : col.prevention, operations.Resize) ? "gs-protected" : ""}
3798
+ ${pn.hasOperation(col == null ? void 0 : col.prevention, pn.Resize) ? "gs-protected" : ""}
3653
3799
  ${dragging ? "gs-hidden" : ""}`,
3654
3800
  style: { height: sheet.headerHeight },
3655
3801
  onMouseDown: handleResizeMouseDown,
@@ -3663,7 +3809,7 @@ const HeaderCellTop = memo(({ x }) => {
3663
3809
  );
3664
3810
  });
3665
3811
  const HeaderCellLeft = memo(({ y }) => {
3666
- const rowId = `${y2r(y)}`;
3812
+ const rowId = `${Et(y)}`;
3667
3813
  const { store, dispatch } = useContext(Context);
3668
3814
  const {
3669
3815
  choosing,
@@ -3679,7 +3825,7 @@ const HeaderCellLeft = memo(({ y }) => {
3679
3825
  } = store;
3680
3826
  const sheet = sheetRef.current;
3681
3827
  const row = sheet == null ? void 0 : sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
3682
- const height = (row == null ? void 0 : row.height) || DEFAULT_HEIGHT;
3828
+ const height = (row == null ? void 0 : row.height) || J;
3683
3829
  const xSheetFocused = isXSheetFocused(store);
3684
3830
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
3685
3831
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
@@ -3715,7 +3861,7 @@ const HeaderCellLeft = memo(({ y }) => {
3715
3861
  dispatch(select({ startY: y, startX: 1, endY: y, endX: -1 }));
3716
3862
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${rowId}:${rowId}`;
3717
3863
  if (editingAnywhere) {
3718
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3864
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3719
3865
  if (inserted) {
3720
3866
  dispatch(select({ startY: y, startX: sheet.numCols, endY: y, endX: 0 }));
3721
3867
  return false;
@@ -3736,7 +3882,7 @@ const HeaderCellLeft = memo(({ y }) => {
3736
3882
  }
3737
3883
  dispatch(setEditingAddress(""));
3738
3884
  dispatch(setDragging(true));
3739
- focus(editorRef.current);
3885
+ j(editorRef.current);
3740
3886
  if (autofillDraggingTo) {
3741
3887
  return false;
3742
3888
  }
@@ -3763,7 +3909,7 @@ const HeaderCellLeft = memo(({ y }) => {
3763
3909
  safePreventDefault(e);
3764
3910
  dispatch(setDragging(false));
3765
3911
  if (autofillDraggingTo) {
3766
- focus(editorRef.current);
3912
+ j(editorRef.current);
3767
3913
  return false;
3768
3914
  }
3769
3915
  },
@@ -3783,10 +3929,10 @@ const HeaderCellLeft = memo(({ y }) => {
3783
3929
  return false;
3784
3930
  }
3785
3931
  if (editingAnywhere) {
3786
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: 1 });
3787
- const [top, bottom] = [y2r(newArea.top), y2r(newArea.bottom)];
3932
+ const newArea = Rs({ ...selectingZone, endY: y, endX: 1 });
3933
+ const [top, bottom] = [Et(newArea.top), Et(newArea.bottom)];
3788
3934
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${top}:${bottom}`;
3789
- insertRef({ input: lastFocused || null, ref: fullRange });
3935
+ Y({ input: lastFocused || null, ref: fullRange });
3790
3936
  }
3791
3937
  if (autofillDraggingTo == null) {
3792
3938
  const { startX } = selectingZone;
@@ -3817,7 +3963,7 @@ const HeaderCellLeft = memo(({ y }) => {
3817
3963
  "th",
3818
3964
  {
3819
3965
  "data-y": y,
3820
- className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${between({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""} ${(row == null ? void 0 : row.filterFixed) ? "gs-filter-fixed" : ""} ${(row == null ? void 0 : row.sortFixed) ? "gs-sort-fixed" : ""}`,
3966
+ className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${Vr({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""} ${(row == null ? void 0 : row.filterFixed) ? "gs-filter-fixed" : ""} ${(row == null ? void 0 : row.sortFixed) ? "gs-sort-fixed" : ""}`,
3821
3967
  style: { ...row == null ? void 0 : row.style, height },
3822
3968
  onContextMenu: handleContextMenu,
3823
3969
  children: /* @__PURE__ */ jsx(
@@ -3839,8 +3985,8 @@ const HeaderCellLeft = memo(({ y }) => {
3839
3985
  horizontal: -1
3840
3986
  }
3841
3987
  ),
3842
- getLabel(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
3843
- !operations.hasOperation(row == null ? void 0 : row.prevention, operations.RowMenu) && /* @__PURE__ */ jsx(
3988
+ Rn(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
3989
+ !pn.hasOperation(row == null ? void 0 : row.prevention, pn.RowMenu) && /* @__PURE__ */ jsx(
3844
3990
  "button",
3845
3991
  {
3846
3992
  className: `gs-menu-btn gs-row-menu-btn ${(rowMenuState == null ? void 0 : rowMenuState.y) === y ? "gs-active" : ""}`,
@@ -3863,7 +4009,7 @@ const HeaderCellLeft = memo(({ y }) => {
3863
4009
  if ((rowMenuState == null ? void 0 : rowMenuState.y) === y) {
3864
4010
  dispatch(setRowMenu(null));
3865
4011
  } else {
3866
- const alreadySelected = between({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
4012
+ const alreadySelected = Vr({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
3867
4013
  if (!alreadySelected) {
3868
4014
  dispatch(selectRows({ range: { start: y, end: y }, numCols: sheet.numCols }));
3869
4015
  }
@@ -3878,7 +4024,7 @@ const HeaderCellLeft = memo(({ y }) => {
3878
4024
  {
3879
4025
  className: `
3880
4026
  gs-resizer
3881
- ${operations.hasOperation(row == null ? void 0 : row.prevention, operations.Resize) ? "gs-protected" : ""}
4027
+ ${pn.hasOperation(row == null ? void 0 : row.prevention, pn.Resize) ? "gs-protected" : ""}
3882
4028
  ${dragging ? "gs-hidden" : ""}`,
3883
4029
  style: { width: sheet.headerWidth },
3884
4030
  onMouseDown: handleResizeMouseDown
@@ -3898,19 +4044,19 @@ const COLOR_CUTTING = "#0077ff";
3898
4044
  const SEARCH_MATCHING_BACKGROUND = "rgba(0, 200, 100, 0.2)";
3899
4045
  const COLOR_SEARCH_MATCHING = "#00aa78";
3900
4046
  const COLOR_AUTOFILL = "#0077aa";
3901
- const fillRect = (ctx, x, y, width, height, color) => {
4047
+ const fillRect = (ctx, x2, y, width, height, color) => {
3902
4048
  ctx.fillStyle = color;
3903
- ctx.fillRect(x, y, width, height);
4049
+ ctx.fillRect(x2, y, width, height);
3904
4050
  };
3905
- const drawRect = (ctx, x, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
4051
+ const drawRect = (ctx, x2, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
3906
4052
  if (fillColor) {
3907
4053
  ctx.fillStyle = fillColor;
3908
- ctx.fillRect(x, y, width, height);
4054
+ ctx.fillRect(x2, y, width, height);
3909
4055
  }
3910
4056
  ctx.strokeStyle = color;
3911
4057
  ctx.lineWidth = lineWidth;
3912
4058
  ctx.setLineDash(dashPattern);
3913
- ctx.strokeRect(x + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
4059
+ ctx.strokeRect(x2 + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
3914
4060
  ctx.setLineDash([]);
3915
4061
  };
3916
4062
  const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, area, color, lineWidth = 2, dashPattern = [], fillColor) => {
@@ -3918,8 +4064,8 @@ const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, a
3918
4064
  if (top === -1 || left === -1 || bottom === -1 || right === -1) {
3919
4065
  return;
3920
4066
  }
3921
- const topLeft = getCellRectPositions(sheet, { y: top, x: left });
3922
- const bottomRight = getCellRectPositions(sheet, { y: bottom, x: right });
4067
+ const topLeft = O(sheet, { y: top, x: left });
4068
+ const bottomRight = O(sheet, { y: bottom, x: right });
3923
4069
  const x1 = topLeft.left - scrollLeft;
3924
4070
  const y1 = topLeft.top - scrollTop;
3925
4071
  const x2 = bottomRight.right - scrollLeft;
@@ -3979,16 +4125,16 @@ const CellStateOverlay = ({ refs = {} }) => {
3979
4125
  ctx.beginPath();
3980
4126
  ctx.rect(headerW, headerH, w - headerW, h2 - headerH);
3981
4127
  ctx.clip();
3982
- const selectingArea = zoneToArea(selectingZone);
4128
+ const selectingArea = Rs(selectingZone);
3983
4129
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, selectingArea, COLOR_SELECTED, 1, [], SELECTING_FILL);
3984
4130
  if (autofillDraggingTo) {
3985
- const autofill = new Autofill(storeRef.current, autofillDraggingTo);
4131
+ const autofill = new En(storeRef.current, autofillDraggingTo);
3986
4132
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, autofill.wholeArea, COLOR_AUTOFILL, 1, [5, 5]);
3987
4133
  }
3988
4134
  {
3989
- const { y, x } = choosing;
3990
- if (y !== -1 && x !== -1) {
3991
- const pos = getCellRectPositions(sheet, { y, x });
4135
+ const { y, x: x2 } = choosing;
4136
+ if (y !== -1 && x2 !== -1) {
4137
+ const pos = O(sheet, { y, x: x2 });
3992
4138
  const vx = pos.left - scrollLeft;
3993
4139
  const vy = pos.top - scrollTop;
3994
4140
  drawRect(ctx, vx, vy, pos.width, pos.height, COLOR_POINTED, 2, []);
@@ -3996,13 +4142,13 @@ const CellStateOverlay = ({ refs = {} }) => {
3996
4142
  }
3997
4143
  const { copyingSheetId, copyingZone, cutting } = registry;
3998
4144
  if (sheet.id === copyingSheetId) {
3999
- const copyingArea = zoneToArea(copyingZone);
4145
+ const copyingArea = Rs(copyingZone);
4000
4146
  const color = cutting ? COLOR_CUTTING : COLOR_COPYING;
4001
4147
  const dashPattern = cutting ? [4, 4] : [6, 4];
4002
4148
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, copyingArea, color, 2.5, dashPattern);
4003
4149
  }
4004
4150
  Object.entries(refs).forEach(([ref, i]) => {
4005
- const palette = COLOR_PALETTE[i % COLOR_PALETTE.length];
4151
+ const palette = _n[i % _n.length];
4006
4152
  try {
4007
4153
  const refArea = sheet.rangeToArea(ref);
4008
4154
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, refArea, palette, 2, [5, 5]);
@@ -4010,8 +4156,8 @@ const CellStateOverlay = ({ refs = {} }) => {
4010
4156
  }
4011
4157
  });
4012
4158
  matchingCells.forEach((address, index) => {
4013
- const { y, x } = a2p(address);
4014
- const pos = getCellRectPositions(sheet, { y, x });
4159
+ const { y, x: x2 } = N$1(address);
4160
+ const pos = O(sheet, { y, x: x2 });
4015
4161
  const vx = pos.left - scrollLeft;
4016
4162
  const vy = pos.top - scrollTop;
4017
4163
  if (vx + pos.width < 0 || vx > w || vy + pos.height < 0 || vy > h2) {
@@ -4033,21 +4179,21 @@ const CellStateOverlay = ({ refs = {} }) => {
4033
4179
  ctx.restore();
4034
4180
  const numCols = sheet.numCols;
4035
4181
  const numRows = sheet.numRows;
4036
- for (let x = 1; x <= numCols; x++) {
4182
+ for (let x2 = 1; x2 <= numCols; x2++) {
4037
4183
  let color = null;
4038
4184
  let backgroundColor = null;
4039
- if (between({ start: selectingZone.startX, end: selectingZone.endX }, x)) {
4185
+ if (Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2)) {
4040
4186
  color = "rgba(80, 180, 255, 1)";
4041
4187
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4042
4188
  }
4043
- if (choosing.x === x) {
4189
+ if (choosing.x === x2) {
4044
4190
  color = COLOR_POINTED;
4045
4191
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)";
4046
4192
  }
4047
4193
  if (!color) {
4048
4194
  continue;
4049
4195
  }
4050
- const pos = getCellRectPositions(sheet, { y: 1, x });
4196
+ const pos = O(sheet, { y: 1, x: x2 });
4051
4197
  const left = pos.left - scrollLeft;
4052
4198
  if (left + pos.width < headerW || left > w) {
4053
4199
  continue;
@@ -4072,7 +4218,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4072
4218
  }
4073
4219
  let color = null;
4074
4220
  let backgroundColor = null;
4075
- if (between({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4221
+ if (Vr({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4076
4222
  color = "rgba(80, 180, 255, 1)";
4077
4223
  backgroundColor = leftHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4078
4224
  }
@@ -4083,7 +4229,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4083
4229
  if (!color) {
4084
4230
  continue;
4085
4231
  }
4086
- const pos = getCellRectPositions(sheet, { y, x: 1 });
4232
+ const pos = O(sheet, { y, x: 1 });
4087
4233
  const top = pos.top - scrollTop;
4088
4234
  if (top + pos.height < headerH || top > h2) {
4089
4235
  continue;
@@ -4172,7 +4318,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4172
4318
  );
4173
4319
  };
4174
4320
  const Tabular = () => {
4175
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4321
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
4176
4322
  const [palette, setPalette] = useState({});
4177
4323
  const { store, dispatch } = useContext(Context);
4178
4324
  const {
@@ -4217,7 +4363,7 @@ const Tabular = () => {
4217
4363
  const handleScroll = useCallback(
4218
4364
  (e) => {
4219
4365
  if (sheet) {
4220
- setVirtualized(virtualize(sheet, e.currentTarget));
4366
+ setVirtualized(q(sheet, e.currentTarget));
4221
4367
  }
4222
4368
  },
4223
4369
  [sheetReactive]
@@ -4251,17 +4397,17 @@ const Tabular = () => {
4251
4397
  }
4252
4398
  const palette2 = {};
4253
4399
  const paletteBySheetName = {};
4254
- const lexer = new Lexer(inputting.substring(1));
4400
+ const lexer = new $t(inputting.substring(1));
4255
4401
  lexer.tokenize();
4256
4402
  let i = 0;
4257
4403
  for (const token of lexer.tokens) {
4258
4404
  if (token.type === "REF" || token.type === "RANGE") {
4259
- const normalizedRef = stripAddressAbsolute(token.stringify());
4405
+ const normalizedRef = Br(token.stringify());
4260
4406
  const splitterIndex = normalizedRef.indexOf("!");
4261
4407
  if (splitterIndex !== -1) {
4262
4408
  const sheetName = normalizedRef.substring(0, splitterIndex);
4263
4409
  const ref = normalizedRef.substring(splitterIndex + 1);
4264
- const stripped = stripSheetName(sheetName);
4410
+ const stripped = on(sheetName);
4265
4411
  const upperRef = ref.toUpperCase();
4266
4412
  if (paletteBySheetName[stripped] == null) {
4267
4413
  paletteBySheetName[stripped] = {};
@@ -4284,14 +4430,14 @@ const Tabular = () => {
4284
4430
  if (!sheet) {
4285
4431
  return;
4286
4432
  }
4287
- sheet.registry.choosingAddress = p2a(choosing);
4433
+ sheet.registry.choosingAddress = D(choosing);
4288
4434
  sheet.registry.choosingSheetId = sheet.id;
4289
4435
  }, [choosing]);
4290
4436
  useEffect(() => {
4291
4437
  if (!sheet) {
4292
4438
  return;
4293
4439
  }
4294
- setVirtualized(virtualize(sheet, tabularRef.current));
4440
+ setVirtualized(q(sheet, tabularRef.current));
4295
4441
  }, [
4296
4442
  tabularRef.current,
4297
4443
  sheetReactive,
@@ -4305,7 +4451,7 @@ const Tabular = () => {
4305
4451
  if (!el) {
4306
4452
  return;
4307
4453
  }
4308
- return preventSafariBounce(el);
4454
+ return $(el);
4309
4455
  }, [sheetReactive]);
4310
4456
  useEffect(() => {
4311
4457
  if (!sheet || !sheet.eager || !sheet.registry.ready) {
@@ -4397,7 +4543,7 @@ const Tabular = () => {
4397
4543
  style: { width: ((_c = virtualized == null ? void 0 : virtualized.adjuster) == null ? void 0 : _c.left) ?? 1 }
4398
4544
  }
4399
4545
  ),
4400
- (_e = (_d = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (x) => /* @__PURE__ */ jsx(HeaderCellTop, { x }, x)),
4546
+ (_e2 = (_d = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _d.map) == null ? void 0 : _e2.call(_d, (x2) => /* @__PURE__ */ jsx(HeaderCellTop, { x: x2 }, x2)),
4401
4547
  /* @__PURE__ */ jsx(
4402
4548
  "th",
4403
4549
  {
@@ -4415,7 +4561,7 @@ const Tabular = () => {
4415
4561
  }
4416
4562
  ),
4417
4563
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }),
4418
- (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x)),
4564
+ (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x2) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x2)),
4419
4565
  /* @__PURE__ */ jsx("th", { className: `gs-adjuster gs-adjuster-horizontal gs-adjuster-vertical` })
4420
4566
  ] }) }),
4421
4567
  /* @__PURE__ */ jsx("tbody", { className: "gs-sheet-body-data", children: (_i = virtualized == null ? void 0 : virtualized.ys) == null ? void 0 : _i.map((y) => {
@@ -4423,7 +4569,7 @@ const Tabular = () => {
4423
4569
  return /* @__PURE__ */ jsxs("tr", { className: `gs-row ${y % 2 === 0 ? "gs-row-even" : "gs-row-odd"}`, children: [
4424
4570
  /* @__PURE__ */ jsx(HeaderCellLeft, { y }),
4425
4571
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-left" }),
4426
- (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x) => /* @__PURE__ */ jsx(Cell, { y, x }, x)),
4572
+ (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x2) => /* @__PURE__ */ jsx(Cell, { y, x: x2 }, x2)),
4427
4573
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-right" })
4428
4574
  ] }, y);
4429
4575
  }) })
@@ -4452,11 +4598,11 @@ const FormulaBar = ({ ready }) => {
4452
4598
  } = store;
4453
4599
  const sheet = sheetRef.current;
4454
4600
  const hlRef = useRef(null);
4455
- const address = choosing.x === -1 ? "" : p2a(choosing);
4601
+ const address = choosing.x === -1 ? "" : D(choosing);
4456
4602
  const cell = sheet == null ? void 0 : sheet.getCell(choosing, { resolution: "SYSTEM" });
4457
4603
  const spilledFromAddress = (_a = sheet == null ? void 0 : sheet.getSystem(choosing)) == null ? void 0 : _a.spilledFrom;
4458
- const originPoint = spilledFromAddress ? a2p(spilledFromAddress) : void 0;
4459
- const originAddress = originPoint != null ? p2a(originPoint) : void 0;
4604
+ const originPoint = spilledFromAddress ? N$1(spilledFromAddress) : void 0;
4605
+ const originAddress = originPoint != null ? D(originPoint) : void 0;
4460
4606
  useEffect(() => {
4461
4607
  var _a2;
4462
4608
  if (!sheet) {
@@ -4473,7 +4619,7 @@ const FormulaBar = ({ ready }) => {
4473
4619
  dispatch(write({ value }));
4474
4620
  }
4475
4621
  dispatch(setEditingAddress(""));
4476
- focus(editorRef.current);
4622
+ j(editorRef.current);
4477
4623
  },
4478
4624
  [before]
4479
4625
  );
@@ -4554,10 +4700,6 @@ const FormulaBar = ({ ready }) => {
4554
4700
  return true;
4555
4701
  }
4556
4702
  const input = e.currentTarget;
4557
- if (handleFormulaQuoteAutoClose(e, inputting)) {
4558
- dispatch(setInputting(input.value));
4559
- return false;
4560
- }
4561
4703
  switch (e.key) {
4562
4704
  case "Tab":
4563
4705
  e.preventDefault();
@@ -4569,7 +4711,7 @@ const FormulaBar = ({ ready }) => {
4569
4711
  dispatch(setInputting(newValue));
4570
4712
  setTimeout(() => {
4571
4713
  if (largeEditorRef.current) {
4572
- focus(largeEditorRef.current);
4714
+ j(largeEditorRef.current);
4573
4715
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4574
4716
  }
4575
4717
  }, 0);
@@ -4600,7 +4742,7 @@ const FormulaBar = ({ ready }) => {
4600
4742
  dispatch(setInputting(newValue));
4601
4743
  setTimeout(() => {
4602
4744
  if (largeEditorRef.current) {
4603
- focus(largeEditorRef.current);
4745
+ j(largeEditorRef.current);
4604
4746
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4605
4747
  }
4606
4748
  }, 0);
@@ -4609,7 +4751,7 @@ const FormulaBar = ({ ready }) => {
4609
4751
  }
4610
4752
  }
4611
4753
  if (e.altKey) {
4612
- insertTextAtCursor(input, "\n");
4754
+ v(input, "\n");
4613
4755
  } else {
4614
4756
  writeCell(input.value);
4615
4757
  dispatch(setInputting(""));
@@ -4631,7 +4773,7 @@ const FormulaBar = ({ ready }) => {
4631
4773
  dispatch(setInputting(before));
4632
4774
  dispatch(setEditingAddress(""));
4633
4775
  e.preventDefault();
4634
- focus(editorRef.current);
4776
+ j(editorRef.current);
4635
4777
  break;
4636
4778
  }
4637
4779
  case "a":
@@ -4650,7 +4792,7 @@ const FormulaBar = ({ ready }) => {
4650
4792
  break;
4651
4793
  }
4652
4794
  const cell2 = sheet.getCell(choosing, { resolution: "SYSTEM" });
4653
- if (operations.hasOperation(cell2 == null ? void 0 : cell2.prevention, operations.Write)) {
4795
+ if (pn.hasOperation(cell2 == null ? void 0 : cell2.prevention, pn.Write)) {
4654
4796
  console.warn("This cell is protected from writing.");
4655
4797
  e.preventDefault();
4656
4798
  }
@@ -4683,7 +4825,7 @@ const FormulaBar = ({ ready }) => {
4683
4825
  dispatch(setInputting(newValue));
4684
4826
  setTimeout(() => {
4685
4827
  if (largeEditorRef.current) {
4686
- focus(largeEditorRef.current);
4828
+ j(largeEditorRef.current);
4687
4829
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4688
4830
  }
4689
4831
  }, 0);
@@ -4858,15 +5000,15 @@ const SearchBar = () => {
4858
5000
  if (!matchingCell || !sheet) {
4859
5001
  return;
4860
5002
  }
4861
- const point = a2p(matchingCell);
5003
+ const point = N$1(matchingCell);
4862
5004
  if (typeof point === "undefined") {
4863
5005
  return;
4864
5006
  }
4865
- smartScroll(sheet, tabularRef.current, point);
5007
+ G(sheet, tabularRef.current, point);
4866
5008
  }, [searchQuery, matchingCellIndex, searchCaseSensitive, searchRegex, sheet, tabularRef]);
4867
5009
  const handleProgressClick = useCallback((e) => {
4868
5010
  const input = e.currentTarget.previousSibling;
4869
- (input == null ? void 0 : input.nodeName) === "INPUT" && focus(input);
5011
+ (input == null ? void 0 : input.nodeName) === "INPUT" && j(input);
4870
5012
  }, []);
4871
5013
  const handleSearchClick = useCallback(() => {
4872
5014
  dispatch(search(1));
@@ -4879,7 +5021,7 @@ const SearchBar = () => {
4879
5021
  if (e.key === "Escape") {
4880
5022
  const el = editorRef == null ? void 0 : editorRef.current;
4881
5023
  if (el) {
4882
- focus(el);
5024
+ j(el);
4883
5025
  }
4884
5026
  dispatch(setSearchQuery(void 0));
4885
5027
  }
@@ -4906,7 +5048,7 @@ const SearchBar = () => {
4906
5048
  if (!selectingZone) {
4907
5049
  return false;
4908
5050
  }
4909
- if (isZoneNotSelected(selectingZone)) {
5051
+ if (rn(selectingZone)) {
4910
5052
  return false;
4911
5053
  }
4912
5054
  const { startY, startX, endY, endX } = selectingZone;
@@ -4917,8 +5059,8 @@ const SearchBar = () => {
4917
5059
  return "";
4918
5060
  }
4919
5061
  const { startY, startX, endY, endX } = selectingZone;
4920
- const topLeft = `${x2c(Math.min(startX, endX))}${y2r(Math.min(startY, endY))}`;
4921
- const bottomRight = `${x2c(Math.max(startX, endX))}${y2r(Math.max(startY, endY))}`;
5062
+ const topLeft = `${W(Math.min(startX, endX))}${Et(Math.min(startY, endY))}`;
5063
+ const bottomRight = `${W(Math.max(startX, endX))}${Et(Math.max(startY, endY))}`;
4922
5064
  return `${topLeft}:${bottomRight}`;
4923
5065
  }, [selectingZone, hasSelection]);
4924
5066
  const handleRangeClick = useCallback(() => {
@@ -4941,13 +5083,13 @@ const SearchBar = () => {
4941
5083
  return "";
4942
5084
  }
4943
5085
  const { startY, startX, endY, endX } = searchRange;
4944
- const topLeft = `${x2c(startX)}${y2r(startY)}`;
4945
- const bottomRight = `${x2c(endX)}${y2r(endY)}`;
5086
+ const topLeft = `${W(startX)}${Et(startY)}`;
5087
+ const bottomRight = `${W(endX)}${Et(endY)}`;
4946
5088
  return `${topLeft}:${bottomRight}`;
4947
5089
  }, [searchRange]);
4948
5090
  const handleCloseClick = useCallback(() => {
4949
5091
  dispatch(setSearchQuery(void 0));
4950
- focus(editorRef.current);
5092
+ j(editorRef.current);
4951
5093
  }, [editorRef]);
4952
5094
  if (typeof searchQuery === "undefined") {
4953
5095
  return null;
@@ -5084,7 +5226,7 @@ function GridSheet({
5084
5226
  console.debug("GridSheet: sheetName is not provided, using default name:", sheetName);
5085
5227
  }
5086
5228
  const { limits, contextMenu, rowMenu, colMenu, eager } = options;
5087
- const sheet = new Sheet({
5229
+ const sheet = new $$1({
5088
5230
  limits,
5089
5231
  name: sheetName,
5090
5232
  registry,
@@ -5144,7 +5286,7 @@ function GridSheet({
5144
5286
  () => initialState
5145
5287
  );
5146
5288
  useEffect(() => {
5147
- embedStyle();
5289
+ re();
5148
5290
  }, []);
5149
5291
  const fillWidth = typeof options.sheetWidth === "string";
5150
5292
  const fillHeight = typeof options.sheetHeight === "string";
@@ -5281,28 +5423,28 @@ function GridSheet({
5281
5423
  ) });
5282
5424
  }
5283
5425
  const estimateSheetHeight = (initialCells) => {
5284
- var _a, _b, _c, _d, _e;
5285
- const auto = getMaxSizesFromCells(initialCells);
5286
- let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? HEADER_HEIGHT;
5426
+ var _a, _b, _c, _d, _e2;
5427
+ const auto = Cs(initialCells);
5428
+ let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? Re;
5287
5429
  for (let y = 1; y <= auto.numRows; y++) {
5288
- const row = y2r(y);
5289
- const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[DEFAULT_ROW_KEY]) == null ? void 0 : _d.height) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.height) || DEFAULT_HEIGHT;
5290
- if (estimatedHeight + height > SHEET_HEIGHT) {
5291
- return SHEET_HEIGHT;
5430
+ const row = Et(y);
5431
+ const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[vt]) == null ? void 0 : _d.height) || ((_e2 = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e2.height) || J;
5432
+ if (estimatedHeight + height > Dr) {
5433
+ return Dr;
5292
5434
  }
5293
5435
  estimatedHeight += height;
5294
5436
  }
5295
5437
  return estimatedHeight + 3;
5296
5438
  };
5297
5439
  const estimateSheetWidth = (initialCells) => {
5298
- var _a, _b, _c, _d, _e;
5299
- const auto = getMaxSizesFromCells(initialCells);
5300
- let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? HEADER_WIDTH;
5301
- for (let x = 1; x <= auto.numCols; x++) {
5302
- const col = x2c(x);
5303
- const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[DEFAULT_COL_KEY]) == null ? void 0 : _d.width) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.width) || DEFAULT_WIDTH;
5304
- if (estimatedWidth + width > SHEET_WIDTH) {
5305
- return SHEET_WIDTH;
5440
+ var _a, _b, _c, _d, _e2;
5441
+ const auto = Cs(initialCells);
5442
+ let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? _e;
5443
+ for (let x2 = 1; x2 <= auto.numCols; x2++) {
5444
+ const col = W(x2);
5445
+ const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[Dt]) == null ? void 0 : _d.width) || ((_e2 = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e2.width) || jt;
5446
+ if (estimatedWidth + width > vr) {
5447
+ return vr;
5306
5448
  }
5307
5449
  estimatedWidth += width;
5308
5450
  }
@@ -5343,70 +5485,70 @@ function makeBorder(options) {
5343
5485
  return result;
5344
5486
  }
5345
5487
  export {
5346
- BaseFunction,
5347
- BaseFunctionAsync,
5488
+ b8 as BaseFunction,
5489
+ b9 as BaseFunctionAsync,
5348
5490
  CheckboxPolicyMixin,
5349
5491
  Children,
5350
5492
  Component,
5351
- DEFAULT_HISTORY_LIMIT,
5352
- FormulaError2 as FormulaError,
5353
- FormulaParser,
5493
+ bq as DEFAULT_HISTORY_LIMIT,
5494
+ x as FormulaError,
5495
+ ba as FormulaParser,
5354
5496
  Fragment2 as Fragment,
5355
5497
  GridSheet,
5356
- Lexer2 as Lexer,
5498
+ $t as Lexer,
5357
5499
  MenuDivider,
5358
5500
  MenuItem,
5359
- Pending2 as Pending,
5360
- PercentagePolicyMixin,
5501
+ k as Pending,
5502
+ bp as PercentagePolicyMixin,
5361
5503
  PluginBase,
5362
- Policy,
5504
+ bn as Policy,
5363
5505
  PureComponent,
5364
- RangeEntity,
5365
- RefEntity,
5366
- Registry,
5367
- Sheet2 as Sheet,
5368
- Spilling,
5506
+ bd as RangeEntity,
5507
+ bb as RefEntity,
5508
+ aZ as Registry,
5509
+ $$1 as Sheet,
5510
+ br as Spilling,
5369
5511
  StrictMode,
5370
5512
  Suspense,
5371
5513
  SuspenseList,
5372
- ThousandSeparatorPolicyMixin,
5373
- Time,
5374
- ValueEntity,
5375
- a2p2 as a2p,
5376
- aa2oa,
5377
- addressesToAreas,
5378
- addressesToCols,
5379
- addressesToRows,
5514
+ bo as ThousandSeparatorPolicyMixin,
5515
+ aU as Time,
5516
+ bc as ValueEntity,
5517
+ N$1 as a2p,
5518
+ aN as aa2oa,
5519
+ aR as addressesToAreas,
5520
+ aS as addressesToCols,
5521
+ aT as addressesToRows,
5380
5522
  applyers,
5381
- areaToRange2 as areaToRange,
5382
- areaToZone2 as areaToZone,
5383
- buildInitialCells,
5384
- buildInitialCellsFromOrigin,
5385
- c2x,
5386
- ch,
5387
- check,
5523
+ zr as areaToRange,
5524
+ Ee as areaToZone,
5525
+ aO as buildInitialCells,
5526
+ aP as buildInitialCellsFromOrigin,
5527
+ aV as c2x,
5528
+ aY as ch,
5529
+ bi as check,
5388
5530
  clip,
5389
5531
  cloneElement,
5390
5532
  render2 as compatRender,
5391
- conditionArg,
5392
- createBook,
5393
- createBooleanMask,
5533
+ bl as conditionArg,
5534
+ a_ as createBook,
5535
+ bk as createBooleanMask,
5394
5536
  createContext2 as createContext,
5395
5537
  createElement,
5396
5538
  createFactory,
5397
5539
  createPortal2 as createPortal,
5398
5540
  createRef2 as createRef,
5399
- createRegistry,
5541
+ a$ as createRegistry,
5400
5542
  createSheetRef,
5401
5543
  createStoreRef,
5402
5544
  defaultColMenuDescriptors,
5403
5545
  defaultContextMenuDescriptors,
5404
5546
  defaultRowMenuDescriptors,
5405
- eachMatrix,
5406
- ensureBoolean,
5407
- ensureDate,
5408
- ensureNumber,
5409
- ensureString,
5547
+ bj as eachMatrix,
5548
+ bg as ensureBoolean,
5549
+ bh as ensureDate,
5550
+ bf as ensureNumber,
5551
+ be as ensureString,
5410
5552
  findDOMNode,
5411
5553
  forwardRef,
5412
5554
  h,
@@ -5414,25 +5556,25 @@ export {
5414
5556
  isValidElement,
5415
5557
  lazy,
5416
5558
  makeBorder,
5417
- matrixShape,
5559
+ aQ as matrixShape,
5418
5560
  memo2 as memo,
5419
- oa2aa,
5420
- operations2 as operations,
5421
- p2a2 as p2a,
5422
- r2y,
5561
+ aM as oa2aa,
5562
+ pn as operations,
5563
+ D as p2a,
5564
+ aW as r2y,
5423
5565
  registerMenuComponent,
5424
5566
  render,
5425
- rh,
5567
+ aX as rh,
5426
5568
  sheet2csv,
5427
- stripMatrix,
5428
- toCellCols,
5429
- toCellMatrix,
5430
- toCellObject,
5431
- toCellRows,
5432
- toValueCols,
5433
- toValueMatrix,
5434
- toValueObject,
5435
- toValueRows,
5569
+ bm as stripMatrix,
5570
+ b7 as toCellCols,
5571
+ b4 as toCellMatrix,
5572
+ b5 as toCellObject,
5573
+ b6 as toCellRows,
5574
+ b3 as toValueCols,
5575
+ b0 as toValueMatrix,
5576
+ b1 as toValueObject,
5577
+ b2 as toValueRows,
5436
5578
  unmountComponentAtNode,
5437
5579
  unstable_batchedUpdates,
5438
5580
  updateSheet,
@@ -5451,10 +5593,10 @@ export {
5451
5593
  useSheetRef,
5452
5594
  useState2 as useState,
5453
5595
  useStoreRef,
5454
- X as userActions,
5596
+ bs as userActions,
5455
5597
  version,
5456
- x2c2 as x2c,
5457
- y2r2 as y2r,
5458
- zoneToArea2 as zoneToArea
5598
+ W as x2c,
5599
+ Et as y2r,
5600
+ Rs as zoneToArea
5459
5601
  };
5460
5602
  //# sourceMappingURL=index.js.map