@gridsheet/react-core 3.0.6 → 3.1.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,9 +1,9 @@
1
- import { calcSideStyle as qn, clampPopup as en, clampLeft as Gn, zoneToArea as ge, focus as O, Lexer as Ge, getFunctionHelps as Pt, expandInput as Qn, y2r as be, x2c as pe, resetInput as Jn, handleFormulaQuoteAutoClose as tn, areaToZone as Qe, insertTextAtCursor as nn, operations as X, isRefInsertable as sn, COLOR_PALETTE as Ie, DEFAULT_WIDTH as vt, DEFAULT_HEIGHT as bt, between as Ae, makeSequence as Xt, p2a as Ee, MIN_HEIGHT as Ht, MIN_WIDTH as Ot, zoneShape as ne, getLabel as wt, FormulaError as es, Pending as ts, insertRef as De, areaToRange as rn, calcBelowPosition as ns, hAlignTransform as ss, among as rs, getAreaInTabular as Lt, isFocus as os, Autofill as is, getCellRectPositions as Fe, a2p as Rt, virtualize as Bt, stripAddressAbsolute as ls, stripSheetName as as, preventSafariBounce as cs, smartScroll as us, isZoneNotSelected as ds, Sheet as gs, embedStyle as fs, getMaxSizesFromCells as on, HEADER_HEIGHT as hs, DEFAULT_ROW_KEY as ms, SHEET_HEIGHT as Kt, HEADER_WIDTH as ps, DEFAULT_COL_KEY as ys, SHEET_WIDTH as Zt } from "@gridsheet/core";
2
- import { BaseFunction as Yr, BaseFunctionAsync as $r, DEFAULT_HISTORY_LIMIT as Pr, FormulaError as Xr, FormulaParser as Hr, Lexer as Or, Pending as Lr, PercentagePolicyMixin as Br, Policy as Kr, RangeEntity as Zr, RefEntity as Ur, Registry as zr, Sheet as Wr, Spilling as _r, ThousandSeparatorPolicyMixin as jr, Time as Vr, ValueEntity as qr, a2p as Gr, aa2oa as Qr, addressesToAreas as Jr, addressesToCols as eo, addressesToRows as to, areaToRange as no, areaToZone as so, buildInitialCells as ro, buildInitialCellsFromOrigin as oo, c2x as io, ch as lo, check as ao, conditionArg as co, createBook as uo, createBooleanMask as go, createRegistry as fo, eachMatrix as ho, ensureBoolean as mo, ensureDate as po, ensureNumber as yo, ensureString as vo, matrixShape as bo, oa2aa as wo, operations as Ro, p2a as Co, r2y as So, rh as No, stripMatrix as Eo, toCellCols as xo, toCellMatrix as ko, toCellObject as To, toCellRows as Ao, toValueCols as Mo, toValueMatrix as Do, toValueObject as Io, toValueRows as Fo, x2c as Yo, y2r as $o, zoneToArea as Po } from "@gridsheet/core";
1
+ import { calcSideStyle as qn, clampPopup as en, clampLeft as Gn, zoneToArea as he, focus as O, Lexer as Ge, getFunctionHelps as Pt, expandInput as Qn, y2r as be, x2c as pe, resetInput as Jn, handleFormulaQuoteAutoClose as tn, areaToZone as Qe, insertTextAtCursor as nn, operations as X, isRefInsertable as sn, COLOR_PALETTE as Ie, DEFAULT_WIDTH as vt, DEFAULT_HEIGHT as bt, between as Ae, makeSequence as Xt, p2a as xe, MIN_HEIGHT as Ht, MIN_WIDTH as Ot, zoneShape as se, getLabel as wt, FormulaError as es, Pending as ts, insertRef as De, areaToRange as rn, calcBelowPosition as ns, hAlignTransform as ss, among as rs, getAreaInTabular as Lt, isFocus as os, Autofill as is, getCellRectPositions as Fe, a2p as Rt, virtualize as Bt, stripAddressAbsolute as ls, stripSheetName as as, preventSafariBounce as cs, smartScroll as us, isZoneNotSelected as ds, Sheet as gs, embedStyle as hs, getMaxSizesFromCells as on, HEADER_HEIGHT as fs, DEFAULT_ROW_KEY as ms, SHEET_HEIGHT as Kt, HEADER_WIDTH as ps, DEFAULT_COL_KEY as ys, SHEET_WIDTH as Wt } from "@gridsheet/core";
2
+ import { BaseFunction as Yr, BaseFunctionAsync as $r, DEFAULT_HISTORY_LIMIT as Pr, FormulaError as Xr, FormulaParser as Hr, Lexer as Or, Pending as Lr, PercentagePolicyMixin as Br, Policy as Kr, RangeEntity as Wr, RefEntity as Zr, Registry as Ur, Sheet as zr, Spilling as _r, ThousandSeparatorPolicyMixin as jr, Time as Vr, ValueEntity as qr, a2p as Gr, aa2oa as Qr, addressesToAreas as Jr, addressesToCols as eo, addressesToRows as to, areaToRange as no, areaToZone as so, buildInitialCells as ro, buildInitialCellsFromOrigin as oo, c2x as io, ch as lo, check as ao, conditionArg as co, createBook as uo, createBooleanMask as go, createRegistry as ho, eachMatrix as fo, ensureBoolean as mo, ensureDate as po, ensureNumber as yo, ensureString as vo, matrixShape as bo, oa2aa as wo, operations as Ro, p2a as Co, r2y as So, rh as No, stripMatrix as xo, toCellCols as Eo, toCellMatrix as ko, toCellObject as To, toCellRows as Ao, toValueCols as Mo, toValueMatrix as Do, toValueObject as Io, toValueRows as Fo, x2c as Yo, y2r as $o, zoneToArea as Po } from "@gridsheet/core";
3
3
  import { jsxs as Y, jsx as a, Fragment as Re } from "react/jsx-runtime";
4
- import at, { createContext as ln, useRef as se, useContext as le, useLayoutEffect as ct, useState as J, useMemo as $e, useCallback as k, memo as nt, useEffect as Z, createRef as an, useReducer as vs } from "react";
5
- import { u as bs, s as ue, w as Ue, a as ee, b as ze, r as ut, c as cn, d as un, e as Pe, f as dn, g as gn, h as we, i as je, j as ws, k as Ut, l as dt, p as gt, m as Je, n as Ne, o as ft, q as ht, t as Ye, v as Ct, x as fn, y as hn, z as mn, A as pn, B as yn, C as vn, D as We, E as et, F as mt, G as st, H as Rs, I as Xe, J as me, K as ke, L as bn, M as Ze, N as zt, O as wn, P as Wt, Q as _t, R as Cs, S as Ss, T as jt, U as Ns, V as Es, W as xs } from "./hooks-CcD8I6FA.mjs";
6
- import { X as Ho } from "./hooks-CcD8I6FA.mjs";
4
+ import at, { createContext as ln, useRef as re, useContext as le, useLayoutEffect as ct, useState as te, useMemo as $e, useCallback as k, memo as nt, useEffect as W, createRef as an, useReducer as vs } from "react";
5
+ import { u as bs, s as ue, w as Ze, a as ne, b as Ue, r as ut, c as cn, d as un, e as Pe, f as dn, g as gn, h as we, i as je, j as ws, k as Zt, l as dt, p as gt, m as Je, n as Ne, o as ht, q as ft, t as Ye, v as Ct, x as hn, y as fn, z as mn, A as pn, B as yn, C as vn, D as ze, E as et, F as mt, G as st, H as Rs, I as Xe, J as me, K as ke, L as bn, M as We, N as Ut, O as wn, P as zt, Q as _t, R as Cs, S as Ss, T as jt, U as Ns, V as xs, W as Es } from "./hooks-CvkA2lFB.mjs";
6
+ import { X as Ho } from "./hooks-CvkA2lFB.mjs";
7
7
  import { createPortal as St } from "react-dom";
8
8
  const ae = ln(
9
9
  {}
@@ -14,7 +14,7 @@ const ae = ln(
14
14
  top: s,
15
15
  left: o
16
16
  }) => {
17
- const i = se(null), l = se(null), { store: f } = le(ae), h = !f.editorHovering;
17
+ const i = re(null), l = re(null), { store: h } = le(ae), f = !h.editorHovering;
18
18
  return ct(() => {
19
19
  const c = l.current;
20
20
  c && qn(c);
@@ -55,7 +55,7 @@ const ae = ln(
55
55
  "div",
56
56
  {
57
57
  ref: i,
58
- className: `gs-fn-guide2 ${h ? "gs-fn-guide2-hidden" : ""}`,
58
+ className: `gs-fn-guide2 ${f ? "gs-fn-guide2-hidden" : ""}`,
59
59
  style: s !== void 0 && o !== void 0 ? { top: s + 4, left: o } : void 0,
60
60
  children: [
61
61
  n.category && /* @__PURE__ */ a("span", { className: `gs-fn-guide-category gs-fn-guide-category-${n.category}`, children: n.category }),
@@ -114,23 +114,23 @@ const ae = ln(
114
114
  selected: s,
115
115
  onOptionMouseDown: o
116
116
  }) => {
117
- const i = se(null), [l, f] = J(t);
117
+ const i = re(null), [l, h] = te(t);
118
118
  return ct(() => {
119
119
  if (!i.current)
120
120
  return;
121
- const h = i.current.getBoundingClientRect().width;
122
- f(Gn(t, h));
123
- }, [t, e]), e.length === 0 ? null : /* @__PURE__ */ a("ul", { ref: i, className: "gs-editor-options", style: { top: n, left: l }, children: e.map((h, c) => /* @__PURE__ */ Y(
121
+ const f = i.current.getBoundingClientRect().width;
122
+ h(Gn(t, f));
123
+ }, [t, e]), e.length === 0 ? null : /* @__PURE__ */ a("ul", { ref: i, className: "gs-editor-options", style: { top: n, left: l }, children: e.map((f, c) => /* @__PURE__ */ Y(
124
124
  "li",
125
125
  {
126
126
  className: `gs-editor-option ${s === c ? " gs-editor-option-selected" : ""}`,
127
127
  onMouseDown: (d) => o(d, c),
128
128
  children: [
129
129
  /* @__PURE__ */ Y("div", { className: "gs-editor-option-content", children: [
130
- /* @__PURE__ */ a("span", { children: h.label ?? h.value }),
130
+ /* @__PURE__ */ a("span", { children: f.label ?? f.value }),
131
131
  s === c && /* @__PURE__ */ a("span", { className: "gs-editor-option-tab", children: "⇥ Tab" })
132
132
  ] }),
133
- (h.isFunction || h.tooltip) && s === c && /* @__PURE__ */ a(Nt, { option: h })
133
+ (f.isFunction || f.tooltip) && s === c && /* @__PURE__ */ a(Nt, { option: f })
134
134
  ]
135
135
  },
136
136
  c
@@ -139,9 +139,9 @@ const ae = ln(
139
139
  const { selectingZone: n, choosing: t, editorRef: s, sheetReactive: o } = e, i = o.current;
140
140
  if (!i)
141
141
  return { top: 0, left: 0, bottom: 0, right: 0 };
142
- const { y: l, x: f } = t;
143
- let c = ge(n);
144
- c.left === -1 && (c = { top: l, left: f, bottom: l, right: f });
142
+ const { y: l, x: h } = t;
143
+ let c = he(n);
144
+ c.left === -1 && (c = { top: l, left: h, bottom: l, right: h });
145
145
  const d = s.current, b = i.trim(c), y = ks(b, {
146
146
  getter: (m, p) => m.getPolicy(p).serializeForClipboard({ point: p, sheet: m })
147
147
  }), g = Ts(b, {
@@ -158,9 +158,9 @@ const ae = ln(
158
158
  } else d != null && (d.value = y, O(d), d.select(), document.execCommand("copy"), d.value = "", d.blur());
159
159
  return c;
160
160
  }, ks = (e, {
161
- getter: n = (l, f) => {
162
- var h;
163
- return String(((h = l.getCell(f)) == null ? void 0 : h.value) ?? "");
161
+ getter: n = (l, h) => {
162
+ var f;
163
+ return String(((f = l.getCell(h)) == null ? void 0 : f.value) ?? "");
164
164
  },
165
165
  filteredRowsIncluded: t = !1,
166
166
  trailingEmptyRowsOmitted: s = !1,
@@ -169,22 +169,22 @@ const ae = ln(
169
169
  `
170
170
  } = {}) => {
171
171
  const l = [];
172
- for (let f = e.top; f <= e.bottom; f++) {
173
- if (e.isRowFiltered(f) && !t)
172
+ for (let h = e.top; h <= e.bottom; h++) {
173
+ if (e.isRowFiltered(h) && !t)
174
174
  continue;
175
- const h = [];
175
+ const f = [];
176
176
  let c = !0;
177
177
  for (let d = e.left; d <= e.right; d++) {
178
- const y = n(e, { y: f, x: d });
178
+ const y = n(e, { y: h, x: d });
179
179
  y !== "" && (c = !1), y.indexOf(`
180
- `) !== -1 ? h.push(`"${y.replace(/"/g, '""')}"`) : h.push(y);
180
+ `) !== -1 ? f.push(`"${y.replace(/"/g, '""')}"`) : f.push(y);
181
181
  }
182
- l.push({ isEmpty: c, line: h.join(o) });
182
+ l.push({ isEmpty: c, line: f.join(o) });
183
183
  }
184
184
  if (s)
185
185
  for (; l.length > 0 && l[l.length - 1].isEmpty; )
186
186
  l.pop();
187
- return l.map((f) => f.line).join(i);
187
+ return l.map((h) => h.line).join(i);
188
188
  }, Ts = (e, {
189
189
  getter: n = (o, i) => {
190
190
  var l;
@@ -198,44 +198,44 @@ const ae = ln(
198
198
  if (e.isRowFiltered(i) && !t)
199
199
  continue;
200
200
  const l = [];
201
- let f = !0;
202
- for (let h = e.left; h <= e.right; h++) {
203
- const d = n(e, { y: i, x: h });
204
- d !== "" && (f = !1);
201
+ let h = !0;
202
+ for (let f = e.left; f <= e.right; f++) {
203
+ const d = n(e, { y: i, x: f });
204
+ d !== "" && (h = !1);
205
205
  const b = d.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
206
206
  l.push(`<td>${b}</td>`);
207
207
  }
208
- o.push({ isEmpty: f, html: `<tr>${l.join("")}</tr>` });
208
+ o.push({ isEmpty: h, html: `<tr>${l.join("")}</tr>` });
209
209
  }
210
210
  if (s)
211
211
  for (; o.length > 0 && o[o.length - 1].isEmpty; )
212
212
  o.pop();
213
213
  return `<table>${o.map((i) => i.html).join("")}</table>`;
214
214
  }, Cn = ({ inputting: e, selectionStart: n, optionsAll: t, functions: s }) => {
215
- const [o, i] = J(0), { filteredOptions: l, matchParams: f, activeFunctionHelp: h, activeArgIndex: c } = $e(() => {
216
- var C, D;
215
+ const [o, i] = te(0), { filteredOptions: l, matchParams: h, activeFunctionHelp: f, activeArgIndex: c } = $e(() => {
216
+ var C, I;
217
217
  const g = e.startsWith("=");
218
218
  let m = null, p = 0;
219
- const A = e.slice(0, n), x = e.slice(n);
220
- if (g && A.length > 1)
219
+ const M = e.slice(0, n), E = e.slice(n);
220
+ if (g && M.length > 1)
221
221
  try {
222
- const r = A.slice(1), u = new Ge(r);
222
+ const r = M.slice(1), u = new Ge(r);
223
223
  u.tokenize();
224
224
  const v = [];
225
225
  for (let N = 0; N < u.tokens.length; N++) {
226
- const I = u.tokens[N];
227
- if (I.type === "FUNCTION") {
226
+ const A = u.tokens[N];
227
+ if (A.type === "FUNCTION") {
228
228
  const R = u.tokens[N + 1];
229
- (R == null ? void 0 : R.type) === "OPEN" ? (v.push({ name: I.entity, argIndex: 0, hasWaitComma: !1 }), N++) : u.tokens.length - 1;
230
- } else I.type === "COMMA" ? v.length > 0 && (v[v.length - 1].argIndex++, v[v.length - 1].hasWaitComma = !0) : I.type === "CLOSE" ? v.length > 0 && v.pop() : I.type !== "SPACE" && v.length > 0 && (v[v.length - 1].hasWaitComma = !1);
229
+ (R == null ? void 0 : R.type) === "OPEN" ? (v.push({ name: A.entity, argIndex: 0, hasWaitComma: !1 }), N++) : u.tokens.length - 1;
230
+ } else A.type === "COMMA" ? v.length > 0 && (v[v.length - 1].argIndex++, v[v.length - 1].hasWaitComma = !0) : A.type === "CLOSE" ? v.length > 0 && v.pop() : A.type !== "SPACE" && v.length > 0 && (v[v.length - 1].hasWaitComma = !1);
231
231
  }
232
232
  if (v.length > 0) {
233
- const N = v[v.length - 1], I = Pt(s);
234
- p = N.argIndex, m = I.find((R) => R.name === N.name.toUpperCase()) || null;
233
+ const N = v[v.length - 1], A = Pt(s);
234
+ p = N.argIndex, m = A.find((R) => R.name === N.name.toUpperCase()) || null;
235
235
  }
236
236
  } catch {
237
237
  }
238
- const F = ((C = A.match(/[a-zA-Z0-9_.]+$/)) == null ? void 0 : C[0]) || "", T = ((D = x.match(/^[a-zA-Z0-9_.]+/)) == null ? void 0 : D[0]) || "", S = g ? (F + T).toLowerCase() : e.toLocaleLowerCase(), M = g && x.slice(T.length).trimStart().startsWith("(");
238
+ const F = ((C = M.match(/[a-zA-Z0-9_.]+$/)) == null ? void 0 : C[0]) || "", T = ((I = E.match(/^[a-zA-Z0-9_.]+/)) == null ? void 0 : I[0]) || "", S = g ? (F + T).toLowerCase() : e.toLocaleLowerCase(), D = g && E.slice(T.length).trimStart().startsWith("(");
239
239
  let $ = [], P = !1;
240
240
  if (g)
241
241
  try {
@@ -252,10 +252,10 @@ const ae = ln(
252
252
  }
253
253
  } catch {
254
254
  }
255
- return g && !P ? S.length > 0 && !M && ($ = Pt(s).map((r) => {
256
- const u = r.name.toLowerCase(), v = u.startsWith(S), N = v ? 0 : -1, I = r.defs.length === 0;
255
+ return g && !P ? S.length > 0 && !D && ($ = Pt(s).map((r) => {
256
+ const u = r.name.toLowerCase(), v = u.startsWith(S), N = v ? 0 : -1, A = r.defs.length === 0;
257
257
  return {
258
- option: { ...r, value: r.name + (I ? "()" : "("), isFunction: !0, label: r.name },
258
+ option: { ...r, value: r.name + (A ? "()" : "("), isFunction: !0, label: r.name },
259
259
  index: N,
260
260
  startsWith: v,
261
261
  keywordCount: 1,
@@ -265,9 +265,9 @@ const ae = ln(
265
265
  const u = r.keywords ?? [String(r.value)];
266
266
  let v = { index: -1, startsWith: !1, keyword: "" };
267
267
  for (const N of u) {
268
- const I = N.toLowerCase(), R = I.indexOf(S);
268
+ const A = N.toLowerCase(), R = A.indexOf(S);
269
269
  if (R !== -1) {
270
- const H = I.startsWith(S);
270
+ const H = A.startsWith(S);
271
271
  (v.index === -1 || R < v.index || R === v.index && H && !v.startsWith) && (v = { index: R, startsWith: H, keyword: N });
272
272
  }
273
273
  }
@@ -295,13 +295,13 @@ const ae = ln(
295
295
  (g) => {
296
296
  if (!g)
297
297
  return { value: e, selectionStart: n };
298
- if (f.isFormula) {
299
- const m = e.slice(0, n - f.matchLengthBefore), p = e.slice(n + f.matchLengthAfter);
298
+ if (h.isFormula) {
299
+ const m = e.slice(0, n - h.matchLengthBefore), p = e.slice(n + h.matchLengthAfter);
300
300
  return { value: m + g.value + p, selectionStart: m.length + g.value.length };
301
301
  } else
302
302
  return { value: String(g.value), selectionStart: String(g.value).length };
303
303
  },
304
- [e, n, f]
304
+ [e, n, h]
305
305
  ), b = k(
306
306
  (g) => l.length > 1 ? (i((m) => m <= 0 ? l.length - 1 : m - 1), g.preventDefault(), !0) : !1,
307
307
  [l.length]
@@ -316,8 +316,8 @@ const ae = ln(
316
316
  replaceWithOption: d,
317
317
  handleArrowUp: b,
318
318
  handleArrowDown: y,
319
- isFormula: f.isFormula,
320
- activeFunctionHelp: h,
319
+ isFormula: h.isFormula,
320
+ activeFunctionHelp: f,
321
321
  activeArgIndex: c
322
322
  };
323
323
  }, rt = ({ children: e, style: n, className: t = "", ...s }) => {
@@ -327,9 +327,9 @@ const ae = ln(
327
327
  o.body
328
328
  );
329
329
  }, Sn = (e, n = !1) => {
330
- const s = new DOMParser().parseFromString(e, "text/html"), o = [], i = (h) => {
330
+ const s = new DOMParser().parseFromString(e, "text/html"), o = [], i = (f) => {
331
331
  var b, y;
332
- const c = /* @__PURE__ */ new Set(), d = h.querySelectorAll("tr,caption");
332
+ const c = /* @__PURE__ */ new Set(), d = f.querySelectorAll("tr,caption");
333
333
  for (let g = 0; g < d.length; g++) {
334
334
  const m = d[g];
335
335
  if (m.tagName === "CAPTION") {
@@ -337,36 +337,36 @@ const ae = ln(
337
337
  F && o.push([{ value: F }]);
338
338
  continue;
339
339
  }
340
- const p = Array.from(m.querySelectorAll("td, th")), A = [];
341
- let x = 0;
340
+ const p = Array.from(m.querySelectorAll("td, th")), M = [];
341
+ let E = 0;
342
342
  for (const F of p) {
343
343
  const T = ((y = F.textContent) == null ? void 0 : y.trim()) ?? "", S = n ? void 0 : (() => {
344
344
  const P = Vt(F.firstElementChild);
345
345
  return { ...Vt(F), ...P };
346
346
  })();
347
- for (; c.has(`${g}-${++x}`); )
348
- A.push({ value: "", style: S, skip: !0 });
349
- A.push({ value: T, style: S });
350
- const M = parseInt(F.getAttribute("rowspan") ?? "1", 10), $ = parseInt(F.getAttribute("colspan") ?? "1", 10);
351
- for (let P = 0; P < M; P++)
347
+ for (; c.has(`${g}-${++E}`); )
348
+ M.push({ value: "", style: S, skip: !0 });
349
+ M.push({ value: T, style: S });
350
+ const D = parseInt(F.getAttribute("rowspan") ?? "1", 10), $ = parseInt(F.getAttribute("colspan") ?? "1", 10);
351
+ for (let P = 0; P < D; P++)
352
352
  for (let C = 0; C < $; C++)
353
- c.add(`${g + P}-${x + C}`);
353
+ c.add(`${g + P}-${E + C}`);
354
354
  }
355
- o.push(A);
355
+ o.push(M);
356
356
  }
357
- }, l = (h, c = []) => {
358
- if (h.nodeType === Node.ELEMENT_NODE) {
359
- const d = h, b = d.tagName;
357
+ }, l = (f, c = []) => {
358
+ if (f.nodeType === Node.ELEMENT_NODE) {
359
+ const d = f, b = d.tagName;
360
360
  b === "TABLE" ? (c.length > 0 && (o.push(c.slice()), c.length = 0), i(d)) : b === "BR" ? (o.push(c.slice()), c.length = 0) : As.has(b) ? (c.length > 0 && (o.push(c.slice()), c.length = 0), d.childNodes.forEach((y) => l(y, c)), c.length > 0 && (o.push(c.slice()), c.length = 0)) : d.childNodes.forEach((y) => l(y, c));
361
- } else if (h.nodeType === Node.TEXT_NODE) {
362
- const b = (h.textContent ?? "").split(/\r?\n/);
361
+ } else if (f.nodeType === Node.TEXT_NODE) {
362
+ const b = (f.textContent ?? "").split(/\r?\n/);
363
363
  for (const y of b) {
364
364
  const g = y.trim();
365
365
  g && c.push({ value: g });
366
366
  }
367
367
  }
368
- }, f = [];
369
- return s.body.childNodes.forEach((h) => l(h, f)), f.length > 0 && o.push(f), o;
368
+ }, h = [];
369
+ return s.body.childNodes.forEach((f) => l(f, h)), h.length > 0 && o.push(h), o;
370
370
  };
371
371
  function Vt(e) {
372
372
  if (!e)
@@ -376,7 +376,7 @@ function Vt(e) {
376
376
  let [o, i] = s.split(":");
377
377
  if (!o || !i || (o = o.trim(), o === "height" || o === "width"))
378
378
  return;
379
- const l = o.trim().replace(/-([a-z])/g, (h, c) => c.toUpperCase());
379
+ const l = o.trim().replace(/-([a-z])/g, (f, c) => c.toUpperCase());
380
380
  if (l === "float" || l === "display" || l.startsWith("padding"))
381
381
  return;
382
382
  if (l === "border") {
@@ -415,8 +415,8 @@ function Vt(e) {
415
415
  });
416
416
  return;
417
417
  }
418
- const f = i.trim();
419
- t[l] = f;
418
+ const h = i.trim();
419
+ t[l] = h;
420
420
  }), t;
421
421
  }
422
422
  const Nn = (e, n = " ") => {
@@ -424,25 +424,25 @@ const Nn = (e, n = " ") => {
424
424
  const t = [[]];
425
425
  let s = t[0], o = !1, i = "";
426
426
  for (let l = 0; l < e.length; l++) {
427
- const f = e[l];
428
- if (f === `
427
+ const h = e[l];
428
+ if (h === `
429
429
  ` && !o) {
430
430
  s.push({ value: ot(i) }), i = "", s = [], t.push(s);
431
431
  continue;
432
432
  }
433
- if (f === n) {
433
+ if (h === n) {
434
434
  s.push({ value: ot(i) }), i = "";
435
435
  continue;
436
436
  }
437
- if (f === '"' && !o && i === "") {
437
+ if (h === '"' && !o && i === "") {
438
438
  o = !0;
439
439
  continue;
440
440
  }
441
- if (f === '"' && o) {
441
+ if (h === '"' && o) {
442
442
  o = !1;
443
443
  continue;
444
444
  }
445
- i += f;
445
+ i += h;
446
446
  }
447
447
  return i && s.push({ value: ot(i) }), t;
448
448
  }, ot = (e) => e.replace(/\x00/g, '"'), As = /* @__PURE__ */ new Set([
@@ -480,31 +480,31 @@ const Nn = (e, n = " ") => {
480
480
  "UL"
481
481
  ]), Ms = ({ mode: e }) => {
482
482
  var Ft, Yt;
483
- const { store: n, dispatch: t } = le(ae), [s, o] = J(!1), [i, l] = J(0), [f, h] = J(!1), c = se(!1), {
483
+ const { store: n, dispatch: t } = le(ae), [s, o] = te(!1), [i, l] = te(0), [h, f] = te(!1), c = re(!1), {
484
484
  choosing: d,
485
485
  inputting: b,
486
486
  selectingZone: y,
487
487
  editorRect: g,
488
488
  editingAddress: m,
489
489
  entering: p,
490
- matchingCells: A,
491
- matchingCellIndex: x,
490
+ matchingCells: M,
491
+ matchingCellIndex: E,
492
492
  searchQuery: F,
493
493
  editorRef: T,
494
494
  largeEditorRef: S,
495
- searchInputRef: M,
495
+ searchInputRef: D,
496
496
  editingOnEnter: $,
497
497
  sheetReactive: P,
498
498
  sheetId: C,
499
- dragging: D
499
+ dragging: I
500
500
  } = n, r = P.current, u = () => {
501
- var de;
502
- if (!f || !L || typeof document > "u" || T.current !== document.activeElement)
501
+ var ge;
502
+ if (!h || !L || typeof document > "u" || T.current !== document.activeElement)
503
503
  return null;
504
- const E = (de = T.current) == null ? void 0 : de.getBoundingClientRect();
505
- if (!E)
504
+ const x = (ge = T.current) == null ? void 0 : ge.getBoundingClientRect();
505
+ if (!x)
506
506
  return null;
507
- const { bottom: q, left: ie } = E;
507
+ const { bottom: V, left: ie } = x;
508
508
  return St(
509
509
  /* @__PURE__ */ Y(Re, { children: [
510
510
  B && R.length === 0 && (!y || y.endY === -1 && y.endX === -1) && /* @__PURE__ */ a(
@@ -512,7 +512,7 @@ const Nn = (e, n = " ") => {
512
512
  {
513
513
  activeFunctionGuide: B,
514
514
  activeArgIndex: z,
515
- top: q,
515
+ top: V,
516
516
  left: ie
517
517
  }
518
518
  ),
@@ -520,7 +520,7 @@ const Nn = (e, n = " ") => {
520
520
  Rn,
521
521
  {
522
522
  filteredOptions: R,
523
- top: q,
523
+ top: V,
524
524
  left: ie,
525
525
  selected: H,
526
526
  onOptionMouseDown: Vn
@@ -529,14 +529,14 @@ const Nn = (e, n = " ") => {
529
529
  ] }),
530
530
  document.body
531
531
  );
532
- }, v = r == null ? void 0 : r.getPolicy(d), N = (v == null ? void 0 : v.getSelectOptions()) ?? [], I = k((E) => {
533
- l(E.currentTarget.selectionStart);
532
+ }, v = r == null ? void 0 : r.getPolicy(d), N = (v == null ? void 0 : v.getSelectOptions()) ?? [], A = k((x) => {
533
+ l(x.currentTarget.selectionStart);
534
534
  }, []), {
535
535
  filteredOptions: R,
536
536
  selected: H,
537
- setSelected: G,
537
+ setSelected: q,
538
538
  replaceWithOption: _,
539
- handleArrowUp: re,
539
+ handleArrowUp: oe,
540
540
  handleArrowDown: ce,
541
541
  activeFunctionHelp: B,
542
542
  activeArgIndex: z
@@ -546,68 +546,68 @@ const Nn = (e, n = " ") => {
546
546
  optionsAll: N,
547
547
  functions: r == null ? void 0 : r.registry.functions
548
548
  });
549
- Z(() => {
549
+ W(() => {
550
550
  O(T == null ? void 0 : T.current);
551
- }, [T]), Z(() => {
551
+ }, [T]), W(() => {
552
552
  r && r.registry.lastFocused != null && r.registry.lastFocused === T.current && r.registry.lastFocused === S.current && t(ue(""));
553
- }, [r == null ? void 0 : r.registry.lastFocused, r, T, S, t]), Z(() => {
553
+ }, [r == null ? void 0 : r.registry.lastFocused, r, T, S, t]), W(() => {
554
554
  r && (r.registry.editingSheetId = C, r.registry.editingAddress = m);
555
- }, [m, r, C]), Z(() => {
555
+ }, [m, r, C]), W(() => {
556
556
  Qn(T.current);
557
557
  }, [b, m, T]);
558
- const { y: U, x: K } = d, W = `${be(U)}`, j = `${pe(K)}${W}`, L = m === j, oe = r == null ? void 0 : r.getCell({ y: U, x: K }, { resolution: "RAW" }), w = r ? r.getSerializedValue({ point: d, cell: oe, resolution: "RAW" }) : "", [V, fe] = J(w), te = k(
559
- (E) => {
560
- V !== E && t(Ue({ value: E })), fe(E);
558
+ const { y: Z, x: J } = d, j = `${be(Z)}`, G = `${pe(J)}${j}`, L = m === G, Q = r == null ? void 0 : r.getCell({ y: Z, x: J }, { resolution: "RAW" }), w = r ? r.getSerializedValue({ point: d, cell: Q, resolution: "RAW" }) : "", [K, de] = te(w), ee = k(
559
+ (x) => {
560
+ K !== x && t(Ze({ value: x })), de(x);
561
561
  },
562
- [V, t]
562
+ [K, t]
563
563
  ), ye = k(
564
- (E) => {
564
+ (x) => {
565
565
  if (!r)
566
566
  return;
567
- const q = R[E];
568
- if (q) {
569
- if (q.isFunction) {
570
- const { value: ie, selectionStart: de } = _(q);
571
- t(ee(ie)), setTimeout(() => {
572
- T.current && (O(T.current), T.current.setSelectionRange(de, de));
567
+ const V = R[x];
568
+ if (V) {
569
+ if (V.isFunction) {
570
+ const { value: ie, selectionStart: ge } = _(V);
571
+ t(ne(ie)), setTimeout(() => {
572
+ T.current && (O(T.current), T.current.setSelectionRange(ge, ge));
573
573
  }, 0);
574
574
  } else {
575
575
  const ie = r.update({
576
- diff: { [j]: { value: q.value } },
576
+ diff: { [G]: { value: V.value } },
577
577
  partial: !0
578
578
  });
579
- t(ze(ie.clone())), t(ue("")), t(ee(""));
579
+ t(Ue(ie.clone())), t(ue("")), t(ne(""));
580
580
  }
581
- G(0);
581
+ q(0);
582
582
  }
583
583
  },
584
- [R, r, j, b, te, t, T]
584
+ [R, r, G, b, ee, t, T]
585
585
  );
586
- Z(() => {
587
- r && (fe(w), t(ee(w)), Jn(T.current, r, d));
586
+ W(() => {
587
+ r && (de(w), t(ne(w)), Jn(T.current, r, d));
588
588
  }, [d, w, t, T, r]);
589
- const { y: xe, x: _e, height: At, width: Mt } = g, Bn = w.split(`
590
- `).length, [Dt, It] = J(!1), Kn = k(
591
- (E) => {
592
- var de, Oe, Me, Le, Be, $t;
593
- if (!r || E.nativeEvent.isComposing || c.current || Dt)
589
+ const { y: Ee, x: _e, height: At, width: Mt } = g, Bn = w.split(`
590
+ `).length, [Dt, It] = te(!1), Kn = k(
591
+ (x) => {
592
+ var ge, Oe, Me, Le, Be, $t;
593
+ if (!r || x.nativeEvent.isComposing || c.current || Dt)
594
594
  return;
595
- E.key === "Meta" || E.key === "Control" || (It(!0), requestAnimationFrame(() => {
595
+ x.key === "Meta" || x.key === "Control" || (It(!0), requestAnimationFrame(() => {
596
596
  It(!1);
597
597
  }));
598
- const q = E.currentTarget;
599
- if (tn(E, b))
600
- return t(ee(q.value)), !1;
601
- const ie = E.shiftKey;
602
- switch (E.key) {
598
+ const V = x.currentTarget;
599
+ if (tn(x, b))
600
+ return t(ne(V.value)), !1;
601
+ const ie = x.shiftKey;
602
+ switch (x.key) {
603
603
  case "Tab":
604
- if (E.preventDefault(), L)
604
+ if (x.preventDefault(), L)
605
605
  if (R.length) {
606
- const ve = (de = R[H]) == null ? void 0 : de.isFunction;
606
+ const ve = (ge = R[H]) == null ? void 0 : ge.isFunction;
607
607
  if (ye(H), ve)
608
608
  return !1;
609
609
  } else
610
- te(q.value), t(ue("")), t(ee(""));
610
+ ee(V.value), t(ue("")), t(ne(""));
611
611
  return t(
612
612
  dt({
613
613
  numRows: r.numRows,
@@ -621,18 +621,18 @@ const Nn = (e, n = " ") => {
621
621
  if (R.length) {
622
622
  const ve = (Oe = R[H]) == null ? void 0 : Oe.isFunction;
623
623
  if (ye(H), ve)
624
- return E.preventDefault(), !1;
624
+ return x.preventDefault(), !1;
625
625
  } else {
626
- if (E.altKey)
627
- return nn(q, `
628
- `), t(ee(q.value)), E.preventDefault(), !1;
629
- if (E.nativeEvent.isComposing)
626
+ if (x.altKey)
627
+ return nn(V, `
628
+ `), t(ne(V.value)), x.preventDefault(), !1;
629
+ if (x.nativeEvent.isComposing)
630
630
  return !1;
631
- te(q.value), t(ue("")), t(ee(""));
631
+ ee(V.value), t(ue("")), t(ne(""));
632
632
  }
633
633
  else if ($ && y.endY === -1) {
634
634
  const ve = document.createEvent("MouseEvents");
635
- return ve.initEvent("dblclick", !0, !0), q.dispatchEvent(ve), E.preventDefault(), !1;
635
+ return ve.initEvent("dblclick", !0, !0), V.dispatchEvent(ve), x.preventDefault(), !1;
636
636
  }
637
637
  return t(
638
638
  dt({
@@ -641,14 +641,14 @@ const Nn = (e, n = " ") => {
641
641
  deltaY: ie ? -1 : 1,
642
642
  deltaX: 0
643
643
  })
644
- ), E.preventDefault(), !1;
644
+ ), x.preventDefault(), !1;
645
645
  case "Backspace":
646
646
  if (!L)
647
- return ((Me = r.getSystem({ y: U, x: K })) == null ? void 0 : Me.spilledFrom) != null ? (E.preventDefault(), !1) : (t(Ut(null)), t(ee("")), !1);
647
+ return ((Me = r.getSystem({ y: Z, x: J })) == null ? void 0 : Me.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(ne("")), !1);
648
648
  break;
649
649
  case "Delete":
650
650
  if (!L)
651
- return ((Le = r.getSystem({ y: U, x: K })) == null ? void 0 : Le.spilledFrom) != null ? (E.preventDefault(), !1) : (t(Ut(null)), t(ee("")), !1);
651
+ return ((Le = r.getSystem({ y: Z, x: J })) == null ? void 0 : Le.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(ne("")), !1);
652
652
  break;
653
653
  case "Shift":
654
654
  return o(!0), !1;
@@ -661,7 +661,7 @@ const Nn = (e, n = " ") => {
661
661
  case "NumLock":
662
662
  return !1;
663
663
  case "Escape":
664
- return t(ws(null)), t(Pe(void 0)), t(ee(V)), !1;
664
+ return t(ws(null)), t(Pe(void 0)), t(ne(K)), !1;
665
665
  case "ArrowLeft":
666
666
  if (!L)
667
667
  return t(
@@ -685,7 +685,7 @@ const Nn = (e, n = " ") => {
685
685
  deltaX: 0
686
686
  })
687
687
  ), !1;
688
- if (re(E))
688
+ if (oe(x))
689
689
  return !0;
690
690
  break;
691
691
  case "ArrowRight":
@@ -711,12 +711,12 @@ const Nn = (e, n = " ") => {
711
711
  deltaX: 0
712
712
  })
713
713
  ), !1;
714
- if (ce(E))
714
+ if (ce(x))
715
715
  return !0;
716
716
  break;
717
717
  case "a":
718
- if ((E.ctrlKey || E.metaKey) && !L)
719
- return E.preventDefault(), t(
718
+ if ((x.ctrlKey || x.metaKey) && !L)
719
+ return x.preventDefault(), t(
720
720
  we({
721
721
  startY: 1,
722
722
  startX: 1,
@@ -726,28 +726,28 @@ const Nn = (e, n = " ") => {
726
726
  ), !1;
727
727
  break;
728
728
  case "c":
729
- if (E.ctrlKey || E.metaKey) {
729
+ if (x.ctrlKey || x.metaKey) {
730
730
  if (!L) {
731
- E.preventDefault();
731
+ x.preventDefault();
732
732
  const ve = tt(n);
733
- return t(gn(Qe(ve))), O(q), !1;
733
+ return t(gn(Qe(ve))), O(V), !1;
734
734
  }
735
735
  return !0;
736
736
  }
737
737
  break;
738
738
  case "f":
739
- if ((E.ctrlKey || E.metaKey) && !L)
740
- return E.preventDefault(), typeof F > "u" && t(Pe("")), t(dn(!1)), requestAnimationFrame(() => O(M.current)), !1;
739
+ if ((x.ctrlKey || x.metaKey) && !L)
740
+ return x.preventDefault(), typeof F > "u" && t(Pe("")), t(dn(!1)), requestAnimationFrame(() => O(D.current)), !1;
741
741
  break;
742
742
  case "r":
743
743
  // R
744
744
  case "y":
745
- if ((E.ctrlKey || E.metaKey) && !L)
746
- return E.preventDefault(), t(ut(null)), requestAnimationFrame(() => t(ee(""))), !1;
745
+ if ((x.ctrlKey || x.metaKey) && !L)
746
+ return x.preventDefault(), t(ut(null)), requestAnimationFrame(() => t(ne(""))), !1;
747
747
  break;
748
748
  case "s":
749
- if ((E.ctrlKey || E.metaKey) && !L)
750
- return E.preventDefault(), ($t = (Be = r.registry).onSave) == null || $t.call(Be, {
749
+ if ((x.ctrlKey || x.metaKey) && !L)
750
+ return x.preventDefault(), ($t = (Be = r.registry).onSave) == null || $t.call(Be, {
751
751
  sheet: r,
752
752
  points: {
753
753
  pointing: d,
@@ -763,25 +763,25 @@ const Nn = (e, n = " ") => {
763
763
  }), !1;
764
764
  break;
765
765
  case "v":
766
- if (E.ctrlKey || E.metaKey)
767
- return E.stopPropagation(), !1;
766
+ if (x.ctrlKey || x.metaKey)
767
+ return x.stopPropagation(), !1;
768
768
  break;
769
769
  case "x":
770
- if ((E.ctrlKey || E.metaKey) && !L) {
771
- E.preventDefault();
770
+ if ((x.ctrlKey || x.metaKey) && !L) {
771
+ x.preventDefault();
772
772
  const ve = tt(n);
773
- return t(un(Qe(ve))), O(q), !1;
773
+ return t(un(Qe(ve))), O(V), !1;
774
774
  }
775
775
  break;
776
776
  case "z":
777
- if ((E.ctrlKey || E.metaKey) && !L)
778
- return E.preventDefault(), E.shiftKey ? t(ut(null)) : t(cn(null)), !1;
777
+ if ((x.ctrlKey || x.metaKey) && !L)
778
+ return x.preventDefault(), x.shiftKey ? t(ut(null)) : t(cn(null)), !1;
779
779
  break;
780
780
  case ";":
781
- (E.ctrlKey || E.metaKey) && (L || (E.preventDefault(), te((/* @__PURE__ */ new Date()).toDateString())));
781
+ (x.ctrlKey || x.metaKey) && (L || (x.preventDefault(), ee((/* @__PURE__ */ new Date()).toDateString())));
782
782
  break;
783
783
  }
784
- return E.ctrlKey || E.metaKey ? !1 : X.hasOperation(oe == null ? void 0 : oe.prevention, X.Write) ? (console.warn("This cell is protected from writing."), !1) : (t(ue(j)), L || t(ee("")), G(0), !1);
784
+ return x.ctrlKey || x.metaKey ? !1 : X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) ? (console.warn("This cell is protected from writing."), !1) : (t(ue(G)), L || t(ne("")), q(0), !1);
785
785
  },
786
786
  [
787
787
  Dt,
@@ -790,90 +790,90 @@ const Nn = (e, n = " ") => {
790
790
  H,
791
791
  $,
792
792
  y,
793
- V,
793
+ K,
794
794
  r,
795
795
  d,
796
796
  n,
797
- oe,
798
- j,
799
- te,
797
+ Q,
798
+ G,
799
+ ee,
800
800
  F,
801
801
  b
802
802
  ]
803
- ), Zn = k(
804
- (E) => {
805
- h(!0), r && (r.registry.lastFocused = E.currentTarget);
803
+ ), Wn = k(
804
+ (x) => {
805
+ f(!0), r && (r.registry.lastFocused = x.currentTarget);
806
806
  },
807
807
  [r]
808
- ), Un = k(
809
- (E) => {
810
- if (X.hasOperation(oe == null ? void 0 : oe.prevention, X.Write)) {
808
+ ), Zn = k(
809
+ (x) => {
810
+ if (X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write)) {
811
811
  console.warn("This cell is protected from writing.");
812
812
  return;
813
813
  }
814
- const q = E.currentTarget;
815
- L || (t(ee(w)), t(ue(j)), requestAnimationFrame(() => {
816
- q.style.width = `${q.scrollWidth}px`, q.style.height = `${q.scrollHeight}px`;
814
+ const V = x.currentTarget;
815
+ L || (t(ne(w)), t(ue(G)), requestAnimationFrame(() => {
816
+ V.style.width = `${V.scrollWidth}px`, V.style.height = `${V.scrollHeight}px`;
817
817
  const ie = new String(w).length;
818
- q.setSelectionRange(ie, ie);
818
+ V.setSelectionRange(ie, ie);
819
819
  }));
820
820
  },
821
- [oe, L, w, j]
822
- ), zn = k(
823
- (E) => {
824
- if (h(!1), sn(E.currentTarget))
821
+ [Q, L, w, G]
822
+ ), Un = k(
823
+ (x) => {
824
+ if (f(!1), sn(x.currentTarget))
825
825
  return !0;
826
- L && te(E.currentTarget.value), t(ue(""));
826
+ L && ee(x.currentTarget.value), t(ue(""));
827
827
  },
828
- [L, te, t]
829
- ), Wn = k(
830
- (E) => {
831
- X.hasOperation(oe == null ? void 0 : oe.prevention, X.Write) || (t(ee(E.currentTarget.value)), l(E.currentTarget.selectionStart), G(0));
828
+ [L, ee, t]
829
+ ), zn = k(
830
+ (x) => {
831
+ X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) || (t(ne(x.currentTarget.value)), l(x.currentTarget.selectionStart), q(0));
832
832
  },
833
- [oe]
833
+ [Q]
834
834
  ), _n = k(
835
- (E) => {
836
- var de, Oe, Me, Le;
835
+ (x) => {
836
+ var ge, Oe, Me, Le;
837
837
  if (L)
838
838
  return !0;
839
- const q = s, ie = (Oe = (de = E.clipboardData) == null ? void 0 : de.getData) == null ? void 0 : Oe.call(de, "text/html");
839
+ const V = s, ie = (Oe = (ge = x.clipboardData) == null ? void 0 : ge.getData) == null ? void 0 : Oe.call(ge, "text/html");
840
840
  if (ie)
841
- t(gt({ matrix: Sn(ie), onlyValue: q }));
841
+ t(gt({ matrix: Sn(ie), onlyValue: V }));
842
842
  else {
843
- const Be = (Le = (Me = E.clipboardData) == null ? void 0 : Me.getData) == null ? void 0 : Le.call(Me, "text/plain");
844
- Be ? t(gt({ matrix: Nn(Be), onlyValue: q })) : console.warn("No clipboard data found.");
843
+ const Be = (Le = (Me = x.clipboardData) == null ? void 0 : Me.getData) == null ? void 0 : Le.call(Me, "text/plain");
844
+ Be ? t(gt({ matrix: Nn(Be), onlyValue: V })) : console.warn("No clipboard data found.");
845
845
  }
846
- return E.preventDefault(), E.stopPropagation(), !1;
846
+ return x.preventDefault(), x.stopPropagation(), !1;
847
847
  },
848
848
  [L, s]
849
849
  ), jn = k(
850
- (E) => {
851
- var ie, de;
850
+ (x) => {
851
+ var ie, ge;
852
852
  o(!1);
853
- const q = ge(n.selectingZone);
854
- (de = r == null ? void 0 : (ie = r.registry).onKeyUp) == null || de.call(ie, {
855
- e: E,
853
+ const V = he(n.selectingZone);
854
+ (ge = r == null ? void 0 : (ie = r.registry).onKeyUp) == null || ge.call(ie, {
855
+ e: x,
856
856
  points: {
857
857
  pointing: d,
858
- selectingFrom: { y: q.top, x: q.left },
859
- selectingTo: { y: q.bottom, x: q.right }
858
+ selectingFrom: { y: V.top, x: V.left },
859
+ selectingTo: { y: V.bottom, x: V.right }
860
860
  }
861
861
  });
862
862
  },
863
863
  [n.selectingZone, d, r]
864
864
  ), Vn = k(
865
- (E, q) => (ye(q), E.preventDefault(), E.stopPropagation(), !1),
865
+ (x, V) => (ye(V), x.preventDefault(), x.stopPropagation(), !1),
866
866
  [ye]
867
867
  );
868
868
  return r ? /* @__PURE__ */ Y(
869
869
  rt,
870
870
  {
871
871
  className: `gs-editor ${L ? "gs-editing" : ""}`,
872
- style: L ? { top: xe, left: _e, height: At } : {},
872
+ style: L ? { top: Ee, left: _e, height: At } : {},
873
873
  "data-mode": e,
874
874
  "data-sheet-id": C,
875
875
  children: [
876
- /* @__PURE__ */ a("div", { className: `gs-cell-label ${L ? " gs-hidden" : ""}`, children: j }),
876
+ /* @__PURE__ */ a("div", { className: `gs-cell-label ${L ? " gs-hidden" : ""}`, children: G }),
877
877
  /* @__PURE__ */ Y("div", { className: "gs-editor-inner", style: { width: Mt }, children: [
878
878
  /* @__PURE__ */ a(
879
879
  "pre",
@@ -884,7 +884,7 @@ const Nn = (e, n = " ") => {
884
884
  height: (Ft = T.current) == null ? void 0 : Ft.scrollHeight,
885
885
  width: (((Yt = T.current) == null ? void 0 : Yt.scrollWidth) ?? 0) - 4
886
886
  },
887
- children: (oe == null ? void 0 : oe.formulaEnabled) ?? !0 ? En(b) : b
887
+ children: (Q == null ? void 0 : Q.formulaEnabled) ?? !0 ? xn(b) : b
888
888
  }
889
889
  ),
890
890
  /* @__PURE__ */ a(
@@ -898,21 +898,21 @@ const Nn = (e, n = " ") => {
898
898
  draggable: !1,
899
899
  ref: T,
900
900
  rows: Bn,
901
- onFocus: Zn,
901
+ onFocus: Wn,
902
902
  style: { minWidth: Mt, minHeight: At },
903
- onDoubleClick: Un,
904
- onBlur: zn,
903
+ onDoubleClick: Zn,
904
+ onBlur: Un,
905
905
  value: b,
906
- onChange: Wn,
907
- onSelect: I,
906
+ onChange: zn,
907
+ onSelect: A,
908
908
  onPaste: _n,
909
909
  onKeyDown: Kn,
910
910
  onKeyUp: jn,
911
911
  onCompositionStart: () => {
912
- c.current = !0, L || (t(ue(j)), t(ee("")));
912
+ c.current = !0, L || (t(ue(G)), t(ne("")));
913
913
  },
914
- onCompositionEnd: (E) => {
915
- c.current = !1, t(ee(E.currentTarget.value));
914
+ onCompositionEnd: (x) => {
915
+ c.current = !1, t(ne(x.currentTarget.value));
916
916
  },
917
917
  onMouseEnter: () => {
918
918
  t(Je(!0));
@@ -930,7 +930,7 @@ const Nn = (e, n = " ") => {
930
930
  }, it = nt(
931
931
  ({ token: e, tokenKey: n, color: t, className: s }) => /* @__PURE__ */ a("span", { style: t ? { color: t } : void 0, className: s, children: e.stringify() }, n),
932
932
  (e, n) => e.tokenKey === n.tokenKey && e.color === n.color && e.className === n.className && e.token.stringify() === n.token.stringify()
933
- ), En = (e) => {
933
+ ), xn = (e) => {
934
934
  if (e[0] !== "=")
935
935
  return /* @__PURE__ */ a(Re, { children: e });
936
936
  const n = new Ge(e.substring(1));
@@ -942,45 +942,45 @@ const Nn = (e, n = " ") => {
942
942
  n.tokens.map((i, l) => {
943
943
  if (i.type === "SPACE")
944
944
  return /* @__PURE__ */ a(at.Fragment, { children: i.stringify() }, `${o}-SPACE-${l}`);
945
- const f = `${o}-${i.type}-${i.stringify()}-${l}`;
945
+ const h = `${o}-${i.type}-${i.stringify()}-${l}`;
946
946
  if (i.type === "REF" || i.type === "RANGE") {
947
- const h = i.stringify(), c = s[h];
947
+ const f = i.stringify(), c = s[f];
948
948
  if (c !== void 0)
949
949
  return /* @__PURE__ */ a(
950
950
  it,
951
951
  {
952
952
  token: i,
953
- tokenKey: f,
953
+ tokenKey: h,
954
954
  color: Ie[c % Ie.length]
955
955
  },
956
- f
956
+ h
957
957
  );
958
958
  const d = Ie[t % Ie.length];
959
- return s[h] = t++, /* @__PURE__ */ a(
959
+ return s[f] = t++, /* @__PURE__ */ a(
960
960
  it,
961
961
  {
962
962
  token: i,
963
- tokenKey: f,
963
+ tokenKey: h,
964
964
  color: d,
965
965
  className: `gs-token-type-${i.type}`
966
966
  },
967
- f
967
+ h
968
968
  );
969
969
  }
970
970
  return /* @__PURE__ */ a(
971
971
  it,
972
972
  {
973
973
  token: i,
974
- tokenKey: f,
974
+ tokenKey: h,
975
975
  className: `gs-token-type-${i.type} gs-token-entity-type-${typeof i.entity}`
976
976
  },
977
- f
977
+ h
978
978
  );
979
979
  })
980
980
  ] });
981
- }, xn = ln({});
981
+ }, En = ln({});
982
982
  function Nr() {
983
- const [e, n] = J(void 0), [t, s] = J();
983
+ const [e, n] = te(void 0), [t, s] = te();
984
984
  return {
985
985
  provided: !0,
986
986
  store: e,
@@ -990,12 +990,12 @@ function Nr() {
990
990
  };
991
991
  }
992
992
  function kn() {
993
- const e = le(xn);
993
+ const e = le(En);
994
994
  return (e == null ? void 0 : e.provided) == null ? [!1, e] : [!0, e];
995
995
  }
996
- function Er({ children: e, context: n }) {
996
+ function xr({ children: e, context: n }) {
997
997
  const [t] = kn();
998
- return t ? /* @__PURE__ */ a(Re, { children: e }) : /* @__PURE__ */ a(xn.Provider, { value: n, children: e });
998
+ return t ? /* @__PURE__ */ a(Re, { children: e }) : /* @__PURE__ */ a(En.Provider, { value: n, children: e });
999
999
  }
1000
1000
  const Ds = ({
1001
1001
  sheetName: e,
@@ -1006,38 +1006,38 @@ const Ds = ({
1006
1006
  editingOnEnter: i,
1007
1007
  mode: l
1008
1008
  }) => {
1009
- const { store: f, dispatch: h } = le(ae), { sheetReactive: c } = f, d = c.current;
1010
- Z(() => {
1009
+ const { store: h, dispatch: f } = le(ae), { sheetReactive: c } = h, d = c.current;
1010
+ W(() => {
1011
1011
  d && e && e !== d.name && (d.name = e, d.registry.sheetIdsByName[e] = d.id, delete d.registry.sheetIdsByName[d.prevName], d.prevName = e);
1012
- }, [e]), Z(() => {
1012
+ }, [e]), W(() => {
1013
1013
  if (!d)
1014
1014
  return;
1015
1015
  const { registry: g } = d;
1016
- requestAnimationFrame(() => g.boot()), g.contextsBySheetId[d.id] = { store: f, dispatch: h }, g.transmit(), s && (s.current = {
1016
+ requestAnimationFrame(() => g.boot()), g.contextsBySheetId[d.id] = { store: h, dispatch: f }, g.transmit(), s && (s.current = {
1017
1017
  sheet: d,
1018
1018
  apply: (m) => {
1019
- h(ze(m));
1019
+ f(Ue(m));
1020
1020
  }
1021
1021
  }), o && (o.current = {
1022
- store: f,
1022
+ store: h,
1023
1023
  apply: (m) => {
1024
- h(Ne(m));
1024
+ f(Ne(m));
1025
1025
  },
1026
- dispatch: h
1026
+ dispatch: f
1027
1027
  });
1028
- }, [f, d, s, o]), Z(() => {
1029
- n && h(Ne({ sheetHeight: n }));
1030
- }, [n, h]), Z(() => {
1031
- t && h(Ne({ sheetWidth: t }));
1032
- }, [t]), Z(() => {
1033
- typeof i < "u" && h(Ne({ editingOnEnter: i }));
1034
- }, [i]), Z(() => {
1035
- l && h(Ne({ mode: l }));
1028
+ }, [h, d, s, o]), W(() => {
1029
+ n && f(Ne({ sheetHeight: n }));
1030
+ }, [n, f]), W(() => {
1031
+ t && f(Ne({ sheetWidth: t }));
1032
+ }, [t]), W(() => {
1033
+ typeof i < "u" && f(Ne({ editingOnEnter: i }));
1034
+ }, [i]), W(() => {
1035
+ l && f(Ne({ mode: l }));
1036
1036
  }, [l]);
1037
1037
  const [b, y] = kn();
1038
- return Z(() => {
1039
- b && (y.setStore(f), y.setApply(() => h));
1040
- }, [f, b, y]), /* @__PURE__ */ a(Re, {});
1038
+ return W(() => {
1039
+ b && (y.setStore(h), y.setApply(() => f));
1040
+ }, [h, b, y]), /* @__PURE__ */ a(Re, {});
1041
1041
  }, Is = () => {
1042
1042
  const { store: e, dispatch: n } = le(ae), {
1043
1043
  resizingPositionY: t,
@@ -1045,55 +1045,55 @@ const Ds = ({
1045
1045
  sheetReactive: o,
1046
1046
  leftHeaderSelecting: i,
1047
1047
  topHeaderSelecting: l,
1048
- selectingZone: f,
1049
- editorRef: h,
1048
+ selectingZone: h,
1049
+ editorRef: f,
1050
1050
  mainRef: c
1051
- } = e, d = o.current, [b, y, g] = t, [m, p, A] = s;
1052
- if (c.current == null || h.current == null || !d)
1051
+ } = e, d = o.current, [b, y, g] = t, [m, p, M] = s;
1052
+ if (c.current == null || f.current == null || !d)
1053
1053
  return /* @__PURE__ */ a("div", { className: "gs-resizing gs-hidden" });
1054
- const x = d.getCell({ y: b === -1 ? 0 : b, x: m === -1 ? 0 : m }, { resolution: "SYSTEM" }), { y: F, x: T } = c.current.getBoundingClientRect(), S = (x == null ? void 0 : x.width) || vt, M = (x == null ? void 0 : x.height) || bt, $ = S + (A - p), P = M + (g - y);
1054
+ const E = d.getCell({ y: b === -1 ? 0 : b, x: m === -1 ? 0 : m }, { resolution: "SYSTEM" }), { y: F, x: T } = c.current.getBoundingClientRect(), S = (E == null ? void 0 : E.width) || vt, D = (E == null ? void 0 : E.height) || bt, $ = S + (M - p), P = D + (g - y);
1055
1055
  return /* @__PURE__ */ Y(
1056
1056
  "div",
1057
1057
  {
1058
1058
  className: `gs-resizing ${b === -1 && m === -1 ? "gs-hidden" : ""}`,
1059
1059
  onMouseUp: () => {
1060
- const r = ge(f), { top: u, left: v, bottom: N, right: I } = r, R = {};
1060
+ const r = he(h), { top: u, left: v, bottom: N, right: A } = r, R = {};
1061
1061
  if (m !== -1) {
1062
1062
  let H = [m];
1063
- l && Ae({ start: v, end: I }, m) && (H = Xt(v, I + 1)), H.forEach((G) => {
1064
- R[Ee({ y: 0, x: G })] = { width: $ };
1063
+ l && Ae({ start: v, end: A }, m) && (H = Xt(v, A + 1)), H.forEach((q) => {
1064
+ R[xe({ y: 0, x: q })] = { width: $ };
1065
1065
  });
1066
1066
  }
1067
1067
  if (b !== -1) {
1068
1068
  let H = [b];
1069
- i && Ae({ start: u, end: N }, b) && (H = Xt(u, N + 1)), H.forEach((G) => {
1070
- R[Ee({ y: G, x: 0 })] = { height: P };
1069
+ i && Ae({ start: u, end: N }, b) && (H = Xt(u, N + 1)), H.forEach((q) => {
1070
+ R[xe({ y: q, x: 0 })] = { height: P };
1071
1071
  });
1072
1072
  }
1073
1073
  d.update({
1074
1074
  diff: R,
1075
1075
  partial: !0,
1076
1076
  operator: "USER",
1077
- undoReflection: { selectingZone: f, sheetId: d.id }
1077
+ undoReflection: { selectingZone: h, sheetId: d.id }
1078
1078
  }), n(
1079
1079
  Ne({
1080
1080
  sheetReactive: { current: d }
1081
1081
  })
1082
- ), n(ft([-1, -1, -1])), n(ht([-1, -1, -1])), O(h.current);
1082
+ ), n(ht([-1, -1, -1])), n(ft([-1, -1, -1])), O(f.current);
1083
1083
  },
1084
1084
  onMouseMove: (r) => {
1085
1085
  if (b !== -1) {
1086
1086
  let u = r.clientY;
1087
- const v = M + (u - y);
1088
- v < Ht && (u += Ht - v), n(ft([b, y, u]));
1087
+ const v = D + (u - y);
1088
+ v < Ht && (u += Ht - v), n(ht([b, y, u]));
1089
1089
  } else if (m !== -1) {
1090
1090
  let u = r.clientX;
1091
1091
  const v = S + (u - p);
1092
- v < Ot && (u += Ot - v), n(ht([m, p, u]));
1092
+ v < Ot && (u += Ot - v), n(ft([m, p, u]));
1093
1093
  }
1094
1094
  },
1095
1095
  children: [
1096
- /* @__PURE__ */ a("div", { className: `gs-line-vertical ${m === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ a("div", { className: "gs-line", style: { width: 1, height: "100%", left: A - T }, children: /* @__PURE__ */ Y("span", { style: { left: "-50%" }, children: [
1096
+ /* @__PURE__ */ a("div", { className: `gs-line-vertical ${m === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ a("div", { className: "gs-line", style: { width: 1, height: "100%", left: M - T }, children: /* @__PURE__ */ Y("span", { style: { left: "-50%" }, children: [
1097
1097
  $,
1098
1098
  "px"
1099
1099
  ] }) }) }),
@@ -1106,7 +1106,7 @@ const Ds = ({
1106
1106
  );
1107
1107
  }, Fs = () => {
1108
1108
  const { store: e } = le(ae), { choosing: n, selectingZone: t, sheetReactive: s } = e, o = s.current;
1109
- return Z(() => {
1109
+ return W(() => {
1110
1110
  o != null && o.isInitialized && o.currentVersion > 0 && o.registry.onChange && o.registry.onChange({
1111
1111
  sheet: o,
1112
1112
  points: {
@@ -1115,7 +1115,7 @@ const Ds = ({
1115
1115
  selectingTo: { y: t.endY, x: t.endX }
1116
1116
  }
1117
1117
  });
1118
- }, [s]), Z(() => {
1118
+ }, [s]), W(() => {
1119
1119
  o && o.registry.onSelect && o.registry.onSelect({
1120
1120
  sheet: o,
1121
1121
  points: {
@@ -1135,15 +1135,15 @@ const Ds = ({
1135
1135
  const { editorRef: s } = e, o = await navigator.clipboard.read();
1136
1136
  let i = [];
1137
1137
  for (let l = 0; l < o.length; l++) {
1138
- const f = o[l];
1139
- if (f.types.indexOf("text/html") !== -1) {
1140
- const c = await (await f.getType("text/html")).text();
1138
+ const h = o[l];
1139
+ if (h.types.indexOf("text/html") !== -1) {
1140
+ const c = await (await h.getType("text/html")).text();
1141
1141
  if (c) {
1142
1142
  i = Sn(c, t);
1143
1143
  break;
1144
1144
  }
1145
- } else if (f.types.indexOf("text/plain") !== -1) {
1146
- const c = await (await f.getType("text/plain")).text();
1145
+ } else if (h.types.indexOf("text/plain") !== -1) {
1146
+ const c = await (await h.getType("text/plain")).text();
1147
1147
  if (c) {
1148
1148
  i = Nn(c);
1149
1149
  break;
@@ -1158,23 +1158,23 @@ const Ds = ({
1158
1158
  const { editorRef: t } = e;
1159
1159
  n(ut(null)), O(t.current);
1160
1160
  }, Ys = async ({ store: e, dispatch: n }) => {
1161
- const { selectingZone: t, editorRef: s } = e, { top: o } = ge(t), i = ne(t).rows;
1161
+ const { selectingZone: t, editorRef: s } = e, { top: o } = he(t), i = se(t).rows;
1162
1162
  n(vn({ numRows: i, y: o, operator: "USER" })), O(s.current);
1163
1163
  }, $s = async ({ store: e, dispatch: n }) => {
1164
- const { selectingZone: t, editorRef: s } = e, { bottom: o } = ge(t), i = ne(t).rows;
1164
+ const { selectingZone: t, editorRef: s } = e, { bottom: o } = he(t), i = se(t).rows;
1165
1165
  n(yn({ numRows: i, y: o, operator: "USER" })), O(s.current);
1166
1166
  }, Ps = async ({ store: e, dispatch: n }) => {
1167
- const { selectingZone: t, editorRef: s } = e, { left: o } = ge(t), i = ne(t).cols;
1167
+ const { selectingZone: t, editorRef: s } = e, { left: o } = he(t), i = se(t).cols;
1168
1168
  n(pn({ numCols: i, x: o, operator: "USER" })), O(s.current);
1169
1169
  }, Xs = async ({ store: e, dispatch: n }) => {
1170
- const { selectingZone: t, editorRef: s } = e, { right: o } = ge(t), i = ne(t).cols;
1170
+ const { selectingZone: t, editorRef: s } = e, { right: o } = he(t), i = se(t).cols;
1171
1171
  n(mn({ numCols: i, x: o, operator: "USER" })), O(s.current);
1172
1172
  }, Hs = async ({ store: e, dispatch: n }) => {
1173
- const { selectingZone: t, editorRef: s } = e, { top: o } = ge(t), i = ne(t).rows;
1174
- n(hn({ numRows: i, y: o, operator: "USER" })), O(s.current);
1173
+ const { selectingZone: t, editorRef: s } = e, { top: o } = he(t), i = se(t).rows;
1174
+ n(fn({ numRows: i, y: o, operator: "USER" })), O(s.current);
1175
1175
  }, Os = async ({ store: e, dispatch: n }) => {
1176
- const { selectingZone: t, editorRef: s } = e, { left: o } = ge(t), i = ne(t).cols;
1177
- n(fn({ numCols: i, x: o, operator: "USER" })), O(s.current);
1176
+ const { selectingZone: t, editorRef: s } = e, { left: o } = he(t), i = se(t).cols;
1177
+ n(hn({ numCols: i, x: o, operator: "USER" })), O(s.current);
1178
1178
  }, Fn = async ({ store: e, dispatch: n }, t) => {
1179
1179
  const s = e.sheetReactive.current;
1180
1180
  s && (s.hasPendingCells() || s.registry.asyncPending.size > 0) && await s.waitForPending(), n(Ct({ x: t, direction: "asc" })), O(e.editorRef.current);
@@ -1190,17 +1190,17 @@ const Ds = ({
1190
1190
  const s = e.sheetReactive.current;
1191
1191
  if (!s)
1192
1192
  return;
1193
- const o = Ee({ y: t, x: 0 }), i = s.getCell({ y: t, x: 0 }, { resolution: "SYSTEM" }), l = !(i != null && i.sortFixed) || void 0;
1194
- s.update({ diff: { [o]: { sortFixed: l } }, partial: !0 }), n(ze(s)), O(e.editorRef.current);
1193
+ const o = xe({ y: t, x: 0 }), i = s.getCell({ y: t, x: 0 }, { resolution: "SYSTEM" }), l = !(i != null && i.sortFixed) || void 0;
1194
+ s.update({ diff: { [o]: { sortFixed: l } }, partial: !0 }), n(Ue(s)), O(e.editorRef.current);
1195
1195
  }, Xn = ({ store: e, dispatch: n }, t) => {
1196
1196
  const s = e.sheetReactive.current;
1197
1197
  if (!s)
1198
1198
  return;
1199
- const o = Ee({ y: t, x: 0 }), i = s.getCell({ y: t, x: 0 }, { resolution: "SYSTEM" }), l = !(i != null && i.filterFixed) || void 0;
1200
- s.update({ diff: { [o]: { filterFixed: l } }, partial: !0 }), n(ze(s)), O(e.editorRef.current);
1199
+ const o = xe({ y: t, x: 0 }), i = s.getCell({ y: t, x: 0 }, { resolution: "SYSTEM" }), l = !(i != null && i.filterFixed) || void 0;
1200
+ s.update({ diff: { [o]: { filterFixed: l } }, partial: !0 }), n(Ue(s)), O(e.editorRef.current);
1201
1201
  }, Hn = async ({ store: e, dispatch: n }) => {
1202
1202
  typeof e.searchQuery > "u" && n(Pe("")), n(dn(!1)), requestAnimationFrame(() => O(e.searchInputRef.current));
1203
- }, xr = {
1203
+ }, Er = {
1204
1204
  copy: Tn,
1205
1205
  cut: An,
1206
1206
  paste: Mn,
@@ -1254,80 +1254,80 @@ const Ds = ({
1254
1254
  {
1255
1255
  id: "insert-rows-above",
1256
1256
  label: (e) => {
1257
- const n = ne(e.selectingZone).rows;
1257
+ const n = se(e.selectingZone).rows;
1258
1258
  return `Insert ${n} row${n > 1 ? "s" : ""} above`;
1259
1259
  },
1260
1260
  visible: (e) => e.leftHeaderSelecting,
1261
1261
  disabled: (e) => {
1262
- const n = ne(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1262
+ const n = se(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1263
1263
  return t.maxNumRows !== -1 && t.numRows + n > t.maxNumRows || X.hasOperation(s == null ? void 0 : s.prevention, X.InsertRowsAbove);
1264
1264
  },
1265
- onClick: (e) => e.insertRowsAbove(e.choosing.y, ne(e.selectingZone).rows)
1265
+ onClick: (e) => e.insertRowsAbove(e.choosing.y, se(e.selectingZone).rows)
1266
1266
  },
1267
1267
  {
1268
1268
  id: "insert-rows-below",
1269
1269
  label: (e) => {
1270
- const n = ne(e.selectingZone).rows;
1270
+ const n = se(e.selectingZone).rows;
1271
1271
  return `Insert ${n} row${n > 1 ? "s" : ""} below`;
1272
1272
  },
1273
1273
  visible: (e) => e.leftHeaderSelecting,
1274
1274
  disabled: (e) => {
1275
- const n = ne(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1275
+ const n = se(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1276
1276
  return t.maxNumRows !== -1 && t.numRows + n > t.maxNumRows || X.hasOperation(s == null ? void 0 : s.prevention, X.InsertRowsBelow);
1277
1277
  },
1278
- onClick: (e) => e.insertRowsBelow(e.choosing.y, ne(e.selectingZone).rows)
1278
+ onClick: (e) => e.insertRowsBelow(e.choosing.y, se(e.selectingZone).rows)
1279
1279
  },
1280
1280
  {
1281
1281
  id: "insert-cols-left",
1282
1282
  label: (e) => {
1283
- const n = ne(e.selectingZone).cols;
1283
+ const n = se(e.selectingZone).cols;
1284
1284
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
1285
1285
  },
1286
1286
  visible: (e) => e.topHeaderSelecting,
1287
1287
  disabled: (e) => {
1288
- const n = ne(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1288
+ const n = se(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1289
1289
  return t.maxNumCols !== -1 && t.numCols + n > t.maxNumCols || X.hasOperation(s == null ? void 0 : s.prevention, X.InsertColsLeft);
1290
1290
  },
1291
- onClick: (e) => e.insertColsLeft(e.choosing.x, ne(e.selectingZone).cols)
1291
+ onClick: (e) => e.insertColsLeft(e.choosing.x, se(e.selectingZone).cols)
1292
1292
  },
1293
1293
  {
1294
1294
  id: "insert-cols-right",
1295
1295
  label: (e) => {
1296
- const n = ne(e.selectingZone).cols;
1296
+ const n = se(e.selectingZone).cols;
1297
1297
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
1298
1298
  },
1299
1299
  visible: (e) => e.topHeaderSelecting,
1300
1300
  disabled: (e) => {
1301
- const n = ne(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1301
+ const n = se(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1302
1302
  return t.maxNumCols !== -1 && t.numCols + n > t.maxNumCols || X.hasOperation(s == null ? void 0 : s.prevention, X.InsertColsRight);
1303
1303
  },
1304
- onClick: (e) => e.insertColsRight(e.choosing.x, ne(e.selectingZone).cols)
1304
+ onClick: (e) => e.insertColsRight(e.choosing.x, se(e.selectingZone).cols)
1305
1305
  },
1306
1306
  {
1307
1307
  id: "remove-rows",
1308
1308
  label: (e) => {
1309
- const n = ne(e.selectingZone).rows;
1309
+ const n = se(e.selectingZone).rows;
1310
1310
  return `Remove ${n} row${n > 1 ? "s" : ""}`;
1311
1311
  },
1312
1312
  visible: (e) => e.leftHeaderSelecting,
1313
1313
  disabled: (e) => {
1314
- const n = ne(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1314
+ const n = se(e.selectingZone).rows, t = e.sheet, s = t.getCell({ y: e.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1315
1315
  return t.minNumRows !== -1 && t.numRows - n < t.minNumRows || X.hasOperation(s == null ? void 0 : s.prevention, X.RemoveRows);
1316
1316
  },
1317
- onClick: (e) => e.removeRows(e.choosing.y, ne(e.selectingZone).rows)
1317
+ onClick: (e) => e.removeRows(e.choosing.y, se(e.selectingZone).rows)
1318
1318
  },
1319
1319
  {
1320
1320
  id: "remove-cols",
1321
1321
  label: (e) => {
1322
- const n = ne(e.selectingZone).cols;
1322
+ const n = se(e.selectingZone).cols;
1323
1323
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
1324
1324
  },
1325
1325
  visible: (e) => e.topHeaderSelecting,
1326
1326
  disabled: (e) => {
1327
- const n = ne(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1327
+ const n = se(e.selectingZone).cols, t = e.sheet, s = t.getCell({ y: 0, x: e.choosing.x }, { resolution: "SYSTEM" });
1328
1328
  return t.minNumCols !== -1 && t.numCols - n < t.minNumCols || X.hasOperation(s == null ? void 0 : s.prevention, X.RemoveCols);
1329
1329
  },
1330
- onClick: (e) => e.removeCols(e.choosing.x, ne(e.selectingZone).cols)
1330
+ onClick: (e) => e.removeCols(e.choosing.x, se(e.selectingZone).cols)
1331
1331
  },
1332
1332
  { type: "divider" },
1333
1333
  {
@@ -1515,7 +1515,7 @@ const Ds = ({
1515
1515
  { type: "divider" },
1516
1516
  { type: "component", componentId: "col-label" }
1517
1517
  ];
1518
- function Et(e, n, t) {
1518
+ function xt(e, n, t) {
1519
1519
  const s = { store: e, dispatch: n }, o = e.sheetReactive.current;
1520
1520
  return {
1521
1521
  sheet: o,
@@ -1535,7 +1535,7 @@ function Et(e, n, t) {
1535
1535
  n(yn({ numRows: l, y: i, operator: "USER" }));
1536
1536
  },
1537
1537
  removeRows: (i, l) => {
1538
- n(hn({ numRows: l, y: i, operator: "USER" }));
1538
+ n(fn({ numRows: l, y: i, operator: "USER" }));
1539
1539
  },
1540
1540
  insertColsLeft: (i, l) => {
1541
1541
  n(pn({ numCols: l, x: i, operator: "USER" }));
@@ -1544,7 +1544,7 @@ function Et(e, n, t) {
1544
1544
  n(mn({ numCols: l, x: i, operator: "USER" }));
1545
1545
  },
1546
1546
  removeCols: (i, l) => {
1547
- n(fn({ numCols: l, x: i, operator: "USER" }));
1547
+ n(hn({ numCols: l, x: i, operator: "USER" }));
1548
1548
  },
1549
1549
  sortRows: async (i, l) => {
1550
1550
  l === "asc" ? await Fn(s, i) : await Yn(s, i);
@@ -1559,9 +1559,9 @@ function Et(e, n, t) {
1559
1559
  updateColLabel: (i, l) => {
1560
1560
  if (!o)
1561
1561
  return;
1562
- const f = Ee({ y: 0, x: i });
1562
+ const h = xe({ y: 0, x: i });
1563
1563
  o.update({
1564
- diff: { [f]: { label: l || void 0 } },
1564
+ diff: { [h]: { label: l || void 0 } },
1565
1565
  partial: !0,
1566
1566
  undoReflection: {
1567
1567
  sheetId: o.id,
@@ -1579,10 +1579,10 @@ function Et(e, n, t) {
1579
1579
  };
1580
1580
  }
1581
1581
  const On = /* @__PURE__ */ new Map();
1582
- function xt(e, n) {
1582
+ function Et(e, n) {
1583
1583
  On.set(e, n);
1584
1584
  }
1585
- function Zs(e) {
1585
+ function Ws(e) {
1586
1586
  return On.get(e);
1587
1587
  }
1588
1588
  const kt = ({
@@ -1594,7 +1594,7 @@ const kt = ({
1594
1594
  onClick: i,
1595
1595
  className: l
1596
1596
  }) => {
1597
- const f = s !== void 0;
1597
+ const h = s !== void 0;
1598
1598
  return /* @__PURE__ */ Y(
1599
1599
  "li",
1600
1600
  {
@@ -1602,13 +1602,13 @@ const kt = ({
1602
1602
  "data-testid": o,
1603
1603
  onClick: t ? void 0 : i,
1604
1604
  children: [
1605
- /* @__PURE__ */ Y("div", { className: `gs-menu-name${f ? " gs-row-fixed-toggle" : ""}`, children: [
1606
- f && /* @__PURE__ */ a("span", { className: `gs-row-fixed-check${s ? " gs-row-fixed-active" : ""}`, children: "✓" }),
1605
+ /* @__PURE__ */ Y("div", { className: `gs-menu-name${h ? " gs-row-fixed-toggle" : ""}`, children: [
1606
+ h && /* @__PURE__ */ a("span", { className: `gs-row-fixed-check${s ? " gs-row-fixed-active" : ""}`, children: "✓" }),
1607
1607
  e
1608
1608
  ] }),
1609
- n != null && n.length > 0 && /* @__PURE__ */ a("div", { className: "gs-menu-shortcut", children: n.map((h, c) => /* @__PURE__ */ Y("span", { children: [
1609
+ n != null && n.length > 0 && /* @__PURE__ */ a("div", { className: "gs-menu-shortcut", children: n.map((f, c) => /* @__PURE__ */ Y("span", { children: [
1610
1610
  c > 0 && /* @__PURE__ */ a("span", { className: "gs-menu-shortcut-sep", children: ", " }),
1611
- /* @__PURE__ */ a("span", { className: "gs-menu-shortcut-badge", children: h.split("+").map(
1611
+ /* @__PURE__ */ a("span", { className: "gs-menu-shortcut-badge", children: f.split("+").map(
1612
1612
  (d, b, y) => b < y.length - 1 ? /* @__PURE__ */ Y("span", { children: [
1613
1613
  d,
1614
1614
  "+"
@@ -1618,25 +1618,25 @@ const kt = ({
1618
1618
  ]
1619
1619
  }
1620
1620
  );
1621
- }, Tt = () => /* @__PURE__ */ a("li", { className: "gs-menu-divider" }), Us = () => {
1622
- const { store: e, dispatch: n } = le(ae), { contextMenuPosition: t, contextMenu: s } = e, { y: o, x: i } = t, l = se(null);
1623
- if (Z(() => {
1621
+ }, Tt = () => /* @__PURE__ */ a("li", { className: "gs-menu-divider" }), Zs = () => {
1622
+ const { store: e, dispatch: n } = le(ae), { contextMenuPosition: t, contextMenu: s } = e, { y: o, x: i } = t, l = re(null);
1623
+ if (W(() => {
1624
1624
  l.current && en(l.current);
1625
1625
  }), o === -1)
1626
1626
  return null;
1627
- const f = () => n(We({ y: -1, x: -1 })), h = Et(e, n, f);
1627
+ const h = () => n(ze({ y: -1, x: -1 })), f = xt(e, n, h);
1628
1628
  return /* @__PURE__ */ a(
1629
1629
  rt,
1630
1630
  {
1631
1631
  className: "gs-menu-modal gs-context-menu-modal",
1632
- onClick: (c) => (c.preventDefault(), f(), !1),
1632
+ onClick: (c) => (c.preventDefault(), h(), !1),
1633
1633
  children: /* @__PURE__ */ a("div", { ref: l, className: "gs-context-menu", style: { top: o, left: i }, children: /* @__PURE__ */ a("ul", { className: "gs-menu-items", children: s.map((c, d) => {
1634
- var A, x;
1634
+ var M, E;
1635
1635
  if (c.type === "divider")
1636
- return c.visible && !c.visible(h) ? null : /* @__PURE__ */ a(Tt, {}, d);
1637
- if (c.type === "component" || !(!c.visible || c.visible(h)))
1636
+ return c.visible && !c.visible(f) ? null : /* @__PURE__ */ a(Tt, {}, d);
1637
+ if (c.type === "component" || !(!c.visible || c.visible(f)))
1638
1638
  return null;
1639
- const y = ((A = c.disabled) == null ? void 0 : A.call(c, h)) ?? !1, g = typeof c.label == "function" ? c.label(h) : c.label, m = typeof c.shortcuts == "function" ? c.shortcuts(h) : c.shortcuts, p = (x = c.checked) == null ? void 0 : x.call(c, h);
1639
+ const y = ((M = c.disabled) == null ? void 0 : M.call(c, f)) ?? !1, g = typeof c.label == "function" ? c.label(f) : c.label, m = typeof c.shortcuts == "function" ? c.shortcuts(f) : c.shortcuts, p = (E = c.checked) == null ? void 0 : E.call(c, f);
1640
1640
  return /* @__PURE__ */ a(
1641
1641
  kt,
1642
1642
  {
@@ -1645,7 +1645,7 @@ const kt = ({
1645
1645
  disabled: y,
1646
1646
  checked: p,
1647
1647
  testId: c.id ? `${c.id}-item` : void 0,
1648
- onClick: () => c.onClick(h)
1648
+ onClick: () => c.onClick(f)
1649
1649
  },
1650
1650
  d
1651
1651
  );
@@ -1663,64 +1663,64 @@ const kt = ({
1663
1663
  nonblank: "Nonblank",
1664
1664
  includes: "Includes",
1665
1665
  excludes: "Excludes"
1666
- }, Gt = ["blank", "nonblank"], Ve = { method: "eq", value: [""] }, zs = ({ x: e, close: n, onWaiting: t }) => {
1667
- const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [f, h] = J([{ ...Ve }]), [c, d] = J("or"), [b, y] = J(null), g = k(
1666
+ }, Gt = ["blank", "nonblank"], Ve = { method: "eq", value: [""] }, Us = ({ x: e, close: n, onWaiting: t }) => {
1667
+ const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = te([{ ...Ve }]), [c, d] = te("or"), [b, y] = te(null), g = k(
1668
1668
  (C) => {
1669
1669
  C && C.focus();
1670
1670
  },
1671
1671
  // eslint-disable-next-line react-hooks/exhaustive-deps
1672
1672
  [e]
1673
1673
  );
1674
- Z(() => {
1674
+ W(() => {
1675
1675
  if (l) {
1676
- const C = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), D = C == null ? void 0 : C.filter;
1677
- D && D.conditions.length > 0 ? (h(D.conditions.map((r) => ({ ...r, value: [...r.value] }))), d(D.mode || "or")) : (h([{ ...Ve, value: [""] }]), d("or"));
1676
+ const C = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), I = C == null ? void 0 : C.filter;
1677
+ I && I.conditions.length > 0 ? (f(I.conditions.map((r) => ({ ...r, value: [...r.value] }))), d(I.mode || "or")) : (f([{ ...Ve, value: [""] }]), d("or"));
1678
1678
  }
1679
1679
  }, [e, l]);
1680
1680
  const m = k(() => {
1681
1681
  y(null), t == null || t(null), n();
1682
1682
  }, [n, t]);
1683
- Z(() => {
1683
+ W(() => {
1684
1684
  b && (t == null || t("Filtering…", m));
1685
- }, [b]), Z(() => {
1685
+ }, [b]), W(() => {
1686
1686
  if (!b)
1687
1687
  return;
1688
1688
  let C = !1;
1689
- const D = () => {
1689
+ const I = () => {
1690
1690
  if (C || !i.current)
1691
1691
  return;
1692
- const { x: v, conditions: N, mode: I } = b;
1693
- N.length > 0 ? o(Ye({ x: v, filter: { mode: I, conditions: N } })) : o(Ye({ x: v })), t == null || t(null), y(null), n();
1692
+ const { x: v, conditions: N, mode: A } = b;
1693
+ N.length > 0 ? o(Ye({ x: v, filter: { mode: A, conditions: N } })) : o(Ye({ x: v })), t == null || t(null), y(null), n();
1694
1694
  }, r = i.current;
1695
- return r && (r.hasPendingCells() || r.registry.asyncPending.size > 0) ? r.waitForPending().then(D) : D(), () => {
1695
+ return r && (r.hasPendingCells() || r.registry.asyncPending.size > 0) ? r.waitForPending().then(I) : I(), () => {
1696
1696
  C = !0;
1697
1697
  };
1698
1698
  }, [b]);
1699
- const p = k((C, D) => {
1700
- h((r) => {
1699
+ const p = k((C, I) => {
1700
+ f((r) => {
1701
1701
  const u = [...r];
1702
- return u[C] = { ...u[C], ...D }, u;
1702
+ return u[C] = { ...u[C], ...I }, u;
1703
1703
  });
1704
- }, []), A = k(() => {
1705
- h((C) => [...C, { ...Ve, value: [""] }]);
1706
- }, []), x = k((C) => {
1707
- h((D) => D.length <= 1 ? [{ ...Ve, value: [""] }] : D.filter((r, u) => u !== C));
1704
+ }, []), M = k(() => {
1705
+ f((C) => [...C, { ...Ve, value: [""] }]);
1706
+ }, []), E = k((C) => {
1707
+ f((I) => I.length <= 1 ? [{ ...Ve, value: [""] }] : I.filter((r, u) => u !== C));
1708
1708
  }, []), F = k(() => {
1709
- const C = f.filter((D) => Gt.includes(D.method) ? !0 : D.value.some((r) => r.trim() !== ""));
1709
+ const C = h.filter((I) => Gt.includes(I.method) ? !0 : I.value.some((r) => r.trim() !== ""));
1710
1710
  y({ x: e, conditions: C, mode: c });
1711
- }, [e, f, c]), T = k(() => {
1711
+ }, [e, h, c]), T = k(() => {
1712
1712
  y(null), o(Ye({ x: e })), n();
1713
1713
  }, [o, e, n]), S = k(() => {
1714
1714
  y(null), o(Ye({})), n();
1715
1715
  }, [o, n]);
1716
1716
  if (!l)
1717
1717
  return null;
1718
- const M = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), $ = X.hasOperation(M == null ? void 0 : M.prevention, X.Filter), P = l.hasActiveFilters();
1718
+ const D = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), $ = X.hasOperation(D == null ? void 0 : D.prevention, X.Filter), P = l.hasActiveFilters();
1719
1719
  return /* @__PURE__ */ a("li", { className: `gs-column-menu-filter${$ ? " gs-disabled" : ""}`, children: /* @__PURE__ */ Y(Re, { children: [
1720
1720
  /* @__PURE__ */ Y("div", { className: "gs-filter-header", children: [
1721
1721
  /* @__PURE__ */ a("div", { className: "gs-menu-name", children: "Filter:" }),
1722
- /* @__PURE__ */ a("button", { className: "gs-filter-add-btn", onClick: A, disabled: $, children: "+ ADD" }),
1723
- /* @__PURE__ */ Y("div", { className: `gs-filter-mode-toggle${f.length <= 1 ? " gs-disabled" : ""}`, children: [
1722
+ /* @__PURE__ */ a("button", { className: "gs-filter-add-btn", onClick: M, disabled: $, children: "+ ADD" }),
1723
+ /* @__PURE__ */ Y("div", { className: `gs-filter-mode-toggle${h.length <= 1 ? " gs-disabled" : ""}`, children: [
1724
1724
  /* @__PURE__ */ Y("label", { className: c === "and" ? "gs-active" : "", children: [
1725
1725
  /* @__PURE__ */ a(
1726
1726
  "input",
@@ -1729,7 +1729,7 @@ const kt = ({
1729
1729
  name: "gs-filter-mode",
1730
1730
  checked: c === "and",
1731
1731
  onChange: () => d("and"),
1732
- disabled: $ || f.length <= 1
1732
+ disabled: $ || h.length <= 1
1733
1733
  }
1734
1734
  ),
1735
1735
  "AND"
@@ -1742,36 +1742,36 @@ const kt = ({
1742
1742
  name: "gs-filter-mode",
1743
1743
  checked: c === "or",
1744
1744
  onChange: () => d("or"),
1745
- disabled: $ || f.length <= 1
1745
+ disabled: $ || h.length <= 1
1746
1746
  }
1747
1747
  ),
1748
1748
  "OR"
1749
1749
  ] })
1750
1750
  ] })
1751
1751
  ] }),
1752
- /* @__PURE__ */ a("div", { className: "gs-filter-conditions", children: f.map((C, D) => /* @__PURE__ */ Y("div", { className: "gs-filter-condition-row", children: [
1752
+ /* @__PURE__ */ a("div", { className: "gs-filter-conditions", children: h.map((C, I) => /* @__PURE__ */ Y("div", { className: "gs-filter-condition-row", children: [
1753
1753
  /* @__PURE__ */ a(
1754
1754
  "select",
1755
1755
  {
1756
1756
  className: "gs-filter-method-select",
1757
1757
  value: C.method,
1758
1758
  disabled: $,
1759
- tabIndex: D * 2 + 1,
1760
- onChange: (r) => p(D, { method: r.target.value }),
1759
+ tabIndex: I * 2 + 1,
1760
+ onChange: (r) => p(I, { method: r.target.value }),
1761
1761
  children: Object.keys(qt).map((r) => /* @__PURE__ */ a("option", { value: r, children: qt[r] }, r))
1762
1762
  }
1763
1763
  ),
1764
1764
  !Gt.includes(C.method) && /* @__PURE__ */ a(
1765
1765
  "input",
1766
1766
  {
1767
- ref: D === 0 ? g : void 0,
1767
+ ref: I === 0 ? g : void 0,
1768
1768
  className: "gs-filter-value-input",
1769
1769
  type: "text",
1770
1770
  placeholder: "Value",
1771
1771
  value: C.value[0] || "",
1772
1772
  disabled: $,
1773
- tabIndex: D * 2 + 2,
1774
- onChange: (r) => p(D, { value: [r.target.value] }),
1773
+ tabIndex: I * 2 + 2,
1774
+ onChange: (r) => p(I, { value: [r.target.value] }),
1775
1775
  onKeyDown: (r) => {
1776
1776
  r.nativeEvent.isComposing || (r.key === "Enter" && F(), r.key === "Escape" && n());
1777
1777
  }
@@ -1781,40 +1781,40 @@ const kt = ({
1781
1781
  "button",
1782
1782
  {
1783
1783
  className: "gs-filter-remove-btn",
1784
- onClick: () => x(D),
1784
+ onClick: () => E(I),
1785
1785
  disabled: $,
1786
1786
  title: "Remove condition",
1787
1787
  children: "✕"
1788
1788
  }
1789
1789
  )
1790
- ] }, D)) }),
1790
+ ] }, I)) }),
1791
1791
  /* @__PURE__ */ Y("div", { className: "gs-filter-actions", children: [
1792
1792
  P && /* @__PURE__ */ a("button", { className: "gs-filter-reset-all-btn", onClick: S, children: "RESET ALL" }),
1793
1793
  /* @__PURE__ */ Y("div", { className: "gs-filter-actions-right", children: [
1794
- (M == null ? void 0 : M.filter) && /* @__PURE__ */ a("button", { className: "gs-filter-reset-btn", onClick: T, children: "RESET" }),
1794
+ (D == null ? void 0 : D.filter) && /* @__PURE__ */ a("button", { className: "gs-filter-reset-btn", onClick: T, children: "RESET" }),
1795
1795
  /* @__PURE__ */ a("button", { className: "gs-filter-apply-btn", onClick: F, disabled: $, children: "APPLY" })
1796
1796
  ] })
1797
1797
  ] })
1798
1798
  ] }) });
1799
1799
  };
1800
- xt("col-filter", zs);
1801
- const Ws = ({ x: e, close: n, onWaiting: t }) => {
1802
- const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [f, h] = J(null), c = k(() => {
1803
- h(null), t == null || t(null), n();
1800
+ Et("col-filter", Us);
1801
+ const zs = ({ x: e, close: n, onWaiting: t }) => {
1802
+ const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = te(null), c = k(() => {
1803
+ f(null), t == null || t(null), n();
1804
1804
  }, [n, t]);
1805
- if (Z(() => {
1806
- f && (t == null || t("Sorting…", c));
1807
- }, [f]), Z(() => {
1808
- if (!f)
1805
+ if (W(() => {
1806
+ h && (t == null || t("Sorting…", c));
1807
+ }, [h]), W(() => {
1808
+ if (!h)
1809
1809
  return;
1810
1810
  let y = !1;
1811
1811
  const g = () => {
1812
- y || !i.current || (o(Ct({ x: f.x, direction: f.direction })), t == null || t(null), h(null), n());
1812
+ y || !i.current || (o(Ct({ x: h.x, direction: h.direction })), t == null || t(null), f(null), n());
1813
1813
  }, m = i.current;
1814
1814
  return m && (m.hasPendingCells() || m.registry.asyncPending.size > 0) ? m.waitForPending().then(g) : g(), () => {
1815
1815
  y = !0;
1816
1816
  };
1817
- }, [f]), !l)
1817
+ }, [h]), !l)
1818
1818
  return null;
1819
1819
  const d = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), b = X.hasOperation(d == null ? void 0 : d.prevention, X.Sort);
1820
1820
  return /* @__PURE__ */ Y("li", { className: `gs-menu-item gs-column-menu-sort${b ? " gs-disabled" : ""}`, children: [
@@ -1825,7 +1825,7 @@ const Ws = ({ x: e, close: n, onWaiting: t }) => {
1825
1825
  {
1826
1826
  className: "gs-sort-btn gs-sort-btn-asc",
1827
1827
  onClick: (y) => {
1828
- y.stopPropagation(), b || h({ x: e, direction: "asc" });
1828
+ y.stopPropagation(), b || f({ x: e, direction: "asc" });
1829
1829
  },
1830
1830
  disabled: b,
1831
1831
  children: "↓ A to Z"
@@ -1836,7 +1836,7 @@ const Ws = ({ x: e, close: n, onWaiting: t }) => {
1836
1836
  {
1837
1837
  className: "gs-sort-btn gs-sort-btn-desc",
1838
1838
  onClick: (y) => {
1839
- y.stopPropagation(), b || h({ x: e, direction: "desc" });
1839
+ y.stopPropagation(), b || f({ x: e, direction: "desc" });
1840
1840
  },
1841
1841
  disabled: b,
1842
1842
  children: "↑ Z to A"
@@ -1845,21 +1845,21 @@ const Ws = ({ x: e, close: n, onWaiting: t }) => {
1845
1845
  ] })
1846
1846
  ] });
1847
1847
  };
1848
- xt("col-sort", Ws);
1848
+ Et("col-sort", zs);
1849
1849
  const _s = ({ x: e, close: n }) => {
1850
- const { store: t, dispatch: s } = le(ae), { sheetReactive: o } = t, i = o.current, l = se(null), [f, h] = J("");
1851
- Z(() => {
1850
+ const { store: t, dispatch: s } = le(ae), { sheetReactive: o } = t, i = o.current, l = re(null), [h, f] = te("");
1851
+ W(() => {
1852
1852
  if (i) {
1853
1853
  const g = i.getCell({ y: 0, x: e }, { resolution: "SYSTEM" });
1854
- h((g == null ? void 0 : g.label) ?? "");
1854
+ f((g == null ? void 0 : g.label) ?? "");
1855
1855
  }
1856
1856
  }, [e, i]);
1857
1857
  const c = k(() => {
1858
1858
  if (!i)
1859
1859
  return;
1860
- const g = Ee({ y: 0, x: e });
1860
+ const g = xe({ y: 0, x: e });
1861
1861
  i.update({
1862
- diff: { [g]: { label: f || void 0 } },
1862
+ diff: { [g]: { label: h || void 0 } },
1863
1863
  partial: !0,
1864
1864
  ignoreFields: [],
1865
1865
  undoReflection: {
@@ -1873,7 +1873,7 @@ const _s = ({ x: e, close: n }) => {
1873
1873
  choosing: t.choosing
1874
1874
  }
1875
1875
  }), s(Ne({ sheetReactive: { current: i } })), n();
1876
- }, [s, e, f, n, i, t.selectingZone, t.choosing]);
1876
+ }, [s, e, h, n, i, t.selectingZone, t.choosing]);
1877
1877
  if (!i)
1878
1878
  return null;
1879
1879
  const d = i.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), b = X.hasOperation(d == null ? void 0 : d.prevention, X.SetLabel), y = wt(i, d == null ? void 0 : d.label, { y: 0, x: e }, e) ?? pe(e);
@@ -1886,9 +1886,9 @@ const _s = ({ x: e, close: n }) => {
1886
1886
  className: "gs-label-input",
1887
1887
  type: "text",
1888
1888
  placeholder: y,
1889
- value: f,
1889
+ value: h,
1890
1890
  disabled: b,
1891
- onChange: (g) => h(g.target.value),
1891
+ onChange: (g) => f(g.target.value),
1892
1892
  onKeyDown: (g) => {
1893
1893
  g.nativeEvent.isComposing || (g.key === "Enter" && c(), g.key === "Escape" && n());
1894
1894
  }
@@ -1897,9 +1897,9 @@ const _s = ({ x: e, close: n }) => {
1897
1897
  /* @__PURE__ */ a("button", { className: "gs-label-apply-btn", onClick: c, disabled: b, children: "UPDATE" })
1898
1898
  ] }) });
1899
1899
  };
1900
- xt("col-label", _s);
1900
+ Et("col-label", _s);
1901
1901
  const js = () => {
1902
- const { store: e, dispatch: n } = le(ae), { columnMenuState: t, editorRef: s, colMenu: o } = e, i = e.sheetReactive.current, l = t == null ? void 0 : t.x, f = t == null ? void 0 : t.position, [h, c] = J(null), d = k(() => {
1902
+ const { store: e, dispatch: n } = le(ae), { columnMenuState: t, editorRef: s, colMenu: o } = e, i = e.sheetReactive.current, l = t == null ? void 0 : t.x, h = t == null ? void 0 : t.position, [f, c] = te(null), d = k(() => {
1903
1903
  n(et(null)), O(s.current);
1904
1904
  }, [n, s]), b = k(
1905
1905
  (g, m) => {
@@ -1907,40 +1907,40 @@ const js = () => {
1907
1907
  },
1908
1908
  [d]
1909
1909
  );
1910
- if (!t || !i || l == null || !f)
1910
+ if (!t || !i || l == null || !h)
1911
1911
  return null;
1912
- const y = Et(e, n, d);
1912
+ const y = xt(e, n, d);
1913
1913
  return /* @__PURE__ */ Y(
1914
1914
  rt,
1915
1915
  {
1916
1916
  className: "gs-menu-modal gs-column-menu-modal",
1917
- onClick: (g) => (g.preventDefault(), h || d(), !1),
1917
+ onClick: (g) => (g.preventDefault(), f || d(), !1),
1918
1918
  children: [
1919
1919
  /* @__PURE__ */ a(
1920
1920
  "div",
1921
1921
  {
1922
1922
  className: "gs-column-menu",
1923
- style: { top: f.y, left: f.x, display: h ? "none" : void 0 },
1923
+ style: { top: h.y, left: h.x, display: f ? "none" : void 0 },
1924
1924
  onClick: (g) => g.stopPropagation(),
1925
1925
  children: /* @__PURE__ */ a("ul", { className: "gs-menu-items", children: o.map((g, m) => {
1926
1926
  var T;
1927
1927
  if (g.type === "component") {
1928
1928
  if (!(!g.visible || g.visible(y, l)))
1929
1929
  return null;
1930
- const M = Zs(g.componentId);
1931
- return M ? /* @__PURE__ */ a(M, { x: l, close: d, onWaiting: b }, m) : null;
1930
+ const D = Ws(g.componentId);
1931
+ return D ? /* @__PURE__ */ a(D, { x: l, close: d, onWaiting: b }, m) : null;
1932
1932
  }
1933
1933
  if (g.type === "divider")
1934
1934
  return g.visible && !g.visible(y) ? null : /* @__PURE__ */ a(Tt, {}, m);
1935
1935
  if (!(!g.visible || g.visible(y, l)))
1936
1936
  return null;
1937
- const A = ((T = g.disabled) == null ? void 0 : T.call(g, y, l)) ?? !1, x = typeof g.label == "function" ? g.label(y, l) : g.label, F = typeof g.shortcuts == "function" ? g.shortcuts(y, l) : g.shortcuts;
1937
+ const M = ((T = g.disabled) == null ? void 0 : T.call(g, y, l)) ?? !1, E = typeof g.label == "function" ? g.label(y, l) : g.label, F = typeof g.shortcuts == "function" ? g.shortcuts(y, l) : g.shortcuts;
1938
1938
  return /* @__PURE__ */ a(
1939
1939
  kt,
1940
1940
  {
1941
- label: x,
1941
+ label: E,
1942
1942
  shortcuts: F,
1943
- disabled: A,
1943
+ disabled: M,
1944
1944
  testId: g.id ? `${g.id}-item` : void 0,
1945
1945
  onClick: () => {
1946
1946
  g.onClick(y, l), n(et(null));
@@ -1951,16 +1951,16 @@ const js = () => {
1951
1951
  }) })
1952
1952
  }
1953
1953
  ),
1954
- h && /* @__PURE__ */ Y(
1954
+ f && /* @__PURE__ */ Y(
1955
1955
  "div",
1956
1956
  {
1957
1957
  className: "gs-column-menu gs-column-menu-waiting",
1958
- style: { top: f.y, left: f.x },
1958
+ style: { top: h.y, left: h.x },
1959
1959
  onClick: (g) => g.stopPropagation(),
1960
1960
  children: [
1961
- /* @__PURE__ */ a("div", { className: "gs-waiting-message", children: h.message }),
1961
+ /* @__PURE__ */ a("div", { className: "gs-waiting-message", children: f.message }),
1962
1962
  /* @__PURE__ */ a("div", { className: "gs-waiting-spinner" }),
1963
- /* @__PURE__ */ a("button", { className: "gs-waiting-cancel-btn", onClick: h.cancel, children: "CANCEL" })
1963
+ /* @__PURE__ */ a("button", { className: "gs-waiting-cancel-btn", onClick: f.cancel, children: "CANCEL" })
1964
1964
  ]
1965
1965
  }
1966
1966
  )
@@ -1974,12 +1974,12 @@ function Vs(e, n, t, s, o) {
1974
1974
  return /* @__PURE__ */ a(Tt, {}, s);
1975
1975
  if (e.type === "component" || !(!e.visible || e.visible(n, t)))
1976
1976
  return null;
1977
- const l = ((d = e.disabled) == null ? void 0 : d.call(e, n, t)) ?? !1, f = typeof e.label == "function" ? e.label(n, t) : e.label, h = typeof e.shortcuts == "function" ? e.shortcuts(n, t) : e.shortcuts, c = e.checked != null ? e.checked(n, t) : void 0;
1977
+ const l = ((d = e.disabled) == null ? void 0 : d.call(e, n, t)) ?? !1, h = typeof e.label == "function" ? e.label(n, t) : e.label, f = typeof e.shortcuts == "function" ? e.shortcuts(n, t) : e.shortcuts, c = e.checked != null ? e.checked(n, t) : void 0;
1978
1978
  return /* @__PURE__ */ a(
1979
1979
  kt,
1980
1980
  {
1981
- label: f,
1982
- shortcuts: h,
1981
+ label: h,
1982
+ shortcuts: f,
1983
1983
  disabled: l,
1984
1984
  checked: c,
1985
1985
  testId: e.id ? `${e.id}-item` : void 0,
@@ -1991,18 +1991,18 @@ function Vs(e, n, t, s, o) {
1991
1991
  );
1992
1992
  }
1993
1993
  const qs = () => {
1994
- const { store: e, dispatch: n } = le(ae), { rowMenuState: t, sheetReactive: s, editorRef: o, rowMenu: i } = e, l = s.current, f = t == null ? void 0 : t.y, h = t == null ? void 0 : t.position, c = () => {
1994
+ const { store: e, dispatch: n } = le(ae), { rowMenuState: t, sheetReactive: s, editorRef: o, rowMenu: i } = e, l = s.current, h = t == null ? void 0 : t.y, f = t == null ? void 0 : t.position, c = () => {
1995
1995
  n(mt(null)), O(o.current);
1996
1996
  };
1997
- if (!t || !l || f == null || !h)
1997
+ if (!t || !l || h == null || !f)
1998
1998
  return null;
1999
- const d = Et(e, n, c);
1999
+ const d = xt(e, n, c);
2000
2000
  return /* @__PURE__ */ a(
2001
2001
  rt,
2002
2002
  {
2003
2003
  className: "gs-menu-modal gs-row-menu-modal",
2004
2004
  onClick: (b) => (b.preventDefault(), c(), !1),
2005
- children: /* @__PURE__ */ a("div", { className: "gs-row-menu", style: { top: h.y, left: h.x }, onClick: (b) => b.stopPropagation(), children: /* @__PURE__ */ a("ul", { className: "gs-menu-items", children: i.map((b, y) => Vs(b, d, f, y, c)) }) })
2005
+ children: /* @__PURE__ */ a("div", { className: "gs-row-menu", style: { top: f.y, left: f.x }, onClick: (b) => b.stopPropagation(), children: /* @__PURE__ */ a("ul", { className: "gs-menu-items", children: i.map((b, y) => Vs(b, d, h, y, c)) }) })
2006
2006
  }
2007
2007
  );
2008
2008
  }, He = (e) => {
@@ -2013,23 +2013,23 @@ const qs = () => {
2013
2013
  return !!(n.buttons & 1) && n.button === 0;
2014
2014
  }
2015
2015
  return !1;
2016
- }, he = (e) => {
2016
+ }, fe = (e) => {
2017
2017
  e.type.startsWith("touch") || e.preventDefault();
2018
2018
  }, Gs = nt(({ y: e, x: n }) => {
2019
- var oe;
2020
- const t = be(e), o = `${pe(n)}${t}`, { store: i, dispatch: l } = le(ae), f = se(!0), h = se(null), [c, d] = J(null), {
2019
+ var Q;
2020
+ const t = be(e), o = `${pe(n)}${t}`, { store: i, dispatch: l } = le(ae), h = re(!0), f = re(null), [c, d] = te(null), {
2021
2021
  sheetReactive: b,
2022
2022
  editingAddress: y,
2023
2023
  choosing: g,
2024
2024
  selectingZone: m,
2025
2025
  leftHeaderSelecting: p,
2026
- topHeaderSelecting: A,
2027
- editorRef: x,
2026
+ topHeaderSelecting: M,
2027
+ editorRef: E,
2028
2028
  autofillDraggingTo: F,
2029
2029
  contextMenu: T
2030
- } = i, S = b.current, M = st(i), $ = S == null ? void 0 : S.registry.lastFocused, P = ge(m), C = y === o, D = g.y === e && g.x === n, r = k(() => {
2031
- var V;
2032
- const w = (V = h.current) == null ? void 0 : V.getBoundingClientRect();
2030
+ } = i, S = b.current, D = st(i), $ = S == null ? void 0 : S.registry.lastFocused, P = he(m), C = y === o, I = g.y === e && g.x === n, r = k(() => {
2031
+ var K;
2032
+ const w = (K = f.current) == null ? void 0 : K.getBoundingClientRect();
2033
2033
  if (w == null)
2034
2034
  return null;
2035
2035
  l(
@@ -2041,16 +2041,16 @@ const qs = () => {
2041
2041
  })
2042
2042
  );
2043
2043
  }, [l]);
2044
- Z(() => {
2045
- if (D && !f.current) {
2044
+ W(() => {
2045
+ if (I && !h.current) {
2046
2046
  r();
2047
2047
  return;
2048
2048
  }
2049
- f.current = !1;
2050
- }, [D, C, r]);
2049
+ h.current = !1;
2050
+ }, [I, C, r]);
2051
2051
  const u = S == null ? void 0 : S.getCell({ y: e, x: n }, { resolution: "SYSTEM" }), v = k(
2052
2052
  (w) => {
2053
- l(Ue({ value: w }));
2053
+ l(Ze({ value: w }));
2054
2054
  },
2055
2055
  [l]
2056
2056
  ), N = k(
@@ -2059,95 +2059,95 @@ const qs = () => {
2059
2059
  },
2060
2060
  [l]
2061
2061
  );
2062
- let I = "", R;
2062
+ let A = "", R;
2063
2063
  try {
2064
2064
  S && (R = S.render({ sheet: S, point: { y: e, x: n }, apply: N, value: void 0 }));
2065
2065
  } catch (w) {
2066
- es.is(w) ? (I = w.message, R = w.code) : (I = w.message, R = "#UNKNOWN");
2066
+ es.is(w) ? (A = w.message, R = w.code) : (A = w.message, R = "#UNKNOWN");
2067
2067
  }
2068
- const [, H] = (S == null ? void 0 : S.getSolvedCache({ y: e, x: n })) ?? [void 0, void 0], G = ts.is(H), _ = x.current, re = !!(S != null && S.registry.editingAddress || y), ce = k(
2068
+ const [, H] = (S == null ? void 0 : S.getSolvedCache({ y: e, x: n })) ?? [void 0, void 0], q = ts.is(H), _ = E.current, oe = !!(S != null && S.registry.editingAddress || y), ce = k(
2069
2069
  (w) => {
2070
- if (w.stopPropagation(), he(w), !S || !He(w) || !_)
2070
+ if (w.stopPropagation(), fe(w), !S || !He(w) || !_)
2071
2071
  return !1;
2072
2072
  if (w.type.startsWith("touch"))
2073
- return re && _ && _.blur(), l(Xe({ y: e, x: n })), l(we({ startY: e, startX: n, endY: e, endX: n })), !0;
2073
+ return oe && _ && _.blur(), l(Xe({ y: e, x: n })), l(we({ startY: e, startX: n, endY: e, endX: n })), !0;
2074
2074
  w.shiftKey ? l(me({ y: e, x: n })) : l(we({ startY: e, startX: n, endY: -1, endX: -1 })), l(ke(!0));
2075
- const V = `${S.sheetPrefix(!M)}${o}`;
2076
- return re && De({ input: $ || null, ref: V }) || (S.registry.lastFocused = _, O(_), l(ue("")), F) ? !1 : (re && v(_.value), w.shiftKey || l(Xe({ y: e, x: n })), !0);
2075
+ const K = `${S.sheetPrefix(!D)}${o}`;
2076
+ return oe && De({ input: $ || null, ref: K }) || (S.registry.lastFocused = _, O(_), l(ue("")), F) ? !1 : (oe && v(_.value), w.shiftKey || l(Xe({ y: e, x: n })), !0);
2077
2077
  },
2078
- [re, _, o, M, $, F, v, S]
2078
+ [oe, _, o, D, $, F, v, S]
2079
2079
  ), B = k(
2080
2080
  (w) => {
2081
2081
  if (w.stopPropagation(), !w.type.startsWith("touch")) {
2082
- if (he(w), l(ke(!1)), F)
2082
+ if (fe(w), l(ke(!1)), F)
2083
2083
  return l(bn(F)), O(_), !1;
2084
- re && l(me({ y: -1, x: -1 }));
2084
+ oe && l(me({ y: -1, x: -1 }));
2085
2085
  }
2086
2086
  },
2087
- [F, re, _]
2087
+ [F, oe, _]
2088
2088
  ), z = k(
2089
2089
  (w) => {
2090
2090
  if (!He(w) || w.type.startsWith("touch") || !S)
2091
2091
  return !1;
2092
- if (he(w), w.stopPropagation(), F)
2093
- return l(Ze({ x: n, y: e })), !1;
2092
+ if (fe(w), w.stopPropagation(), F)
2093
+ return l(We({ x: n, y: e })), !1;
2094
2094
  if (p)
2095
2095
  return l(me({ y: e, x: S.numCols })), !1;
2096
- if (A)
2096
+ if (M)
2097
2097
  return l(me({ y: S.numRows, x: n })), !1;
2098
- if (re && !sn($ || null))
2098
+ if (oe && !sn($ || null))
2099
2099
  return !1;
2100
- if (l(me({ y: e, x: n })), re) {
2101
- const V = ge({ ...m, endY: e, endX: n }), fe = `${S.sheetPrefix(!M)}${rn(V)}`;
2102
- De({ input: $ || null, ref: fe });
2100
+ if (l(me({ y: e, x: n })), oe) {
2101
+ const K = he({ ...m, endY: e, endX: n }), de = `${S.sheetPrefix(!D)}${rn(K)}`;
2102
+ De({ input: $ || null, ref: de });
2103
2103
  }
2104
2104
  return !0;
2105
2105
  },
2106
2106
  [
2107
2107
  F,
2108
2108
  p,
2109
- A,
2109
+ M,
2110
2110
  S,
2111
- re,
2111
+ oe,
2112
2112
  $,
2113
2113
  m,
2114
- M
2114
+ D
2115
2115
  ]
2116
- ), U = k(
2116
+ ), Z = k(
2117
2117
  (w) => {
2118
- l(Ze({ x: n, y: e })), l(ke(!0)), w.stopPropagation();
2118
+ l(We({ x: n, y: e })), l(ke(!0)), w.stopPropagation();
2119
2119
  },
2120
2120
  [l, n, e]
2121
- ), K = k(() => {
2122
- var V;
2123
- const w = (V = h.current) == null ? void 0 : V.getBoundingClientRect();
2121
+ ), J = k(() => {
2122
+ var K;
2123
+ const w = (K = f.current) == null ? void 0 : K.getBoundingClientRect();
2124
2124
  w && d(ns(w));
2125
- }, []), W = k(() => {
2125
+ }, []), j = k(() => {
2126
2126
  d(null);
2127
- }, []), Q = k(
2128
- (w) => T.length > 0 ? (w.stopPropagation(), he(w), l(We({ y: w.clientY, x: w.clientX })), !1) : !0,
2127
+ }, []), U = k(
2128
+ (w) => T.length > 0 ? (w.stopPropagation(), fe(w), l(ze({ y: w.clientY, x: w.clientX })), !1) : !0,
2129
2129
  [T.length]
2130
- ), j = k(
2130
+ ), G = k(
2131
2131
  (w) => {
2132
- w.stopPropagation(), he(w), ue(o);
2133
- const V = document.createEvent("MouseEvents");
2134
- return V.initEvent("dblclick", !0, !0), _ == null || _.dispatchEvent(V), !1;
2132
+ w.stopPropagation(), fe(w), ue(o);
2133
+ const K = document.createEvent("MouseEvents");
2134
+ return K.initEvent("dblclick", !0, !0), _ == null || _.dispatchEvent(K), !1;
2135
2135
  },
2136
2136
  [o, _]
2137
- ), L = $e(() => !C && D && P.bottom === -1 || P.bottom === e && P.right === n ? "gs-autofill-drag" : "gs-autofill-drag gs-hidden", [C, D, P]);
2137
+ ), L = $e(() => !C && I && P.bottom === -1 || P.bottom === e && P.right === n ? "gs-autofill-drag" : "gs-autofill-drag gs-hidden", [C, I, P]);
2138
2138
  return S ? _ ? /* @__PURE__ */ a(
2139
2139
  "td",
2140
2140
  {
2141
- ref: h,
2141
+ ref: f,
2142
2142
  "data-x": n,
2143
2143
  "data-y": e,
2144
2144
  "data-address": o,
2145
- className: `gs-cell ${rs(P, { y: e, x: n }) ? "gs-selecting" : ""} ${D ? "gs-choosing" : ""} ${C ? "gs-editing" : ""} ${G ? "gs-pending" : ""}`,
2145
+ className: `gs-cell ${rs(P, { y: e, x: n }) ? "gs-selecting" : ""} ${I ? "gs-choosing" : ""} ${C ? "gs-editing" : ""} ${q ? "gs-pending" : ""}`,
2146
2146
  style: {
2147
2147
  ...u == null ? void 0 : u.style
2148
2148
  },
2149
- onContextMenu: Q,
2150
- onDoubleClick: j,
2149
+ onContextMenu: U,
2150
+ onDoubleClick: G,
2151
2151
  children: /* @__PURE__ */ Y(
2152
2152
  "div",
2153
2153
  {
@@ -2163,16 +2163,16 @@ const qs = () => {
2163
2163
  className: "gs-cell-inner",
2164
2164
  style: {
2165
2165
  ...u == null ? void 0 : u.style,
2166
- textAlign: ((oe = u == null ? void 0 : u.style) == null ? void 0 : oe.textAlign) || (u == null ? void 0 : u.justifyContent) || "left",
2166
+ textAlign: ((Q = u == null ? void 0 : u.style) == null ? void 0 : Q.textAlign) || (u == null ? void 0 : u.justifyContent) || "left",
2167
2167
  alignItems: (u == null ? void 0 : u.alignItems) || "start"
2168
2168
  },
2169
2169
  children: [
2170
- I && /* @__PURE__ */ a(
2170
+ A && /* @__PURE__ */ a(
2171
2171
  "div",
2172
2172
  {
2173
2173
  className: "gs-formula-error-triangle",
2174
- onMouseEnter: K,
2175
- onMouseLeave: W
2174
+ onMouseEnter: J,
2175
+ onMouseLeave: j
2176
2176
  }
2177
2177
  ),
2178
2178
  /* @__PURE__ */ a(
@@ -2190,7 +2190,7 @@ const qs = () => {
2190
2190
  ]
2191
2191
  }
2192
2192
  ),
2193
- I && c && /* @__PURE__ */ a(
2193
+ A && c && /* @__PURE__ */ a(
2194
2194
  "div",
2195
2195
  {
2196
2196
  className: "gs-formula-error-tooltip",
@@ -2199,10 +2199,10 @@ const qs = () => {
2199
2199
  left: c.x,
2200
2200
  transform: ss(c.hAlign)
2201
2201
  },
2202
- children: I
2202
+ children: A
2203
2203
  }
2204
2204
  ),
2205
- /* @__PURE__ */ a("div", { className: L, onMouseDown: U })
2205
+ /* @__PURE__ */ a("div", { className: L, onMouseDown: Z })
2206
2206
  ]
2207
2207
  }
2208
2208
  )
@@ -2215,9 +2215,9 @@ const qs = () => {
2215
2215
  }), Qs = 0.4, Js = 200;
2216
2216
  let Qt = (/* @__PURE__ */ new Date()).getTime(), Ke = 0;
2217
2217
  function Te({ style: e, horizontal: n = 0, vertical: t = 0, className: s = "" }) {
2218
- const o = se(null), { store: i, dispatch: l } = le(ae), {
2219
- tabularRef: f,
2220
- autofillDraggingTo: h,
2218
+ const o = re(null), { store: i, dispatch: l } = le(ae), {
2219
+ tabularRef: h,
2220
+ autofillDraggingTo: f,
2221
2221
  dragging: c,
2222
2222
  selectingZone: d,
2223
2223
  editorRef: b,
@@ -2225,89 +2225,89 @@ function Te({ style: e, horizontal: n = 0, vertical: t = 0, className: s = "" })
2225
2225
  searchInputRef: g,
2226
2226
  editingAddress: m
2227
2227
  } = i, p = y.current;
2228
- let A = !1;
2229
- const x = st(i), F = !!(p != null && p.registry.editingAddress || m), T = k(
2228
+ let M = !1;
2229
+ const E = st(i), F = !!(p != null && p.registry.editingAddress || m), T = k(
2230
2230
  (r) => {
2231
2231
  if (!p)
2232
2232
  return { x: -1, y: -1 };
2233
2233
  if (n == 0 && t == 0) {
2234
- const I = f.current.getBoundingClientRect(), { left: R, top: H, right: G, bottom: _ } = I;
2235
- n = r.pageX > G ? 1 : r.pageX < R ? -1 : 0, n === 0 && (t = r.pageY > _ ? 1 : r.pageY < H ? -1 : 0);
2234
+ const A = h.current.getBoundingClientRect(), { left: R, top: H, right: q, bottom: _ } = A;
2235
+ n = r.pageX > q ? 1 : r.pageX < R ? -1 : 0, n === 0 && (t = r.pageY > _ ? 1 : r.pageY < H ? -1 : 0);
2236
2236
  }
2237
- const u = Lt(f.current);
2237
+ const u = Lt(h.current);
2238
2238
  let { endX: v, endY: N } = d;
2239
2239
  return n ? v = n > 0 ? u.right : u.left : t && (N = t > 0 ? u.bottom : u.top), { x: v, y: N };
2240
2240
  },
2241
2241
  [p, n, t, d]
2242
2242
  ), S = k(
2243
2243
  (r) => {
2244
- if (!A || f.current === null || !p)
2244
+ if (!M || h.current === null || !p)
2245
2245
  return;
2246
2246
  const u = (/* @__PURE__ */ new Date()).getTime();
2247
- u - Qt > 1e3 && (Ke = 0), Qt = u, f.current.scrollBy({
2247
+ u - Qt > 1e3 && (Ke = 0), Qt = u, h.current.scrollBy({
2248
2248
  left: Ke * n,
2249
2249
  top: Ke * t
2250
2250
  }), O(b.current);
2251
2251
  const { x: v, y: N } = T(r);
2252
- if (h) {
2253
- const { y: I, x: R } = h;
2254
- l(Ze({ y: N === -1 ? I : N, x: v === -1 ? R : v }));
2252
+ if (f) {
2253
+ const { y: A, x: R } = f;
2254
+ l(We({ y: N === -1 ? A : N, x: v === -1 ? R : v }));
2255
2255
  } else {
2256
2256
  if (F) {
2257
- const I = ge({ ...d, endY: N, endX: v }), R = p.sheetPrefix(!x), H = rn(I), G = `${R}${H}`;
2258
- De({ input: b.current, ref: G });
2257
+ const A = he({ ...d, endY: N, endX: v }), R = p.sheetPrefix(!E), H = rn(A), q = `${R}${H}`;
2258
+ De({ input: b.current, ref: q });
2259
2259
  }
2260
2260
  l(me({ y: N, x: v }));
2261
2261
  }
2262
2262
  Ke = Math.min(Ke + Qs, Js), o.current = requestAnimationFrame(() => S(r));
2263
2263
  },
2264
2264
  [
2265
- A,
2265
+ M,
2266
2266
  p,
2267
2267
  n,
2268
2268
  t,
2269
- h,
2269
+ f,
2270
2270
  F,
2271
2271
  d,
2272
- x,
2272
+ E,
2273
2273
  T
2274
2274
  ]
2275
- ), M = k(
2275
+ ), D = k(
2276
2276
  (r) => {
2277
- if (r.preventDefault(), r.stopPropagation(), !A) {
2278
- if (A = !0, n === 0 || t === 0) {
2279
- const u = f.current.getBoundingClientRect(), { left: v, top: N, right: I, bottom: R } = u;
2280
- n || (n = r.pageX > I ? 1 : r.pageX < v ? -1 : 0), n === 0 && (t || (t = r.pageY > R ? 1 : r.pageY < N ? -1 : 0));
2277
+ if (r.preventDefault(), r.stopPropagation(), !M) {
2278
+ if (M = !0, n === 0 || t === 0) {
2279
+ const u = h.current.getBoundingClientRect(), { left: v, top: N, right: A, bottom: R } = u;
2280
+ n || (n = r.pageX > A ? 1 : r.pageX < v ? -1 : 0), n === 0 && (t || (t = r.pageY > R ? 1 : r.pageY < N ? -1 : 0));
2281
2281
  }
2282
2282
  o.current = requestAnimationFrame(() => S(r));
2283
2283
  }
2284
2284
  },
2285
- [A, n, t, S]
2285
+ [M, n, t, S]
2286
2286
  ), $ = k(() => {
2287
- o.current !== null && (cancelAnimationFrame(o.current), o.current = null), A = !1, os(g.current) || O(b.current);
2287
+ o.current !== null && (cancelAnimationFrame(o.current), o.current = null), M = !1, os(g.current) || O(b.current);
2288
2288
  }, []), P = k(
2289
2289
  (r) => {
2290
2290
  r.preventDefault(), r.stopPropagation();
2291
- const u = Lt(f.current);
2291
+ const u = Lt(h.current);
2292
2292
  if (u.bottom === -1 || u.right === -1)
2293
2293
  return;
2294
2294
  const { x: v, y: N } = T(r);
2295
- if (h) {
2296
- const { y: I, x: R } = h;
2297
- l(bn({ y: N === -1 ? I : N, x: v === -1 ? R : v })), O(b.current);
2295
+ if (f) {
2296
+ const { y: A, x: R } = f;
2297
+ l(bn({ y: N === -1 ? A : N, x: v === -1 ? R : v })), O(b.current);
2298
2298
  } else
2299
2299
  F && l(me({ y: -1, x: -1 }));
2300
2300
  },
2301
- [h, F, T]
2301
+ [f, F, T]
2302
2302
  ), C = k(
2303
2303
  (r) => {
2304
2304
  $(), l(ke(!1)), requestAnimationFrame(() => P(r));
2305
2305
  },
2306
2306
  [$, P]
2307
- ), D = k(() => {
2307
+ ), I = k(() => {
2308
2308
  $();
2309
2309
  }, [$]);
2310
- return Z(() => $, [$]), !b.current || !c && !h ? /* @__PURE__ */ a("div", { className: `gs-scroll-handle gs-hidden ${s}` }) : /* @__PURE__ */ a(
2310
+ return W(() => $, [$]), !b.current || !c && !f ? /* @__PURE__ */ a("div", { className: `gs-scroll-handle gs-hidden ${s}` }) : /* @__PURE__ */ a(
2311
2311
  "div",
2312
2312
  {
2313
2313
  style: e,
@@ -2315,8 +2315,8 @@ function Te({ style: e, horizontal: n = 0, vertical: t = 0, className: s = "" })
2315
2315
  onMouseUp: (r) => {
2316
2316
  C(r);
2317
2317
  },
2318
- onMouseEnter: M,
2319
- onMouseLeave: D
2318
+ onMouseEnter: D,
2319
+ onMouseLeave: I
2320
2320
  }
2321
2321
  );
2322
2322
  }
@@ -2325,23 +2325,23 @@ const er = nt(({ x: e }) => {
2325
2325
  sheetReactive: o,
2326
2326
  editingAddress: i,
2327
2327
  choosing: l,
2328
- selectingZone: f,
2329
- topHeaderSelecting: h,
2328
+ selectingZone: h,
2329
+ topHeaderSelecting: f,
2330
2330
  editorRef: c,
2331
2331
  autofillDraggingTo: d,
2332
2332
  dragging: b,
2333
2333
  contextMenu: y,
2334
2334
  columnMenuState: g
2335
- } = t, m = o.current, p = m == null ? void 0 : m.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), A = (p == null ? void 0 : p.width) || vt, x = !!(p != null && p.filter && p.filter.conditions.length > 0), F = st(t), T = m == null ? void 0 : m.registry.lastFocused, S = !!(m != null && m.registry.editingAddress || i), M = k(
2335
+ } = t, m = o.current, p = m == null ? void 0 : m.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), M = (p == null ? void 0 : p.width) || vt, E = !!(p != null && p.filter && p.filter.conditions.length > 0), F = st(t), T = m == null ? void 0 : m.registry.lastFocused, S = !!(m != null && m.registry.editingAddress || i), D = k(
2336
2336
  (r) => {
2337
- s(Ue({ value: r, point: l }));
2337
+ s(Ze({ value: r, point: l }));
2338
2338
  },
2339
2339
  [l]
2340
2340
  ), $ = k((r) => {
2341
- s(ht([e, r.clientX, r.clientX])), r.stopPropagation(), he(r);
2341
+ s(ft([e, r.clientX, r.clientX])), r.stopPropagation(), fe(r);
2342
2342
  }, []), P = k(
2343
2343
  (r) => {
2344
- if (r.stopPropagation(), he(r), !He(r) || !m || b)
2344
+ if (r.stopPropagation(), fe(r), !He(r) || !m || b)
2345
2345
  return !1;
2346
2346
  if (r.type.startsWith("touch"))
2347
2347
  return S && c.current && c.current.blur(), s(Xe({ y: 1, x: e })), s(we({ startY: 1, startX: e, endY: m.numRows, endX: e })), !0;
@@ -2349,13 +2349,13 @@ const er = nt(({ x: e }) => {
2349
2349
  const u = `${m.sheetPrefix(!F)}${n}:${n}`;
2350
2350
  if (S && De({ input: T || null, ref: u }))
2351
2351
  return s(we({ startY: m.numRows, startX: e, endY: 0, endX: e })), !1;
2352
- let v = r.shiftKey ? f.startX : e;
2352
+ let v = r.shiftKey ? h.startX : e;
2353
2353
  return v === -1 && (v = l.x), s(
2354
- zt({
2354
+ Ut({
2355
2355
  range: { start: v, end: e },
2356
2356
  numRows: m.numRows
2357
2357
  })
2358
- ), S && M((T == null ? void 0 : T.value) ?? ""), s(ue("")), s(ke(!0)), O(c.current), !d;
2358
+ ), S && D((T == null ? void 0 : T.value) ?? ""), s(ue("")), s(ke(!0)), O(c.current), !d;
2359
2359
  },
2360
2360
  [
2361
2361
  b,
@@ -2363,28 +2363,28 @@ const er = nt(({ x: e }) => {
2363
2363
  F,
2364
2364
  n,
2365
2365
  T,
2366
- f,
2366
+ h,
2367
2367
  l,
2368
2368
  d,
2369
2369
  c
2370
2370
  ]
2371
2371
  ), C = k(
2372
2372
  (r) => {
2373
- if (r.stopPropagation(), !r.type.startsWith("touch") && (he(r), s(ke(!1)), d))
2373
+ if (r.stopPropagation(), !r.type.startsWith("touch") && (fe(r), s(ke(!1)), d))
2374
2374
  return O(c.current), !1;
2375
2375
  },
2376
2376
  [d]
2377
- ), D = wn((r) => {
2377
+ ), I = wn((r) => {
2378
2378
  if (!He(r) || !m || r.type.startsWith("touch"))
2379
2379
  return !1;
2380
- if (he(r), r.stopPropagation(), d)
2381
- return s(Ze({ y: 1, x: e })), !1;
2380
+ if (fe(r), r.stopPropagation(), d)
2381
+ return s(We({ y: 1, x: e })), !1;
2382
2382
  if (S) {
2383
- const u = ge({ ...f, endY: 1, endX: e }), [v, N] = [pe(u.left), pe(u.right)], I = `${m.sheetPrefix(!F)}${v}:${N}`;
2384
- De({ input: T || null, ref: I });
2383
+ const u = he({ ...h, endY: 1, endX: e }), [v, N] = [pe(u.left), pe(u.right)], A = `${m.sheetPrefix(!F)}${v}:${N}`;
2384
+ De({ input: T || null, ref: A });
2385
2385
  }
2386
2386
  if (d == null) {
2387
- const { startY: u } = f;
2387
+ const { startY: u } = h;
2388
2388
  s(u === 1 ? me({ y: m.numRows, x: e }) : me({ y: 1, x: e }));
2389
2389
  }
2390
2390
  return !1;
@@ -2393,16 +2393,16 @@ const er = nt(({ x: e }) => {
2393
2393
  "th",
2394
2394
  {
2395
2395
  "data-x": e,
2396
- className: `gs-th gs-th-top ${l.x === e ? "gs-choosing" : ""} ${Ae({ start: f.startX, end: f.endX }, e) ? h ? "gs-th-selecting" : "gs-selecting" : ""}`,
2397
- style: { ...p == null ? void 0 : p.style, width: A, minWidth: A, maxWidth: A },
2398
- onContextMenu: (r) => y.length > 0 ? (r.stopPropagation(), he(r), s(We({ y: r.clientY, x: r.clientX })), !1) : !0,
2396
+ className: `gs-th gs-th-top ${l.x === e ? "gs-choosing" : ""} ${Ae({ start: h.startX, end: h.endX }, e) ? f ? "gs-th-selecting" : "gs-selecting" : ""}`,
2397
+ style: { ...p == null ? void 0 : p.style, width: M, minWidth: M, maxWidth: M },
2398
+ onContextMenu: (r) => y.length > 0 ? (r.stopPropagation(), fe(r), s(ze({ y: r.clientY, x: r.clientX })), !1) : !0,
2399
2399
  children: /* @__PURE__ */ a(
2400
2400
  "div",
2401
2401
  {
2402
2402
  className: "gs-th-inner-wrap",
2403
2403
  onMouseDown: P,
2404
2404
  onTouchStart: P,
2405
- onMouseEnter: D,
2405
+ onMouseEnter: I,
2406
2406
  onMouseUp: C,
2407
2407
  children: /* @__PURE__ */ Y("div", { className: "gs-th-inner", style: { height: m.headerHeight, position: "relative" }, children: [
2408
2408
  /* @__PURE__ */ a(
@@ -2410,7 +2410,7 @@ const er = nt(({ x: e }) => {
2410
2410
  {
2411
2411
  style: {
2412
2412
  position: "absolute",
2413
- zIndex: h ? -1 : 1
2413
+ zIndex: f ? -1 : 1
2414
2414
  },
2415
2415
  vertical: -1
2416
2416
  }
@@ -2425,7 +2425,7 @@ const er = nt(({ x: e }) => {
2425
2425
  !X.hasOperation(p == null ? void 0 : p.prevention, X.ColumnMenu) && /* @__PURE__ */ a(
2426
2426
  "button",
2427
2427
  {
2428
- className: `gs-menu-btn gs-column-menu-btn ${x ? "gs-filtered" : ""} ${(g == null ? void 0 : g.x) === e ? "gs-active" : ""}`,
2428
+ className: `gs-menu-btn gs-column-menu-btn ${E ? "gs-filtered" : ""} ${(g == null ? void 0 : g.x) === e ? "gs-active" : ""}`,
2429
2429
  onMouseDown: (r) => {
2430
2430
  r.stopPropagation(), r.preventDefault(), r.currentTarget.dataset.pressX = String(r.clientX), r.currentTarget.dataset.pressY = String(r.clientY);
2431
2431
  },
@@ -2435,7 +2435,7 @@ const er = nt(({ x: e }) => {
2435
2435
  if (Math.abs(r.clientX - v) > 4 || Math.abs(r.clientY - N) > 4)
2436
2436
  return;
2437
2437
  const R = u.getBoundingClientRect();
2438
- (g == null ? void 0 : g.x) === e ? s(et(null)) : (Ae({ start: f.startX, end: f.endX }, e) && f.startY === 1 && f.endY === m.numRows || s(zt({ range: { start: e, end: e }, numRows: m.numRows })), s(et({ x: e, position: { y: R.bottom, x: R.left } })));
2438
+ (g == null ? void 0 : g.x) === e ? s(et(null)) : (Ae({ start: h.startX, end: h.endX }, e) && h.startY === 1 && h.endY === m.numRows || s(Ut({ range: { start: e, end: e }, numRows: m.numRows })), s(et({ x: e, position: { y: R.bottom, x: R.left } })));
2439
2439
  },
2440
2440
  children: "⋮"
2441
2441
  }
@@ -2465,80 +2465,80 @@ const er = nt(({ x: e }) => {
2465
2465
  choosing: o,
2466
2466
  editingAddress: i,
2467
2467
  selectingZone: l,
2468
- leftHeaderSelecting: f,
2469
- editorRef: h,
2468
+ leftHeaderSelecting: h,
2469
+ editorRef: f,
2470
2470
  sheetReactive: c,
2471
2471
  autofillDraggingTo: d,
2472
2472
  dragging: b,
2473
2473
  contextMenu: y,
2474
2474
  rowMenuState: g
2475
- } = t, m = c.current, p = m == null ? void 0 : m.getCell({ y: e, x: 0 }, { resolution: "SYSTEM" }), A = (p == null ? void 0 : p.height) || bt, x = st(t), F = m == null ? void 0 : m.registry.lastFocused, T = !!(m != null && m.registry.editingAddress || i), S = k(
2475
+ } = t, m = c.current, p = m == null ? void 0 : m.getCell({ y: e, x: 0 }, { resolution: "SYSTEM" }), M = (p == null ? void 0 : p.height) || bt, E = st(t), F = m == null ? void 0 : m.registry.lastFocused, T = !!(m != null && m.registry.editingAddress || i), S = k(
2476
2476
  (r) => {
2477
- s(Ue({ value: r, point: o }));
2477
+ s(Ze({ value: r, point: o }));
2478
2478
  },
2479
2479
  [o]
2480
- ), M = k((r) => {
2481
- s(ft([e, r.clientY, r.clientY])), r.stopPropagation(), he(r);
2480
+ ), D = k((r) => {
2481
+ s(ht([e, r.clientY, r.clientY])), r.stopPropagation(), fe(r);
2482
2482
  }, []), $ = k(
2483
2483
  (r) => {
2484
- if (r.stopPropagation(), he(r), !He(r) || !m || b)
2484
+ if (r.stopPropagation(), fe(r), !He(r) || !m || b)
2485
2485
  return !1;
2486
2486
  if (r.type.startsWith("touch"))
2487
- return T && h.current && h.current.blur(), s(Xe({ y: e, x: 1 })), s(we({ startY: e, startX: 1, endY: e, endX: m.numCols })), !0;
2487
+ return T && f.current && f.current.blur(), s(Xe({ y: e, x: 1 })), s(we({ startY: e, startX: 1, endY: e, endX: m.numCols })), !0;
2488
2488
  s(we({ startY: e, startX: 1, endY: e, endX: -1 }));
2489
- const u = `${m.sheetPrefix(!x)}${n}:${n}`;
2489
+ const u = `${m.sheetPrefix(!E)}${n}:${n}`;
2490
2490
  if (T && De({ input: F || null, ref: u }))
2491
2491
  return s(we({ startY: e, startX: m.numCols, endY: e, endX: 0 })), !1;
2492
2492
  let v = r.shiftKey ? l.startY : e;
2493
2493
  return v === -1 && (v = o.y), s(
2494
- Wt({
2494
+ zt({
2495
2495
  range: { start: v, end: e },
2496
2496
  numCols: m.numCols
2497
2497
  })
2498
- ), T && S((F == null ? void 0 : F.value) ?? ""), s(ue("")), s(ke(!0)), O(h.current), !d;
2498
+ ), T && S((F == null ? void 0 : F.value) ?? ""), s(ue("")), s(ke(!0)), O(f.current), !d;
2499
2499
  },
2500
2500
  [
2501
2501
  b,
2502
2502
  T,
2503
- x,
2503
+ E,
2504
2504
  n,
2505
2505
  F,
2506
2506
  l,
2507
2507
  o,
2508
2508
  d,
2509
- h
2509
+ f
2510
2510
  ]
2511
2511
  ), P = k(
2512
2512
  (r) => {
2513
- if (r.stopPropagation(), !r.type.startsWith("touch") && (he(r), s(ke(!1)), d))
2514
- return O(h.current), !1;
2513
+ if (r.stopPropagation(), !r.type.startsWith("touch") && (fe(r), s(ke(!1)), d))
2514
+ return O(f.current), !1;
2515
2515
  },
2516
2516
  [d]
2517
2517
  ), C = wn((r) => {
2518
2518
  if (!He(r) || !m || r.type.startsWith("touch"))
2519
2519
  return !1;
2520
- if (he(r), r.stopPropagation(), d)
2521
- return s(Ze({ y: e, x: 1 })), !1;
2520
+ if (fe(r), r.stopPropagation(), d)
2521
+ return s(We({ y: e, x: 1 })), !1;
2522
2522
  if (T) {
2523
- const u = ge({ ...l, endY: e, endX: 1 }), [v, N] = [be(u.top), be(u.bottom)], I = `${m.sheetPrefix(!x)}${v}:${N}`;
2524
- De({ input: F || null, ref: I });
2523
+ const u = he({ ...l, endY: e, endX: 1 }), [v, N] = [be(u.top), be(u.bottom)], A = `${m.sheetPrefix(!E)}${v}:${N}`;
2524
+ De({ input: F || null, ref: A });
2525
2525
  }
2526
2526
  if (d == null) {
2527
2527
  const { startX: u } = l;
2528
2528
  s(u === 1 ? me({ y: e, x: m.numCols }) : me({ y: e, x: 1 }));
2529
2529
  }
2530
2530
  return !1;
2531
- }, 100), D = k(
2532
- (r) => y.length > 0 ? (r.stopPropagation(), he(r), s(We({ y: r.clientY, x: r.clientX })), !1) : !0,
2531
+ }, 100), I = k(
2532
+ (r) => y.length > 0 ? (r.stopPropagation(), fe(r), s(ze({ y: r.clientY, x: r.clientX })), !1) : !0,
2533
2533
  [y.length]
2534
2534
  );
2535
2535
  return m ? /* @__PURE__ */ a(
2536
2536
  "th",
2537
2537
  {
2538
2538
  "data-y": e,
2539
- className: `gs-th gs-th-left ${o.y === e ? "gs-choosing" : ""} ${Ae({ start: l.startY, end: l.endY }, e) ? f ? "gs-th-selecting" : "gs-selecting" : ""} ${p != null && p.filterFixed ? "gs-filter-fixed" : ""} ${p != null && p.sortFixed ? "gs-sort-fixed" : ""}`,
2540
- style: { ...p == null ? void 0 : p.style, height: A },
2541
- onContextMenu: D,
2539
+ className: `gs-th gs-th-left ${o.y === e ? "gs-choosing" : ""} ${Ae({ start: l.startY, end: l.endY }, e) ? h ? "gs-th-selecting" : "gs-selecting" : ""} ${p != null && p.filterFixed ? "gs-filter-fixed" : ""} ${p != null && p.sortFixed ? "gs-sort-fixed" : ""}`,
2540
+ style: { ...p == null ? void 0 : p.style, height: M },
2541
+ onContextMenu: I,
2542
2542
  children: /* @__PURE__ */ a(
2543
2543
  "div",
2544
2544
  {
@@ -2553,7 +2553,7 @@ const er = nt(({ x: e }) => {
2553
2553
  {
2554
2554
  style: {
2555
2555
  position: "absolute",
2556
- zIndex: f ? -1 : 1
2556
+ zIndex: h ? -1 : 1
2557
2557
  },
2558
2558
  horizontal: -1
2559
2559
  }
@@ -2572,7 +2572,7 @@ const er = nt(({ x: e }) => {
2572
2572
  if (Math.abs(r.clientX - v) > 4 || Math.abs(r.clientY - N) > 4)
2573
2573
  return;
2574
2574
  const R = u.getBoundingClientRect();
2575
- (g == null ? void 0 : g.y) === e ? s(mt(null)) : (Ae({ start: l.startY, end: l.endY }, e) && l.startX === 1 && l.endX === m.numCols || s(Wt({ range: { start: e, end: e }, numCols: m.numCols })), s(mt({ y: e, position: { y: R.bottom, x: R.right } })));
2575
+ (g == null ? void 0 : g.y) === e ? s(mt(null)) : (Ae({ start: l.startY, end: l.endY }, e) && l.startX === 1 && l.endX === m.numCols || s(zt({ range: { start: e, end: e }, numCols: m.numCols })), s(mt({ y: e, position: { y: R.bottom, x: R.right } })));
2576
2576
  },
2577
2577
  children: "⋮"
2578
2578
  }
@@ -2585,7 +2585,7 @@ const er = nt(({ x: e }) => {
2585
2585
  ${X.hasOperation(p == null ? void 0 : p.prevention, X.Resize) ? "gs-protected" : ""}
2586
2586
  ${b ? "gs-hidden" : ""}`,
2587
2587
  style: { width: m.headerWidth },
2588
- onMouseDown: M
2588
+ onMouseDown: D
2589
2589
  }
2590
2590
  )
2591
2591
  ] })
@@ -2595,14 +2595,14 @@ const er = nt(({ x: e }) => {
2595
2595
  ) : null;
2596
2596
  }), lt = "rgba(0, 119, 255, 1)", nr = "rgba(0, 119, 255, 0.6)", sr = "rgba(0, 128, 255, 0.2)", rr = "#0077ff", or = "#0077ff", ir = "rgba(0, 200, 100, 0.2)", lr = "#00aa78", ar = "#0077aa", Jt = (e, n, t, s, o, i) => {
2597
2597
  e.fillStyle = i, e.fillRect(n, t, s, o);
2598
- }, yt = (e, n, t, s, o, i, l = 2, f = [], h) => {
2599
- h && (e.fillStyle = h, e.fillRect(n, t, s, o)), e.strokeStyle = i, e.lineWidth = l, e.setLineDash(f), e.strokeRect(n + l / 2, t + l / 2, s - l, o - l), e.setLineDash([]);
2600
- }, qe = (e, n, t, s, o, i, l, f, h = 2, c = [], d) => {
2598
+ }, yt = (e, n, t, s, o, i, l = 2, h = [], f) => {
2599
+ f && (e.fillStyle = f, e.fillRect(n, t, s, o)), e.strokeStyle = i, e.lineWidth = l, e.setLineDash(h), e.strokeRect(n + l / 2, t + l / 2, s - l, o - l), e.setLineDash([]);
2600
+ }, qe = (e, n, t, s, o, i, l, h, f = 2, c = [], d) => {
2601
2601
  const { top: b, left: y, bottom: g, right: m } = l;
2602
2602
  if (b === -1 || y === -1 || g === -1 || m === -1)
2603
2603
  return;
2604
- const p = Fe(n, { y: b, x: y }), A = Fe(n, { y: g, x: m }), x = p.left - s, F = p.top - t, T = A.right - s, S = A.bottom - t;
2605
- T < 0 || x > o || S < 0 || F > i || yt(e, x, F, T - x, S - F, f, h, c, d);
2604
+ const p = Fe(n, { y: b, x: y }), M = Fe(n, { y: g, x: m }), E = p.left - s, F = p.top - t, T = M.right - s, S = M.bottom - t;
2605
+ T < 0 || E > o || S < 0 || F > i || yt(e, E, F, T - E, S - F, h, f, c, d);
2606
2606
  }, cr = ({ refs: e = {} }) => {
2607
2607
  const { store: n } = le(ae), {
2608
2608
  sheetReactive: t,
@@ -2610,116 +2610,120 @@ const er = nt(({ x: e }) => {
2610
2610
  choosing: o,
2611
2611
  selectingZone: i,
2612
2612
  matchingCells: l,
2613
- matchingCellIndex: f,
2614
- autofillDraggingTo: h,
2613
+ matchingCellIndex: h,
2614
+ autofillDraggingTo: f,
2615
2615
  topHeaderSelecting: c,
2616
2616
  leftHeaderSelecting: d,
2617
2617
  mode: b,
2618
2618
  dragging: y
2619
- } = n, g = t.current, m = se(null), p = se(0), A = se(n);
2620
- A.current = n;
2621
- const x = k(() => {
2619
+ } = n, g = t.current, m = re(null), p = re(0), M = re(n);
2620
+ M.current = n;
2621
+ const E = k(() => {
2622
2622
  if (!g || !s.current || !m.current)
2623
2623
  return;
2624
- const S = m.current, M = S.getContext("2d");
2625
- if (!M)
2624
+ const S = m.current, D = S.getContext("2d");
2625
+ if (!D)
2626
2626
  return;
2627
- const $ = s.current, P = window.devicePixelRatio || 1, C = $.clientWidth, D = $.clientHeight;
2628
- (S.width !== C * P || S.height !== D * P) && (S.style.width = `${C}px`, S.style.height = `${D}px`, S.width = C * P, S.height = D * P), M.setTransform(P, 0, 0, P, 0, 0), M.clearRect(0, 0, C, D);
2629
- const { registry: r } = g, u = $.scrollTop, v = $.scrollLeft, N = g.headerWidth, I = g.headerHeight;
2630
- M.save(), M.beginPath(), M.rect(N, I, C - N, D - I), M.clip();
2631
- const R = ge(i);
2632
- if (qe(M, g, u, v, C, D, R, nr, 1, [], sr), h) {
2633
- const B = new is(A.current, h);
2634
- qe(M, g, u, v, C, D, B.wholeArea, ar, 1, [5, 5]);
2627
+ const $ = s.current, P = window.devicePixelRatio || 1, C = $.clientWidth, I = $.clientHeight;
2628
+ (S.width !== C * P || S.height !== I * P) && (S.style.width = `${C}px`, S.style.height = `${I}px`, S.width = C * P, S.height = I * P), D.setTransform(P, 0, 0, P, 0, 0), D.clearRect(0, 0, C, I);
2629
+ const { registry: r } = g, u = $.scrollTop, v = $.scrollLeft, N = g.headerWidth, A = g.headerHeight;
2630
+ D.save(), D.beginPath(), D.rect(N, A, C - N, I - A), D.clip();
2631
+ const R = he(i);
2632
+ if (qe(D, g, u, v, C, I, R, nr, 1, [], sr), f) {
2633
+ const B = new is(M.current, f);
2634
+ qe(D, g, u, v, C, I, B.wholeArea, ar, 1, [5, 5]);
2635
2635
  }
2636
2636
  {
2637
2637
  const { y: B, x: z } = o;
2638
2638
  if (B !== -1 && z !== -1) {
2639
- const U = Fe(g, { y: B, x: z }), K = U.left - v, W = U.top - u;
2640
- yt(M, K, W, U.width, U.height, lt, 2, []);
2639
+ const Z = Fe(g, { y: B, x: z }), J = Z.left - v, j = Z.top - u;
2640
+ yt(D, J, j, Z.width, Z.height, lt, 2, []);
2641
2641
  }
2642
2642
  }
2643
- const { copyingSheetId: H, copyingZone: G, cutting: _ } = r;
2643
+ const { copyingSheetId: H, copyingZone: q, cutting: _ } = r;
2644
2644
  if (g.id === H) {
2645
- const B = ge(G);
2646
- qe(M, g, u, v, C, D, B, _ ? or : rr, 2.5, _ ? [4, 4] : [6, 4]);
2645
+ const B = he(q);
2646
+ qe(D, g, u, v, C, I, B, _ ? or : rr, 2.5, _ ? [4, 4] : [6, 4]);
2647
2647
  }
2648
2648
  Object.entries(e).forEach(([B, z]) => {
2649
- const U = Ie[z % Ie.length];
2649
+ const Z = Ie[z % Ie.length];
2650
2650
  try {
2651
- const K = g.rangeToArea(B);
2652
- qe(M, g, u, v, C, D, K, U, 2, [5, 5]);
2651
+ const J = g.rangeToArea(B);
2652
+ qe(D, g, u, v, C, I, J, Z, 2, [5, 5]);
2653
2653
  } catch {
2654
2654
  }
2655
2655
  }), l.forEach((B, z) => {
2656
- const { y: U, x: K } = Rt(B), W = Fe(g, { y: U, x: K }), Q = W.left - v, j = W.top - u;
2657
- if (Q + W.width < 0 || Q > C || j + W.height < 0 || j > D)
2656
+ const { y: Z, x: J } = Rt(B), j = Fe(g, { y: Z, x: J }), U = j.left - v, G = j.top - u;
2657
+ if (U + j.width < 0 || U > C || G + j.height < 0 || G > I)
2658
2658
  return;
2659
- const L = z === f;
2659
+ const L = z === h;
2660
2660
  yt(
2661
- M,
2662
- Q,
2663
- j,
2664
- W.width,
2665
- W.height,
2661
+ D,
2662
+ U,
2663
+ G,
2664
+ j.width,
2665
+ j.height,
2666
2666
  L ? lr : "transparent",
2667
2667
  L ? 2 : 0,
2668
2668
  [],
2669
2669
  ir
2670
2670
  );
2671
- }), M.restore();
2672
- const re = g.numCols, ce = g.numRows;
2673
- for (let B = 1; B <= re; B++) {
2674
- let z = null, U = null;
2675
- if (Ae({ start: i.startX, end: i.endX }, B) && (z = "rgba(80, 180, 255, 1)", U = c ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.x === B && (z = lt, U = c ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2671
+ }), D.restore();
2672
+ const oe = g.numCols, ce = g.numRows;
2673
+ for (let B = 1; B <= oe; B++) {
2674
+ let z = null, Z = null;
2675
+ if (Ae({ start: i.startX, end: i.endX }, B) && (z = "rgba(80, 180, 255, 1)", Z = c ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.x === B && (z = lt, Z = c ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2676
2676
  continue;
2677
- const K = Fe(g, { y: 1, x: B }), W = K.left - v;
2678
- if (W + K.width < N || W > C)
2677
+ const J = Fe(g, { y: 1, x: B }), j = J.left - v;
2678
+ if (j + J.width < N || j > C)
2679
2679
  continue;
2680
- const Q = Math.max(W, N), j = Math.min(W + K.width, C) - Q;
2681
- j > 0 && (U && Jt(M, Q, 0, j, I, U), M.strokeStyle = z, M.lineWidth = 2, M.beginPath(), M.moveTo(Q, I + 1), M.lineTo(Q + j, I + 1), M.stroke());
2680
+ const U = Math.max(j, N), G = Math.min(j + J.width, C) - U;
2681
+ G > 0 && (Z && Jt(D, U, 0, G, A, Z), D.strokeStyle = z, D.lineWidth = 2, D.beginPath(), D.moveTo(U, A + 1), D.lineTo(U + G, A + 1), D.stroke());
2682
2682
  }
2683
2683
  for (let B = 1; B <= ce; B++) {
2684
2684
  if (g.isRowFiltered(B))
2685
2685
  continue;
2686
- let z = null, U = null;
2687
- if (Ae({ start: i.startY, end: i.endY }, B) && (z = "rgba(80, 180, 255, 1)", U = d ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.y === B && (z = lt, U = d ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2686
+ let z = null, Z = null;
2687
+ if (Ae({ start: i.startY, end: i.endY }, B) && (z = "rgba(80, 180, 255, 1)", Z = d ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.y === B && (z = lt, Z = d ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2688
2688
  continue;
2689
- const K = Fe(g, { y: B, x: 1 }), W = K.top - u;
2690
- if (W + K.height < I || W > D)
2689
+ const J = Fe(g, { y: B, x: 1 }), j = J.top - u;
2690
+ if (j + J.height < A || j > I)
2691
2691
  continue;
2692
- const Q = Math.max(W, I), j = Math.min(W + K.height, D) - Q;
2693
- j > 0 && (U && Jt(M, 0, Q, N, j, U), M.strokeStyle = z, M.lineWidth = 2, M.beginPath(), M.moveTo(N + 1, Q), M.lineTo(N + 1, Q + j), M.stroke());
2692
+ const U = Math.max(j, A), G = Math.min(j + J.height, I) - U;
2693
+ G > 0 && (Z && Jt(D, 0, U, N, G, Z), D.strokeStyle = z, D.lineWidth = 2, D.beginPath(), D.moveTo(N + 1, U), D.lineTo(N + 1, U + G), D.stroke());
2694
2694
  }
2695
2695
  }, [
2696
2696
  g,
2697
+ // The Sheet instance is mutated in place, so its identity stays stable across structural
2698
+ // changes (insert/remove rows & cols, resize, sort, filter). Depend on its monotonic version
2699
+ // so the overlay redraws when the grid layout shifts; otherwise the old box stays misaligned.
2700
+ g == null ? void 0 : g.currentVersion,
2697
2701
  s,
2698
2702
  o,
2699
2703
  i,
2700
2704
  l,
2701
- f,
2702
2705
  h,
2706
+ f,
2703
2707
  c,
2704
2708
  d,
2705
2709
  b,
2706
2710
  y,
2707
2711
  e
2708
2712
  ]), F = k(() => {
2709
- cancelAnimationFrame(p.current), p.current = requestAnimationFrame(x);
2710
- }, [x]), T = k(() => {
2711
- x();
2712
- }, [x]);
2713
- return Z(() => (F(), () => cancelAnimationFrame(p.current)), [F]), Z(() => {
2713
+ cancelAnimationFrame(p.current), p.current = requestAnimationFrame(E);
2714
+ }, [E]), T = k(() => {
2715
+ E();
2716
+ }, [E]);
2717
+ return W(() => (F(), () => cancelAnimationFrame(p.current)), [F]), W(() => {
2714
2718
  const S = s.current;
2715
2719
  if (!S)
2716
2720
  return;
2717
2721
  S.addEventListener("scroll", T);
2718
- const M = new ResizeObserver(() => x());
2719
- return M.observe(S), () => {
2720
- S.removeEventListener("scroll", T), M.disconnect();
2722
+ const D = new ResizeObserver(() => E());
2723
+ return D.observe(S), () => {
2724
+ S.removeEventListener("scroll", T), D.disconnect();
2721
2725
  };
2722
- }, [s, T, x]), /* @__PURE__ */ a(
2726
+ }, [s, T, E]), /* @__PURE__ */ a(
2723
2727
  "div",
2724
2728
  {
2725
2729
  style: {
@@ -2746,24 +2750,24 @@ const er = nt(({ x: e }) => {
2746
2750
  }
2747
2751
  );
2748
2752
  }, ur = () => {
2749
- var $, P, C, D, r, u, v, N, I;
2750
- const [e, n] = J({}), { store: t, dispatch: s } = le(ae), {
2753
+ var $, P, C, I, r, u, v, N, A;
2754
+ const [e, n] = te({}), { store: t, dispatch: s } = le(ae), {
2751
2755
  sheetReactive: o,
2752
2756
  choosing: i,
2753
2757
  editingAddress: l,
2754
- tabularRef: f,
2755
- mainRef: h,
2758
+ tabularRef: h,
2759
+ mainRef: f,
2756
2760
  sheetWidth: c,
2757
2761
  sheetHeight: d,
2758
2762
  inputting: b,
2759
2763
  leftHeaderSelecting: y,
2760
2764
  topHeaderSelecting: g,
2761
2765
  contextMenu: m
2762
- } = t, p = o.current, [A, x] = J(null), F = k((R) => {
2766
+ } = t, p = o.current, [M, E] = te(null), F = k((R) => {
2763
2767
  R.preventDefault(), R.stopPropagation();
2764
2768
  }, []), T = k(
2765
2769
  (R) => {
2766
- p && x(Bt(p, R.currentTarget));
2770
+ p && E(Bt(p, R.currentTarget));
2767
2771
  },
2768
2772
  [o]
2769
2773
  ), S = k(() => {
@@ -2778,45 +2782,47 @@ const er = nt(({ x: e }) => {
2778
2782
  );
2779
2783
  }));
2780
2784
  }, [o]);
2781
- Z(() => {
2785
+ W(() => {
2782
2786
  if (!p)
2783
2787
  return;
2784
2788
  if (!(l && b.startsWith("="))) {
2785
2789
  n({}), p.registry.paletteBySheetName = {};
2786
2790
  return;
2787
2791
  }
2788
- const H = {}, G = {}, _ = new Ge(b.substring(1));
2792
+ const H = {}, q = {}, _ = new Ge(b.substring(1));
2789
2793
  _.tokenize();
2790
- let re = 0;
2794
+ let oe = 0;
2791
2795
  for (const ce of _.tokens)
2792
2796
  if (ce.type === "REF" || ce.type === "RANGE") {
2793
2797
  const B = ls(ce.stringify()), z = B.indexOf("!");
2794
2798
  if (z !== -1) {
2795
- const U = B.substring(0, z), K = B.substring(z + 1), W = as(U), Q = K.toUpperCase();
2796
- G[W] == null && (G[W] = {}), G[W][Q] == null && (G[W][Q] = re++);
2799
+ const Z = B.substring(0, z), J = B.substring(z + 1), j = as(Z), U = J.toUpperCase();
2800
+ q[j] == null && (q[j] = {}), q[j][U] == null && (q[j][U] = oe++);
2797
2801
  } else {
2798
- const U = B.toUpperCase();
2799
- H[U] == null && (H[U] = re++);
2802
+ const Z = B.toUpperCase();
2803
+ H[Z] == null && (H[Z] = oe++);
2800
2804
  }
2801
2805
  }
2802
- n(H), p.registry.paletteBySheetName = G;
2803
- }, [t.inputting, t.editingAddress, o]), Z(() => {
2804
- p && (p.registry.choosingAddress = Ee(i), p.registry.choosingSheetId = p.id);
2805
- }, [i]), Z(() => {
2806
- p && x(Bt(p, f.current));
2806
+ n(H), p.registry.paletteBySheetName = q;
2807
+ }, [t.inputting, t.editingAddress, o]), W(() => {
2808
+ p && (p.registry.choosingAddress = xe(i), p.registry.choosingSheetId = p.id);
2809
+ }, [i]), W(() => {
2810
+ p && E(Bt(p, h.current));
2807
2811
  }, [
2808
- f.current,
2812
+ h.current,
2809
2813
  o,
2810
- ($ = h.current) == null ? void 0 : $.clientHeight,
2811
- (P = h.current) == null ? void 0 : P.clientWidth,
2814
+ ($ = f.current) == null ? void 0 : $.clientHeight,
2815
+ (P = f.current) == null ? void 0 : P.clientWidth,
2812
2816
  d,
2813
2817
  c
2814
- ]), Z(() => {
2815
- const R = f.current;
2818
+ ]), W(() => {
2819
+ const R = h.current;
2816
2820
  if (R)
2817
2821
  return cs(R);
2818
- }, [o]);
2819
- const M = {
2822
+ }, [o]), W(() => {
2823
+ !p || !p.eager || !p.registry.ready || p.resolveAll();
2824
+ }, [p, o]);
2825
+ const D = {
2820
2826
  ...e,
2821
2827
  ...p ? p.registry.paletteBySheetName[p.name] : {}
2822
2828
  };
@@ -2828,7 +2834,7 @@ const er = nt(({ x: e }) => {
2828
2834
  width: c === -1 ? void 0 : Math.min(c, p.totalWidth),
2829
2835
  height: d === -1 ? void 0 : Math.min(d, p.totalHeight)
2830
2836
  },
2831
- ref: f,
2837
+ ref: h,
2832
2838
  onMouseMove: F,
2833
2839
  onScroll: T,
2834
2840
  children: /* @__PURE__ */ Y(
@@ -2841,7 +2847,7 @@ const er = nt(({ x: e }) => {
2841
2847
  overflow: "clip"
2842
2848
  },
2843
2849
  children: [
2844
- /* @__PURE__ */ a(cr, { refs: M }),
2850
+ /* @__PURE__ */ a(cr, { refs: D }),
2845
2851
  /* @__PURE__ */ Y("table", { className: "gs-table", children: [
2846
2852
  /* @__PURE__ */ a("thead", { className: "gs-thead", style: { height: p.headerHeight }, children: /* @__PURE__ */ Y("tr", { className: "gs-row", children: [
2847
2853
  /* @__PURE__ */ a(
@@ -2870,11 +2876,11 @@ const er = nt(({ x: e }) => {
2870
2876
  },
2871
2877
  onMouseUp: (R) => {
2872
2878
  R.stopPropagation();
2873
- const H = R.currentTarget, G = Number(H.dataset.pressX ?? R.clientX), _ = Number(H.dataset.pressY ?? R.clientY);
2874
- if (Math.abs(R.clientX - G) > 4 || Math.abs(R.clientY - _) > 4)
2879
+ const H = R.currentTarget, q = Number(H.dataset.pressX ?? R.clientX), _ = Number(H.dataset.pressY ?? R.clientY);
2880
+ if (Math.abs(R.clientX - q) > 4 || Math.abs(R.clientY - _) > 4)
2875
2881
  return;
2876
2882
  const ce = H.getBoundingClientRect();
2877
- s(We({ y: ce.bottom, x: ce.left }));
2883
+ s(ze({ y: ce.bottom, x: ce.left }));
2878
2884
  },
2879
2885
  children: "⋮"
2880
2886
  }
@@ -2886,15 +2892,15 @@ const er = nt(({ x: e }) => {
2886
2892
  "th",
2887
2893
  {
2888
2894
  className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-left",
2889
- style: { width: ((C = A == null ? void 0 : A.adjuster) == null ? void 0 : C.left) ?? 1 }
2895
+ style: { width: ((C = M == null ? void 0 : M.adjuster) == null ? void 0 : C.left) ?? 1 }
2890
2896
  }
2891
2897
  ),
2892
- (r = (D = A == null ? void 0 : A.xs) == null ? void 0 : D.map) == null ? void 0 : r.call(D, (R) => /* @__PURE__ */ a(er, { x: R }, R)),
2898
+ (r = (I = M == null ? void 0 : M.xs) == null ? void 0 : I.map) == null ? void 0 : r.call(I, (R) => /* @__PURE__ */ a(er, { x: R }, R)),
2893
2899
  /* @__PURE__ */ a(
2894
2900
  "th",
2895
2901
  {
2896
2902
  className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-right",
2897
- style: { width: (u = A == null ? void 0 : A.adjuster) == null ? void 0 : u.right }
2903
+ style: { width: (u = M == null ? void 0 : M.adjuster) == null ? void 0 : u.right }
2898
2904
  }
2899
2905
  )
2900
2906
  ] }) }),
@@ -2903,19 +2909,19 @@ const er = nt(({ x: e }) => {
2903
2909
  "th",
2904
2910
  {
2905
2911
  className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-vertical",
2906
- style: { height: ((v = A == null ? void 0 : A.adjuster) == null ? void 0 : v.top) ?? 1 }
2912
+ style: { height: ((v = M == null ? void 0 : M.adjuster) == null ? void 0 : v.top) ?? 1 }
2907
2913
  }
2908
2914
  ),
2909
2915
  /* @__PURE__ */ a("td", { className: "gs-adjuster gs-adjuster-vertical" }),
2910
- (N = A == null ? void 0 : A.xs) == null ? void 0 : N.map((R) => /* @__PURE__ */ a("td", { className: "gs-adjuster gs-adjuster-vertical" }, R)),
2916
+ (N = M == null ? void 0 : M.xs) == null ? void 0 : N.map((R) => /* @__PURE__ */ a("td", { className: "gs-adjuster gs-adjuster-vertical" }, R)),
2911
2917
  /* @__PURE__ */ a("th", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-vertical" })
2912
2918
  ] }) }),
2913
- /* @__PURE__ */ a("tbody", { className: "gs-sheet-body-data", children: (I = A == null ? void 0 : A.ys) == null ? void 0 : I.map((R) => {
2919
+ /* @__PURE__ */ a("tbody", { className: "gs-sheet-body-data", children: (A = M == null ? void 0 : M.ys) == null ? void 0 : A.map((R) => {
2914
2920
  var H;
2915
2921
  return /* @__PURE__ */ Y("tr", { className: `gs-row ${R % 2 === 0 ? "gs-row-even" : "gs-row-odd"}`, children: [
2916
2922
  /* @__PURE__ */ a(tr, { y: R }),
2917
2923
  /* @__PURE__ */ a("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-left" }),
2918
- (H = A == null ? void 0 : A.xs) == null ? void 0 : H.map((G) => /* @__PURE__ */ a(Gs, { y: R, x: G }, G)),
2924
+ (H = M == null ? void 0 : M.xs) == null ? void 0 : H.map((q) => /* @__PURE__ */ a(Gs, { y: R, x: q }, q)),
2919
2925
  /* @__PURE__ */ a("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-right" })
2920
2926
  ] }, R);
2921
2927
  }) })
@@ -2926,8 +2932,8 @@ const er = nt(({ x: e }) => {
2926
2932
  }
2927
2933
  ) });
2928
2934
  }, dr = ({ ready: e }) => {
2929
- var L, oe;
2930
- const { store: n, dispatch: t } = le(ae), [s, o] = J(""), [i, l] = J(0), [f, h] = J(!1), {
2935
+ var L, Q;
2936
+ const { store: n, dispatch: t } = le(ae), [s, o] = te(""), [i, l] = te(0), [h, f] = te(!1), {
2931
2937
  choosing: c,
2932
2938
  selectingZone: d,
2933
2939
  editorRef: b,
@@ -2935,88 +2941,88 @@ const er = nt(({ x: e }) => {
2935
2941
  sheetReactive: g,
2936
2942
  inputting: m,
2937
2943
  editingAddress: p,
2938
- dragging: A
2939
- } = n, x = g.current, F = se(null), T = c.x === -1 ? "" : Ee(c), S = x == null ? void 0 : x.getCell(c, { resolution: "SYSTEM" }), M = (L = x == null ? void 0 : x.getSystem(c)) == null ? void 0 : L.spilledFrom, $ = M ? Rt(M) : void 0, P = $ != null ? Ee($) : void 0;
2940
- Z(() => {
2941
- var V;
2942
- if (!x)
2944
+ dragging: M
2945
+ } = n, E = g.current, F = re(null), T = c.x === -1 ? "" : xe(c), S = E == null ? void 0 : E.getCell(c, { resolution: "SYSTEM" }), D = (L = E == null ? void 0 : E.getSystem(c)) == null ? void 0 : L.spilledFrom, $ = D ? Rt(D) : void 0, P = $ != null ? xe($) : void 0;
2946
+ W(() => {
2947
+ var K;
2948
+ if (!E)
2943
2949
  return;
2944
- let w = ((V = x.getCell(c, { resolution: "SYSTEM" })) == null ? void 0 : V.value) ?? "";
2945
- w = x.getSerializedValue({ point: c, cell: { ...S, value: w }, resolution: "RAW" }), y.current.value = w, o(w);
2946
- }, [T, x]);
2950
+ let w = ((K = E.getCell(c, { resolution: "SYSTEM" })) == null ? void 0 : K.value) ?? "";
2951
+ w = E.getSerializedValue({ point: c, cell: { ...S, value: w }, resolution: "RAW" }), y.current.value = w, o(w);
2952
+ }, [T, E]);
2947
2953
  const C = k(
2948
2954
  (w) => {
2949
- s !== w && t(Ue({ value: w })), t(ue("")), O(b.current);
2955
+ s !== w && t(Ze({ value: w })), t(ue("")), O(b.current);
2950
2956
  },
2951
2957
  [s]
2952
2958
  );
2953
- Z(() => {
2954
- const w = new ResizeObserver((V) => {
2955
- V.forEach(z);
2959
+ W(() => {
2960
+ const w = new ResizeObserver((K) => {
2961
+ K.forEach(z);
2956
2962
  });
2957
2963
  return y.current && w.observe(y.current), () => {
2958
2964
  w.disconnect();
2959
2965
  };
2960
2966
  }, []);
2961
- const D = x == null ? void 0 : x.getPolicy(c), r = (D == null ? void 0 : D.getSelectOptions()) || [], {
2967
+ const I = E == null ? void 0 : E.getPolicy(c), r = (I == null ? void 0 : I.getSelectOptions()) || [], {
2962
2968
  filteredOptions: u,
2963
2969
  selected: v,
2964
2970
  replaceWithOption: N,
2965
- handleArrowUp: I,
2971
+ handleArrowUp: A,
2966
2972
  handleArrowDown: R,
2967
2973
  activeFunctionHelp: H,
2968
- activeArgIndex: G
2974
+ activeArgIndex: q
2969
2975
  } = Cn({
2970
2976
  inputting: m,
2971
2977
  selectionStart: i,
2972
2978
  optionsAll: r,
2973
- functions: x == null ? void 0 : x.registry.functions
2974
- }), _ = se(!1), re = y.current, ce = k((w) => {
2975
- t(ee(w.currentTarget.value)), l(w.currentTarget.selectionStart);
2979
+ functions: E == null ? void 0 : E.registry.functions
2980
+ }), _ = re(!1), oe = y.current, ce = k((w) => {
2981
+ t(ne(w.currentTarget.value)), l(w.currentTarget.selectionStart);
2976
2982
  }, []), B = k((w) => {
2977
2983
  l(w.currentTarget.selectionStart);
2978
2984
  }, []), z = k(() => {
2979
2985
  !F.current || !y.current || (F.current.style.height = `${y.current.clientHeight}px`, F.current.scrollLeft = y.current.scrollLeft, F.current.scrollTop = y.current.scrollTop);
2980
- }, []), U = k(
2986
+ }, []), Z = k(
2981
2987
  (w) => {
2982
- !re || !x || (h(!0), t(ue(T)), x.registry.lastFocused = w.currentTarget);
2988
+ !oe || !E || (f(!0), t(ue(T)), E.registry.lastFocused = w.currentTarget);
2983
2989
  },
2984
- [re, T, x]
2990
+ [oe, T, E]
2985
2991
  );
2986
2992
  k(
2987
2993
  (w) => {
2988
- if (h(!1), w.currentTarget.value.startsWith("="))
2994
+ if (f(!1), w.currentTarget.value.startsWith("="))
2989
2995
  return !0;
2990
2996
  p && C(w.currentTarget.value);
2991
2997
  },
2992
2998
  [p, C]
2993
2999
  );
2994
- const K = k(
3000
+ const J = k(
2995
3001
  (w) => {
2996
3002
  if (w.nativeEvent.isComposing || _.current)
2997
3003
  return;
2998
- if (w.ctrlKey || !x)
3004
+ if (w.ctrlKey || !E)
2999
3005
  return !0;
3000
- const V = w.currentTarget;
3006
+ const K = w.currentTarget;
3001
3007
  if (tn(w, m))
3002
- return t(ee(V.value)), !1;
3008
+ return t(ne(K.value)), !1;
3003
3009
  switch (w.key) {
3004
3010
  case "Tab":
3005
3011
  if (w.preventDefault(), u.length) {
3006
- const te = u[v];
3007
- if (te == null ? void 0 : te.isFunction) {
3008
- const { value: xe, selectionStart: _e } = N(te);
3009
- return t(ee(xe)), setTimeout(() => {
3012
+ const ee = u[v];
3013
+ if (ee == null ? void 0 : ee.isFunction) {
3014
+ const { value: Ee, selectionStart: _e } = N(ee);
3015
+ return t(ne(Ee)), setTimeout(() => {
3010
3016
  y.current && (O(y.current), y.current.setSelectionRange(_e, _e));
3011
3017
  }, 0), !1;
3012
3018
  } else {
3013
- const xe = x.update({ diff: { [T]: { value: te.value } }, partial: !0 });
3014
- t(ze(xe.clone())), t(ue("")), t(ee(""));
3019
+ const Ee = E.update({ diff: { [T]: { value: ee.value } }, partial: !0 });
3020
+ t(Ue(Ee.clone())), t(ue("")), t(ne(""));
3015
3021
  }
3016
3022
  }
3017
3023
  break;
3018
3024
  case "ArrowUp":
3019
- if (I(w))
3025
+ if (A(w))
3020
3026
  return !0;
3021
3027
  break;
3022
3028
  case "ArrowDown":
@@ -3025,22 +3031,22 @@ const er = nt(({ x: e }) => {
3025
3031
  break;
3026
3032
  case "Enter": {
3027
3033
  if (u.length) {
3028
- const te = u[v];
3029
- if (te != null && te.isFunction) {
3030
- const { value: ye, selectionStart: xe } = N(te);
3031
- return t(ee(ye)), setTimeout(() => {
3032
- y.current && (O(y.current), y.current.setSelectionRange(xe, xe));
3034
+ const ee = u[v];
3035
+ if (ee != null && ee.isFunction) {
3036
+ const { value: ye, selectionStart: Ee } = N(ee);
3037
+ return t(ne(ye)), setTimeout(() => {
3038
+ y.current && (O(y.current), y.current.setSelectionRange(Ee, Ee));
3033
3039
  }, 0), w.preventDefault(), !1;
3034
3040
  }
3035
3041
  }
3036
3042
  if (w.altKey)
3037
- nn(V, `
3043
+ nn(K, `
3038
3044
  `);
3039
3045
  else
3040
- return C(V.value), t(ee("")), t(
3046
+ return C(K.value), t(ne("")), t(
3041
3047
  dt({
3042
- numRows: x.numRows,
3043
- numCols: x.numCols,
3048
+ numRows: E.numRows,
3049
+ numCols: E.numCols,
3044
3050
  deltaY: 1,
3045
3051
  deltaX: 0
3046
3052
  })
@@ -3048,7 +3054,7 @@ const er = nt(({ x: e }) => {
3048
3054
  break;
3049
3055
  }
3050
3056
  case "Escape": {
3051
- V.value = s, t(ee(s)), t(ue("")), w.preventDefault(), O(b.current);
3057
+ K.value = s, t(ne(s)), t(ue("")), w.preventDefault(), O(b.current);
3052
3058
  break;
3053
3059
  }
3054
3060
  case "a":
@@ -3063,11 +3069,11 @@ const er = nt(({ x: e }) => {
3063
3069
  return !0;
3064
3070
  break;
3065
3071
  }
3066
- const fe = x.getCell(c, { resolution: "SYSTEM" });
3067
- return X.hasOperation(fe == null ? void 0 : fe.prevention, X.Write) && (console.warn("This cell is protected from writing."), w.preventDefault()), z(), !1;
3072
+ const de = E.getCell(c, { resolution: "SYSTEM" });
3073
+ return X.hasOperation(de == null ? void 0 : de.prevention, X.Write) && (console.warn("This cell is protected from writing."), w.preventDefault()), z(), !1;
3068
3074
  },
3069
3075
  [
3070
- x,
3076
+ E,
3071
3077
  c,
3072
3078
  T,
3073
3079
  s,
@@ -3076,56 +3082,56 @@ const er = nt(({ x: e }) => {
3076
3082
  u,
3077
3083
  v,
3078
3084
  N,
3079
- I,
3085
+ A,
3080
3086
  R,
3081
3087
  m
3082
3088
  ]
3083
- ), W = k(
3084
- (w, V) => {
3089
+ ), j = k(
3090
+ (w, K) => {
3085
3091
  w.preventDefault(), w.stopPropagation();
3086
- const fe = u[V];
3087
- if (fe.isFunction) {
3088
- const { value: te, selectionStart: ye } = N(fe);
3089
- C(te), t(ee(te)), setTimeout(() => {
3092
+ const de = u[K];
3093
+ if (de.isFunction) {
3094
+ const { value: ee, selectionStart: ye } = N(de);
3095
+ C(ee), t(ne(ee)), setTimeout(() => {
3090
3096
  y.current && (O(y.current), y.current.setSelectionRange(ye, ye));
3091
3097
  }, 0);
3092
3098
  }
3093
3099
  },
3094
3100
  [u, N, C, t]
3095
- ), Q = e ? {} : { visibility: "hidden" };
3096
- if (!x)
3097
- return /* @__PURE__ */ Y("label", { className: "gs-formula-bar gs-hidden", style: Q, children: [
3101
+ ), U = e ? {} : { visibility: "hidden" };
3102
+ if (!E)
3103
+ return /* @__PURE__ */ Y("label", { className: "gs-formula-bar gs-hidden", style: U, children: [
3098
3104
  /* @__PURE__ */ a("div", { className: "gs-selecting-address" }),
3099
3105
  /* @__PURE__ */ a("div", { className: "gs-fx", children: "Fx" }),
3100
3106
  /* @__PURE__ */ a("div", { className: "gs-formula-bar-editor-inner", children: /* @__PURE__ */ a("textarea", {}) })
3101
3107
  ] });
3102
- const j = () => {
3103
- var te;
3104
- if (!f || typeof document > "u" || y.current !== document.activeElement)
3108
+ const G = () => {
3109
+ var ee;
3110
+ if (!h || typeof document > "u" || y.current !== document.activeElement)
3105
3111
  return null;
3106
- const w = (te = y.current) == null ? void 0 : te.getBoundingClientRect();
3112
+ const w = (ee = y.current) == null ? void 0 : ee.getBoundingClientRect();
3107
3113
  if (!w)
3108
3114
  return null;
3109
- const V = w.bottom, fe = w.left;
3115
+ const K = w.bottom, de = w.left;
3110
3116
  return St(
3111
3117
  /* @__PURE__ */ Y(Re, { children: [
3112
3118
  H && u.length === 0 && (!d || d.endY === -1 && d.endX === -1) && /* @__PURE__ */ a(
3113
3119
  Nt,
3114
3120
  {
3115
3121
  activeFunctionGuide: H,
3116
- activeArgIndex: G,
3117
- top: V,
3118
- left: fe
3122
+ activeArgIndex: q,
3123
+ top: K,
3124
+ left: de
3119
3125
  }
3120
3126
  ),
3121
3127
  u.length > 0 && c.x !== -1 && /* @__PURE__ */ a(
3122
3128
  Rn,
3123
3129
  {
3124
3130
  filteredOptions: u,
3125
- top: V,
3126
- left: fe,
3131
+ top: K,
3132
+ left: de,
3127
3133
  selected: v,
3128
- onOptionMouseDown: W
3134
+ onOptionMouseDown: j
3129
3135
  }
3130
3136
  )
3131
3137
  ] }),
@@ -3138,7 +3144,7 @@ const er = nt(({ x: e }) => {
3138
3144
  className: "gs-formula-bar",
3139
3145
  "data-sheet-id": n.sheetId,
3140
3146
  "data-spill": P != null ? "true" : void 0,
3141
- style: Q,
3147
+ style: U,
3142
3148
  children: [
3143
3149
  /* @__PURE__ */ a(Te, { style: { position: "absolute", left: 0, top: 0, zIndex: 2 }, vertical: -1 }),
3144
3150
  /* @__PURE__ */ a("div", { className: "gs-selecting-address", children: P ?? T }),
@@ -3150,10 +3156,10 @@ const er = nt(({ x: e }) => {
3150
3156
  className: "gs-editor-hl",
3151
3157
  ref: F,
3152
3158
  style: {
3153
- height: (oe = y.current) == null ? void 0 : oe.clientHeight,
3159
+ height: (Q = y.current) == null ? void 0 : Q.clientHeight,
3154
3160
  width: "100%"
3155
3161
  },
3156
- children: (S == null ? void 0 : S.formulaEnabled) ?? !0 ? En(m) : m
3162
+ children: (S == null ? void 0 : S.formulaEnabled) ?? !0 ? xn(m) : m
3157
3163
  }
3158
3164
  ),
3159
3165
  /* @__PURE__ */ a(
@@ -3168,18 +3174,18 @@ const er = nt(({ x: e }) => {
3168
3174
  value: m,
3169
3175
  readOnly: P != null,
3170
3176
  onInput: ce,
3171
- onFocus: U,
3177
+ onFocus: Z,
3172
3178
  onSelect: B,
3173
3179
  onPaste: (w) => {
3174
3180
  w.stopPropagation();
3175
3181
  },
3176
- onKeyDown: K,
3182
+ onKeyDown: J,
3177
3183
  onKeyUp: z,
3178
3184
  onCompositionStart: () => {
3179
3185
  _.current = !0;
3180
3186
  },
3181
3187
  onCompositionEnd: (w) => {
3182
- _.current = !1, t(ee(w.currentTarget.value));
3188
+ _.current = !1, t(ne(w.currentTarget.value));
3183
3189
  },
3184
3190
  onScroll: z,
3185
3191
  onMouseEnter: (w) => {
@@ -3190,7 +3196,7 @@ const er = nt(({ x: e }) => {
3190
3196
  }
3191
3197
  }
3192
3198
  ),
3193
- j()
3199
+ G()
3194
3200
  ] })
3195
3201
  ]
3196
3202
  }
@@ -3215,35 +3221,35 @@ const er = nt(({ x: e }) => {
3215
3221
  /* @__PURE__ */ a("path", { stroke: "none", d: "M0 0h24v24H0z", fill: n }),
3216
3222
  /* @__PURE__ */ a("path", { d: "M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0", fill: n }),
3217
3223
  /* @__PURE__ */ a("path", { d: "M21 21l-6 -6", fill: n })
3218
- ] }), fr = ({ style: e, color: n = "none", size: t = 24 }) => /* @__PURE__ */ Y(Ln, { style: e, size: t, children: [
3224
+ ] }), hr = ({ style: e, color: n = "none", size: t = 24 }) => /* @__PURE__ */ Y(Ln, { style: e, size: t, children: [
3219
3225
  /* @__PURE__ */ a("path", { stroke: "none", d: "M0 0h24v24H0z", fill: n }),
3220
3226
  /* @__PURE__ */ a("path", { d: "M18 6l-12 12", fill: n }),
3221
3227
  /* @__PURE__ */ a("path", { d: "M6 6l12 12", fill: n })
3222
- ] }), hr = () => {
3228
+ ] }), fr = () => {
3223
3229
  const { store: e, dispatch: n } = le(ae), {
3224
3230
  rootRef: t,
3225
3231
  editorRef: s,
3226
3232
  searchInputRef: o,
3227
3233
  tabularRef: i,
3228
3234
  searchQuery: l,
3229
- searchCaseSensitive: f,
3230
- searchRegex: h,
3235
+ searchCaseSensitive: h,
3236
+ searchRegex: f,
3231
3237
  searchRange: c,
3232
3238
  selectingZone: d,
3233
3239
  matchingCellIndex: b,
3234
3240
  matchingCells: y,
3235
3241
  sheetReactive: g
3236
3242
  } = e, m = g.current, p = y[b];
3237
- Z(() => {
3243
+ W(() => {
3238
3244
  if (!p || !m)
3239
3245
  return;
3240
3246
  const u = Rt(p);
3241
3247
  typeof u > "u" || us(m, i.current, u);
3242
- }, [l, b, f, h, m, i]);
3243
- const A = k((u) => {
3248
+ }, [l, b, h, f, m, i]);
3249
+ const M = k((u) => {
3244
3250
  const v = u.currentTarget.previousSibling;
3245
3251
  (v == null ? void 0 : v.nodeName) === "INPUT" && O(v);
3246
- }, []), x = k(() => {
3252
+ }, []), E = k(() => {
3247
3253
  n(_t(1));
3248
3254
  }, []), F = k((u) => {
3249
3255
  n(Pe(u.currentTarget.value));
@@ -3257,48 +3263,48 @@ const er = nt(({ x: e }) => {
3257
3263
  },
3258
3264
  [s]
3259
3265
  ), S = k(() => {
3260
- n(Cs(!f));
3261
- }, [f]), M = k(() => {
3262
- n(Ss(!h));
3263
- }, [h]), $ = $e(() => {
3266
+ n(Cs(!h));
3267
+ }, [h]), D = k(() => {
3268
+ n(Ss(!f));
3269
+ }, [f]), $ = $e(() => {
3264
3270
  if (!d || ds(d))
3265
3271
  return !1;
3266
- const { startY: u, startX: v, endY: N, endX: I } = d;
3267
- return !(u === N && v === I);
3272
+ const { startY: u, startX: v, endY: N, endX: A } = d;
3273
+ return !(u === N && v === A);
3268
3274
  }, [d]), P = $e(() => {
3269
3275
  if (!d || !$)
3270
3276
  return "";
3271
- const { startY: u, startX: v, endY: N, endX: I } = d, R = `${pe(Math.min(v, I))}${be(Math.min(u, N))}`, H = `${pe(Math.max(v, I))}${be(Math.max(u, N))}`;
3277
+ const { startY: u, startX: v, endY: N, endX: A } = d, R = `${pe(Math.min(v, A))}${be(Math.min(u, N))}`, H = `${pe(Math.max(v, A))}${be(Math.max(u, N))}`;
3272
3278
  return `${R}:${H}`;
3273
3279
  }, [d, $]), C = k(() => {
3274
3280
  if (c)
3275
3281
  n(jt(void 0));
3276
3282
  else if (d && $) {
3277
- const { startY: u, startX: v, endY: N, endX: I } = d;
3283
+ const { startY: u, startX: v, endY: N, endX: A } = d;
3278
3284
  n(
3279
3285
  jt({
3280
3286
  startY: Math.min(u, N),
3281
- startX: Math.min(v, I),
3287
+ startX: Math.min(v, A),
3282
3288
  endY: Math.max(u, N),
3283
- endX: Math.max(v, I)
3289
+ endX: Math.max(v, A)
3284
3290
  })
3285
3291
  );
3286
3292
  }
3287
- }, [c, d, $]), D = $e(() => {
3293
+ }, [c, d, $]), I = $e(() => {
3288
3294
  if (!c)
3289
3295
  return "";
3290
- const { startY: u, startX: v, endY: N, endX: I } = c, R = `${pe(v)}${be(u)}`, H = `${pe(I)}${be(N)}`;
3296
+ const { startY: u, startX: v, endY: N, endX: A } = c, R = `${pe(v)}${be(u)}`, H = `${pe(A)}${be(N)}`;
3291
3297
  return `${R}:${H}`;
3292
3298
  }, [c]), r = k(() => {
3293
3299
  n(Pe(void 0)), O(s.current);
3294
3300
  }, [s]);
3295
3301
  return typeof l > "u" || t.current === null ? null : /* @__PURE__ */ Y("label", { className: `gs-search-bar ${y.length > 0 ? "gs-search-found" : ""}`, children: [
3296
- /* @__PURE__ */ Y("div", { className: "gs-search-progress", onClick: A, children: [
3302
+ /* @__PURE__ */ Y("div", { className: "gs-search-progress", onClick: M, children: [
3297
3303
  y.length === 0 ? 0 : b + 1,
3298
3304
  " / ",
3299
3305
  y.length
3300
3306
  ] }),
3301
- /* @__PURE__ */ a("div", { className: "gs-search-bar-icon", onClick: x, children: /* @__PURE__ */ a(gr, { style: { verticalAlign: "middle", marginLeft: "5px" } }) }),
3307
+ /* @__PURE__ */ a("div", { className: "gs-search-bar-icon", onClick: E, children: /* @__PURE__ */ a(gr, { style: { verticalAlign: "middle", marginLeft: "5px" } }) }),
3302
3308
  /* @__PURE__ */ Y("div", { className: "gs-search-input-wrapper", children: [
3303
3309
  /* @__PURE__ */ Y("div", { className: "gs-search-input-ghost", children: [
3304
3310
  /* @__PURE__ */ a("span", { className: "gs-search-ghost-text", children: l }),
@@ -3322,10 +3328,10 @@ const er = nt(({ x: e }) => {
3322
3328
  {
3323
3329
  className: "gs-search-button-on",
3324
3330
  onClick: C,
3325
- title: `Search range: ${D}`,
3331
+ title: `Search range: ${I}`,
3326
3332
  children: [
3327
3333
  "in ",
3328
- D
3334
+ I
3329
3335
  ]
3330
3336
  }
3331
3337
  ) }),
@@ -3336,7 +3342,7 @@ const er = nt(({ x: e }) => {
3336
3342
  /* @__PURE__ */ a("div", { className: "gs-search-button gs-search-casesensitive", children: /* @__PURE__ */ a(
3337
3343
  "span",
3338
3344
  {
3339
- className: `${f ? "gs-search-button-on" : ""}`,
3345
+ className: `${h ? "gs-search-button-on" : ""}`,
3340
3346
  onClick: S,
3341
3347
  title: "Case sensitive",
3342
3348
  children: "Aa"
@@ -3345,16 +3351,16 @@ const er = nt(({ x: e }) => {
3345
3351
  /* @__PURE__ */ a("div", { className: "gs-search-button gs-search-regex", children: /* @__PURE__ */ a(
3346
3352
  "span",
3347
3353
  {
3348
- className: `${h ? "gs-search-button-on" : ""}`,
3349
- onClick: M,
3354
+ className: `${f ? "gs-search-button-on" : ""}`,
3355
+ onClick: D,
3350
3356
  title: "Regular expression",
3351
3357
  children: ".*"
3352
3358
  }
3353
3359
  ) })
3354
3360
  ] }),
3355
- /* @__PURE__ */ a("a", { className: "gs-search-close", onClick: r, children: /* @__PURE__ */ a(fr, { style: { verticalAlign: "middle" } }) })
3361
+ /* @__PURE__ */ a("a", { className: "gs-search-close", onClick: r, children: /* @__PURE__ */ a(hr, { style: { verticalAlign: "middle" } }) })
3356
3362
  ] });
3357
- }, kr = () => an(), mr = () => se(null), Tr = () => an(), pr = () => se(null);
3363
+ }, kr = () => an(), mr = () => re(null), Tr = () => an(), pr = () => re(null);
3358
3364
  function Ar({
3359
3365
  initialCells: e,
3360
3366
  sheetName: n = "",
@@ -3363,27 +3369,28 @@ function Ar({
3363
3369
  options: o = {},
3364
3370
  className: i,
3365
3371
  style: l,
3366
- book: f
3372
+ book: h
3367
3373
  }) {
3368
- var B, z, U;
3369
- const { sheetResize: h, showFormulaBar: c = !0, mode: d = "light" } = o, b = se(null), y = se(null), g = se(null), m = se(null), p = se(null), A = se(null), x = se(null), F = mr(), T = t ?? F, S = pr(), M = s ?? S, $ = Ns({}), P = f ?? $, { registry: C } = P, [D] = J(() => n ? (C._componentSheetIds.has(n) || C._componentSheetIds.set(n, ++C.sheetHead), C._componentSheetIds.get(n)) : ++C.sheetHead), r = se(null), [u] = J(() => {
3370
- var w;
3371
- n || (n = `Sheet${D}`, console.debug("GridSheet: sheetName is not provided, using default name:", n));
3372
- const { limits: K, contextMenu: W, rowMenu: Q, colMenu: j } = o, L = new gs({
3373
- limits: K,
3374
+ var Z, J, j;
3375
+ const { sheetResize: f, showFormulaBar: c = !0, mode: d = "light" } = o, b = re(null), y = re(null), g = re(null), m = re(null), p = re(null), M = re(null), E = re(null), F = mr(), T = t ?? F, S = pr(), D = s ?? S, $ = Ns({}), P = h ?? $, { registry: C } = P, [I] = te(() => n ? (C._componentSheetIds.has(n) || C._componentSheetIds.set(n, ++C.sheetHead), C._componentSheetIds.get(n)) : ++C.sheetHead), r = re(null), [u] = te(() => {
3376
+ var ee;
3377
+ n || (n = `Sheet${I}`, console.debug("GridSheet: sheetName is not provided, using default name:", n));
3378
+ const { limits: U, contextMenu: G, rowMenu: L, colMenu: Q, eager: w } = o, K = new gs({
3379
+ limits: U,
3374
3380
  name: n,
3375
- registry: C
3381
+ registry: C,
3382
+ eager: w
3376
3383
  });
3377
- return L.id = D, C.sheetIdsByName[n] = D, L.initialize(e), (w = C.onInit) == null || w.call(C, { sheet: L }), L.setTotalSize(), r.current = L, {
3378
- sheetId: D,
3384
+ return K.id = I, C.sheetIdsByName[n] = I, K.initialize(e), (ee = C.onInit) == null || ee.call(C, { sheet: K }), K.setTotalSize(), r.current = K, {
3385
+ sheetId: I,
3379
3386
  sheetReactive: r,
3380
3387
  rootRef: b,
3381
3388
  flashRef: y,
3382
3389
  mainRef: g,
3383
3390
  searchInputRef: m,
3384
3391
  editorRef: p,
3385
- largeEditorRef: A,
3386
- tabularRef: x,
3392
+ largeEditorRef: M,
3393
+ tabularRef: E,
3387
3394
  choosing: { y: 1, x: 1 },
3388
3395
  inputting: "",
3389
3396
  selectingZone: { startY: 1, startX: 1, endY: -1, endX: -1 },
@@ -3402,9 +3409,9 @@ function Ar({
3402
3409
  searchRegex: !1,
3403
3410
  editingOnEnter: !0,
3404
3411
  contextMenuPosition: { y: -1, x: -1 },
3405
- contextMenu: W ?? Ls,
3406
- rowMenu: Q ?? Bs,
3407
- colMenu: j ?? Ks,
3412
+ contextMenu: G ?? Ls,
3413
+ rowMenu: L ?? Bs,
3414
+ colMenu: Q ?? Ks,
3408
3415
  resizingPositionY: [-1, -1, -1],
3409
3416
  resizingPositionX: [-1, -1, -1],
3410
3417
  columnMenuState: null,
@@ -3413,86 +3420,99 @@ function Ar({
3413
3420
  mode: "light"
3414
3421
  };
3415
3422
  }), [v, N] = vs(
3416
- Es,
3423
+ xs,
3417
3424
  u,
3418
3425
  () => u
3419
3426
  );
3420
- Z(() => {
3421
- fs();
3427
+ W(() => {
3428
+ hs();
3422
3429
  }, []);
3423
- const [I, R] = J((o == null ? void 0 : o.sheetHeight) || yr(e)), [H, G] = J((o == null ? void 0 : o.sheetWidth) || vr(e));
3424
- Z(() => {
3425
- const K = g.current;
3426
- if (!K)
3430
+ const A = typeof o.sheetWidth == "string", R = typeof o.sheetHeight == "string", [H, q] = te(
3431
+ typeof (o == null ? void 0 : o.sheetHeight) == "number" ? o.sheetHeight : yr(e)
3432
+ ), [_, oe] = te(
3433
+ typeof (o == null ? void 0 : o.sheetWidth) == "number" ? o.sheetWidth : vr(e)
3434
+ );
3435
+ W(() => {
3436
+ const U = g.current;
3437
+ if (!U)
3427
3438
  return;
3428
- let W = !0;
3429
- const Q = new ResizeObserver(() => {
3430
- if (W) {
3431
- W = !1;
3439
+ let G = !0;
3440
+ const L = new ResizeObserver(() => {
3441
+ if (G && (G = !1, !A && !R))
3432
3442
  return;
3433
- }
3434
- const j = b.current;
3435
- R(j ? Math.min(K.clientHeight, j.clientHeight) : K.clientHeight), G(j ? Math.min(K.clientWidth, j.clientWidth) : K.clientWidth);
3443
+ const Q = b.current;
3444
+ q(Q ? Math.min(U.clientHeight, Q.clientHeight) : U.clientHeight), oe(Q ? Math.min(U.clientWidth, Q.clientWidth) : U.clientWidth);
3436
3445
  });
3437
- return Q.observe(K), () => Q.disconnect();
3438
- }, []), Z(() => {
3439
- o.sheetHeight && R(o.sheetHeight);
3440
- }, [o.sheetHeight]), Z(() => {
3441
- o.sheetWidth && G(o.sheetWidth);
3446
+ return L.observe(U), () => L.disconnect();
3447
+ }, [A, R]), W(() => {
3448
+ typeof o.sheetHeight == "number" && q(o.sheetHeight);
3449
+ }, [o.sheetHeight]), W(() => {
3450
+ typeof o.sheetWidth == "number" && oe(o.sheetWidth);
3442
3451
  }, [o.sheetWidth]);
3443
- const [_, re] = J(!1);
3444
- Z(() => {
3445
- _ && re(!1);
3452
+ const [ce, B] = te(!1);
3453
+ W(() => {
3454
+ ce && B(!1);
3446
3455
  });
3447
- const ce = k(
3448
- (K) => {
3449
- if (!xs(K.type)) {
3450
- N(K);
3456
+ const z = k(
3457
+ (U) => {
3458
+ if (!Es(U.type)) {
3459
+ N(U);
3451
3460
  return;
3452
3461
  }
3453
- re(!0), requestAnimationFrame(() => {
3454
- N(K);
3462
+ B(!0), requestAnimationFrame(() => {
3463
+ N(U);
3455
3464
  });
3456
3465
  },
3457
3466
  [N]
3458
3467
  );
3459
- return /* @__PURE__ */ a(ae.Provider, { value: { store: v, dispatch: ce }, children: /* @__PURE__ */ Y(
3468
+ return /* @__PURE__ */ a(ae.Provider, { value: { store: v, dispatch: z }, children: /* @__PURE__ */ Y(
3460
3469
  "div",
3461
3470
  {
3462
3471
  className: `gs-root1 ${C.ready ? "gs-initialized" : ""}`,
3463
3472
  ref: b,
3464
3473
  "data-sheet-name": n,
3465
3474
  "data-mode": d,
3466
- "data-rows": ((B = v.sheetReactive.current) == null ? void 0 : B.numRows) ?? 0,
3467
- "data-cols": ((z = v.sheetReactive.current) == null ? void 0 : z.numCols) ?? 0,
3475
+ "data-rows": ((Z = v.sheetReactive.current) == null ? void 0 : Z.numRows) ?? 0,
3476
+ "data-cols": ((J = v.sheetReactive.current) == null ? void 0 : J.numCols) ?? 0,
3477
+ style: A || R ? {
3478
+ // inline-flex (when width isn't filled) keeps the prior shrink-to-content width.
3479
+ display: A ? "flex" : "inline-flex",
3480
+ flexDirection: "column",
3481
+ ...A ? { width: o.sheetWidth } : null,
3482
+ ...R ? { height: o.sheetHeight } : null
3483
+ } : void 0,
3468
3484
  children: [
3469
3485
  /* @__PURE__ */ a("div", { className: "gs-flash-overlay", ref: y }),
3470
3486
  /* @__PURE__ */ a(Te, { style: { position: "fixed", top: 0, left: 0 } }),
3471
3487
  /* @__PURE__ */ a(Te, { style: { position: "absolute", zIndex: 4, right: 0, top: 0, width: 5 }, horizontal: 1 }),
3472
3488
  /* @__PURE__ */ a(Te, { style: { position: "absolute", zIndex: 4, left: 0, bottom: 0, height: 5 }, vertical: 1 }),
3473
- typeof v.searchQuery > "u" ? c && /* @__PURE__ */ a(dr, { ready: C.ready }) : /* @__PURE__ */ a(hr, {}),
3489
+ typeof v.searchQuery > "u" ? c && /* @__PURE__ */ a(dr, { ready: C.ready }) : /* @__PURE__ */ a(fr, {}),
3474
3490
  /* @__PURE__ */ Y(
3475
3491
  "div",
3476
3492
  {
3477
3493
  className: `gs-main ${i || ""}`,
3478
3494
  ref: g,
3479
3495
  style: {
3480
- //width: '100%',
3496
+ ...A ? { width: "100%" } : null,
3481
3497
  maxWidth: "100%",
3482
- maxHeight: g.current ? window.innerHeight - g.current.getBoundingClientRect().top : (((U = v.sheetReactive.current) == null ? void 0 : U.fullHeight) || 0) + 2,
3483
- resize: h,
3498
+ // In fill-height mode the parent's height is the limit (flex:1 fills the remaining
3499
+ // space below the formula bar); otherwise cap at the viewport bottom as before.
3500
+ ...R ? { flex: 1, minHeight: 0, maxHeight: "100%" } : {
3501
+ maxHeight: g.current ? window.innerHeight - g.current.getBoundingClientRect().top : (((j = v.sheetReactive.current) == null ? void 0 : j.fullHeight) || 0) + 2
3502
+ },
3503
+ resize: f,
3484
3504
  ...l
3485
3505
  },
3486
3506
  children: [
3487
3507
  /* @__PURE__ */ a(Ms, { mode: d }),
3488
3508
  /* @__PURE__ */ a(ur, {}),
3489
- /* @__PURE__ */ a(Ds, { ...o, sheetHeight: I, sheetWidth: H, sheetName: n, sheetRef: T, storeRef: M }),
3490
- /* @__PURE__ */ a(Us, {}),
3509
+ /* @__PURE__ */ a(Ds, { ...o, sheetHeight: H, sheetWidth: _, sheetName: n, sheetRef: T, storeRef: D }),
3510
+ /* @__PURE__ */ a(Zs, {}),
3491
3511
  /* @__PURE__ */ a(js, {}),
3492
3512
  /* @__PURE__ */ a(qs, {}),
3493
3513
  /* @__PURE__ */ a(Is, {}),
3494
3514
  /* @__PURE__ */ a(Fs, {}),
3495
- _ && /* @__PURE__ */ a("div", { className: "gs-loading-overlay", children: /* @__PURE__ */ a("div", { className: "gs-loading-spinner" }) })
3515
+ ce && /* @__PURE__ */ a("div", { className: "gs-loading-overlay", children: /* @__PURE__ */ a("div", { className: "gs-loading-spinner" }) })
3496
3516
  ]
3497
3517
  }
3498
3518
  )
@@ -3501,24 +3521,24 @@ function Ar({
3501
3521
  ) });
3502
3522
  }
3503
3523
  const yr = (e) => {
3504
- var s, o, i, l, f;
3524
+ var s, o, i, l, h;
3505
3525
  const n = on(e);
3506
- let t = ((s = e[0]) == null ? void 0 : s.height) ?? hs;
3507
- for (let h = 1; h <= n.numRows; h++) {
3508
- const c = be(h), d = ((o = e == null ? void 0 : e[c]) == null ? void 0 : o.height) || ((i = e == null ? void 0 : e["0" + c]) == null ? void 0 : i.height) || ((l = e == null ? void 0 : e[ms]) == null ? void 0 : l.height) || ((f = e == null ? void 0 : e.default) == null ? void 0 : f.height) || bt;
3526
+ let t = ((s = e[0]) == null ? void 0 : s.height) ?? fs;
3527
+ for (let f = 1; f <= n.numRows; f++) {
3528
+ const c = be(f), d = ((o = e == null ? void 0 : e[c]) == null ? void 0 : o.height) || ((i = e == null ? void 0 : e["0" + c]) == null ? void 0 : i.height) || ((l = e == null ? void 0 : e[ms]) == null ? void 0 : l.height) || ((h = e == null ? void 0 : e.default) == null ? void 0 : h.height) || bt;
3509
3529
  if (t + d > Kt)
3510
3530
  return Kt;
3511
3531
  t += d;
3512
3532
  }
3513
3533
  return t + 3;
3514
3534
  }, vr = (e) => {
3515
- var s, o, i, l, f;
3535
+ var s, o, i, l, h;
3516
3536
  const n = on(e);
3517
3537
  let t = ((s = e[0]) == null ? void 0 : s.width) ?? ps;
3518
- for (let h = 1; h <= n.numCols; h++) {
3519
- const c = pe(h), d = ((o = e == null ? void 0 : e[c]) == null ? void 0 : o.width) || ((i = e == null ? void 0 : e[c + "0"]) == null ? void 0 : i.width) || ((l = e == null ? void 0 : e[ys]) == null ? void 0 : l.width) || ((f = e == null ? void 0 : e.default) == null ? void 0 : f.width) || vt;
3520
- if (t + d > Zt)
3521
- return Zt;
3538
+ for (let f = 1; f <= n.numCols; f++) {
3539
+ const c = pe(f), d = ((o = e == null ? void 0 : e[c]) == null ? void 0 : o.width) || ((i = e == null ? void 0 : e[c + "0"]) == null ? void 0 : i.width) || ((l = e == null ? void 0 : e[ys]) == null ? void 0 : l.width) || ((h = e == null ? void 0 : e.default) == null ? void 0 : h.width) || vt;
3540
+ if (t + d > Wt)
3541
+ return Wt;
3522
3542
  t += d;
3523
3543
  }
3524
3544
  return t + 3;
@@ -3553,12 +3573,12 @@ export {
3553
3573
  kt as MenuItem,
3554
3574
  Lr as Pending,
3555
3575
  Br as PercentagePolicyMixin,
3556
- Er as PluginBase,
3576
+ xr as PluginBase,
3557
3577
  Kr as Policy,
3558
- Zr as RangeEntity,
3559
- Ur as RefEntity,
3560
- zr as Registry,
3561
- Wr as Sheet,
3578
+ Wr as RangeEntity,
3579
+ Zr as RefEntity,
3580
+ Ur as Registry,
3581
+ zr as Sheet,
3562
3582
  _r as Spilling,
3563
3583
  jr as ThousandSeparatorPolicyMixin,
3564
3584
  Vr as Time,
@@ -3568,7 +3588,7 @@ export {
3568
3588
  Jr as addressesToAreas,
3569
3589
  eo as addressesToCols,
3570
3590
  to as addressesToRows,
3571
- xr as applyers,
3591
+ Er as applyers,
3572
3592
  no as areaToRange,
3573
3593
  so as areaToZone,
3574
3594
  ro as buildInitialCells,
@@ -3580,13 +3600,13 @@ export {
3580
3600
  co as conditionArg,
3581
3601
  uo as createBook,
3582
3602
  go as createBooleanMask,
3583
- fo as createRegistry,
3603
+ ho as createRegistry,
3584
3604
  kr as createSheetRef,
3585
3605
  Tr as createStoreRef,
3586
3606
  Ks as defaultColMenuDescriptors,
3587
3607
  Ls as defaultContextMenuDescriptors,
3588
3608
  Bs as defaultRowMenuDescriptors,
3589
- ho as eachMatrix,
3609
+ fo as eachMatrix,
3590
3610
  mo as ensureBoolean,
3591
3611
  po as ensureDate,
3592
3612
  yo as ensureNumber,
@@ -3597,11 +3617,11 @@ export {
3597
3617
  Ro as operations,
3598
3618
  Co as p2a,
3599
3619
  So as r2y,
3600
- xt as registerMenuComponent,
3620
+ Et as registerMenuComponent,
3601
3621
  No as rh,
3602
3622
  ks as sheet2csv,
3603
- Eo as stripMatrix,
3604
- xo as toCellCols,
3623
+ xo as stripMatrix,
3624
+ Eo as toCellCols,
3605
3625
  ko as toCellMatrix,
3606
3626
  To as toCellObject,
3607
3627
  Ao as toCellRows,
@@ -3609,7 +3629,7 @@ export {
3609
3629
  Do as toValueMatrix,
3610
3630
  Io as toValueObject,
3611
3631
  Fo as toValueRows,
3612
- ze as updateSheet,
3632
+ Ue as updateSheet,
3613
3633
  Ns as useBook,
3614
3634
  Nr as useInitialPluginContext,
3615
3635
  kn as usePluginContext,