@sheetxl/grid-react 0.7.9 → 0.7.11

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.
@@ -1,54 +1,54 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { jsx as Ce, jsxs as _t, Fragment as Qn } from "react/jsx-runtime";
3
- import { useCallbackRef as T, HorizontalAlignment as mn, KeyCodes as Ot, ReactUtils as Q, MouseButtonCodes as Xn, useSynchronizedPointerHandler as un, useId as Oo, useFullscreenPortal as go, SimpleCommand as se, KeyModifiers as ae, useImperativeElement as wo, ScrollPane as zo } from "@sheetxl/utils-react";
4
- import { useRef as ie, useReducer as zn, useState as ut, useEffect as wt, useCallback as W, useLayoutEffect as en, useMemo as Ae, memo as Kt, forwardRef as tn, version as Lo, createElement as xo, useImperativeHandle as $o } from "react";
5
- import { CoordUtils as V, CommonUtils as Nt, RangeOrientation as Ht, Direction as w, AnchorLocation as _e } from "@sheetxl/utils";
6
- import { createPortal as po } from "react-dom";
2
+ import { jsx as Ce, jsxs as Qt, Fragment as _n } from "react/jsx-runtime";
3
+ import { useCallbackRef as P, HorizontalAlignment as mn, KeyCodes as Ot, ReactUtils as X, MouseButtonCodes as jn, useSynchronizedPointerHandler as un, useId as To, useAnimatedMeasure as Do, useFullscreenPortal as fo, SimpleCommand as ie, KeyModifiers as ce, useImperativeElement as go, ScrollPane as Oo } from "@sheetxl/utils-react";
4
+ import { useRef as se, useReducer as Zn, useState as gt, useEffect as It, useCallback as V, useLayoutEffect as en, useMemo as Ae, memo as Kt, forwardRef as tn, version as zo, createElement as wo, useImperativeHandle as Lo } from "react";
5
+ import { CoordUtils as F, CommonUtils as Nt, RangeOrientation as Ht, Direction as g, AnchorLocation as Qe } from "@sheetxl/utils";
6
+ import { createPortal as xo } from "react-dom";
7
7
  /**
8
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.9
8
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.11
9
9
  *
10
10
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
11
11
  * License: The license can be found at https://www.sheetxl.com/license.
12
12
  */
13
13
  const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1 }) => {
14
- let s, i, l;
15
- t === "column" ? (s = r.columnMetadataMap, i = r.lastMeasuredColumnIndex, l = r.recalcColumnIndices) : (s = r.rowMetadataMap, i = r.lastMeasuredRowIndex, l = r.recalcRowIndices);
16
- const h = l.length > 0;
14
+ let d, i, l;
15
+ t === "column" ? (d = r.columnMetadataMap, i = r.lastMeasuredColumnIndex, l = r.recalcColumnIndices) : (d = r.rowMetadataMap, i = r.lastMeasuredRowIndex, l = r.recalcRowIndices);
16
+ const w = l.length > 0;
17
17
  if (n > i) {
18
- let O = 0;
18
+ let L = 0;
19
19
  if (i >= 0) {
20
- const z = s[i];
21
- O = z.offset + z.size;
20
+ const O = d[i];
21
+ L = O.offset + O.size;
22
22
  }
23
- for (let z = i + 1; z <= n; z++) {
24
- let M = h ? l.includes(z) ? o(z) * c : s[z]?.size || o(z) * c : o(z) * c;
25
- s[z] = { offset: O, size: M }, O += M;
23
+ for (let O = i + 1; O <= n; O++) {
24
+ let R = w ? l.includes(O) ? o(O) * c : d[O]?.size || o(O) * c : o(O) * c;
25
+ d[O] = { offset: L, size: R }, L += R;
26
26
  }
27
27
  t === "column" ? r.lastMeasuredColumnIndex = n : r.lastMeasuredRowIndex = n;
28
28
  }
29
- return s[n], s[n];
30
- }, eo = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, offset: c, scale: s }) => {
29
+ return d[n], d[n];
30
+ }, Qn = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, offset: c, scale: d }) => {
31
31
  let i, l;
32
32
  t === "column" ? (i = r.columnMetadataMap, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, l = r.lastMeasuredRowIndex);
33
- let h = 0;
34
- return h = (l > 0 ? i[l].offset : 0) >= c ? mo({ itemType: t, itemSize: n, instanceProps: r, high: l, low: 0, offset: c, scale: s }) : Bo({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: Math.max(0, l), offset: c, scale: s }), h = Math.min(h, o), h;
35
- }, mo = ({ itemType: t, itemSize: n, instanceProps: o, high: r, low: c, offset: s, scale: i }) => {
33
+ let w = 0;
34
+ return w = (l > 0 ? i[l].offset : 0) >= c ? po({ itemType: t, itemSize: n, instanceProps: r, high: l, low: 0, offset: c, scale: d }) : $o({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: Math.max(0, l), offset: c, scale: d }), w = Math.min(w, o), w;
35
+ }, po = ({ itemType: t, itemSize: n, instanceProps: o, high: r, low: c, offset: d, scale: i }) => {
36
36
  for (; c <= r; ) {
37
- const l = c + Math.floor((r - c) / 2), h = dn({ itemType: t, itemSize: n, index: l, instanceProps: o, scale: i }).offset;
38
- if (h === s) return l;
39
- h < s ? c = l + 1 : h > s && (r = l - 1);
37
+ const l = c + Math.floor((r - c) / 2), w = dn({ itemType: t, itemSize: n, index: l, instanceProps: o, scale: i }).offset;
38
+ if (w === d) return l;
39
+ w < d ? c = l + 1 : w > d && (r = l - 1);
40
40
  }
41
41
  return c > 0 ? c - 1 : 0;
42
- }, Bo = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: c, offset: s, scale: i }) => {
42
+ }, $o = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: c, offset: d, scale: i }) => {
43
43
  let l = 1;
44
- for (; c < o && dn({ itemType: t, itemSize: n, index: c, instanceProps: r, scale: i }).offset < s; ) c += l, l *= 2;
45
- return mo({ itemType: t, itemSize: n, instanceProps: r, high: Math.min(c, o - 1), low: Math.floor(c / 2), offset: s, scale: i });
46
- }, Ao = (t) => {
47
- const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: c, defaultColumnWidth: s, getColumnWidth: i } = t || {}, l = ie({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), h = T((k) => eo({ itemType: "row", itemCount: n, itemSize: c ?? (() => r ?? 20), instanceProps: l.current, offset: k }), [n, c, r]), O = T((k) => k === -1 ? 0 : dn({ itemType: "row", index: k, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).offset, [c, r]), z = T((k) => dn({ itemType: "row", index: k, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).size, [c, r]), M = T((k) => eo({ itemType: "column", itemCount: o, itemSize: i ?? (() => s ?? 75), instanceProps: l.current, offset: k }), [o, i, s]), R = T((k) => k === -1 ? 0 : dn({ itemType: "column", index: k, itemSize: i ?? (() => s ?? 75), instanceProps: l.current }).offset, [i, s]), $ = T((k) => dn({ itemType: "column", index: k, itemSize: i ?? (() => s ?? 75), instanceProps: l.current }).size, [i, s]), [Y, q] = zn((k) => k + 1, 0), _ = () => ({ getRowOffset: O, getColOffset: R, getRowIndex: h, getColIndex: M }), [Ie, Z] = ut(() => t ? _() : null);
48
- return wt(() => {
49
- Z(t ? _() : null);
50
- }, [Y, n, o, s, r, z, $]), Ie;
51
- }, vo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", to = (t) => {
44
+ for (; c < o && dn({ itemType: t, itemSize: n, index: c, instanceProps: r, scale: i }).offset < d; ) c += l, l *= 2;
45
+ return po({ itemType: t, itemSize: n, instanceProps: r, high: Math.min(c, o - 1), low: Math.floor(c / 2), offset: d, scale: i });
46
+ }, Bo = (t) => {
47
+ const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: c, defaultColumnWidth: d, getColumnWidth: i } = t || {}, l = se({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), w = P((T) => Qn({ itemType: "row", itemCount: n, itemSize: c ?? (() => r ?? 20), instanceProps: l.current, offset: T }), [n, c, r]), L = P((T) => T === -1 ? 0 : dn({ itemType: "row", index: T, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).offset, [c, r]), O = P((T) => dn({ itemType: "row", index: T, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).size, [c, r]), R = P((T) => Qn({ itemType: "column", itemCount: o, itemSize: i ?? (() => d ?? 75), instanceProps: l.current, offset: T }), [o, i, d]), M = P((T) => T === -1 ? 0 : dn({ itemType: "column", index: T, itemSize: i ?? (() => d ?? 75), instanceProps: l.current }).offset, [i, d]), A = P((T) => dn({ itemType: "column", index: T, itemSize: i ?? (() => d ?? 75), instanceProps: l.current }).size, [i, d]), [le, J] = Zn((T) => T + 1, 0), te = () => ({ getRowOffset: L, getColOffset: M, getRowIndex: w, getColIndex: R }), [ze, Q] = gt(() => t ? te() : null);
48
+ return It(() => {
49
+ Q(t ? te() : null);
50
+ }, [le, n, o, d, r, O, A]), ze;
51
+ }, mo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", eo = (t) => {
52
52
  if (!t) return null;
53
53
  if (t.eventType === "start") return { type: t.eventType };
54
54
  if (t.eventType === "submit") return { type: t.eventType };
@@ -60,164 +60,164 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
60
60
  return t.activeCoords && (n.activeCoords = t.activeCoords), n;
61
61
  }
62
62
  return { type: t.eventType ?? "unknown" };
63
- }, Fo = (t) => !0, Vo = (t) => !!t && !(t.ctrlKey || t.metaKey || t.altKey || t.isComposing) && (!(t.shiftKey || t.key !== "F2" && t.key !== " " && t.key !== "Backspace") || (!t.shiftKey || t.key !== " ") && vo.indexOf(t.key) !== -1), Wo = (t) => !!t && t.type === "dblclick" && { editMode: !0 }, Uo = (t) => {
64
- const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: c, cellBounds: s, isInBounds: i, getCellEditor: l, propsEditor: h, borderStrokeFill: O = "rgb(33, 115, 70)", borderStrokeWidth: z = 2, alignment: M = mn.Left, style: R, ...$ } = t, Y = ie(null), q = ie(null), [_, Ie] = ut(!1), Z = n.coords, k = W(async (fe) => {
65
- if (Y.current?.getBoundingClientRect()) {
66
- if (fe.eventType === "keyboard") {
67
- const A = fe.event, p = new KeyboardEvent(A.type, { bubbles: !0, cancelable: !0, view: window, key: A.key, code: A.code, location: A.location, repeat: A.repeat, isComposing: A.isComposing, charCode: A.charCode, keyCode: A.keyCode, which: A.which, ctrlKey: A.ctrlKey, shiftKey: A.shiftKey, altKey: A.altKey, metaKey: A.metaKey });
68
- p.isSynthetic = !0, p.key, q.current?.dispatchEvent(p);
69
- } else fe.eventType === "pointer" || console.warn("unsupported event type", fe);
70
- await new Promise((A) => requestAnimationFrame(A));
63
+ }, Ao = (t) => !0, Fo = (t) => !!t && !(t.ctrlKey || t.metaKey || t.altKey || t.isComposing) && (!(t.shiftKey || t.key !== "F2" && t.key !== " " && t.key !== "Backspace") || (!t.shiftKey || t.key !== " ") && mo.indexOf(t.key) !== -1), Vo = (t) => !!t && t.type === "dblclick" && { editMode: !0 }, Wo = (t) => {
64
+ const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: c, cellBounds: d, isInBounds: i, getCellEditor: l, propsEditor: w, borderStrokeFill: L = "rgb(33, 115, 70)", borderStrokeWidth: O = 2, alignment: R = mn.Left, style: M, ...A } = t, le = se(null), J = se(null), [te, ze] = gt(!1), Q = n.coords, T = V(async (ue) => {
65
+ if (le.current?.getBoundingClientRect()) {
66
+ if (ue.eventType === "keyboard") {
67
+ const $ = ue.event, p = new KeyboardEvent($.type, { bubbles: !0, cancelable: !0, view: window, key: $.key, code: $.code, location: $.location, repeat: $.repeat, isComposing: $.isComposing, charCode: $.charCode, keyCode: $.keyCode, which: $.which, ctrlKey: $.ctrlKey, shiftKey: $.shiftKey, altKey: $.altKey, metaKey: $.metaKey });
68
+ p.isSynthetic = !0, p.key, J.current?.dispatchEvent(p);
69
+ } else ue.eventType === "pointer" || console.warn("unsupported event type", ue);
70
+ await new Promise(($) => requestAnimationFrame($));
71
71
  }
72
72
  }, []);
73
- wt(() => {
74
- const fe = q.current;
75
- return Ie(!0), q.current.startEdit?.(n.startEvent), (async () => {
76
- n.editorRefs.push(fe), n.editorRefsDispatchEditorEvent.push(k);
73
+ It(() => {
74
+ const ue = J.current;
75
+ return ze(!0), J.current.startEdit?.(n.startEvent), (async () => {
76
+ n.editorRefs.push(ue), n.editorRefsDispatchEditorEvent.push(T);
77
77
  const ye = [...n.events];
78
- for (let A = 0; A < ye.length; A++) await k(ye[A]);
79
- n.onMount(fe);
78
+ for (let $ = 0; $ < ye.length; $++) await T(ye[$]);
79
+ n.onMount(ue);
80
80
  })(), () => {
81
- const ye = n.editorRefs.indexOf(fe);
82
- ye !== -1 && n.editorRefs.splice(ye, 1), n.onUnmount(fe);
81
+ const ye = n.editorRefs.indexOf(ue);
82
+ ye !== -1 && n.editorRefs.splice(ye, 1), n.onUnmount(ue);
83
83
  };
84
84
  }, []);
85
- const U = W(() => r(n), []), he = W(() => {
85
+ const _ = V(() => r(n), []), ve = V(() => {
86
86
  c(n);
87
- }, []), P = o.current && V.isEqualCells(o.current, Z), ce = i && P && _, Ve = l({ autoFocus: !!n.startEvent?.autoFocus, ...h, onSubmitEdit: U, onCancelEdit: he, ref: q }, Z), Pe = s.x + Q.boundPixel(-z / 2), We = Q.boundPixel(s.width + z / 2, !0);
88
- return Ce("div", { tabIndex: 0, ref: Y, style: { background: void 0, ...R, opacity: ce ? R?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${s.y + Q.boundPixel(-z / 2)}px`, height: Q.boundPixel(s.height + z / 2, !0), left: `${Pe}px`, width: We }, ...$, children: Ce("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${Q.boundPixel(1)}px`, top: `${Q.boundPixel(1)}px`, width: Q.boundPixel(s.width - 2, !0), height: Q.boundPixel(s.height - 2, !0), outline: `${z}px ${O} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: Ve }) });
89
- }, Sr = (t) => {
90
- const { view: n, canEdit: o = Fo, getCellEditor: r, onBeforeStartEdit: c, onStartEdit: s, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, isEditorStartKeyEvent: O = Vo, isEditorStartPointerEvent: z = Wo, containerProps: M, borderStrokeFill: R, borderStrokeWidth: $ = 2, getRangeCoords: Y = null, activeCoords: q, alignment: _ = mn.Left } = t, [Ie, Z] = ut(!1), [k, U] = ut(void 0), he = T((D, b, Me, oe, pe, Ue) => {
87
+ }, []), W = o.current && F.isEqualCells(o.current, Q), me = i && W && te, Ve = l({ autoFocus: !!n.startEvent?.autoFocus, ...w, onSubmitEdit: _, onCancelEdit: ve, ref: J }, Q), ke = d.x + X.boundPixel(-O / 2), We = X.boundPixel(d.width + O / 2, !0);
88
+ return Ce("div", { tabIndex: 0, ref: le, style: { background: void 0, ...M, opacity: me ? M?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${d.y + X.boundPixel(-O / 2)}px`, height: X.boundPixel(d.height + O / 2, !0), left: `${ke}px`, width: We }, ...A, children: Ce("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${X.boundPixel(1)}px`, top: `${X.boundPixel(1)}px`, width: X.boundPixel(d.width - 2, !0), height: X.boundPixel(d.height - 2, !0), outline: `${O}px ${L} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: Ve }) });
89
+ }, xr = (t) => {
90
+ const { view: n, canEdit: o = Ao, getCellEditor: r, onBeforeStartEdit: c, onStartEdit: d, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: w, isEditorStartKeyEvent: L = Fo, isEditorStartPointerEvent: O = Vo, containerProps: R, borderStrokeFill: M, borderStrokeWidth: A = 2, getRangeCoords: le = null, activeCoords: J, alignment: te = mn.Left } = t, [ze, Q] = gt(!1), [T, _] = gt(void 0), ve = P((k, b, Re, ne, we, Ue) => {
91
91
  if (!b) return null;
92
- const lt = pe?.(b, D), Mt = D.getRangeCoordsBounds(lt), it = D.toClipBounds(Mt), jt = Mt, pt = D.getZoom();
92
+ const lt = we?.(b, k), Mt = k.getRangeCoordsBounds(lt), it = k.toClipBounds(Mt), qt = Mt, xt = k.getZoom();
93
93
  if (!it) return null;
94
- Me && (Me *= pt), oe && (oe *= pt);
95
- let v = jt, re = !1;
96
- if (Me !== void 0) {
97
- let Qe = { ...lt }, ln = 0;
98
- for (; !re && v.width <= Me && ln < 20; ) {
94
+ Re && (Re *= xt), ne && (ne *= xt);
95
+ let v = qt, oe = !1;
96
+ if (Re !== void 0) {
97
+ let Je = { ...lt }, ln = 0;
98
+ for (; !oe && v.width <= Re && ln < 20; ) {
99
99
  ln++, ln > 19 && console.warn("max width reached");
100
- const Zt = D.getTotalRangeCoords(), Dt = D.getLayout();
101
- Ue === mn.Left ? Qe.colEnd + 1 < Zt.colEnd ? Qe.colEnd = Dt.getColIndex(v.x + Me) : re = !0 : Ue === mn.Right ? Qe.colStart - 1 >= 0 ? Qe.colStart = Dt.getColIndex(v.x - (Me - v.width)) : re = !0 : Ue === mn.Center && Qe.colEnd + 1 < Zt.colEnd && Qe.colStart - 1 >= 0 ? (Qe.colStart = Dt.getColIndex(v.x - (Me - v.width) / 2), Qe.colEnd = Dt.getColIndex(v.x + v.width + (Me - v.width) / 2)) : re = !0, re || (v = D.getRangeCoordsBounds(Qe));
100
+ const _t = k.getTotalRangeCoords(), Tt = k.getLayout();
101
+ Ue === mn.Left ? Je.colEnd + 1 < _t.colEnd ? Je.colEnd = Tt.getColIndex(v.x + Re) : oe = !0 : Ue === mn.Right ? Je.colStart - 1 >= 0 ? Je.colStart = Tt.getColIndex(v.x - (Re - v.width)) : oe = !0 : Ue === mn.Center && Je.colEnd + 1 < _t.colEnd && Je.colStart - 1 >= 0 ? (Je.colStart = Tt.getColIndex(v.x - (Re - v.width) / 2), Je.colEnd = Tt.getColIndex(v.x + v.width + (Re - v.width) / 2)) : oe = !0, oe || (v = k.getRangeCoordsBounds(Je));
102
102
  }
103
103
  }
104
- v.height = jt.height, oe !== void 0 && (v.height = Math.max(oe + 1, jt.height));
105
- const { width: He, height: ft } = D.getViewportSize();
106
- return { x: v.x ?? 0, y: v.y ?? 0, height: Math.min(ft - v.y, v.height) + 1, width: Math.min(He - v.x, v.width) + 1 };
107
- }, [_]), P = T(o, [o]), ce = W(() => {
104
+ v.height = qt.height, ne !== void 0 && (v.height = Math.max(ne + 1, qt.height));
105
+ const { width: He, height: ht } = k.getViewportSize();
106
+ return { x: v.x ?? 0, y: v.y ?? 0, height: Math.min(ht - v.y, v.height) + 1, width: Math.min(He - v.x, v.width) + 1 };
107
+ }, [te]), W = P(o, [o]), me = V(() => {
108
108
  n?.getStage()?.focus();
109
- }, [n]), Ve = ie(null), Pe = T((D) => {
110
- c?.(D), L(), Z(!0), Ve.current = null;
111
- }, [c]), We = T((D) => {
112
- s?.(D.coords);
113
- }, [s]), fe = T((D) => {
114
- D.isSubmitted || D.isCancelled || (p.current.isEditorClosed = !0, ce(), D.isCancelled = !0, l?.(D.coords), L());
115
- }, [l]), ye = T((D) => {
116
- if (D.isSubmitted || D.isCancelled) return !1;
109
+ }, [n]), Ve = se(null), ke = P((k) => {
110
+ c?.(k), D(), Q(!0), Ve.current = null;
111
+ }, [c]), We = P((k) => {
112
+ d?.(k.coords);
113
+ }, [d]), ue = P((k) => {
114
+ k.isSubmitted || k.isCancelled || (p.current.isEditorClosed = !0, me(), k.isCancelled = !0, l?.(k.coords), D());
115
+ }, [l]), ye = P((k) => {
116
+ if (k.isSubmitted || k.isCancelled) return !1;
117
117
  try {
118
- return Ve.current = D.coords, D.isEditorClosing = !0, D.isSubmitted = !0, D.isEditorSubmitted || (D.isEditorSubmitted = !0, D.editorRefs[0]?.submitEdit?.()), D.coords, i?.(D.coords), D.isEditorClosed = !0, ce(), L(), !0;
118
+ return Ve.current = k.coords, k.isEditorClosing = !0, k.isSubmitted = !0, k.isEditorSubmitted || (k.isEditorSubmitted = !0, k.editorRefs[0]?.submitEdit?.()), k.coords, i?.(k.coords), k.isEditorClosed = !0, me(), D(), !0;
119
119
  } catch (b) {
120
- throw D.isEditorClosing = !1, D.isSubmitted = !1, b;
120
+ throw k.isEditorClosing = !1, k.isSubmitted = !1, b;
121
121
  }
122
- }, [i]), A = T((D) => {
123
- Z(!1), h?.(D.coords), L();
124
- }, [h]), p = ie(null), Ne = ie(null), Xe = ie(null), te = ie([]), [be, J] = zn((D) => D + 1, 0), L = W((D) => {
125
- D && te.current.push(D), J();
126
- }, []), X = T((D) => {
127
- if (D.defaultPrevented || D.isSynthetic || !n) return;
128
- const b = n?.getCellCoordsFromClient(D.clientX, D.clientY);
129
- b && L({ eventType: "pointer", event: D, coords: b });
130
- }, [n]), Pt = T((D) => {
131
- const b = D.nativeEvent;
132
- X(b);
133
- }, [n]), Et = T((D) => {
134
- if (D.defaultPrevented || D.isSynthetic || !n?.getStage()) return;
122
+ }, [i]), $ = P((k) => {
123
+ Q(!1), w?.(k.coords), D();
124
+ }, [w]), p = se(null), Ne = se(null), Xe = se(null), Z = se([]), [be, Y] = Zn((k) => k + 1, 0), D = V((k) => {
125
+ k && Z.current.push(k), Y();
126
+ }, []), q = P((k) => {
127
+ if (k.defaultPrevented || k.isSynthetic || !n) return;
128
+ const b = n?.getCellCoordsFromClient(k.clientX, k.clientY);
129
+ b && D({ eventType: "pointer", event: k, coords: b });
130
+ }, [n]), Pt = P((k) => {
131
+ const b = k.nativeEvent;
132
+ q(b);
133
+ }, [n]), Et = P((k) => {
134
+ if (k.defaultPrevented || k.isSynthetic || !n?.getStage()) return;
135
135
  const b = Ne.current;
136
- O(D, b) && (D.stopPropagation(), D.preventDefault()), D.key, L({ eventType: "keyboard", event: D, coords: b });
136
+ L(k, b) && (k.stopPropagation(), k.preventDefault()), k.key, D({ eventType: "keyboard", event: k, coords: b });
137
137
  }, [n]);
138
138
  en(() => {
139
- const D = (oe, pe) => {
140
- const Ue = pe?.cell ?? oe;
139
+ const k = (ne, we) => {
140
+ const Ue = we?.cell ?? ne;
141
141
  if (!Ue) return null;
142
142
  const lt = Ue;
143
- if (!P(Ue)) return null;
144
- Pe?.(Ue);
143
+ if (!W(Ue)) return null;
144
+ ke?.(Ue);
145
145
  const Mt = Nt.uuidV4();
146
- pe = Object.freeze({ autoFocus: !0, ...pe }), Xe.current = Ue;
147
- const it = { coords: lt, startEvent: pe, uuid: Mt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (jt) => {
148
- it.isMounted || (it.isMounted = !0, L());
149
- }, onUnmount: (jt) => {
146
+ we = Object.freeze({ autoFocus: !0, ...we }), Xe.current = Ue;
147
+ const it = { coords: lt, startEvent: we, uuid: Mt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (qt) => {
148
+ it.isMounted || (it.isMounted = !0, D());
149
+ }, onUnmount: (qt) => {
150
150
  if (it.editorRefs.length === 0) {
151
- const pt = () => {
152
- it.isMounted = !1, L();
151
+ const xt = () => {
152
+ it.isMounted = !1, D();
153
153
  };
154
- if (document.activeElement !== document.body) pt();
154
+ if (document.activeElement !== document.body) xt();
155
155
  else {
156
- const v = (re) => {
157
- re.defaultPrevented || re.target !== document.body || Et(re);
156
+ const v = (oe) => {
157
+ oe.defaultPrevented || oe.target !== document.body || Et(oe);
158
158
  };
159
159
  window.addEventListener("keydown", v, !0), n.getStage()?.addEventListener("focusin", () => {
160
- window.removeEventListener("keydown", v), pt();
161
- }, Ho), ce();
160
+ window.removeEventListener("keydown", v), xt();
161
+ }, Uo), me();
162
162
  }
163
163
  }
164
164
  } };
165
165
  return it;
166
166
  };
167
- if (te.current.length <= 0 && !p.current) return;
168
- const b = te.current[0];
169
- to(b), ((oe) => {
170
- const pe = [], Ue = oe?.length ?? 0;
167
+ if (Z.current.length <= 0 && !p.current) return;
168
+ const b = Z.current[0];
169
+ eo(b), ((ne) => {
170
+ const we = [], Ue = ne?.length ?? 0;
171
171
  for (let lt = 0; lt < Ue; lt++) {
172
- const Mt = oe[lt];
173
- pe.push(to(Mt));
172
+ const Mt = ne[lt];
173
+ we.push(eo(Mt));
174
174
  }
175
- })(te.current), p.current, p.current;
176
- let Me = p.current;
175
+ })(Z.current), p.current, p.current;
176
+ let Re = p.current;
177
177
  if (p.current) {
178
178
  if (p.current.isDone) p.current = null;
179
179
  else if (p.current.isSubmitted || p.current.isCancelled) {
180
180
  if (p.current.isMounted) return;
181
- p.current.isDone || (A(p.current), p.current.isDone = !0);
181
+ p.current.isDone || ($(p.current), p.current.isDone = !0);
182
182
  }
183
183
  }
184
184
  if (b) {
185
185
  if (b.eventType === "start") {
186
- const oe = b, pe = oe.startEvent?.cell ?? Ne.current;
187
- p.current && V.isEqualCells(p.current.coords, pe) || (p.current = D(pe, oe.startEvent));
186
+ const ne = b, we = ne.startEvent?.cell ?? Ne.current;
187
+ p.current && F.isEqualCells(p.current.coords, we) || (p.current = k(we, ne.startEvent));
188
188
  } else if (b.eventType === "keyboard") {
189
- const oe = b.event;
189
+ const ne = b.event;
190
190
  if (p.current) {
191
- let pe = !1;
192
- switch (oe.which) {
191
+ let we = !1;
192
+ switch (ne.which) {
193
193
  case Ot.Left:
194
194
  case Ot.Right:
195
195
  case Ot.Up:
196
196
  case Ot.Down:
197
197
  case Ot.Enter:
198
198
  case Ot.Tab:
199
- pe = !0;
199
+ we = !0;
200
200
  }
201
- if (!pe) {
201
+ if (!we) {
202
202
  p.current.events.push(b);
203
203
  for (let Ue = 0; Ue < p.current.editorRefsDispatchEditorEvent.length; Ue++) p.current.editorRefsDispatchEditorEvent[Ue](b);
204
204
  }
205
- } else if (O(oe, b.coords)) {
206
- let pe;
207
- const Ue = D(pe?.cell ?? Ne.current, pe);
205
+ } else if (L(ne, b.coords)) {
206
+ let we;
207
+ const Ue = k(we?.cell ?? Ne.current, we);
208
208
  Ue && Ue.events.push(b), p.current = Ue;
209
209
  }
210
210
  } else if (b.eventType === "pointer") {
211
- const oe = b.event;
211
+ const ne = b.event;
212
212
  if (p.current) {
213
213
  p.current.events.push(b);
214
- for (let pe = 0; pe < p.current.editorRefsDispatchEditorEvent.length; pe++) p.current.editorRefsDispatchEditorEvent[pe](b);
214
+ for (let we = 0; we < p.current.editorRefsDispatchEditorEvent.length; we++) p.current.editorRefsDispatchEditorEvent[we](b);
215
215
  } else {
216
- const pe = b?.coords ?? Ne.current, Ue = z(oe, pe);
216
+ const we = b?.coords ?? Ne.current, Ue = O(ne, we);
217
217
  if (Ue) {
218
218
  let lt;
219
219
  typeof lt != "boolean" && (lt = Ue);
220
- const Mt = D(pe, lt);
220
+ const Mt = k(we, lt);
221
221
  Mt && Mt.events.push(b), p.current = Mt;
222
222
  }
223
223
  }
@@ -229,11 +229,11 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
229
229
  } else if (b.eventType === "cancel") {
230
230
  if (p.current && !p.current.isSubmitted && !p.current.isCancelled) {
231
231
  if (!p.current.isMounted) return;
232
- fe(p.current);
232
+ ue(p.current);
233
233
  }
234
234
  } else if (b.eventType === "coordsChange") {
235
- const oe = b;
236
- if (Ne.current = oe.activeCoords, p.current, p.current && !p.current.isSubmitted && !p.current.isCancelled) {
235
+ const ne = b;
236
+ if (Ne.current = ne.activeCoords, p.current, p.current && !p.current.isSubmitted && !p.current.isCancelled) {
237
237
  if (!p.current.isMounted) return;
238
238
  try {
239
239
  ye(p.current);
@@ -242,390 +242,339 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
242
242
  }
243
243
  }
244
244
  }
245
- te.current.length > 0 && (te.current.shift(), L()), te.current.length === 0 && (!p.current || p.current.isEditorClosing || p.current.isEditorClosed ? !p.current && Me && ce() : p.current.isMounted && !p.current.isStarted && (p.current.isStarted = !0, p.current.startEvent.autoFocus && (typeof p.current.startEvent.autoFocus == "string" ? p.current.editorRefs[0]?.autoFocus(p.current.startEvent.autoFocus) : p.current.editorRefs[0]?.autoFocus()), We?.(p.current), requestAnimationFrame(() => {
245
+ Z.current.length > 0 && (Z.current.shift(), D()), Z.current.length === 0 && (!p.current || p.current.isEditorClosing || p.current.isEditorClosed ? !p.current && Re && me() : p.current.isMounted && !p.current.isStarted && (p.current.isStarted = !0, p.current.startEvent.autoFocus && (typeof p.current.startEvent.autoFocus == "string" ? p.current.editorRefs[0]?.autoFocus(p.current.startEvent.autoFocus) : p.current.editorRefs[0]?.autoFocus()), We?.(p.current), requestAnimationFrame(() => {
246
246
  n && p.current?.coords && n.scrollCellCoordsIntoView(p.current.coords);
247
247
  })));
248
- }, [be]), wt(() => {
249
- Xe.current = q;
250
- const D = p.current?.coords;
251
- V.isEqualCells(D, q) || (p.current && (p.current.isEditorClosing = !0), L({ eventType: "coordsChange", activeCoords: q }));
252
- }, [q]);
253
- const xt = W((D) => {
254
- Et(D.nativeEvent);
255
- }, []), { width: ht = 0, height: ge = 0 } = k ?? { width: 0, height: 0 }, Wt = T(r, [r]);
256
- return { overlay: T((D) => {
248
+ }, [be]), It(() => {
249
+ Xe.current = J;
250
+ const k = p.current?.coords;
251
+ F.isEqualCells(k, J) || (p.current && (p.current.isEditorClosing = !0), D({ eventType: "coordsChange", activeCoords: J }));
252
+ }, [J]);
253
+ const wt = V((k) => {
254
+ Et(k.nativeEvent);
255
+ }, []), { width: ut = 0, height: he = 0 } = T ?? { width: 0, height: 0 }, Wt = P(r, [r]);
256
+ return { overlay: P((k) => {
257
257
  if (!p.current || p.current.isEditorClosed) return p.current, null;
258
258
  p.current.coords;
259
- let b = he(D, p.current.coords, ht, ge, Y, _), Me = !0;
260
- b && b.width !== 0 && b.height !== 0 || (b = { x: 0, y: 0, width: ht, height: ht }, Me = !1);
261
- const oe = D.getZoom(), pe = { containerBounds: { x: 0, y: 0, width: b.width / oe, height: b.height / oe }, setNaturalSize: U, zoom: oe };
262
- return Ce(Uo, { session: p.current, refLatestCoords: Xe, handleSubmitEdit: ye, handleCancelEdit: fe, cellBounds: b, borderStrokeWidth: $, borderStrokeFill: R, isInBounds: Me, getCellEditor: Wt, propsEditor: pe, alignment: _, ...M }, "editor:" + p.current.uuid);
263
- }, [r, Y, be, ht, ge, _, $, R]), startEdit: W((D) => {
264
- L({ eventType: "start", startEvent: D });
265
- }, []), submitEdit: W(() => {
266
- L({ eventType: "submit" });
267
- }, []), cancelEdit: W(() => {
268
- L({ eventType: "cancel" });
269
- }, []), onKeyboardEvent: xt, onPointerEvent: Pt, onKeyboardEventNative: Et, onPointerEventNative: X, isEditing: Ie };
270
- }, Ho = Object.freeze({ once: !0 });
271
- var No = function() {
272
- }, So = typeof window < "u", Ko = So ? en : wt, no = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
273
- const yo = So && window.ResizeObserver !== void 0 ? function() {
274
- var t = ut(null), n = t[0], o = t[1], r = ut(no), c = r[0], s = r[1], i = Ae(function() {
275
- return new window.ResizeObserver(function(l) {
276
- if (l[0]) {
277
- var h = l[0].contentRect, O = h.x, z = h.y, M = h.width, R = h.height, $ = h.top, Y = h.left, q = h.bottom, _ = h.right;
278
- s({ x: O, y: z, width: M, height: R, top: $, left: Y, bottom: q, right: _ });
279
- }
280
- });
281
- }, []);
282
- return Ko(function() {
283
- if (n) return i.observe(n), function() {
284
- i.disconnect();
285
- };
286
- }, [n]), [o, c];
287
- } : function() {
288
- return [No, no];
289
- }, jo = 3, qo = 0.5, Yo = 50, Kn = (t) => ({ x: t.x, y: t.y, width: t.width, height: t.height, top: t.top, left: t.left, right: t.right, bottom: t.bottom });
290
- function Xo(t = {}) {
291
- const { threshold: n = qo, stillnessThreshold: o = jo, maxHierarchyDepth: r = Yo } = t, [c, s] = yo(), i = ie(null), [l, h] = zn((Y) => Y + 1, 0), O = ie(void 0), z = ie({ x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 }), M = W((Y) => {
292
- i.current = Y, typeof c == "function" && c(Y);
293
- }, [c]), [R, $] = ut(s);
294
- return wt(() => {
295
- s && !R && $(s);
296
- }, [s, R]), wt(() => {
297
- const Y = i.current;
298
- if (!Y) return;
299
- let q = !1, _ = 0;
300
- const Ie = () => {
301
- if (!Y) return;
302
- const P = Y.getBoundingClientRect(), ce = z.current;
303
- Math.abs(P.x - ce.x) > n || Math.abs(P.y - ce.y) > n || Math.abs(P.width - ce.width) > n || Math.abs(P.height - ce.height) > n ? (q || (q = !0, $(Kn(P)), h()), _ = 0) : _++, q && _ >= o && (q = !1, $(Kn(P)), h()), z.current = Kn(P), O.current = requestAnimationFrame(Ie);
304
- };
305
- O.current = requestAnimationFrame(Ie);
306
- const Z = (P) => {
307
- q = !0, h();
308
- }, k = (P) => {
309
- q = !1, _ = o, h();
310
- };
311
- let U = Y;
312
- const he = [];
313
- for (; U && U !== document.documentElement && (U.addEventListener("animationstart", Z, !0), U.addEventListener("animationend", k, !0), U.addEventListener("transitionstart", Z, !0), U.addEventListener("transitionend", k, !0), he.push(U), U = U.parentElement, !(he.length > r)); ) ;
314
- return () => {
315
- O.current && cancelAnimationFrame(O.current), he.forEach((P) => {
316
- P.removeEventListener("animationstart", Z, !0), P.removeEventListener("animationend", k, !0), P.removeEventListener("transitionstart", Z, !0), P.removeEventListener("transitionend", k, !0);
317
- });
318
- };
319
- }, [l, s, n, o, r]), [M, R];
320
- }
321
- const yr = ({ gridRef: t, gridMainRef: n, orientation: o = Ht.Row, headerCount: r, selectionPolicy: c = "multiple", newSelectionMode: s = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: h, pointerDownInterceptor: O, pointerMoveInterceptor: z, onPointerUp: M, newSelection: R, modifySelection: $, appendSelection: Y, clearSelections: q }) => {
322
- const _ = r ?? ((o === Ht.Row ? t.current?.rowCount : t.current?.columnCount) || 0), Ie = ie(null), Z = ie(null), k = ie(!1), U = ie(null), he = W((A) => o === Ht.Column ? { rowIndex: 0, colIndex: A.colIndex } : { rowIndex: A.rowIndex, colIndex: 0 }, [o]), P = W((A) => o === Ht.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: A.colIndex } : { rowIndex: A.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), ce = (A) => {
323
- Z.current = P(A), $(Z.current, Ie.current);
324
- }, Ve = W((A, p) => {
259
+ let b = ve(k, p.current.coords, ut, he, le, te), Re = !0;
260
+ b && b.width !== 0 && b.height !== 0 || (b = { x: 0, y: 0, width: ut, height: ut }, Re = !1);
261
+ const ne = k.getZoom(), we = { containerBounds: { x: 0, y: 0, width: b.width / ne, height: b.height / ne }, setNaturalSize: _, zoom: ne };
262
+ return Ce(Wo, { session: p.current, refLatestCoords: Xe, handleSubmitEdit: ye, handleCancelEdit: ue, cellBounds: b, borderStrokeWidth: A, borderStrokeFill: M, isInBounds: Re, getCellEditor: Wt, propsEditor: we, alignment: te, ...R }, "editor:" + p.current.uuid);
263
+ }, [r, le, be, ut, he, te, A, M]), startEdit: V((k) => {
264
+ D({ eventType: "start", startEvent: k });
265
+ }, []), submitEdit: V(() => {
266
+ D({ eventType: "submit" });
267
+ }, []), cancelEdit: V(() => {
268
+ D({ eventType: "cancel" });
269
+ }, []), onKeyboardEvent: wt, onPointerEvent: Pt, onKeyboardEventNative: Et, onPointerEventNative: q, isEditing: ze };
270
+ }, Uo = Object.freeze({ once: !0 }), pr = ({ gridRef: t, gridMainRef: n, orientation: o = Ht.Row, headerCount: r, selectionPolicy: c = "multiple", newSelectionMode: d = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: w, pointerDownInterceptor: L, pointerMoveInterceptor: O, onPointerUp: R, newSelection: M, modifySelection: A, appendSelection: le, clearSelections: J }) => {
271
+ const te = r ?? ((o === Ht.Row ? t.current?.rowCount : t.current?.columnCount) || 0), ze = se(null), Q = se(null), T = se(!1), _ = se(null), ve = V(($) => o === Ht.Column ? { rowIndex: 0, colIndex: $.colIndex } : { rowIndex: $.rowIndex, colIndex: 0 }, [o]), W = V(($) => o === Ht.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: $.colIndex } : { rowIndex: $.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), me = ($) => {
272
+ Q.current = W($), A(Q.current, ze.current);
273
+ }, Ve = V(($, p) => {
325
274
  if (!t.current) return;
326
- const Ne = t.current.getViewFromClient(A, p)?.getCellCoordsFromClient(A, p);
275
+ const Ne = t.current.getViewFromClient($, p)?.getCellCoordsFromClient($, p);
327
276
  return Ne ? (o === Ht.Column ? Ne.rowIndex = n.current.getViewport().rowStart : Ne.colIndex = n.current.getViewport().colStart, Ne) : void 0;
328
- }, []), Pe = W((A, p = !1) => {
329
- let Ne = A;
330
- return p || (Ne = { ...A }, o === Ht.Row ? delete Ne.colIndex : delete Ne.rowIndex), n.current?.scrollCellCoordsIntoView(Ne);
331
- }, [o]), We = T(h, [h]), fe = T(l, [l]), ye = Ae(() => ({ onPointerDown: (A) => {
332
- if (!t || !t.current || A.nativeEvent.defaultPrevented) return;
333
- const p = Ve(A.nativeEvent.clientX, A.nativeEvent.clientY);
277
+ }, []), ke = V(($, p = !1) => {
278
+ let Ne = $;
279
+ return p || (Ne = { ...$ }, o === Ht.Row ? delete Ne.colIndex : delete Ne.rowIndex), n.current?.scrollCellCoordsIntoView(Ne);
280
+ }, [o]), We = P(w, [w]), ue = P(l, [l]), ye = Ae(() => ({ onPointerDown: ($) => {
281
+ if (!t || !t.current || $.nativeEvent.defaultPrevented) return;
282
+ const p = Ve($.nativeEvent.clientX, $.nativeEvent.clientY);
334
283
  if (!p) return;
335
- A.nativeEvent.which, Xn.Right;
336
- const Ne = A.nativeEvent.shiftKey, Xe = A.nativeEvent.ctrlKey || A.nativeEvent.metaKey;
337
- if (O?.(A, p) === !1) return;
338
- fe?.(), k.current = !0;
339
- const te = n.current?.getViewFromClient(A.nativeEvent.clientX, A.nativeEvent.clientY), be = ((J, L) => o === Ht.Column ? { ...J, rowIndex: L.rowStart } : { ...J, colIndex: L.colStart })(p, te.getVisibleRangeCoords());
340
- if (Ne) ce(p);
284
+ $.nativeEvent.which, jn.Right;
285
+ const Ne = $.nativeEvent.shiftKey, Xe = $.nativeEvent.ctrlKey || $.nativeEvent.metaKey;
286
+ if (L?.($, p) === !1) return;
287
+ ue?.(), T.current = !0;
288
+ const Z = n.current?.getViewFromClient($.nativeEvent.clientX, $.nativeEvent.clientY), be = ((Y, D) => o === Ht.Column ? { ...Y, rowIndex: D.rowStart } : { ...Y, colIndex: D.colStart })(p, Z.getVisibleRangeCoords());
289
+ if (Ne) me(p);
341
290
  else {
342
- if (Xe) return ((J, L = J, X) => {
343
- Ie.current = he(J), Z.current = P(L), Y(Ie.current, Z.current, X);
344
- })(p, p, be), void (i && Pe(be, !0));
345
- ((J, L = J, X) => {
346
- Ie.current = he(J), Z.current = P(L), R(Ie.current, Z.current, X);
347
- })(p, p, be), ce(p), i && Pe(be, !0);
291
+ if (Xe) return ((Y, D = Y, q) => {
292
+ ze.current = ve(Y), Q.current = W(D), le(ze.current, Q.current, q);
293
+ })(p, p, be), void (i && ke(be, !0));
294
+ ((Y, D = Y, q) => {
295
+ ze.current = ve(Y), Q.current = W(D), M(ze.current, Q.current, q);
296
+ })(p, p, be), me(p), i && ke(be, !0);
348
297
  }
349
- }, onPointerMoveOrWait: Nt.throttle((A) => {
350
- if (!k.current || !t?.current) return;
351
- const p = Ve(A.clientX, A.clientY);
352
- if (p && z?.(A, p) !== !1) {
353
- if (V.isEqualCells(U.current, p)) return q();
354
- ce(p), Pe(p);
298
+ }, onPointerMoveOrWait: Nt.throttle(($) => {
299
+ if (!T.current || !t?.current) return;
300
+ const p = Ve($.clientX, $.clientY);
301
+ if (p && O?.($, p) !== !1) {
302
+ if (F.isEqualCells(_.current, p)) return J();
303
+ me(p), ke(p);
355
304
  }
356
- }, 60), onPointerUp: (A) => {
357
- k.current = !1, We?.(), M?.(A);
358
- }, processTouch: !0, consumeTouch: !0 }), [c, i, _, s, q, O, M]);
359
- return { onPointerDown: T(un(ye), []), getCellCoordsFromClient: Ve };
305
+ }, 60), onPointerUp: ($) => {
306
+ T.current = !1, We?.(), R?.($);
307
+ }, processTouch: !0, consumeTouch: !0 }), [c, i, te, d, J, L, R]);
308
+ return { onPointerDown: P(un(ye), []), getCellCoordsFromClient: Ve };
360
309
  }, Fe = (t, n, o) => {
361
310
  if (!t) return n;
362
311
  let r = n;
363
- const c = o === w.Right || o === w.Down;
312
+ const c = o === g.Right || o === g.Down;
364
313
  for (; ; ) {
365
- const s = t(r, !c);
366
- if (s === 0) return r;
367
- c ? r += s : r -= s;
314
+ const d = t(r, !c);
315
+ if (d === 0) return r;
316
+ c ? r += d : r -= d;
368
317
  }
369
318
  }, Pn = (t, n, o) => {
370
319
  const r = [];
371
320
  let c = n;
372
321
  for (; c <= o; ) {
373
- const s = Math.max(0, t(c));
374
- s === 0 ? (r.push(c), c++) : c += s;
322
+ const d = Math.max(0, t(c));
323
+ d === 0 ? (r.push(c), c++) : c += d;
375
324
  }
376
325
  return r;
377
- }, Go = (t, n, o, r, c, s) => {
378
- if (!n) return s;
326
+ }, Ho = (t, n, o, r, c, d) => {
327
+ if (!n) return d;
379
328
  let { rowIndex: i, colIndex: l } = t;
380
329
  switch (r) {
381
- case w.Down: {
382
- i = Fe(o, Math.min(i + 1, s), r);
383
- let h = n({ rowIndex: i, colIndex: l });
384
- for (; !h && i < s; ) i = Fe(o, Math.min(++i, s), r), h = n({ rowIndex: i, colIndex: l });
330
+ case g.Down: {
331
+ i = Fe(o, Math.min(i + 1, d), r);
332
+ let w = n({ rowIndex: i, colIndex: l });
333
+ for (; !w && i < d; ) i = Fe(o, Math.min(++i, d), r), w = n({ rowIndex: i, colIndex: l });
385
334
  return i;
386
335
  }
387
- case w.Up: {
388
- i = Fe(o, Math.max(i - 1, s), r);
389
- let h = n({ rowIndex: i, colIndex: l });
390
- for (; !h && i > s; ) i = Fe(o, Math.max(--i, s), r), h = n({ rowIndex: i, colIndex: l });
336
+ case g.Up: {
337
+ i = Fe(o, Math.max(i - 1, d), r);
338
+ let w = n({ rowIndex: i, colIndex: l });
339
+ for (; !w && i > d; ) i = Fe(o, Math.max(--i, d), r), w = n({ rowIndex: i, colIndex: l });
391
340
  return i;
392
341
  }
393
- case w.Right: {
394
- l = Fe(o, Math.min(l + 1, s), r);
395
- let h = n({ rowIndex: i, colIndex: l });
396
- for (; !h && l < s; ) l = Fe(o, Math.min(++l, s), r), h = n({ rowIndex: i, colIndex: l });
342
+ case g.Right: {
343
+ l = Fe(o, Math.min(l + 1, d), r);
344
+ let w = n({ rowIndex: i, colIndex: l });
345
+ for (; !w && l < d; ) l = Fe(o, Math.min(++l, d), r), w = n({ rowIndex: i, colIndex: l });
397
346
  return l;
398
347
  }
399
- case w.Left: {
400
- l = Fe(o, Math.max(l - 1, s), r);
401
- let h = n({ rowIndex: i, colIndex: l });
402
- for (; !h && l > s; ) l = Fe(o, Math.max(--l, s), r), h = n({ rowIndex: i, colIndex: l });
348
+ case g.Left: {
349
+ l = Fe(o, Math.max(l - 1, d), r);
350
+ let w = n({ rowIndex: i, colIndex: l });
351
+ for (; !w && l > d; ) l = Fe(o, Math.max(--l, d), r), w = n({ rowIndex: i, colIndex: l });
403
352
  return l;
404
353
  }
405
354
  default:
406
- return s;
355
+ return d;
407
356
  }
408
- }, Zo = (t, n = () => !0, o, r, c, s) => {
357
+ }, No = (t, n = () => !0, o, r, c, d) => {
409
358
  let { rowIndex: i, colIndex: l } = t;
410
359
  switch (r) {
411
- case w.Down: {
412
- i = Fe(o, Math.min(i + 1, s), r);
413
- let h = n?.({ rowIndex: i, colIndex: l });
414
- for (; h && i < s; ) i = Fe(o, Math.min(++i, s), r), h = n?.({ rowIndex: i, colIndex: l });
360
+ case g.Down: {
361
+ i = Fe(o, Math.min(i + 1, d), r);
362
+ let w = n?.({ rowIndex: i, colIndex: l });
363
+ for (; w && i < d; ) i = Fe(o, Math.min(++i, d), r), w = n?.({ rowIndex: i, colIndex: l });
415
364
  return n?.({ rowIndex: i, colIndex: l }) ? i : i - 1;
416
365
  }
417
- case w.Up: {
418
- i = Fe(o, Math.max(i - 1, s), r);
419
- let h = n?.({ rowIndex: i, colIndex: l });
420
- for (; h && i > s; ) i = Fe(o, Math.max(--i, s), r), h = n?.({ rowIndex: i, colIndex: l });
366
+ case g.Up: {
367
+ i = Fe(o, Math.max(i - 1, d), r);
368
+ let w = n?.({ rowIndex: i, colIndex: l });
369
+ for (; w && i > d; ) i = Fe(o, Math.max(--i, d), r), w = n?.({ rowIndex: i, colIndex: l });
421
370
  return n?.({ rowIndex: i, colIndex: l }) ? i : i + 1;
422
371
  }
423
- case w.Right: {
424
- l = Fe(o, Math.min(l + 1, s), r);
425
- let h = n?.({ rowIndex: i, colIndex: l });
426
- for (; h && l < s; ) l = Fe(o, Math.min(++l, s), r), h = n?.({ rowIndex: i, colIndex: l });
372
+ case g.Right: {
373
+ l = Fe(o, Math.min(l + 1, d), r);
374
+ let w = n?.({ rowIndex: i, colIndex: l });
375
+ for (; w && l < d; ) l = Fe(o, Math.min(++l, d), r), w = n?.({ rowIndex: i, colIndex: l });
427
376
  return n?.({ rowIndex: i, colIndex: l }) ? l : l - 1;
428
377
  }
429
- case w.Left: {
430
- l = Fe(o, Math.max(l - 1, s), r);
431
- let h = n?.({ rowIndex: i, colIndex: l });
432
- for (; h && l > s; ) l = Fe(o, Math.max(--l, s), r), h = n?.({ rowIndex: i, colIndex: l });
378
+ case g.Left: {
379
+ l = Fe(o, Math.max(l - 1, d), r);
380
+ let w = n?.({ rowIndex: i, colIndex: l });
381
+ for (; w && l > d; ) l = Fe(o, Math.max(--l, d), r), w = n?.({ rowIndex: i, colIndex: l });
433
382
  return n?.({ rowIndex: i, colIndex: l }) ? l : l + 1;
434
383
  }
435
384
  default:
436
385
  return null;
437
386
  }
438
- }, Jo = (t, n, o, r, c, s) => {
439
- if (!n) return s;
440
- let i, { rowIndex: l, colIndex: h } = t;
441
- r === w.Down ? i = { rowIndex: l + 1, colIndex: h } : r === w.Up ? i = { rowIndex: l - 1, colIndex: h } : r === w.Right ? i = { rowIndex: l, colIndex: h + 1 } : r === w.Left && (i = { rowIndex: l, colIndex: h - 1 });
442
- const O = n(t), z = n(i);
443
- var M, R;
444
- return (R = z, !(M = O) && !R || !M && R || M && !R ? Go : Zo)(t, n, o, r, !1, s) ?? s;
445
- }, oo = (t, n) => `${t}:${n}`, ro = (t, n, o, r, c, s) => {
387
+ }, Ko = (t, n, o, r, c, d) => {
388
+ if (!n) return d;
389
+ let i, { rowIndex: l, colIndex: w } = t;
390
+ r === g.Down ? i = { rowIndex: l + 1, colIndex: w } : r === g.Up ? i = { rowIndex: l - 1, colIndex: w } : r === g.Right ? i = { rowIndex: l, colIndex: w + 1 } : r === g.Left && (i = { rowIndex: l, colIndex: w - 1 });
391
+ const L = n(t), O = n(i);
392
+ var R, M;
393
+ return (M = O, !(R = L) && !M || !R && M || R && !M ? Ho : No)(t, n, o, r, !1, d) ?? d;
394
+ }, to = (t, n) => `${t}:${n}`, no = (t, n, o, r, c, d) => {
446
395
  if (o - n >= c - r) return r;
447
396
  let i = r;
448
- return t === "nearest" && (r - n > 0 ? t = "start" : o - c > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (c - r) : t === "center" && (i = n + (o - n) / 2 - (c - r) / 2), i < r ? Math.max(0, i) : i > r ? Math.min(i, s - (c - r)) : void 0;
449
- }, lo = (t, n, o, r) => (console.log("todo: implement convertToVisibleRanges"), t), Gn = (t, n = w.Right, o, r, c, s = null) => {
450
- if (s && V.isEqualSelectionCoords(s, t)) return t;
397
+ return t === "nearest" && (r - n > 0 ? t = "start" : o - c > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (c - r) : t === "center" && (i = n + (o - n) / 2 - (c - r) / 2), i < r ? Math.max(0, i) : i > r ? Math.min(i, d - (c - r)) : void 0;
398
+ }, oo = (t, n, o, r) => (console.log("todo: implement convertToVisibleRanges"), t), Yn = (t, n = g.Right, o, r, c, d = null) => {
399
+ if (d && F.isEqualSelectionCoords(d, t)) return t;
451
400
  const i = t.ranges[t.rangeIndex];
452
- if (!V.isRangesIntersect({ rowStart: t.cell.rowIndex, colStart: t.cell.colIndex, rowEnd: t.cell.rowIndex, colEnd: t.cell.colIndex }, i)) return t;
453
- let l = { ...t.cell }, h = t.rangeIndex;
401
+ if (!F.isRangesIntersect({ rowStart: t.cell.rowIndex, colStart: t.cell.colIndex, rowEnd: t.cell.rowIndex, colEnd: t.cell.colIndex }, i)) return t;
402
+ let l = { ...t.cell }, w = t.rangeIndex;
454
403
  switch (n) {
455
- case w.Right:
404
+ case g.Right:
456
405
  l.colIndex = Fe(c, l.colIndex + 1, n);
457
406
  break;
458
- case w.Left:
407
+ case g.Left:
459
408
  l.colIndex = Fe(c, l.colIndex - 1, n);
460
409
  break;
461
- case w.Down:
410
+ case g.Down:
462
411
  l.rowIndex = Fe(r, l.rowIndex + 1, n);
463
412
  break;
464
- case w.Up:
413
+ case g.Up:
465
414
  l.rowIndex = Fe(r, l.rowIndex - 1, n);
466
415
  }
467
- const O = (R) => {
468
- if (R) {
469
- h = t.rangeIndex >= t.ranges.length - 1 ? 0 : t.rangeIndex + 1;
470
- const $ = t.ranges[h];
471
- l = { colIndex: $.colStart, rowIndex: $.rowStart };
416
+ const L = (M) => {
417
+ if (M) {
418
+ w = t.rangeIndex >= t.ranges.length - 1 ? 0 : t.rangeIndex + 1;
419
+ const A = t.ranges[w];
420
+ l = { colIndex: A.colStart, rowIndex: A.rowStart };
472
421
  } else {
473
- h = t.rangeIndex <= 0 ? t.ranges.length - 1 : t.rangeIndex - 1;
474
- const $ = t.ranges[h];
475
- l = { colIndex: $.colEnd, rowIndex: $.rowEnd };
422
+ w = t.rangeIndex <= 0 ? t.ranges.length - 1 : t.rangeIndex - 1;
423
+ const A = t.ranges[w];
424
+ l = { colIndex: A.colEnd, rowIndex: A.rowEnd };
476
425
  }
477
426
  };
478
- if (n === w.Right && l.colIndex > i.colEnd && l.rowIndex === i.rowEnd) O(!0);
479
- else if (n === w.Left && l.colIndex < i.colStart && l.rowIndex === i.rowStart) O(!1);
480
- else if (n === w.Down && l.colIndex === i.colEnd && l.rowIndex > i.rowEnd) O(!0);
481
- else if (n === w.Up && l.colIndex === i.colStart && l.rowIndex < i.rowStart) O(!1);
427
+ if (n === g.Right && l.colIndex > i.colEnd && l.rowIndex === i.rowEnd) L(!0);
428
+ else if (n === g.Left && l.colIndex < i.colStart && l.rowIndex === i.rowStart) L(!1);
429
+ else if (n === g.Down && l.colIndex === i.colEnd && l.rowIndex > i.rowEnd) L(!0);
430
+ else if (n === g.Up && l.colIndex === i.colStart && l.rowIndex < i.rowStart) L(!1);
482
431
  else {
483
- let R = l.rowIndex, $ = l.colIndex;
432
+ let M = l.rowIndex, A = l.colIndex;
484
433
  switch (n) {
485
- case w.Right:
486
- $ > i.colEnd && (R = Fe(r, R + 1, n), $ = i.colStart, R > i.rowEnd && (R = i.rowStart));
434
+ case g.Right:
435
+ A > i.colEnd && (M = Fe(r, M + 1, n), A = i.colStart, M > i.rowEnd && (M = i.rowStart));
487
436
  break;
488
- case w.Left:
489
- $ < i.colStart && (R = Fe(r, R - 1, n), $ = i.colEnd, R < i.rowStart && (R = i.rowEnd));
437
+ case g.Left:
438
+ A < i.colStart && (M = Fe(r, M - 1, n), A = i.colEnd, M < i.rowStart && (M = i.rowEnd));
490
439
  break;
491
- case w.Down:
492
- R > i.rowEnd && ($ = Fe(c, $ + 1, n), R = i.rowStart, $ > i.colEnd && ($ = i.colStart));
440
+ case g.Down:
441
+ M > i.rowEnd && (A = Fe(c, A + 1, n), M = i.rowStart, A > i.colEnd && (A = i.colStart));
493
442
  break;
494
- case w.Up:
495
- R < i.rowStart && ($ = Fe(c, $ - 1, n), R = i.rowEnd, $ < i.colStart && ($ = i.colEnd));
443
+ case g.Up:
444
+ M < i.rowStart && (A = Fe(c, A - 1, n), M = i.rowEnd, A < i.colStart && (A = i.colEnd));
496
445
  }
497
- l = { rowIndex: R, colIndex: $ };
446
+ l = { rowIndex: M, colIndex: A };
498
447
  }
499
- let z = o(l);
500
- if (!V.isRangeWithinRange(z, i)) {
501
- const R = V.intersectRanges(z, i);
502
- R && (z = R);
448
+ let O = o(l);
449
+ if (!F.isRangeWithinRange(O, i)) {
450
+ const M = F.intersectRanges(O, i);
451
+ M && (O = M);
503
452
  }
504
- let M = { rowStart: Fe(r, z.rowStart, w.Down), colStart: Fe(c, z.colStart, w.Right), rowEnd: Fe(r, z.rowEnd, w.Up), colEnd: Fe(c, z.colEnd, w.Left) };
505
- if (M.rowStart !== l.rowIndex || M.colStart !== l.colIndex) {
453
+ let R = { rowStart: Fe(r, O.rowStart, g.Down), colStart: Fe(c, O.colStart, g.Right), rowEnd: Fe(r, O.rowEnd, g.Up), colEnd: Fe(c, O.colEnd, g.Left) };
454
+ if (R.rowStart !== l.rowIndex || R.colStart !== l.colIndex) {
506
455
  switch (n) {
507
- case w.Right:
508
- t.ranges[h].colStart === M.colStart && t.ranges[h].colEnd === M.colEnd && (l.rowIndex = M.rowEnd), l.colIndex = M.colEnd;
456
+ case g.Right:
457
+ t.ranges[w].colStart === R.colStart && t.ranges[w].colEnd === R.colEnd && (l.rowIndex = R.rowEnd), l.colIndex = R.colEnd;
509
458
  break;
510
- case w.Left:
511
- t.ranges[h].colStart === M.colStart && t.ranges[h].colEnd === M.colEnd && (l.rowIndex = M.rowStart), l.rowIndex === M.rowStart ? l.colIndex = M.colStart + 1 : l.colIndex = M.colStart;
459
+ case g.Left:
460
+ t.ranges[w].colStart === R.colStart && t.ranges[w].colEnd === R.colEnd && (l.rowIndex = R.rowStart), l.rowIndex === R.rowStart ? l.colIndex = R.colStart + 1 : l.colIndex = R.colStart;
512
461
  break;
513
- case w.Down:
514
- t.ranges[h].rowStart === M.rowStart && t.ranges[h].rowEnd === M.rowEnd && (l.colIndex = M.colEnd), l.rowIndex = M.rowEnd;
462
+ case g.Down:
463
+ t.ranges[w].rowStart === R.rowStart && t.ranges[w].rowEnd === R.rowEnd && (l.colIndex = R.colEnd), l.rowIndex = R.rowEnd;
515
464
  break;
516
- case w.Up:
517
- t.ranges[h].rowStart === M.rowStart && t.ranges[h].rowEnd === M.rowEnd && (l.colIndex = M.colStart), l.colIndex === M.colStart ? l.rowIndex = M.rowStart + 1 : l.rowIndex = M.rowStart;
465
+ case g.Up:
466
+ t.ranges[w].rowStart === R.rowStart && t.ranges[w].rowEnd === R.rowEnd && (l.colIndex = R.colStart), l.colIndex === R.colStart ? l.rowIndex = R.rowStart + 1 : l.rowIndex = R.rowStart;
518
467
  }
519
- return Gn({ cell: l, ranges: t.ranges, rangeIndex: h }, n, o, r, c, s ?? t);
468
+ return Yn({ cell: l, ranges: t.ranges, rangeIndex: w }, n, o, r, c, d ?? t);
520
469
  }
521
- return { ranges: t.ranges, cell: l, rangeIndex: h };
522
- }, io = (t, n) => {
470
+ return { ranges: t.ranges, cell: l, rangeIndex: w };
471
+ }, ro = (t, n) => {
523
472
  let o, r = 0, c = 0;
524
- return n.colStart < t.colStart ? (o = w.Left, r = t.colStart - n.colStart, c = n.colStart) : n.colEnd > t.colEnd ? (o = w.Right, r = n.colEnd - t.colEnd, c = n.colEnd) : n.rowStart < t.rowStart ? (o = w.Up, r = t.rowStart - n.rowStart, c = n.rowStart) : n.rowEnd > t.rowEnd && (o = w.Down, r = n.rowEnd - t.rowEnd, c = n.rowEnd), { direction: o, amount: r, index: c };
473
+ return n.colStart < t.colStart ? (o = g.Left, r = t.colStart - n.colStart, c = n.colStart) : n.colEnd > t.colEnd ? (o = g.Right, r = n.colEnd - t.colEnd, c = n.colEnd) : n.rowStart < t.rowStart ? (o = g.Up, r = t.rowStart - n.rowStart, c = n.rowStart) : n.rowEnd > t.rowEnd && (o = g.Down, r = n.rowEnd - t.rowEnd, c = n.rowEnd), { direction: o, amount: r, index: c };
525
474
  }, On = (t, n = !1, o, r) => {
526
475
  if (!o) return 0;
527
- const c = !n, s = c ? 1 : -1;
528
- let i = o(c ? t : t + 1), l = o(c ? t + 1 : t), h = t + (c ? 2 : -1), O = 0;
529
- for (; (l - i) * s <= 0; ) {
530
- if (c && h - 1 > r + 1 || !c && h + 1 < r) return O;
531
- i = l, l = o(h), h += s, O++;
476
+ const c = !n, d = c ? 1 : -1;
477
+ let i = o(c ? t : t + 1), l = o(c ? t + 1 : t), w = t + (c ? 2 : -1), L = 0;
478
+ for (; (l - i) * d <= 0; ) {
479
+ if (c && w - 1 > r + 1 || !c && w + 1 < r) return L;
480
+ i = l, l = o(w), w += d, L++;
532
481
  }
533
- return O;
534
- }, co = (t, n, o, r, c) => {
535
- const s = {};
482
+ return L;
483
+ }, lo = (t, n, o, r, c) => {
484
+ const d = {};
536
485
  let i = null, l = null;
537
- const h = o.length;
538
- for (let O = 0; O < h && o[O] <= c; O++) {
539
- const z = o[O];
540
- if (z < r) continue;
541
- const M = i === z ? l : n ? t.getColOffset(z) : t.getRowOffset(z), R = n ? t.getColOffset(z + 1) : t.getRowOffset(z + 1);
542
- i = z + 1, l = R, s[z] = Object.freeze({ offset: M, size: R - M, spanIndex: O });
486
+ const w = o.length;
487
+ for (let L = 0; L < w && o[L] <= c; L++) {
488
+ const O = o[L];
489
+ if (O < r) continue;
490
+ const R = i === O ? l : n ? t.getColOffset(O) : t.getRowOffset(O), M = n ? t.getColOffset(O + 1) : t.getRowOffset(O + 1);
491
+ i = O + 1, l = M, d[O] = Object.freeze({ offset: R, size: M - R, spanIndex: L });
543
492
  }
544
- return Object.freeze(s);
545
- }, so = (t, n, o) => {
493
+ return Object.freeze(d);
494
+ }, io = (t, n, o) => {
546
495
  const r = t.getColOffset(n.colStart) + (o?.left ?? 0), c = t.getRowOffset(n.rowStart) + (o?.top ?? 0);
547
496
  return { x: r, y: c, width: t.getColOffset(n.colEnd + 1) + (o?.right ?? 0) - (o?.left ?? 0) - r, height: t.getRowOffset(n.rowEnd + 1) + (o?.bottom ?? 0) - (o?.top ?? 0) - c };
548
- }, Qo = (t, n, o) => {
497
+ }, qo = (t, n, o) => {
549
498
  if (!o) return !1;
550
499
  const r = o.x;
551
500
  if (t < r || t > r + o.width) return !1;
552
501
  const c = o.y;
553
502
  return !(n < c || n > c + o.height);
554
- }, jn = (t, n = !0) => `M ${Q.boundPixel(t.left)} ${Q.boundPixel(t.top)} L ${Q.boundPixel(t.right, !0)} ${Q.boundPixel(t.top)} L ${Q.boundPixel(t.right, !0)} ${Q.boundPixel(t.bottom, !0)} L ${Q.boundPixel(t.left)} ${Q.boundPixel(t.bottom, !0)} L ${Q.boundPixel(t.left)} ${Q.boundPixel(t.top)} ${n ? "Z" : ""}`, ao = (t) => {
555
- const { linePoints: n, bounds: o, pathProps: r, style: c, ...s } = t;
556
- return Ce("svg", { width: `${Q.boundPixel(o.width, !0)}`, height: `${Q.boundPixel(o.height, !0)}`, viewBox: `0 0 ${Q.boundPixel(o.width, !0)} ${Q.boundPixel(o.height, !0)}`, style: { position: "absolute", left: `${Q.boundPixel(o.x)}px`, top: `${Q.boundPixel(o.y)}px`, width: `${Q.boundPixel(o.width, !0)}px`, height: `${Q.boundPixel(o.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...c }, ...s, children: Ce("path", { d: `M ${Q.boundPixel(n[0])} ${Q.boundPixel(n[1])} L ${Q.boundPixel(n[2])} ${Q.boundPixel(n[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r }) });
557
- }, _o = (t) => {
558
- const { x: n = 0, y: o = 0, width: r = 0, height: c = 0, fill: s, stroke: i, strokeWidth: l = 0, strokeDasharray: h, strokeDashoffset: O, clipPath: z, pathBounds: M, pathProps: R, style: $, ...Y } = t, q = o, _ = n, Ie = r, Z = c;
559
- let k = null;
560
- if (s) {
561
- let U = jn({ top: 0, left: 0, bottom: Z, right: Ie });
562
- M && (U = U + " " + jn({ top: M.y - q, left: M.x - _, bottom: M.height + M.y - q, right: M.width + M.x - _ })), k = [Ce("path", { d: U, fill: s, stroke: "none", fillRule: "evenodd" }, "fill")];
503
+ }, Nn = (t, n = !0) => `M ${X.boundPixel(t.left)} ${X.boundPixel(t.top)} L ${X.boundPixel(t.right, !0)} ${X.boundPixel(t.top)} L ${X.boundPixel(t.right, !0)} ${X.boundPixel(t.bottom, !0)} L ${X.boundPixel(t.left)} ${X.boundPixel(t.bottom, !0)} L ${X.boundPixel(t.left)} ${X.boundPixel(t.top)} ${n ? "Z" : ""}`, co = (t) => {
504
+ const { linePoints: n, bounds: o, pathProps: r, style: c, ...d } = t;
505
+ return Ce("svg", { width: `${X.boundPixel(o.width, !0)}`, height: `${X.boundPixel(o.height, !0)}`, viewBox: `0 0 ${X.boundPixel(o.width, !0)} ${X.boundPixel(o.height, !0)}`, style: { position: "absolute", left: `${X.boundPixel(o.x)}px`, top: `${X.boundPixel(o.y)}px`, width: `${X.boundPixel(o.width, !0)}px`, height: `${X.boundPixel(o.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...c }, ...d, children: Ce("path", { d: `M ${X.boundPixel(n[0])} ${X.boundPixel(n[1])} L ${X.boundPixel(n[2])} ${X.boundPixel(n[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r }) });
506
+ }, jo = (t) => {
507
+ const { x: n = 0, y: o = 0, width: r = 0, height: c = 0, fill: d, stroke: i, strokeWidth: l = 0, strokeDasharray: w, strokeDashoffset: L, clipPath: O, pathBounds: R, pathProps: M, style: A, ...le } = t, J = o, te = n, ze = r, Q = c;
508
+ let T = null;
509
+ if (d) {
510
+ let _ = Nn({ top: 0, left: 0, bottom: Q, right: ze });
511
+ R && (_ = _ + " " + Nn({ top: R.y - J, left: R.x - te, bottom: R.height + R.y - J, right: R.width + R.x - te })), T = [Ce("path", { d: _, fill: d, stroke: "none", fillRule: "evenodd" }, "fill")];
563
512
  }
564
- return _t("svg", { width: `${Q.boundPixel(r, !0)}`, height: `${Q.boundPixel(c, !0)}`, viewBox: `0 0 ${Q.boundPixel(r, !0)} ${Q.boundPixel(c, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${Q.boundPixel(n)}px`, top: `${Q.boundPixel(o)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...$ }, ...Y, children: [k, Ce("path", { d: jn({ top: 0, left: 0, right: Ie, bottom: Z }), fill: "none", strokeDasharray: h, strokeDashoffset: O, stroke: i, vectorEffect: "non-scaling-stroke", strokeWidth: l, ...R })] });
565
- }, er = (t) => {
513
+ return Qt("svg", { width: `${X.boundPixel(r, !0)}`, height: `${X.boundPixel(c, !0)}`, viewBox: `0 0 ${X.boundPixel(r, !0)} ${X.boundPixel(c, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${X.boundPixel(n)}px`, top: `${X.boundPixel(o)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...A }, ...le, children: [T, Ce("path", { d: Nn({ top: 0, left: 0, right: ze, bottom: Q }), fill: "none", strokeDasharray: w, strokeDashoffset: L, stroke: i, vectorEffect: "non-scaling-stroke", strokeWidth: l, ...M })] });
514
+ }, Yo = (t) => {
566
515
  const { key: n, ...o } = t;
567
- return Ce(bo, { ...o }, n);
568
- }, bo = Kt((t) => {
569
- const { stroke: n, fill: o, x: r = 0, y: c = 0, width: s = 0, height: i = 0, style: l, isAnimatedStroke: h, animatedStrokeProps: O, range: z, cell: M, ...R } = t, $ = h || !!O, Y = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...O };
570
- let q = Y.dashGap + Y.dashLength;
571
- const _ = Y.speed * q, Ie = Oo().replaceAll(":", ""), Z = `${Y.name}-${Ie}`;
572
- let k;
573
- return wt(() => {
574
- if (!$) return;
575
- const U = `@keyframes ${Z} {
516
+ return Ce(vo, { ...o }, n);
517
+ }, vo = Kt((t) => {
518
+ const { stroke: n, fill: o, x: r = 0, y: c = 0, width: d = 0, height: i = 0, style: l, isAnimatedStroke: w, animatedStrokeProps: L, range: O, cell: R, ...M } = t, A = w || !!L, le = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...L };
519
+ let J = le.dashGap + le.dashLength;
520
+ const te = le.speed * J, ze = To().replaceAll(":", ""), Q = `${le.name}-${ze}`;
521
+ let T;
522
+ return It(() => {
523
+ if (!A) return;
524
+ const _ = `@keyframes ${Q} {
576
525
  to {
577
526
  stroke-dashoffset: 0px;
578
527
  }
579
- }`, he = document.createElement("style");
580
- return he.appendChild(document.createTextNode(U)), document.head.appendChild(he), he.sheet.insertRule(U, 0), () => {
581
- document.head.removeChild(he);
528
+ }`, ve = document.createElement("style");
529
+ return ve.appendChild(document.createTextNode(_)), document.head.appendChild(ve), ve.sheet.insertRule(_, 0), () => {
530
+ document.head.removeChild(ve);
582
531
  };
583
- }, [$]), $ && (k = { strokeDasharray: `${Y.dashLength}px ${Y.dashGap}px`, strokeDashoffset: `${q}px`, animation: `${Z} ${_}ms linear infinite`, willChange: "stroke-dashoffset" }), Ce(_o, { x: r, y: c, width: s, height: i, stroke: n, fill: o, shapeRendering: "crispEdges", style: { ...k, ...l }, ...R });
532
+ }, [A]), A && (T = { strokeDasharray: `${le.dashLength}px ${le.dashGap}px`, strokeDashoffset: `${J}px`, animation: `${Q} ${te}ms linear infinite`, willChange: "stroke-dashoffset" }), Ce(jo, { x: r, y: c, width: d, height: i, stroke: n, fill: o, shapeRendering: "crispEdges", style: { ...T, ...l }, ...M });
584
533
  });
585
- function Co(t) {
534
+ function So(t) {
586
535
  var n, o, r = "";
587
536
  if (typeof t == "string" || typeof t == "number") r += t;
588
537
  else if (typeof t == "object") if (Array.isArray(t)) {
589
538
  var c = t.length;
590
- for (n = 0; n < c; n++) t[n] && (o = Co(t[n])) && (r && (r += " "), r += o);
539
+ for (n = 0; n < c; n++) t[n] && (o = So(t[n])) && (r && (r += " "), r += o);
591
540
  } else for (o in t) t[o] && (r && (r += " "), r += o);
592
541
  return r;
593
542
  }
594
543
  function rn() {
595
- for (var t, n, o = 0, r = "", c = arguments.length; o < c; o++) (t = arguments[o]) && (n = Co(t)) && (r && (r += " "), r += n);
544
+ for (var t, n, o = 0, r = "", c = arguments.length; o < c; o++) (t = arguments[o]) && (n = So(t)) && (r && (r += " "), r += n);
596
545
  return r;
597
546
  }
598
- bo.displayName = "Selection";
599
- const Io = Kt(tn((t, n) => {
600
- const { x: o = 0, y: r = 0, borderWidth: c = 1, size: s = 6, borderStroke: i, corner: l, style: h, className: O, background: z, ...M } = t;
547
+ vo.displayName = "Selection";
548
+ const yo = Kt(tn((t, n) => {
549
+ const { x: o = 0, y: r = 0, borderWidth: c = 1, size: d = 6, borderStroke: i, corner: l, style: w, className: L, background: O, ...R } = t;
601
550
  if (o === 0 || r === 0) return null;
602
- let R = !0, $ = !0, Y = !0, q = !0;
551
+ let M = !0, A = !0, le = !0, J = !0;
603
552
  switch (l) {
604
553
  case "tl":
605
- R = !1, $ = !1;
554
+ M = !1, A = !1;
606
555
  break;
607
556
  case "bl":
608
- R = !1, q = !1;
557
+ M = !1, J = !1;
609
558
  break;
610
559
  case "br":
611
- Y = !1, q = !1;
560
+ le = !1, J = !1;
612
561
  break;
613
562
  case "tr":
614
- $ = !1, Y = !1;
563
+ A = !1, le = !1;
615
564
  }
616
- return Ce("div", { className: rn("fill-handle", O), style: { position: "absolute", left: o - (s + (R ? c : 0)) / 2, top: r - (s + ($ ? c : 0)) / 2, width: s, height: s, borderLeft: R ? `${c}px ${i}` : void 0, borderTop: $ ? `${c}px ${i}` : void 0, borderRight: Y ? `${c}px ${i}` : void 0, borderBottom: q ? `${c}px ${i}` : void 0, background: z, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...h }, tabIndex: -1, ...M });
565
+ return Ce("div", { className: rn("fill-handle", L), style: { position: "absolute", left: o - (d + (M ? c : 0)) / 2, top: r - (d + (A ? c : 0)) / 2, width: d, height: d, borderLeft: M ? `${c}px ${i}` : void 0, borderTop: A ? `${c}px ${i}` : void 0, borderRight: le ? `${c}px ${i}` : void 0, borderBottom: J ? `${c}px ${i}` : void 0, background: O, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...w }, tabIndex: -1, ...R });
617
566
  }));
618
- function qn(t, n) {
567
+ function Kn(t, n) {
619
568
  if (typeof t == "function") return t(n);
620
569
  t && (t.current = n);
621
570
  }
622
- Io.displayName = "FillHandle";
623
- var tr = parseInt(Lo.split(".")[0], 10) >= 19 ? function(t) {
571
+ yo.displayName = "FillHandle";
572
+ var Xo = parseInt(zo.split(".")[0], 10) >= 19 ? function(t) {
624
573
  return (n) => {
625
574
  const o = [];
626
575
  for (const r of t) {
627
- const c = qn(r, n), s = typeof c == "function";
628
- o.push(s ? c : () => qn(r, null));
576
+ const c = Kn(r, n), d = typeof c == "function";
577
+ o.push(d ? c : () => Kn(r, null));
629
578
  }
630
579
  return () => {
631
580
  for (const r of o) r();
@@ -633,21 +582,21 @@ var tr = parseInt(Lo.split(".")[0], 10) >= 19 ? function(t) {
633
582
  };
634
583
  } : function(t) {
635
584
  return (n) => {
636
- for (const o of t) qn(o, n);
585
+ for (const o of t) Kn(o, n);
637
586
  };
638
587
  };
639
- const nr = Q.detectIt().supportsTouchEvents, Zn = Kt(tn((t, n) => {
640
- const { range: o, view: r, anchor: c, borderStroke: s = "rgb(33, 115, 70)", background: i = "white", borderWidth: l = 1.5, size: h = 22, style: O, className: z, selectionTouchPointerHandler: M, onTouchSelectStart: R, onTouchSelectEnd: $, currentTouchAnchor: Y, scrollableElement: q, scrollableRoot: _, ...Ie } = t;
641
- if (!nr) return null;
642
- const Z = T(R, [R]), k = T($, [$]), { bounds: U, coordsPivot: he, key: P } = Ae(() => {
588
+ const Go = X.detectIt().supportsTouchEvents, Xn = Kt(tn((t, n) => {
589
+ const { range: o, view: r, anchor: c, borderStroke: d = "rgb(33, 115, 70)", background: i = "white", borderWidth: l = 1.5, size: w = 22, style: L, className: O, selectionTouchPointerHandler: R, onTouchSelectStart: M, onTouchSelectEnd: A, currentTouchAnchor: le, scrollableElement: J, scrollableRoot: te, ...ze } = t;
590
+ if (!Go) return null;
591
+ const Q = P(M, [M]), T = P(A, [A]), { bounds: _, coordsPivot: ve, key: W } = Ae(() => {
643
592
  if (!o || !r) return null;
644
- let be = null, J = null;
593
+ let be = null, Y = null;
645
594
  switch (c) {
646
595
  case "tl":
647
- be = { colIndex: o.colEnd, rowIndex: o.rowEnd }, J = { colIndex: o.colStart, rowIndex: o.rowStart };
596
+ be = { colIndex: o.colEnd, rowIndex: o.rowEnd }, Y = { colIndex: o.colStart, rowIndex: o.rowStart };
648
597
  break;
649
598
  case "br":
650
- be = { colIndex: o.colStart, rowIndex: o.rowStart }, J = { colIndex: o.colEnd, rowIndex: o.rowEnd };
599
+ be = { colIndex: o.colStart, rowIndex: o.rowStart }, Y = { colIndex: o.colEnd, rowIndex: o.rowEnd };
651
600
  break;
652
601
  case "t":
653
602
  case "l":
@@ -659,1253 +608,1270 @@ const nr = Q.detectIt().supportsTouchEvents, Zn = Kt(tn((t, n) => {
659
608
  case "r":
660
609
  be = { colIndex: o.colStart, rowIndex: o.rowEnd };
661
610
  }
662
- let L = r.getRangeCoordsBounds(J ? { rowStart: J.rowIndex, colStart: J.colIndex, rowEnd: J.rowIndex, colEnd: J.colIndex } : o);
663
- const X = r.getBounds(), Pt = r.getViewportSize(), Et = X.x, xt = X.y, ht = Pt.width, ge = Pt.height;
611
+ let D = r.getRangeCoordsBounds(Y ? { rowStart: Y.rowIndex, colStart: Y.colIndex, rowEnd: Y.rowIndex, colEnd: Y.colIndex } : o);
612
+ const q = r.getBounds(), Pt = r.getViewportSize(), Et = q.x, wt = q.y, ut = Pt.width, he = Pt.height;
664
613
  switch (c) {
665
614
  case "tl":
666
615
  break;
667
616
  case "br":
668
- L.x = L.x + L.width, L.y = L.y + L.height;
617
+ D.x = D.x + D.width, D.y = D.y + D.height;
669
618
  break;
670
619
  case "t":
671
- L.x = ht / 2 - Et;
620
+ D.x = ut / 2 - Et;
672
621
  break;
673
622
  case "b":
674
- L.x = ht / 2 - Et, L.y = L.y + L.height;
623
+ D.x = ut / 2 - Et, D.y = D.y + D.height;
675
624
  break;
676
625
  case "l":
677
- L.y = ge / 2 - xt;
626
+ D.y = he / 2 - wt;
678
627
  break;
679
628
  case "r":
680
- L.x = L.x + L.width, L.y = ge / 2 - xt;
629
+ D.x = D.x + D.width, D.y = he / 2 - wt;
681
630
  }
682
- const Wt = r.toClipBounds(L, 0);
683
- return !Wt || Wt.width <= 0 || Wt.height <= 0 || L.x < 0 || L.y < 0 || L.x > ht || L.y > ge ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: L, coordsAnchor: null, coordsPivot: be, key: "touchSelect-" + r.getAnchor() + "-" + c };
684
- }, [o, r, c]), ce = ie(null), Ve = Ae(() => {
685
- const be = (J) => c === "t" || c === "b" ? { ...J, colIndex: void 0 } : c === "l" || c === "r" ? { ...J, rowIndex: void 0 } : J;
686
- return { processTouch: !0, consumeTouch: !0, onPointerDown: (J, L) => {
687
- const X = be(r.getCellCoordsFromClient(J.clientX, J.clientY));
688
- return ce.current = { coordsPivot: he }, Z?.(c), M.onSelectionPointerDown(J, L, r, X, he, !1, !0);
689
- }, onPointerMoveOrWait: (J, L, X) => {
690
- const Pt = be(r.getCellCoordsFromClient(J.clientX, J.clientY));
691
- return M.onSelectionPointerMoveOrWait(J, L, X, r, Pt, ce.current?.coordsPivot, !0, !0);
692
- }, onPointerUp: (J, L, X) => (ce.current = null, k?.(c), M.onPointerUp(J, L, X)) };
693
- }, [M, o, r, c]), Pe = un(Ve), [We, { y: fe, x: ye }] = Xo(), A = ie(null), { getPortalContainer: p, isFullscreen: Ne } = go(), [Xe, te] = ut(null);
694
- return wt(() => {
695
- const be = A.current?.getBoundingClientRect();
696
- if (!be || !U) return void te(null);
697
- let J = 0, L = 0, X = q;
698
- for (; X; ) J += X.scrollLeft, L += X.scrollTop, X = _ && X === _.parentElement ? null : X.parentElement;
699
- te(po(Ce("div", { className: rn("touch-select-handle", z), ref: n, style: { position: "absolute", left: J + (be?.x ?? 0) - (h + l) / 2, top: L + (be?.y ?? 0) - (h + l) / 2, width: h, height: h, borderWidth: `${l}px`, border: s, borderRadius: "50%", background: i, boxShadow: `0 0 0 1.5px ${i}`, cursor: "grab", pointerEvents: "all", opacity: Y ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...O }, tabIndex: -1, onPointerDown: Pe, ...Ie }), _ ?? p(), P));
700
- }, [fe, ye, U?.x, U?.y, U?.width, U?.height, z, Y, i, h, l, s, q, Ne]), U ? _t(Qn, { children: [Ce("div", { ref: tr([We, A]), style: { position: "absolute", left: U.x, top: U.y, opacity: 0 } }), Xe] }) : null;
631
+ const Wt = r.toClipBounds(D, 0);
632
+ return !Wt || Wt.width <= 0 || Wt.height <= 0 || D.x < 0 || D.y < 0 || D.x > ut || D.y > he ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: D, coordsAnchor: null, coordsPivot: be, key: "touchSelect-" + r.getAnchor() + "-" + c };
633
+ }, [o, r, c]), me = se(null), Ve = Ae(() => {
634
+ const be = (Y) => c === "t" || c === "b" ? { ...Y, colIndex: void 0 } : c === "l" || c === "r" ? { ...Y, rowIndex: void 0 } : Y;
635
+ return { processTouch: !0, consumeTouch: !0, onPointerDown: (Y, D) => {
636
+ const q = be(r.getCellCoordsFromClient(Y.clientX, Y.clientY));
637
+ return me.current = { coordsPivot: ve }, Q?.(c), R.onSelectionPointerDown(Y, D, r, q, ve, !1, !0);
638
+ }, onPointerMoveOrWait: (Y, D, q) => {
639
+ const Pt = be(r.getCellCoordsFromClient(Y.clientX, Y.clientY));
640
+ return R.onSelectionPointerMoveOrWait(Y, D, q, r, Pt, me.current?.coordsPivot, !0, !0);
641
+ }, onPointerUp: (Y, D, q) => (me.current = null, T?.(c), R.onPointerUp(Y, D, q)) };
642
+ }, [R, o, r, c]), ke = un(Ve), [We, { y: ue, x: ye }] = Do(), $ = se(null), { getPortalContainer: p, isFullscreen: Ne } = fo(), [Xe, Z] = gt(null);
643
+ return It(() => {
644
+ const be = $.current?.getBoundingClientRect();
645
+ if (!be || !_) return void Z(null);
646
+ let Y = 0, D = 0, q = J;
647
+ for (; q; ) Y += q.scrollLeft, D += q.scrollTop, q = te && q === te.parentElement ? null : q.parentElement;
648
+ Z(xo(Ce("div", { className: rn("touch-select-handle", O), ref: n, style: { position: "absolute", left: Y + (be?.x ?? 0) - (w + l) / 2, top: D + (be?.y ?? 0) - (w + l) / 2, width: w, height: w, borderWidth: `${l}px`, border: d, borderRadius: "50%", background: i, boxShadow: `0 0 0 1.5px ${i}`, cursor: "grab", pointerEvents: "all", opacity: le ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...L }, tabIndex: -1, onPointerDown: ke, ...ze }), te ?? p(), W));
649
+ }, [ue, ye, _?.x, _?.y, _?.width, _?.height, O, le, i, w, l, d, J, Ne]), _ ? Qt(_n, { children: [Ce("div", { ref: Xo([We, $]), style: { position: "absolute", left: _.x, top: _.y, opacity: 0 } }), Xe] }) : null;
701
650
  }));
702
- Zn.displayName = "TouchSelectHandle";
703
- const Vt = -10, or = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Eo = Object.freeze({ colIndex: 0, rowIndex: 0 }), Jn = Object.freeze([]), $t = (t) => {
651
+ Xn.displayName = "TouchSelectHandle";
652
+ const Vt = -10, _o = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), bo = Object.freeze({ colIndex: 0, rowIndex: 0 }), Gn = Object.freeze([]), $t = (t) => {
704
653
  if (t && t.cell && t.ranges && t.rangeIndex > -1 && t.rangeIndex <= t.ranges.length) return t;
705
- const n = { cell: null, ranges: t?.ranges ?? Jn };
706
- return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell = Eo), V.isEqualSelectionCoords(n, t) ? t : n;
707
- }, Dn = (t, n, o) => {
654
+ const n = { cell: null, ranges: t?.ranges ?? Gn };
655
+ return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell = bo), F.isEqualSelectionCoords(n, t) ? t : n;
656
+ }, Tn = (t, n, o) => {
708
657
  const r = t.getVisibleRangeCoords(), c = t.getScrollOrientation();
709
- !c.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), !c.vertical && (n.rowIndex > r.rowEnd || n.rowIndex < r.rowStart) && (n = { ...n, rowIndex: n.rowIndex > r.rowEnd ? r.rowEnd + 1 : r.rowEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), t.scrollCellCoordsIntoView(n);
710
- }, rr = () => !1, br = ({ gridRef: t, commands: n, layout: o, selection: r, onSelectionChange: c, onSelectionDragStart: s, onSelectionDragEnd: i, selectionPolicy: l = "multiple", newSelectionMode: h = "clear", allowDeselectSelection: O = !0, onFillPreview: z, onFillCancel: M, onFillDone: R, onFill: $, disableFillDrag: Y = !$, fillHandleBorderColor: q = "white", hiddenRowsAt: _, hiddenColumnsAt: Ie, isContentfulCell: Z, contentfulCellFinder: k = Jo, getDataCoords: U, alwaysScrollToActiveCoords: he = !1, selectionBounds: P, pointerDownInterceptor: ce, pointerMoveInterceptor: Ve, mergedRanges: Pe, canSelectionSpanMergedCells: We = rr, onMoveDragStart: fe, onMoveDragUpdate: ye, onMoveDragEnd: A, onMoveDragDone: p, selectionRenderer: Ne = er, disableMoveDrag: Xe = !A, getCellCoordsAsRangeCoords: te = V.cellToRange, moveDragHitSize: be = 6, moveDragOutlineSize: J = 4, selectionBackgroundColor: L = "rgba(16, 124, 65, 0.1)", selectionBorderColor: X = "rgb(33, 115, 70)", selectionRemoveBorderColor: Pt = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Et = "rgba(250, 10, 10, 0.1)", disableTouchSelection: xt = !1, touchSelectHandleProps: ht }) => {
711
- const ge = W(() => ({ top: P?.top ?? 0, left: P?.left ?? 0, bottom: t.current?.rowCount - 1 || 0, right: t.current?.columnCount - 1 || 0 }), []), Wt = T($, [$]), D = T(z, [z]), b = T(M, [M]), Me = T(R, [R]), oe = T(Z, [Z]), pe = T(Ne, [Ne]), Ue = T((e, a = !1) => On(e, a, o.getRowOffset, a ? ge().bottom : ge().top), [o?.getRowOffset]), lt = T(_ ?? Ue, [_]), Mt = T((e, a = !1) => On(e, a, o.getColOffset, a ? ge().right : ge().left), [o?.getColOffset]), it = T(Ie ?? Mt, [Ie]), [jt, pt] = ut(() => $t(r)), v = Ae(() => $t(jt), [jt]), re = ie(v), He = ie(!0);
658
+ !c.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(Qe.Center)), !c.vertical && (n.rowIndex > r.rowEnd || n.rowIndex < r.rowStart) && (n = { ...n, rowIndex: n.rowIndex > r.rowEnd ? r.rowEnd + 1 : r.rowEnd - 1 }, t = o.current.getViewFromLocation(Qe.Center)), t.scrollCellCoordsIntoView(n);
659
+ }, Zo = () => !1, mr = ({ gridRef: t, commands: n, layout: o, selection: r, onSelectionChange: c, onSelectionDragStart: d, onSelectionDragEnd: i, selectionPolicy: l = "multiple", newSelectionMode: w = "clear", allowDeselectSelection: L = !0, onFillPreview: O, onFillCancel: R, onFillDone: M, onFill: A, disableFillDrag: le = !A, fillHandleBorderColor: J = "white", hiddenRowsAt: te, hiddenColumnsAt: ze, isContentfulCell: Q, contentfulCellFinder: T = Ko, getDataCoords: _, alwaysScrollToActiveCoords: ve = !1, selectionBounds: W, pointerDownInterceptor: me, pointerMoveInterceptor: Ve, mergedRanges: ke, canSelectionSpanMergedCells: We = Zo, onMoveDragStart: ue, onMoveDragUpdate: ye, onMoveDragEnd: $, onMoveDragDone: p, selectionRenderer: Ne = Yo, disableMoveDrag: Xe = !$, getCellCoordsAsRangeCoords: Z = F.cellToRange, moveDragHitSize: be = 6, moveDragOutlineSize: Y = 4, selectionBackgroundColor: D = "rgba(16, 124, 65, 0.1)", selectionBorderColor: q = "rgb(33, 115, 70)", selectionRemoveBorderColor: Pt = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Et = "rgba(250, 10, 10, 0.1)", disableTouchSelection: wt = !1, touchSelectHandleProps: ut }) => {
660
+ const he = V(() => ({ top: W?.top ?? 0, left: W?.left ?? 0, bottom: t.current?.rowCount - 1 || 0, right: t.current?.columnCount - 1 || 0 }), []), Wt = P(A, [A]), k = P(O, [O]), b = P(R, [R]), Re = P(M, [M]), ne = P(Q, [Q]), we = P(Ne, [Ne]), Ue = P((e, s = !1) => On(e, s, o.getRowOffset, s ? he().bottom : he().top), [o?.getRowOffset]), lt = P(te ?? Ue, [te]), Mt = P((e, s = !1) => On(e, s, o.getColOffset, s ? he().right : he().left), [o?.getColOffset]), it = P(ze ?? Mt, [ze]), [qt, xt] = gt(() => $t(r)), v = Ae(() => $t(qt), [qt]), oe = se(v), He = se(!0);
712
661
  en(Nt.throttle(() => {
713
- pt((e) => {
662
+ xt((e) => {
714
663
  He.current = !0;
715
- const a = $t(r);
716
- return V.isEqualSelectionCoords(a, e) ? e : a;
664
+ const s = $t(r);
665
+ return F.isEqualSelectionCoords(s, e) ? e : s;
717
666
  });
718
667
  }, 0), [r]), en(() => {
719
- re.current = v;
720
- }, [v]), wt(() => {
721
- He.current || !c || V.isEqualSelectionCoords(r, v) || c(v);
668
+ oe.current = v;
669
+ }, [v]), It(() => {
670
+ He.current || !c || F.isEqualSelectionCoords(r, v) || c(v);
722
671
  }, [v]);
723
- const ft = W((e) => {
724
- pt((a) => {
725
- He.current = !1, a = $t(a);
726
- let u = typeof e == "function" ? e(a.ranges) : e ?? Jn;
727
- if (V.isEqualRangesArrays(u, a.ranges)) return a;
728
- let d = Math.max(u.length ? 0 : -1, Math.min(a.rangeIndex, u.length - 1)), g = a.cell;
729
- d === -1 || V.isCellWithinRange(g, u[d]) || (g = { rowIndex: u[d].rowStart, colIndex: u[d].colStart }), u.length === 1 && V.isSingleCell(u[0]) && V.isCellWithinRange(g, u[0]) && (u = [], d = -1);
730
- const E = { cell: g, ranges: u, rangeIndex: d };
731
- return V.isEqualSelectionCoords(E, a) ? a : E;
672
+ const ht = V((e) => {
673
+ xt((s) => {
674
+ He.current = !1, s = $t(s);
675
+ let u = typeof e == "function" ? e(s.ranges) : e ?? Gn;
676
+ if (F.isEqualRangesArrays(u, s.ranges)) return s;
677
+ let a = Math.max(u.length ? 0 : -1, Math.min(s.rangeIndex, u.length - 1)), f = s.cell;
678
+ a === -1 || F.isCellWithinRange(f, u[a]) || (f = { rowIndex: u[a].rowStart, colIndex: u[a].colStart }), u.length === 1 && F.isSingleCell(u[0]) && F.isCellWithinRange(f, u[0]) && (u = [], a = -1);
679
+ const E = { cell: f, ranges: u, rangeIndex: a };
680
+ return F.isEqualSelectionCoords(E, s) ? s : E;
732
681
  });
733
- }, []), Qe = T((e) => {
734
- pt((a) => {
735
- He.current = !1, a = $t(a);
736
- const u = e ?? Eo, d = te(u);
737
- if (!V.isSingleCell(d) && a.ranges.length === 0) return { ranges: [d], rangeIndex: 0, cell: u };
738
- if (V.isEqualCells(u, a.cell)) return a;
739
- let g = a.ranges, E = a.rangeIndex;
740
- a.ranges.length === 1 && (V.isSingleCell(a.ranges[0]) && V.isCellWithinRange(u, a.ranges[0]) || !V.isCellWithinRange(u, a.ranges[0])) && (g = [], E = -1);
741
- const x = { ranges: g, rangeIndex: E, cell: u };
742
- return V.isEqualSelectionCoords(x, a) ? a : x;
682
+ }, []), Je = P((e) => {
683
+ xt((s) => {
684
+ He.current = !1, s = $t(s);
685
+ const u = e ?? bo, a = Z(u);
686
+ if (!F.isSingleCell(a) && s.ranges.length === 0) return { ranges: [a], rangeIndex: 0, cell: u };
687
+ if (F.isEqualCells(u, s.cell)) return s;
688
+ let f = s.ranges, E = s.rangeIndex;
689
+ s.ranges.length === 1 && (F.isSingleCell(s.ranges[0]) && F.isCellWithinRange(u, s.ranges[0]) || !F.isCellWithinRange(u, s.ranges[0])) && (f = [], E = -1);
690
+ const x = { ranges: f, rangeIndex: E, cell: u };
691
+ return F.isEqualSelectionCoords(x, s) ? s : x;
743
692
  });
744
- }, [te]), [ln, Zt] = ut(null), [Dt, hn] = ut(null), Gt = ie(null), [De, Ut] = ut(null), St = ie(null), Bt = ie(null), [vn, cn] = ut(null), Ge = ie(null), Ke = ie(null), nn = ie(Pe);
745
- wt(() => {
746
- nn.current = Pe;
747
- }, [Pe]);
748
- const yt = T((e, a = { inline: "nearest", block: "nearest" }) => {
749
- let { rowIndex: u, colIndex: d } = e;
750
- u === void 0 && v?.cell && (u = v.cell.rowIndex), d === void 0 && v?.cell && (d = v.cell.colIndex), u !== void 0 && d !== void 0 && t.current?.scrollCellCoordsIntoView({ rowIndex: u, colIndex: d }, a);
751
- }, [v]), qt = W((e) => {
752
- const a = ge();
753
- return e.rowIndex < a.top || e.colIndex < a.left || e.colIndex > a.right || e.rowIndex > a.bottom;
754
- }, []), ke = T((e, a) => {
693
+ }, [Z]), [ln, _t] = gt(null), [Tt, hn] = gt(null), Gt = se(null), [Pe, Ut] = gt(null), vt = se(null), Bt = se(null), [vn, cn] = gt(null), Ge = se(null), Ke = se(null), nn = se(ke);
694
+ It(() => {
695
+ nn.current = ke;
696
+ }, [ke]);
697
+ const St = P((e, s = { inline: "nearest", block: "nearest" }) => {
698
+ let { rowIndex: u, colIndex: a } = e;
699
+ u === void 0 && v?.cell && (u = v.cell.rowIndex), a === void 0 && v?.cell && (a = v.cell.colIndex), u !== void 0 && a !== void 0 && t.current?.scrollCellCoordsIntoView({ rowIndex: u, colIndex: a }, s);
700
+ }, [v]), jt = V((e) => {
701
+ const s = he();
702
+ return e.rowIndex < s.top || e.colIndex < s.left || e.colIndex > s.right || e.rowIndex > s.bottom;
703
+ }, []), Me = P((e, s) => {
755
704
  if (!t?.current) return null;
756
- const u = { rowStart: Math.min(e.rowIndex, a.rowIndex), colStart: Math.min(e.colIndex, a.colIndex), rowEnd: Math.max(e.rowIndex, a.rowIndex), colEnd: Math.max(e.colIndex, a.colIndex) };
705
+ const u = { rowStart: Math.min(e.rowIndex, s.rowIndex), colStart: Math.min(e.colIndex, s.colIndex), rowEnd: Math.max(e.rowIndex, s.rowIndex), colEnd: Math.max(e.colIndex, s.colIndex) };
757
706
  if (We?.(u)) return u;
758
- const g = te(e), E = te(a), x = { rowStart: Math.min(g.rowStart, E.rowStart), colStart: Math.min(g.colStart, E.colStart), rowEnd: Math.max(g.rowEnd, E.rowEnd), colEnd: Math.max(g.colEnd, E.colEnd) };
759
- let G;
760
- return typeof nn.current == "function" ? G = nn.current(x) : Pe && (G = Pe), G ? V.extendRangeToUnionRanges(x, G) : x;
761
- }, [We, te]), Ze = T((e, a, u) => {
762
- const d = e.ranges.length > 0 ? e.ranges[e.rangeIndex] : { rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, g = { rowStart: Math.min(a.rowIndex ?? d.rowStart, u.rowIndex ?? d.rowStart), colStart: Math.min(a.colIndex ?? d.colStart, u.colIndex ?? d.colStart), rowEnd: Math.max(a.rowIndex ?? d.rowEnd, u.rowIndex ?? d.rowEnd), colEnd: Math.max(a.colIndex ?? d.colEnd, u.colIndex ?? d.colEnd) }, E = { rowIndex: g.rowStart, colIndex: g.colStart }, x = { rowIndex: g.rowEnd, colIndex: g.colEnd };
763
- if (!(qt(E) || qt(x)))
764
- return ke(E, x);
765
- }, [ke]), gt = T((e, a, u) => {
766
- if (l === "single" || !re.current) return;
767
- const d = Ze(re.current, e, a ?? re.current.cell);
768
- if (!d) return;
769
- const g = re.current.rangeIndex;
770
- ft((E) => E.length ? E.map((x, G) => g === G ? d : x) : [d]), u && d && Qe({ colIndex: d.colStart, rowIndex: d.rowStart });
771
- }, []), Rt = W((e, a, u) => {
772
- if (!re.current) return;
773
- e = { ...re.current?.cell, ...e }, a = a ?? e;
774
- const d = Ze(re.current, e, a);
775
- if (!d) return;
776
- const g = { rowIndex: d.rowStart, colIndex: d.colStart }, E = { ...g, ...u };
777
- h === "clear" ? (Ge.current = E, Jt()) : h === "modify" ? gt(g) : Ee(g), Qe(E);
778
- }, []), Ee = W((e, a = e, u) => {
779
- l !== "multiple" || !e || qt(e) || qt(a) || pt((d) => {
780
- He.current = !1, d = $t(d);
781
- const g = ke(e, a);
782
- if (!g) return d;
783
- let E = d.ranges.length > 0 ? [...d.ranges] : [ke(d.cell, d.cell)];
784
- E.push(g);
785
- const x = { ranges: E, cell: { rowIndex: g.rowStart, colIndex: g.colStart, ...u }, rangeIndex: E.length - 1 };
786
- return V.isEqualSelectionCoords(x, d) ? d : x;
707
+ const f = Z(e), E = Z(s), x = { rowStart: Math.min(f.rowStart, E.rowStart), colStart: Math.min(f.colStart, E.colStart), rowEnd: Math.max(f.rowEnd, E.rowEnd), colEnd: Math.max(f.colEnd, E.colEnd) };
708
+ let j;
709
+ return typeof nn.current == "function" ? j = nn.current(x) : ke && (j = ke), j ? F.extendRangeToUnionRanges(x, j) : x;
710
+ }, [We, Z]), _e = P((e, s, u) => {
711
+ const a = e.ranges.length > 0 ? e.ranges[e.rangeIndex] : { rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, f = { rowStart: Math.min(s.rowIndex ?? a.rowStart, u.rowIndex ?? a.rowStart), colStart: Math.min(s.colIndex ?? a.colStart, u.colIndex ?? a.colStart), rowEnd: Math.max(s.rowIndex ?? a.rowEnd, u.rowIndex ?? a.rowEnd), colEnd: Math.max(s.colIndex ?? a.colEnd, u.colIndex ?? a.colEnd) }, E = { rowIndex: f.rowStart, colIndex: f.colStart }, x = { rowIndex: f.rowEnd, colIndex: f.colEnd };
712
+ if (!(jt(E) || jt(x)))
713
+ return Me(E, x);
714
+ }, [Me]), ft = P((e, s, u) => {
715
+ if (l === "single" || !oe.current) return;
716
+ const a = _e(oe.current, e, s ?? oe.current.cell);
717
+ if (!a) return;
718
+ const f = oe.current.rangeIndex;
719
+ ht((E) => E.length ? E.map((x, j) => f === j ? a : x) : [a]), u && a && Je({ colIndex: a.colStart, rowIndex: a.rowStart });
720
+ }, []), Rt = V((e, s, u) => {
721
+ if (!oe.current) return;
722
+ e = { ...oe.current?.cell, ...e }, s = s ?? e;
723
+ const a = _e(oe.current, e, s);
724
+ if (!a) return;
725
+ const f = { rowIndex: a.rowStart, colIndex: a.colStart }, E = { ...f, ...u };
726
+ w === "clear" ? (Ge.current = E, Zt()) : w === "modify" ? ft(f) : Ie(f), Je(E);
727
+ }, []), Ie = V((e, s = e, u) => {
728
+ l !== "multiple" || !e || jt(e) || jt(s) || xt((a) => {
729
+ He.current = !1, a = $t(a);
730
+ const f = Me(e, s);
731
+ if (!f) return a;
732
+ let E = a.ranges.length > 0 ? [...a.ranges] : [Me(a.cell, a.cell)];
733
+ E.push(f);
734
+ const x = { ranges: E, cell: { rowIndex: f.rowStart, colIndex: f.colStart, ...u }, rangeIndex: E.length - 1 };
735
+ return F.isEqualSelectionCoords(x, a) ? a : x;
787
736
  });
788
- }, []), Jt = () => {
789
- ft(Jn);
790
- }, zt = Q.detectIt().primaryInput === "touch", ot = ie(null), kt = ie(null), Tt = ie(null), sn = Ae(() => ({ onPointerDown: (e) => {
737
+ }, []), Zt = () => {
738
+ ht(Gn);
739
+ }, zt = X.detectIt().primaryInput === "touch", ot = se(null), kt = se(null), Dt = se(null), sn = Ae(() => ({ onPointerDown: (e) => {
791
740
  if (!t || !t.current) return !1;
792
- const a = e.nativeEvent, u = t.current.getViewFromClient(a.clientX, a.clientY);
793
- if (a.pointerType === "touch" || a.type === "touchstart") return kt.current = { topLeft: u.getScrollTopLeft(), point: { x: a.clientX, y: a.clientY } }, !0;
794
- const d = u.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
795
- if (!d) return !1;
796
- ot.current = { anchor: u.getAnchor(), coords: d }, Ke.current = null;
797
- const g = e.nativeEvent.which === Xn.Right;
798
- if (g && V.indexOfCoords(d, v.ranges) !== -1)
741
+ const s = e.nativeEvent, u = t.current.getViewFromClient(s.clientX, s.clientY);
742
+ if (s.pointerType === "touch" || s.type === "touchstart") return kt.current = { topLeft: u.getScrollTopLeft(), point: { x: s.clientX, y: s.clientY } }, !0;
743
+ const a = u.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
744
+ if (!a) return !1;
745
+ ot.current = { anchor: u.getAnchor(), coords: a }, Ke.current = null;
746
+ const f = e.nativeEvent.which === jn.Right;
747
+ if (f && F.indexOfCoords(a, v.ranges) !== -1)
799
748
  return !1;
800
- const E = e.nativeEvent.shiftKey, x = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, G = x, F = O, N = v.ranges.length > 0, ee = x && F;
801
- if (ce?.(e, d, v) === !1) return !1;
802
- s?.(re.current, e.nativeEvent);
803
- const Se = !g && l !== "single";
804
- if (E) return gt(d), Se;
805
- const j = V.isEqualCells(d, v.cell);
806
- if (G) {
807
- if (j && (!ee || !N)) return Se;
808
- if (x && V.indexOfCoords(d, v.ranges) !== -1 && F) {
809
- St.current = d;
810
- const K = ke(d, d);
811
- return Bt.current = K, Ut(K), Se;
749
+ const E = e.nativeEvent.shiftKey, x = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, j = x, B = L, H = v.ranges.length > 0, G = x && B;
750
+ if (me?.(e, a, v) === !1) return !1;
751
+ d?.(oe.current, e.nativeEvent);
752
+ const Se = !f && l !== "single";
753
+ if (E) return ft(a), Se;
754
+ const K = F.isEqualCells(a, v.cell);
755
+ if (j) {
756
+ if (K && (!G || !H)) return Se;
757
+ if (x && F.indexOfCoords(a, v.ranges) !== -1 && B) {
758
+ vt.current = a;
759
+ const N = Me(a, a);
760
+ return Bt.current = N, Ut(N), Se;
812
761
  }
813
- return Ee(d), Se;
762
+ return Ie(a), Se;
814
763
  }
815
- he && yt(d), j && v.ranges.length === 0 || Rt(d);
816
- }, onPointerMoveOrWait: Nt.throttle((e, a) => {
764
+ ve && St(a), K && v.ranges.length === 0 || Rt(a);
765
+ }, onPointerMoveOrWait: Nt.throttle((e, s) => {
817
766
  if (!t?.current || e.pointerType === "touch" || e.type === "touchmove" || !ot.current) return;
818
767
  const u = ot.current.anchor;
819
- let d = t.current.getViewFromLocation(u), g = d.getCellCoordsFromClient(e.clientX, e.clientY);
820
- if (!V.isEqualCells(g, ot.current?.coords) && (ot.current = { anchor: u, coords: g }, g && Ve?.(e, g, re.current) !== !1)) {
821
- if (St.current) {
822
- const E = { rowStart: Math.min(g.rowIndex, St.current.rowIndex), colStart: Math.min(g.colIndex, St.current.colIndex), rowEnd: Math.max(g.rowIndex, St.current.rowIndex), colEnd: Math.max(g.colIndex, St.current.colIndex) }, x = { rowIndex: E.rowStart, colIndex: E.colStart }, G = { rowIndex: E.rowEnd, colIndex: E.colEnd };
823
- if (qt(x) || qt(G)) return;
824
- const F = ke(x, G);
825
- Bt.current = F, Ut(F);
826
- } else gt(g);
827
- Tt.current = a, Dn(d, g, t);
768
+ let a = t.current.getViewFromLocation(u), f = a.getCellCoordsFromClient(e.clientX, e.clientY);
769
+ if (!F.isEqualCells(f, ot.current?.coords) && (ot.current = { anchor: u, coords: f }, f && Ve?.(e, f, oe.current) !== !1)) {
770
+ if (vt.current) {
771
+ const E = { rowStart: Math.min(f.rowIndex, vt.current.rowIndex), colStart: Math.min(f.colIndex, vt.current.colIndex), rowEnd: Math.max(f.rowIndex, vt.current.rowIndex), colEnd: Math.max(f.colIndex, vt.current.colIndex) }, x = { rowIndex: E.rowStart, colIndex: E.colStart }, j = { rowIndex: E.rowEnd, colIndex: E.colEnd };
772
+ if (jt(x) || jt(j)) return;
773
+ const B = Me(x, j);
774
+ Bt.current = B, Ut(B);
775
+ } else ft(f);
776
+ Dt.current = s, Tn(a, f, t);
828
777
  }
829
778
  }, 60), onPointerUp: (e) => {
830
779
  if (ot.current = null, e.pointerType === "touch" || e.type === "touchend") {
831
780
  if (kt.current) {
832
- const u = t.current.getViewFromClient(kt.current.point.x, kt.current.point.y), d = u.getScrollTopLeft();
833
- if (d.left === kt.current.topLeft.left && d.top === kt.current.topLeft.top) {
834
- const g = u.getCellCoordsFromClient(kt.current.point.x, kt.current.point.y);
835
- Rt(g);
781
+ const u = t.current.getViewFromClient(kt.current.point.x, kt.current.point.y), a = u.getScrollTopLeft();
782
+ if (a.left === kt.current.topLeft.left && a.top === kt.current.topLeft.top) {
783
+ const f = u.getCellCoordsFromClient(kt.current.point.x, kt.current.point.y);
784
+ Rt(f);
836
785
  }
837
786
  }
838
787
  return kt.current = null, void (ot.current = null);
839
788
  }
840
789
  try {
841
- i?.(re.current, e);
790
+ i?.(oe.current, e);
842
791
  } catch (u) {
843
792
  console.warn(u);
844
793
  }
845
- if (!St.current) return;
846
- const a = Bt.current;
847
- St.current = null, Bt.current = null, Ut(null), pt((u) => {
794
+ if (!vt.current) return;
795
+ const s = Bt.current;
796
+ vt.current = null, Bt.current = null, Ut(null), xt((u) => {
848
797
  if (He.current = !1, (u = $t(u)).ranges.length === 0) return u;
849
- let d = [], g = -1, E = u.cell;
850
- for (let G = 0; G < u.ranges.length; G++) {
851
- const F = u.ranges[G];
852
- if (V.isRangesIntersect(F, a)) {
853
- const N = Nt.subtractRect({ top: F.rowStart, left: F.colStart, bottom: F.rowEnd + 1, right: F.colEnd + 1 }, { top: a.rowStart, left: a.colStart, bottom: a.rowEnd + 1, right: a.colEnd + 1 });
854
- for (let ee = 0; ee < N.length; ee++) {
855
- const Se = { rowStart: N[ee].top, colStart: N[ee].left, rowEnd: N[ee].bottom - 1, colEnd: N[ee].right - 1 };
856
- d.push(Se), V.isCellWithinRange(u.cell, Se) && (g = d.length - 1);
798
+ let a = [], f = -1, E = u.cell;
799
+ for (let j = 0; j < u.ranges.length; j++) {
800
+ const B = u.ranges[j];
801
+ if (F.isRangesIntersect(B, s)) {
802
+ const H = Nt.subtractRect({ top: B.rowStart, left: B.colStart, bottom: B.rowEnd + 1, right: B.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
803
+ for (let G = 0; G < H.length; G++) {
804
+ const Se = { rowStart: H[G].top, colStart: H[G].left, rowEnd: H[G].bottom - 1, colEnd: H[G].right - 1 };
805
+ a.push(Se), F.isCellWithinRange(u.cell, Se) && (f = a.length - 1);
857
806
  }
858
- } else d.push(F);
859
- d.length > 0 && g === -1 && V.isCellWithinRange(u.cell, F) && (g = d.length - 1, E = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
807
+ } else a.push(B);
808
+ a.length > 0 && f === -1 && F.isCellWithinRange(u.cell, B) && (f = a.length - 1, E = { rowIndex: a[a.length - 1].rowStart, colIndex: a[a.length - 1].colStart });
860
809
  }
861
- const x = { cell: E, rangeIndex: g, ranges: d };
862
- return V.isEqualSelectionCoords(x, u) ? u : x;
810
+ const x = { cell: E, rangeIndex: f, ranges: a };
811
+ return F.isEqualSelectionCoords(x, u) ? u : x;
863
812
  });
864
- }, processTouch: !0, consumeTouch: !1 }), [v, l, O, he, h]), Ln = T(un(sn), []), $n = Ae(() => ({ onSelectionPointerDown: (e, a, u, d, g = v.cell, E = he, x = e.nativeEvent.shiftKey, G = !1) => {
813
+ }, processTouch: !0, consumeTouch: !1 }), [v, l, L, ve, w]), zn = P(un(sn), []), Ln = Ae(() => ({ onSelectionPointerDown: (e, s, u, a, f = v.cell, E = ve, x = e.nativeEvent.shiftKey, j = !1) => {
865
814
  if (!t || !t.current) return !1;
866
815
  e.stopPropagation(), e.preventDefault(), e.nativeEvent.stopImmediatePropagation();
867
- const F = u ?? t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), N = d ?? F.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
868
- if (!N) return !1;
869
- ot.current = { anchor: F.getAnchor(), coords: N }, Ke.current = null;
870
- const ee = e.nativeEvent.which === Xn.Right;
871
- if (ee && V.indexOfCoords(N, v.ranges) !== -1)
816
+ const B = u ?? t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), H = a ?? B.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
817
+ if (!H) return !1;
818
+ ot.current = { anchor: B.getAnchor(), coords: H }, Ke.current = null;
819
+ const G = e.nativeEvent.which === jn.Right;
820
+ if (G && F.indexOfCoords(H, v.ranges) !== -1)
872
821
  return !1;
873
- const Se = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, j = Se, K = O, dt = v.ranges.length > 0, I = Se && K;
874
- if (ce?.(e, N, v) === !1) return !1;
875
- s?.(re.current, e.nativeEvent);
876
- const ve = !ee && l !== "single";
877
- if (x) return gt(N, g, G), ve;
878
- const It = V.isEqualCells(N, g);
879
- if (j) {
880
- if (It && (!I || !dt)) return ve;
881
- if (I && V.indexOfCoords(N, v.ranges) !== -1 && K) {
882
- St.current = N;
883
- const xe = ke(N, N);
884
- return Bt.current = xe, Ut(xe), ve;
822
+ const Se = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, K = Se, N = L, dt = v.ranges.length > 0, I = Se && N;
823
+ if (me?.(e, H, v) === !1) return !1;
824
+ d?.(oe.current, e.nativeEvent);
825
+ const pe = !G && l !== "single";
826
+ if (x) return ft(H, f, j), pe;
827
+ const Ct = F.isEqualCells(H, f);
828
+ if (K) {
829
+ if (Ct && (!I || !dt)) return pe;
830
+ if (I && F.indexOfCoords(H, v.ranges) !== -1 && N) {
831
+ vt.current = H;
832
+ const ge = Me(H, H);
833
+ return Bt.current = ge, Ut(ge), pe;
885
834
  }
886
- return Ee(N), ve;
835
+ return Ie(H), pe;
887
836
  }
888
- E && yt(N), It && v.ranges.length === 0 || Rt(N);
889
- }, onSelectionPointerMoveOrWait: (e, a, u, d, g, E = v.cell, x = !0, G = !1) => {
837
+ E && St(H), Ct && v.ranges.length === 0 || Rt(H);
838
+ }, onSelectionPointerMoveOrWait: (e, s, u, a, f, E = v.cell, x = !0, j = !1) => {
890
839
  if (!t?.current || (e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation(), !ot.current)) return;
891
- const F = ot.current.anchor;
892
- let N = d ?? t.current.getViewFromLocation(F), ee = g ?? N.getCellCoordsFromClient(e.clientX, e.clientY);
893
- if (!V.isEqualCells(ee, ot.current?.coords) && (ot.current = { anchor: F, coords: ee }, ee && Ve?.(e, ee, re.current) !== !1)) {
894
- if (St.current) {
895
- const Se = { rowStart: Math.min(ee.rowIndex, St.current.rowIndex), colStart: Math.min(ee.colIndex, St.current.colIndex), rowEnd: Math.max(ee.rowIndex, St.current.rowIndex), colEnd: Math.max(ee.colIndex, St.current.colIndex) }, j = { rowIndex: Se.rowStart, colIndex: Se.colStart }, K = { rowIndex: Se.rowEnd, colIndex: Se.colEnd };
896
- if (qt(j) || qt(K)) return;
897
- const dt = ke(j, K);
840
+ const B = ot.current.anchor;
841
+ let H = a ?? t.current.getViewFromLocation(B), G = f ?? H.getCellCoordsFromClient(e.clientX, e.clientY);
842
+ if (!F.isEqualCells(G, ot.current?.coords) && (ot.current = { anchor: B, coords: G }, G && Ve?.(e, G, oe.current) !== !1)) {
843
+ if (vt.current) {
844
+ const Se = { rowStart: Math.min(G.rowIndex, vt.current.rowIndex), colStart: Math.min(G.colIndex, vt.current.colIndex), rowEnd: Math.max(G.rowIndex, vt.current.rowIndex), colEnd: Math.max(G.colIndex, vt.current.colIndex) }, K = { rowIndex: Se.rowStart, colIndex: Se.colStart }, N = { rowIndex: Se.rowEnd, colIndex: Se.colEnd };
845
+ if (jt(K) || jt(N)) return;
846
+ const dt = Me(K, N);
898
847
  Bt.current = dt, Ut(dt);
899
- } else gt(ee, E, G);
900
- x && Dn(N, ee, t);
848
+ } else ft(G, E, j);
849
+ x && Tn(H, G, t);
901
850
  }
902
851
  }, onPointerUp: (e) => {
903
852
  ot.current = null, e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
904
853
  try {
905
- i?.(re.current, e);
854
+ i?.(oe.current, e);
906
855
  } catch (u) {
907
856
  console.warn(u);
908
857
  }
909
- if (!St.current) return;
910
- const a = Bt.current;
911
- St.current = null, Bt.current = null, Ut(null), pt((u) => {
858
+ if (!vt.current) return;
859
+ const s = Bt.current;
860
+ vt.current = null, Bt.current = null, Ut(null), xt((u) => {
912
861
  if (He.current = !1, (u = $t(u)).ranges.length === 0) return u;
913
- let d = [], g = -1, E = u.cell;
914
- for (let G = 0; G < u.ranges.length; G++) {
915
- const F = u.ranges[G];
916
- if (V.isRangesIntersect(F, a)) {
917
- const N = Nt.subtractRect({ top: F.rowStart, left: F.colStart, bottom: F.rowEnd + 1, right: F.colEnd + 1 }, { top: a.rowStart, left: a.colStart, bottom: a.rowEnd + 1, right: a.colEnd + 1 });
918
- for (let ee = 0; ee < N.length; ee++) {
919
- const Se = { rowStart: N[ee].top, colStart: N[ee].left, rowEnd: N[ee].bottom - 1, colEnd: N[ee].right - 1 };
920
- d.push(Se), V.isCellWithinRange(u.cell, Se) && (g = d.length - 1);
862
+ let a = [], f = -1, E = u.cell;
863
+ for (let j = 0; j < u.ranges.length; j++) {
864
+ const B = u.ranges[j];
865
+ if (F.isRangesIntersect(B, s)) {
866
+ const H = Nt.subtractRect({ top: B.rowStart, left: B.colStart, bottom: B.rowEnd + 1, right: B.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
867
+ for (let G = 0; G < H.length; G++) {
868
+ const Se = { rowStart: H[G].top, colStart: H[G].left, rowEnd: H[G].bottom - 1, colEnd: H[G].right - 1 };
869
+ a.push(Se), F.isCellWithinRange(u.cell, Se) && (f = a.length - 1);
921
870
  }
922
- } else d.push(F);
923
- d.length > 0 && g === -1 && V.isCellWithinRange(u.cell, F) && (g = d.length - 1, E = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
871
+ } else a.push(B);
872
+ a.length > 0 && f === -1 && F.isCellWithinRange(u.cell, B) && (f = a.length - 1, E = { rowIndex: a[a.length - 1].rowStart, colIndex: a[a.length - 1].colStart });
924
873
  }
925
- const x = { cell: E, rangeIndex: g, ranges: d };
926
- return V.isEqualSelectionCoords(x, u) ? u : x;
874
+ const x = { cell: E, rangeIndex: f, ranges: a };
875
+ return F.isEqualSelectionCoords(x, u) ? u : x;
927
876
  });
928
- } }), [v, l, O, he, h]), rt = T((e, a = !1, u = !1, d = 0) => {
877
+ } }), [v, l, L, ve, w]), rt = P((e, s = !1, u = !1, a = 0) => {
929
878
  if (!t.current || !v.cell) return;
930
- let g = v.cell, E = v.cell;
931
- if (a && v.ranges.length > 0) {
932
- const I = v.ranges[v.rangeIndex], ve = v.cell;
879
+ let f = v.cell, E = v.cell;
880
+ if (s && v.ranges.length > 0) {
881
+ const I = v.ranges[v.rangeIndex], pe = v.cell;
933
882
  switch (e) {
934
- case w.Up:
935
- E = { rowIndex: ve.rowIndex === I.rowStart ? I.rowEnd : I.rowStart, colIndex: I.colEnd }, g = { rowIndex: ve.rowIndex === I.rowStart ? I.rowStart : I.rowEnd, colIndex: I.colStart };
883
+ case g.Up:
884
+ E = { rowIndex: pe.rowIndex === I.rowStart ? I.rowEnd : I.rowStart, colIndex: I.colEnd }, f = { rowIndex: pe.rowIndex === I.rowStart ? I.rowStart : I.rowEnd, colIndex: I.colStart };
936
885
  break;
937
- case w.Down:
938
- E = { rowIndex: ve.rowIndex === I.rowEnd ? I.rowStart : I.rowEnd, colIndex: I.colEnd }, g = { rowIndex: ve.rowIndex === I.rowEnd ? I.rowEnd : I.rowStart, colIndex: I.colStart };
886
+ case g.Down:
887
+ E = { rowIndex: pe.rowIndex === I.rowEnd ? I.rowStart : I.rowEnd, colIndex: I.colEnd }, f = { rowIndex: pe.rowIndex === I.rowEnd ? I.rowEnd : I.rowStart, colIndex: I.colStart };
939
888
  break;
940
- case w.Left:
941
- E = { rowIndex: I.rowEnd, colIndex: ve.colIndex === I.colStart ? I.colEnd : I.colStart }, g = { rowIndex: I.rowStart, colIndex: ve.colIndex === I.colStart ? I.colStart : I.colEnd };
889
+ case g.Left:
890
+ E = { rowIndex: I.rowEnd, colIndex: pe.colIndex === I.colStart ? I.colEnd : I.colStart }, f = { rowIndex: I.rowStart, colIndex: pe.colIndex === I.colStart ? I.colStart : I.colEnd };
942
891
  break;
943
- case w.Right:
944
- E = { rowIndex: I.rowEnd, colIndex: ve.colIndex === I.colEnd ? I.colStart : I.colEnd }, g = { rowIndex: I.rowStart, colIndex: ve.colIndex === I.colEnd ? I.colEnd : I.colStart };
892
+ case g.Right:
893
+ E = { rowIndex: I.rowEnd, colIndex: pe.colIndex === I.colEnd ? I.colStart : I.colEnd }, f = { rowIndex: I.rowStart, colIndex: pe.colIndex === I.colEnd ? I.colEnd : I.colStart };
945
894
  }
946
895
  }
947
- const x = te(E);
948
- let { rowStart: G, colStart: F } = x;
949
- const N = ge();
896
+ const x = Z(E);
897
+ let { rowStart: j, colStart: B } = x;
898
+ const H = he();
950
899
  if (Ke.current) switch (e) {
951
- case w.Up:
952
- case w.Down:
953
- Ke.current.colIndex >= x.colStart && Ke.current.colIndex <= x.colEnd && (F = Ke.current.colIndex);
900
+ case g.Up:
901
+ case g.Down:
902
+ Ke.current.colIndex >= x.colStart && Ke.current.colIndex <= x.colEnd && (B = Ke.current.colIndex);
954
903
  break;
955
- case w.Left:
956
- case w.Right:
957
- Ke.current.rowIndex >= x.rowStart && Ke.current.rowIndex <= x.rowEnd && (G = Ke.current.rowIndex);
904
+ case g.Left:
905
+ case g.Right:
906
+ Ke.current.rowIndex >= x.rowStart && Ke.current.rowIndex <= x.rowEnd && (j = Ke.current.rowIndex);
958
907
  }
959
- if (!d) {
908
+ if (!a) {
960
909
  switch (e) {
961
- case w.Up:
962
- G = Fe(lt, Math.max(x.rowStart - 1, N.top), e);
910
+ case g.Up:
911
+ j = Fe(lt, Math.max(x.rowStart - 1, H.top), e);
963
912
  break;
964
- case w.Down:
965
- G = Fe(lt, Math.min(x.rowEnd + 1, N.bottom), e);
913
+ case g.Down:
914
+ j = Fe(lt, Math.min(x.rowEnd + 1, H.bottom), e);
966
915
  break;
967
- case w.Left:
968
- F = Fe(it, Math.max(x.colStart - 1, N.left), e);
916
+ case g.Left:
917
+ B = Fe(it, Math.max(x.colStart - 1, H.left), e);
969
918
  break;
970
- case w.Right:
971
- F = Fe(it, Math.min(x.colEnd + 1, N.right), e);
919
+ case g.Right:
920
+ B = Fe(it, Math.min(x.colEnd + 1, H.right), e);
972
921
  }
973
922
  if (u) switch (e) {
974
- case w.Up:
975
- G = k({ ...E, colIndex: v.cell.colIndex }, oe, lt, e, !1, Math.max(N.top, lt(N.top, !1)));
923
+ case g.Up:
924
+ j = T({ ...E, colIndex: v.cell.colIndex }, ne, lt, e, !1, Math.max(H.top, lt(H.top, !1)));
976
925
  break;
977
- case w.Down:
978
- G = k({ ...E, colIndex: v.cell.colIndex }, oe, lt, e, !1, Math.min(N.bottom, N.bottom - lt(N.bottom, !0)));
926
+ case g.Down:
927
+ j = T({ ...E, colIndex: v.cell.colIndex }, ne, lt, e, !1, Math.min(H.bottom, H.bottom - lt(H.bottom, !0)));
979
928
  break;
980
- case w.Left:
981
- F = k({ ...E, rowIndex: v.cell.rowIndex }, oe, it, e, !1, Math.max(N.left, it(N.left, !1)));
929
+ case g.Left:
930
+ B = T({ ...E, rowIndex: v.cell.rowIndex }, ne, it, e, !1, Math.max(H.left, it(H.left, !1)));
982
931
  break;
983
- case w.Right:
984
- F = k({ ...E, rowIndex: v.cell.rowIndex }, oe, it, e, !1, Math.min(N.right, N.right - it(N.right, !0)));
932
+ case g.Right:
933
+ B = T({ ...E, rowIndex: v.cell.rowIndex }, ne, it, e, !1, Math.min(H.right, H.right - it(H.right, !0)));
985
934
  }
986
935
  }
987
- let ee = null;
988
- if (d) {
936
+ let G = null;
937
+ if (a) {
989
938
  let I = 0;
990
939
  switch (e) {
991
- case w.Up:
992
- I = o.getRowOffset(G + 1), G = Math.max(N.top, o.getRowIndex(I - d)), ee = { top: o.getRowOffset(G + 1) - (I - t.current.getScrollPosition().top) };
940
+ case g.Up:
941
+ I = o.getRowOffset(j + 1), j = Math.max(H.top, o.getRowIndex(I - a)), G = { top: o.getRowOffset(j + 1) - (I - t.current.getScrollPosition().top) };
993
942
  break;
994
- case w.Down:
995
- I = o.getRowOffset(G), G = Math.min(N.bottom, o.getRowIndex(I + d)), ee = { top: o.getRowOffset(G) - (I - t.current.getScrollPosition().top) };
943
+ case g.Down:
944
+ I = o.getRowOffset(j), j = Math.min(H.bottom, o.getRowIndex(I + a)), G = { top: o.getRowOffset(j) - (I - t.current.getScrollPosition().top) };
996
945
  break;
997
- case w.Left:
998
- I = o.getColOffset(F + 1), F = Math.max(N.left, o.getColIndex(I - d)), ee = { left: o.getColOffset(F + 1) - (I - t.current.getScrollPosition().left) };
946
+ case g.Left:
947
+ I = o.getColOffset(B + 1), B = Math.max(H.left, o.getColIndex(I - a)), G = { left: o.getColOffset(B + 1) - (I - t.current.getScrollPosition().left) };
999
948
  break;
1000
- case w.Right:
1001
- I = o.getColOffset(F), F = Math.min(N.right, o.getColIndex(I + d)), ee = { left: o.getColOffset(F) - (I - t.current.getScrollPosition().left) };
949
+ case g.Right:
950
+ I = o.getColOffset(B), B = Math.min(H.right, o.getColIndex(I + a)), G = { left: o.getColOffset(B) - (I - t.current.getScrollPosition().left) };
1002
951
  }
1003
952
  }
1004
- const Se = { rowIndex: G, colIndex: F }, j = te(Se), K = { rowIndex: j.rowStart, colIndex: j.colStart };
1005
- a || (Ke.current = Se);
1006
- const dt = V.isEqualCells(Ge.current, K) && V.isEqualCells(Ge.current, g);
1007
- if (a && !dt ? gt(K, g) : Rt(K), ee) t.current.scrollTo(ee);
953
+ const Se = { rowIndex: j, colIndex: B }, K = Z(Se), N = { rowIndex: K.rowStart, colIndex: K.colStart };
954
+ s || (Ke.current = Se);
955
+ const dt = F.isEqualCells(Ge.current, N) && F.isEqualCells(Ge.current, f);
956
+ if (s && !dt ? ft(N, f) : Rt(N), G) t.current.scrollTo(G);
1008
957
  else {
1009
- if (a && Ge.current) {
1010
- const I = ge();
1011
- if (e === w.Right && Ge.current.colIndex === I.left || e === w.Left && Ge.current.colIndex === I.right || e === w.Up && Ge.current.rowIndex === I.bottom || e === w.Down && Ge.current.rowIndex === I.top) return;
958
+ if (s && Ge.current) {
959
+ const I = he();
960
+ if (e === g.Right && Ge.current.colIndex === I.left || e === g.Left && Ge.current.colIndex === I.right || e === g.Up && Ge.current.rowIndex === I.bottom || e === g.Down && Ge.current.rowIndex === I.top) return;
1012
961
  }
1013
- e === w.Left || e === w.Right ? yt({ colIndex: Se.colIndex }) : e !== w.Up && e !== w.Down || yt({ rowIndex: Se.rowIndex });
962
+ e === g.Left || e === g.Right ? St({ colIndex: Se.colIndex }) : e !== g.Up && e !== g.Down || St({ rowIndex: Se.rowIndex });
1014
963
  }
1015
- }, [v, te]), Yt = T((e) => {
964
+ }, [v, Z]), Yt = P((e) => {
1016
965
  if (!t.current) return;
1017
966
  if (v.ranges.length === 0) return void rt(e);
1018
- const a = te(v.cell);
1019
- if (V.isEqualRangesArrays([a], v.ranges)) return void rt(e);
1020
- const u = Gn(v, e, te, lt, it);
1021
- pt((d) => {
1022
- He.current = !1, d = $t(d);
1023
- const g = { ...d, cell: u.cell, rangeIndex: u.rangeIndex };
1024
- return V.isEqualSelectionCoords(g, d) ? d : g;
1025
- }), u.cell && yt(u.cell);
1026
- }, [v, te]), Bn = W(() => {
1027
- const e = ge();
1028
- gt({ rowIndex: e.top }, { rowIndex: e.bottom });
1029
- }, []), An = W(() => {
1030
- const e = ge();
1031
- gt({ colIndex: e.left }, { colIndex: e.right });
1032
- }, []), Qt = T(() => {
1033
- v.cell && t?.current && yt(v.cell);
1034
- }, [v.cell]), Sn = W((e = !1) => {
1035
- const a = { rowIndex: ge().top };
1036
- e ? gt(a) : Rt(a), yt(a);
1037
- }, []), yn = W((e = !1) => {
1038
- const a = { rowIndex: ge().bottom };
1039
- e ? gt(a) : Rt(a), yt(a);
1040
- }, []), fn = W((e = !1) => {
1041
- const a = { colIndex: ge().left };
1042
- e ? gt(a) : Rt(a), yt(a);
1043
- }, []), an = W((e = !1) => {
1044
- const a = ge(), u = { rowIndex: a.top, colIndex: a.left };
1045
- e ? gt(u) : Rt(u), yt(u);
1046
- }, []), gn = W((e = !1) => {
1047
- const a = ge(), u = { colIndex: U?.()?.colEnd ?? a.right };
1048
- e ? gt(u) : Rt(u), yt(u);
1049
- }, [U]), on = W((e = !1) => {
1050
- const a = ge(), u = { rowIndex: U?.()?.rowEnd ?? a.bottom, colIndex: U?.()?.colEnd ?? a.right };
1051
- e ? gt(u) : Rt(u), yt(u);
1052
- }, [U]), wn = T((e) => {
967
+ const s = Z(v.cell);
968
+ if (F.isEqualRangesArrays([s], v.ranges)) return void rt(e);
969
+ const u = Yn(v, e, Z, lt, it);
970
+ xt((a) => {
971
+ He.current = !1, a = $t(a);
972
+ const f = { ...a, cell: u.cell, rangeIndex: u.rangeIndex };
973
+ return F.isEqualSelectionCoords(f, a) ? a : f;
974
+ }), u.cell && St(u.cell);
975
+ }, [v, Z]), $n = V(() => {
976
+ const e = he();
977
+ ft({ rowIndex: e.top }, { rowIndex: e.bottom });
978
+ }, []), Bn = V(() => {
979
+ const e = he();
980
+ ft({ colIndex: e.left }, { colIndex: e.right });
981
+ }, []), Jt = P(() => {
982
+ v.cell && t?.current && St(v.cell);
983
+ }, [v.cell]), Sn = V((e = !1) => {
984
+ const s = { rowIndex: he().top };
985
+ e ? ft(s) : Rt(s), St(s);
986
+ }, []), yn = V((e = !1) => {
987
+ const s = { rowIndex: he().bottom };
988
+ e ? ft(s) : Rt(s), St(s);
989
+ }, []), fn = V((e = !1) => {
990
+ const s = { colIndex: he().left };
991
+ e ? ft(s) : Rt(s), St(s);
992
+ }, []), an = V((e = !1) => {
993
+ const s = he(), u = { rowIndex: s.top, colIndex: s.left };
994
+ e ? ft(u) : Rt(u), St(u);
995
+ }, []), gn = V((e = !1) => {
996
+ const s = he(), u = { colIndex: _?.()?.colEnd ?? s.right };
997
+ e ? ft(u) : Rt(u), St(u);
998
+ }, [_]), on = V((e = !1) => {
999
+ const s = he(), u = { rowIndex: _?.()?.rowEnd ?? s.bottom, colIndex: _?.()?.colEnd ?? s.right };
1000
+ e ? ft(u) : Rt(u), St(u);
1001
+ }, [_]), wn = P((e) => {
1053
1002
  if (!t.current || v.ranges.length <= 1) return;
1054
- const a = e === w.Left || e === w.Up;
1055
- let u = v.rangeIndex + (a ? -1 : 1);
1003
+ const s = e === g.Left || e === g.Up;
1004
+ let u = v.rangeIndex + (s ? -1 : 1);
1056
1005
  u < 0 ? u = v.ranges.length - 1 : u > v.ranges.length - 1 && (u = 0);
1057
- const d = v.ranges[u], g = Gn({ cell: { rowIndex: d.rowEnd, colIndex: d.colEnd }, rangeIndex: 0, ranges: [d] }, w.Right, te, lt, it);
1058
- pt((E) => {
1006
+ const a = v.ranges[u], f = Yn({ cell: { rowIndex: a.rowEnd, colIndex: a.colEnd }, rangeIndex: 0, ranges: [a] }, g.Right, Z, lt, it);
1007
+ xt((E) => {
1059
1008
  He.current = !1, E = $t(E);
1060
- const x = { ...E, cell: g.cell, rangeIndex: u };
1061
- return V.isEqualSelectionCoords(x, E) ? E : x;
1062
- }), g.cell && yt(g.cell);
1063
- }, [v, te]), Fn = T(() => {
1064
- const e = lo(v);
1065
- pt((a) => {
1066
- He.current = !1, a = $t(a);
1067
- const u = { ...a, visibleSelection: e };
1068
- return V.isEqualSelectionCoords(u, a) ? a : u;
1069
- }), e.cell && yt(e.cell);
1070
- }, [v, te]), Vn = T(() => {
1009
+ const x = { ...E, cell: f.cell, rangeIndex: u };
1010
+ return F.isEqualSelectionCoords(x, E) ? E : x;
1011
+ }), f.cell && St(f.cell);
1012
+ }, [v, Z]), An = P(() => {
1013
+ const e = oo(v);
1014
+ xt((s) => {
1015
+ He.current = !1, s = $t(s);
1016
+ const u = { ...s, visibleSelection: e };
1017
+ return F.isEqualSelectionCoords(u, s) ? s : u;
1018
+ }), e.cell && St(e.cell);
1019
+ }, [v, Z]), Fn = P(() => {
1071
1020
  if (!t.current || v.ranges.length === 0) return;
1072
- const e = v.cell, a = v.ranges[v.rangeIndex], u = lo({ cell: e, rangeIndex: 0, ranges: [a] }), d = u.ranges[u.rangeIndex];
1073
- let g;
1074
- g = d.rowStart === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowStart, colIndex: d.colEnd } : d.rowStart === e.rowIndex && d.colEnd === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colStart } : d.rowEnd === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colEnd } : { rowIndex: d.rowStart, colIndex: d.colStart }, pt((E) => {
1021
+ const e = v.cell, s = v.ranges[v.rangeIndex], u = oo({ cell: e, rangeIndex: 0, ranges: [s] }), a = u.ranges[u.rangeIndex];
1022
+ let f;
1023
+ f = a.rowStart === e.rowIndex && a.colStart === e.colIndex ? { rowIndex: a.rowStart, colIndex: a.colEnd } : a.rowStart === e.rowIndex && a.colEnd === e.colIndex ? { rowIndex: a.rowEnd, colIndex: a.colStart } : a.rowEnd === e.rowIndex && a.colStart === e.colIndex ? { rowIndex: a.rowEnd, colIndex: a.colEnd } : { rowIndex: a.rowStart, colIndex: a.colStart }, xt((E) => {
1075
1024
  E = $t(E);
1076
- const x = { ...E, cell: g };
1077
- return V.isEqualSelectionCoords(x, E) ? E : x;
1078
- }), g && yt(g);
1079
- }, [v, te]), bn = W((e = !1) => {
1080
- rt(w.Down, e, !1, t.current.getDimensions().containerHeight);
1081
- }, []), At = W((e = !1) => {
1082
- rt(w.Up, e, !1, t.current.getDimensions().containerHeight);
1083
- }, []), Cn = W((e = !1) => {
1084
- rt(w.Right, e, !1, t.current.getDimensions().containerWidth);
1085
- }, []), xn = W((e = !1) => {
1086
- rt(w.Left, e, !1, t.current.getDimensions().containerWidth);
1087
- }, []), In = W(() => {
1088
- Yt(w.Left);
1089
- }, []), En = W(() => {
1090
- Yt(w.Right);
1091
- }, []), Wn = W(() => {
1092
- Yt(w.Up);
1093
- }, []), Un = W(() => {
1094
- Yt(w.Down);
1095
- }, []), pn = W(() => {
1096
- wn(w.Left);
1097
- }, []), Hn = W(() => {
1098
- wn(w.Right);
1099
- }, []), Nn = W(() => {
1100
- Vn();
1101
- }, []), Rn = W(() => {
1102
- rt(w.Left, !1, !1);
1103
- }, []), f = W(() => {
1104
- rt(w.Left, !0, !1);
1105
- }, []), m = W(() => {
1106
- rt(w.Left, !1, !0);
1107
- }, []), C = W(() => {
1108
- rt(w.Left, !0, !0);
1109
- }, []), S = W(() => {
1110
- rt(w.Right, !1, !1);
1111
- }, []), y = W(() => {
1112
- rt(w.Right, !0, !1);
1113
- }, []), B = W(() => {
1114
- rt(w.Right, !1, !0);
1115
- }, []), me = W(() => {
1116
- rt(w.Right, !0, !0);
1117
- }, []), le = W(() => {
1118
- rt(w.Up, !1, !1);
1119
- }, []), we = W(() => {
1120
- rt(w.Up, !0, !1);
1121
- }, []), H = W(() => {
1122
- rt(w.Up, !1, !0);
1123
- }, []), Re = W(() => {
1124
- rt(w.Up, !0, !0);
1125
- }, []), je = W(() => {
1126
- rt(w.Down, !1, !1);
1127
- }, []), $e = W(() => {
1128
- rt(w.Down, !0, !1);
1129
- }, []), Je = W(() => {
1130
- rt(w.Down, !1, !0);
1131
- }, []), Te = W(() => {
1132
- rt(w.Down, !0, !0);
1133
- }, []), de = W(() => {
1134
- ft((e) => e.slice(0, -1));
1025
+ const x = { ...E, cell: f };
1026
+ return F.isEqualSelectionCoords(x, E) ? E : x;
1027
+ }), f && St(f);
1028
+ }, [v, Z]), bn = V((e = !1) => {
1029
+ rt(g.Down, e, !1, t.current.getDimensions().containerHeight);
1030
+ }, []), At = V((e = !1) => {
1031
+ rt(g.Up, e, !1, t.current.getDimensions().containerHeight);
1032
+ }, []), Cn = V((e = !1) => {
1033
+ rt(g.Right, e, !1, t.current.getDimensions().containerWidth);
1034
+ }, []), xn = V((e = !1) => {
1035
+ rt(g.Left, e, !1, t.current.getDimensions().containerWidth);
1036
+ }, []), In = V(() => {
1037
+ Yt(g.Left);
1038
+ }, []), En = V(() => {
1039
+ Yt(g.Right);
1040
+ }, []), Vn = V(() => {
1041
+ Yt(g.Up);
1042
+ }, []), Wn = V(() => {
1043
+ Yt(g.Down);
1044
+ }, []), pn = V(() => {
1045
+ wn(g.Left);
1046
+ }, []), Un = V(() => {
1047
+ wn(g.Right);
1048
+ }, []), Hn = V(() => {
1049
+ Fn();
1050
+ }, []), Rn = V(() => {
1051
+ rt(g.Left, !1, !1);
1052
+ }, []), h = V(() => {
1053
+ rt(g.Left, !0, !1);
1054
+ }, []), m = V(() => {
1055
+ rt(g.Left, !1, !0);
1056
+ }, []), C = V(() => {
1057
+ rt(g.Left, !0, !0);
1058
+ }, []), S = V(() => {
1059
+ rt(g.Right, !1, !1);
1060
+ }, []), y = V(() => {
1061
+ rt(g.Right, !0, !1);
1062
+ }, []), z = V(() => {
1063
+ rt(g.Right, !1, !0);
1064
+ }, []), xe = V(() => {
1065
+ rt(g.Right, !0, !0);
1066
+ }, []), re = V(() => {
1067
+ rt(g.Up, !1, !1);
1068
+ }, []), fe = V(() => {
1069
+ rt(g.Up, !0, !1);
1070
+ }, []), U = V(() => {
1071
+ rt(g.Up, !1, !0);
1072
+ }, []), Ee = V(() => {
1073
+ rt(g.Up, !0, !0);
1074
+ }, []), qe = V(() => {
1075
+ rt(g.Down, !1, !1);
1076
+ }, []), $e = V(() => {
1077
+ rt(g.Down, !0, !1);
1078
+ }, []), Ze = V(() => {
1079
+ rt(g.Down, !1, !0);
1080
+ }, []), Te = V(() => {
1081
+ rt(g.Down, !0, !0);
1082
+ }, []), ae = V(() => {
1083
+ ht((e) => e.slice(0, -1));
1135
1084
  }, []), ct = Ae(() => {
1136
- const e = ge();
1137
- return ((a, u, d, g, E) => {
1138
- const x = a.length;
1139
- for (let G = 0; G < x; G++) {
1140
- const F = a[G];
1141
- if (F.rowStart === u && F.colStart === d && F.rowEnd === g && F.colEnd === E) return !0;
1085
+ const e = he();
1086
+ return ((s, u, a, f, E) => {
1087
+ const x = s.length;
1088
+ for (let j = 0; j < x; j++) {
1089
+ const B = s[j];
1090
+ if (B.rowStart === u && B.colStart === a && B.rowEnd === f && B.colEnd === E) return !0;
1142
1091
  }
1143
1092
  return !1;
1144
1093
  })(v.ranges, e.top, e.left, e.bottom, e.right);
1145
- }, [P, v.ranges]), et = W((e, a = !0) => {
1146
- Ge.current = e, Qe(e), a && e && t?.current && yt(e);
1147
- }, []), Be = T((e = !0) => {
1148
- const a = Gt.current;
1149
- if (!re.current?.cell) return;
1150
- const u = re.current?.ranges, d = re.current?.cell;
1151
- if (!d || !a || !a) return;
1152
- let g = null;
1153
- if (g = u.length > 0 ? u[u.length - 1] : te(d), g.colEnd >= g.colStart && g.rowEnd >= g.rowStart) {
1154
- const E = io(g, a);
1155
- let x = e ? Wt : D;
1094
+ }, [W, v.ranges]), et = V((e, s = !0) => {
1095
+ Ge.current = e, Je(e), s && e && t?.current && St(e);
1096
+ }, []), Be = P((e = !0) => {
1097
+ const s = Gt.current;
1098
+ if (!oe.current?.cell) return;
1099
+ const u = oe.current?.ranges, a = oe.current?.cell;
1100
+ if (!a || !s || !s) return;
1101
+ let f = null;
1102
+ if (f = u.length > 0 ? u[u.length - 1] : Z(a), f.colEnd >= f.colStart && f.rowEnd >= f.rowStart) {
1103
+ const E = ro(f, s);
1104
+ let x = e ? Wt : k;
1156
1105
  try {
1157
- x?.(g, a, E.direction);
1158
- } catch (G) {
1159
- console.warn(G);
1106
+ x?.(f, s, E.direction);
1107
+ } catch (j) {
1108
+ console.warn(j);
1160
1109
  } finally {
1161
- e && Me?.();
1110
+ e && Re?.();
1162
1111
  }
1163
1112
  }
1164
- }, [te]), tt = ie(null), bt = Ae(() => ({ onPointerDown: (e, a) => {
1165
- if (Tt.current = a, !t || !t.current) return !1;
1166
- const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), d = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1167
- d && (e.stopPropagation(), Zt("crosshair"), tt.current = { anchor: u.getAnchor(), coords: d });
1168
- }, onPointerMoveOrWait: (e, a) => {
1169
- if (Y || !t?.current || !re.current || !tt.current) return;
1113
+ }, [Z]), tt = se(null), yt = Ae(() => ({ onPointerDown: (e, s) => {
1114
+ if (Dt.current = s, !t || !t.current) return !1;
1115
+ const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), a = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1116
+ a && (e.stopPropagation(), _t("crosshair"), tt.current = { anchor: u.getAnchor(), coords: a });
1117
+ }, onPointerMoveOrWait: (e, s) => {
1118
+ if (le || !t?.current || !oe.current || !tt.current) return;
1170
1119
  const u = tt.current.anchor;
1171
- let d = t.current.getViewFromLocation(u), g = d.getCellCoordsFromClient(e.clientX, e.clientY);
1172
- if (!g) return;
1173
- tt.current = { anchor: u, coords: g };
1174
- const E = re.current.ranges;
1175
- let x = ke(re.current.cell, g);
1120
+ let a = t.current.getViewFromLocation(u), f = a.getCellCoordsFromClient(e.clientX, e.clientY);
1121
+ if (!f) return;
1122
+ tt.current = { anchor: u, coords: f };
1123
+ const E = oe.current.ranges;
1124
+ let x = Me(oe.current.cell, f);
1176
1125
  if (!x) return;
1177
- const G = E.length > 0, F = G ? E[E.length - 1] : te(re.current.cell);
1126
+ const j = E.length > 0, B = j ? E[E.length - 1] : Z(oe.current.cell);
1178
1127
  if (!x) return;
1179
- const N = x.rowStart < F.rowStart ? w.Up : x.rowEnd > F.rowEnd ? w.Down : x.colEnd > F.colEnd ? w.Right : w.Left, ee = ge();
1180
- N === w.Left && (x = { ...F, colStart: Math.max(ee.left, x.colStart) }), N === w.Up && (x = { ...F, rowStart: Math.max(ee.top, x.rowStart) }), N === w.Right && (x = { ...F, colEnd: Math.min(ee.right, x.colEnd) }), N === w.Down && (x = { ...F, rowEnd: Math.min(ee.bottom, x.rowEnd) });
1181
- const Se = io(F, x);
1182
- if (!We?.(F)) {
1183
- let j;
1184
- typeof nn.current == "function" ? j = nn.current(F) : Pe && (j = Pe), x = ((K, dt, I, ve, It, xe) => {
1185
- const ue = { ...dt };
1186
- if (I.length === 0) return ue;
1187
- if (It === w.Left) {
1188
- const at = K.colEnd + 1 - K.colStart;
1189
- ue.colStart = K.colStart - Math.ceil(xe / at) * at, ue.colStart < ve.left && (ue.colStart = ue.colStart + Math.ceil((ve.left - ue.colStart) / at) * at);
1190
- } else if (It === w.Right) {
1191
- const at = K.colEnd + 1 - K.colStart;
1192
- ue.colEnd = K.colEnd + Math.ceil(xe / at) * at, ue.colEnd > ve.right && (ue.colEnd = ue.colEnd - Math.ceil((ve.right - ue.colEnd) / at) * at);
1193
- } else if (It === w.Up) {
1194
- const at = K.rowEnd + 1 - K.rowStart;
1195
- ue.rowStart = K.rowStart - Math.ceil(xe / at) * at, ue.rowStart < ve.top && (ue.rowStart = ue.rowStart + Math.ceil((ve.top - ue.rowStart) / at) * at);
1196
- } else if (It === w.Down) {
1197
- const at = K.rowEnd + 1 - K.rowStart;
1198
- ue.rowEnd = K.rowEnd + Math.ceil(xe / at) * at, ue.rowEnd > ve.bottom && (ue.rowEnd = ue.rowEnd - Math.ceil((ve.bottom - ue.rowEnd) / at) * at);
1128
+ const H = x.rowStart < B.rowStart ? g.Up : x.rowEnd > B.rowEnd ? g.Down : x.colEnd > B.colEnd ? g.Right : g.Left, G = he();
1129
+ H === g.Left && (x = { ...B, colStart: Math.max(G.left, x.colStart) }), H === g.Up && (x = { ...B, rowStart: Math.max(G.top, x.rowStart) }), H === g.Right && (x = { ...B, colEnd: Math.min(G.right, x.colEnd) }), H === g.Down && (x = { ...B, rowEnd: Math.min(G.bottom, x.rowEnd) });
1130
+ const Se = ro(B, x);
1131
+ if (!We?.(B)) {
1132
+ let K;
1133
+ typeof nn.current == "function" ? K = nn.current(B) : ke && (K = ke), x = ((N, dt, I, pe, Ct, ge) => {
1134
+ const de = { ...dt };
1135
+ if (I.length === 0) return de;
1136
+ if (Ct === g.Left) {
1137
+ const at = N.colEnd + 1 - N.colStart;
1138
+ de.colStart = N.colStart - Math.ceil(ge / at) * at, de.colStart < pe.left && (de.colStart = de.colStart + Math.ceil((pe.left - de.colStart) / at) * at);
1139
+ } else if (Ct === g.Right) {
1140
+ const at = N.colEnd + 1 - N.colStart;
1141
+ de.colEnd = N.colEnd + Math.ceil(ge / at) * at, de.colEnd > pe.right && (de.colEnd = de.colEnd - Math.ceil((pe.right - de.colEnd) / at) * at);
1142
+ } else if (Ct === g.Up) {
1143
+ const at = N.rowEnd + 1 - N.rowStart;
1144
+ de.rowStart = N.rowStart - Math.ceil(ge / at) * at, de.rowStart < pe.top && (de.rowStart = de.rowStart + Math.ceil((pe.top - de.rowStart) / at) * at);
1145
+ } else if (Ct === g.Down) {
1146
+ const at = N.rowEnd + 1 - N.rowStart;
1147
+ de.rowEnd = N.rowEnd + Math.ceil(ge / at) * at, de.rowEnd > pe.bottom && (de.rowEnd = de.rowEnd - Math.ceil((pe.bottom - de.rowEnd) / at) * at);
1199
1148
  }
1200
- return ue;
1201
- })(F, x, j, ee, Se.direction, Se.amount);
1149
+ return de;
1150
+ })(B, x, K, G, Se.direction, Se.amount);
1202
1151
  }
1203
- if (G && V.isRangeWithinRange(x, F) && (x = null), !V.isEqualRanges(x, Gt.current)) {
1152
+ if (j && F.isRangeWithinRange(x, B) && (x = null), !F.isEqualRanges(x, Gt.current)) {
1204
1153
  if (hn(x), Gt.current = x, !x) {
1205
1154
  try {
1206
1155
  b?.();
1207
1156
  } catch {
1208
1157
  }
1209
- return void Me?.();
1158
+ return void Re?.();
1210
1159
  }
1211
1160
  Be(!1);
1212
1161
  }
1213
- Tt.current = a, Dn(d, g, t);
1214
- }, onPointerUp: (e, a) => {
1215
- Tt.current = a, Promise.resolve(Be(!0)).finally(() => {
1216
- Me?.(), hn(null), Gt.current = null, tt.current = null, Zt(null), t.current?.focus();
1162
+ Dt.current = s, Tn(a, f, t);
1163
+ }, onPointerUp: (e, s) => {
1164
+ Dt.current = s, Promise.resolve(Be(!0)).finally(() => {
1165
+ Re?.(), hn(null), Gt.current = null, tt.current = null, _t(null), t.current?.focus();
1217
1166
  });
1218
- } }), [te]), qe = un(bt), ne = Ae(() => ({ onPointerDown: qe }), [qe]), [Ye, mt] = ut(null), Oe = ie(null), nt = Ae(() => ({ onPointerDown: (e, a) => {
1219
- if (Tt.current = a, !t || !t.current) return !1;
1220
- const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), d = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1221
- if (!d) return;
1222
- if (ce?.(e, d, v) === !1) return !1;
1223
- e.stopPropagation(), Zt("default");
1224
- const g = u.getRelativePointFromClient(0, 0), E = re.current?.ranges[re.current?.ranges.length - 1] ?? V.cellToRange(re.current?.cell), x = u.toClipBounds(u.getRangeCoordsBounds(E)), G = { x: 0, y: 0 };
1225
- x.x - g.x > e.nativeEvent.clientX ? G.x = e.nativeEvent.clientX - (x.x - g.x) : e.nativeEvent.clientX >= x.x - g.x + x.width && (G.x = Math.max(0, e.nativeEvent.clientX - (x.x - g.x + x.width)) + 1), x.y - g.y > e.nativeEvent.clientY ? G.y = e.nativeEvent.clientY - (x.y - g.y) : e.nativeEvent.clientY >= x.y - g.y + x.height && (G.y = Math.max(0, e.nativeEvent.clientY - (x.y - g.y + x.height)) + 1), fe?.(E, e.nativeEvent, a), Oe.current = { range: E, anchor: u.getAnchor(), cell: d, isMoving: !1, extrusion: G };
1226
- }, onPointerMoveOrWait: (e, a, u) => {
1227
- if (Xe || !t?.current || !re.current || !Oe.current) return;
1228
- const d = e.clientX - u.clientX, g = e.clientY - u.clientY;
1229
- if (Oe.current.isMoving = Oe.current.isMoving || Math.abs(d) > Math.max(1, 2) || Math.abs(g) > Math.max(1, 2) || performance.now() - u.timeStamp > 500, !Oe.current.isMoving) return;
1230
- const E = Oe.current.anchor, x = Oe.current.extrusion;
1231
- let G = t.current.getViewFromLocation(E), F = G.getCellCoordsFromClient(e.clientX - x.x, e.clientY - x.y, !0);
1232
- if (!F) return;
1233
- const N = Oe.current.cell, ee = Oe.current.range, Se = ge(), j = ee.colEnd - ee.colStart + 1, K = Math.min(Math.max(0, N.colIndex - ee.colStart), j - 1), dt = Math.min(Se.right - j + 1, Math.max(Se.left, F.colIndex - K)), I = ee.rowEnd - ee.rowStart + 1, ve = Math.min(Math.max(0, N.rowIndex - ee.rowStart), I - 1), It = Math.min(Se.bottom - I + 1, Math.max(Se.top, F.rowIndex - ve)), xe = { colStart: dt, colEnd: dt + j - 1, rowStart: It, rowEnd: It + I - 1 };
1234
- V.isEqualRanges(Ye, xe) && !((ue) => !ue || !Tt.current || Tt.current.ctrlKey !== ue.ctrlKey || Tt.current.shiftKey !== ue.shiftKey || Tt.current.altKey !== ue.altKey || Tt.current.metaKey !== ue.metaKey)(e) || (mt(xe), ye?.(xe, e, a)), Tt.current = a, Dn(G, F, t);
1235
- }, onPointerUp: (e, a) => {
1236
- Tt.current = a;
1167
+ } }), [Z]), je = un(yt), ee = Ae(() => ({ onPointerDown: je }), [je]), [Ye, pt] = gt(null), De = se(null), nt = Ae(() => ({ onPointerDown: (e, s) => {
1168
+ if (Dt.current = s, !t || !t.current) return !1;
1169
+ const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), a = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1170
+ if (!a) return;
1171
+ if (me?.(e, a, v) === !1) return !1;
1172
+ e.stopPropagation(), _t("default");
1173
+ const f = u.getRelativePointFromClient(0, 0), E = oe.current?.ranges[oe.current?.ranges.length - 1] ?? F.cellToRange(oe.current?.cell), x = u.toClipBounds(u.getRangeCoordsBounds(E)), j = { x: 0, y: 0 };
1174
+ x.x - f.x > e.nativeEvent.clientX ? j.x = e.nativeEvent.clientX - (x.x - f.x) : e.nativeEvent.clientX >= x.x - f.x + x.width && (j.x = Math.max(0, e.nativeEvent.clientX - (x.x - f.x + x.width)) + 1), x.y - f.y > e.nativeEvent.clientY ? j.y = e.nativeEvent.clientY - (x.y - f.y) : e.nativeEvent.clientY >= x.y - f.y + x.height && (j.y = Math.max(0, e.nativeEvent.clientY - (x.y - f.y + x.height)) + 1), ue?.(E, e.nativeEvent, s), De.current = { range: E, anchor: u.getAnchor(), cell: a, isMoving: !1, extrusion: j };
1175
+ }, onPointerMoveOrWait: (e, s, u) => {
1176
+ if (Xe || !t?.current || !oe.current || !De.current) return;
1177
+ const a = e.clientX - u.clientX, f = e.clientY - u.clientY;
1178
+ if (De.current.isMoving = De.current.isMoving || Math.abs(a) > Math.max(1, 2) || Math.abs(f) > Math.max(1, 2) || performance.now() - u.timeStamp > 500, !De.current.isMoving) return;
1179
+ const E = De.current.anchor, x = De.current.extrusion;
1180
+ let j = t.current.getViewFromLocation(E), B = j.getCellCoordsFromClient(e.clientX - x.x, e.clientY - x.y, !0);
1181
+ if (!B) return;
1182
+ const H = De.current.cell, G = De.current.range, Se = he(), K = G.colEnd - G.colStart + 1, N = Math.min(Math.max(0, H.colIndex - G.colStart), K - 1), dt = Math.min(Se.right - K + 1, Math.max(Se.left, B.colIndex - N)), I = G.rowEnd - G.rowStart + 1, pe = Math.min(Math.max(0, H.rowIndex - G.rowStart), I - 1), Ct = Math.min(Se.bottom - I + 1, Math.max(Se.top, B.rowIndex - pe)), ge = { colStart: dt, colEnd: dt + K - 1, rowStart: Ct, rowEnd: Ct + I - 1 };
1183
+ F.isEqualRanges(Ye, ge) && !((de) => !de || !Dt.current || Dt.current.ctrlKey !== de.ctrlKey || Dt.current.shiftKey !== de.shiftKey || Dt.current.altKey !== de.altKey || Dt.current.metaKey !== de.metaKey)(e) || (pt(ge), ye?.(ge, e, s)), Dt.current = s, Tn(j, B, t);
1184
+ }, onPointerUp: (e, s) => {
1185
+ Dt.current = s;
1237
1186
  const u = () => {
1238
- mt(null), Oe.current = null, Zt(null), t.current?.focus();
1187
+ pt(null), De.current = null, _t(null), t.current?.focus();
1239
1188
  };
1240
- if (!Oe.current) return void u();
1241
- const d = Oe.current.range, g = Ye;
1242
- A?.(d, e, a), Promise.resolve(d && g && p?.(d, g, e, a)).finally(() => {
1189
+ if (!De.current) return void u();
1190
+ const a = De.current.range, f = Ye;
1191
+ $?.(a, e, s), Promise.resolve(a && f && p?.(a, f, e, s)).finally(() => {
1243
1192
  u();
1244
1193
  });
1245
- } }), [Ye]), Le = un(nt), ze = Ae(() => ({ onPointerDown: Le }), [Le]), vt = ie(null), st = Ae(() => {
1246
- const e = V.isEqualSelectionCoords(v, vt.current) ? vt.current : v;
1247
- return vt.current = e, e;
1248
- }, [v]), Ct = W((e) => {
1249
- let a = null, u = "br";
1250
- const d = [], g = { stroke: q, fill: L, strokeWidth: 0.5 }, E = (j, K, dt) => {
1251
- const I = e.toClipBounds(e.getRangeCoordsBounds(j), Vt);
1194
+ } }), [Ye]), Le = un(nt), Oe = Ae(() => ({ onPointerDown: Le }), [Le]), mt = se(null), st = Ae(() => {
1195
+ const e = F.isEqualSelectionCoords(v, mt.current) ? mt.current : v;
1196
+ return mt.current = e, e;
1197
+ }, [v]), bt = V((e) => {
1198
+ let s = null, u = "br";
1199
+ const a = [], f = { stroke: J, fill: D, strokeWidth: 0.5 }, E = (K, N, dt) => {
1200
+ const I = e.toClipBounds(e.getRangeCoordsBounds(K), Vt);
1252
1201
  if (!I) return;
1253
- I.x = I.width > 0 ? I.x : I.x - g.strokeWidth / 2, I.y = I.height > 0 ? I.y : I.y - g.strokeWidth / 2, I.width = Math.max(I.width, g.strokeWidth), I.height = Math.max(I.height, g.strokeWidth);
1254
- const ve = { key: `selection-fill-${K}`, range: j, ...I, ...g };
1202
+ I.x = I.width > 0 ? I.x : I.x - f.strokeWidth / 2, I.y = I.height > 0 ? I.y : I.y - f.strokeWidth / 2, I.width = Math.max(I.width, f.strokeWidth), I.height = Math.max(I.height, f.strokeWidth);
1203
+ const pe = { key: `selection-fill-${N}`, range: K, ...I, ...f };
1255
1204
  if (dt) {
1256
- const It = e.getCellCoordsAsRangeCoords(dt);
1257
- ve.cell = dt, ve.pathBounds = e.toClipBounds(e.getRangeCoordsBounds(It), Vt), ve.pathBounds && (ve.pathBounds.width <= 0 || ve.pathBounds.height <= 0) && (delete ve.pathBounds, delete ve.cell);
1205
+ const Ct = e.getCellCoordsAsRangeCoords(dt);
1206
+ pe.cell = dt, pe.pathBounds = e.toClipBounds(e.getRangeCoordsBounds(Ct), Vt), pe.pathBounds && (pe.pathBounds.width <= 0 || pe.pathBounds.height <= 0) && (delete pe.pathBounds, delete pe.cell);
1258
1207
  }
1259
- return pe(ve);
1208
+ return we(pe);
1260
1209
  };
1261
1210
  let x = v ? $t(v) : null;
1262
- const G = x?.cell ? e.getCellCoordsAsRangeCoords(x?.cell) : or;
1263
- !x || x.ranges && x.ranges.length !== 0 || (x = { ranges: [G], rangeIndex: 0, cell: x.cell });
1264
- for (let j = 0; x && j < x.ranges.length; j++) {
1265
- const K = x.ranges[j], dt = E(K, j, j === x.rangeIndex ? x.cell : null);
1266
- dt && d.push(dt);
1267
- const I = 2, ve = 0.5, It = e.toClipBounds(e.getRangeCoordsBounds(K, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1268
- if (It) {
1269
- const xe = (x.ranges.length, 4);
1270
- d.push(pe({ range: K, key: `selection-inside-edge-${j}`, x: It.x - 1, y: It.y - 1, width: Math.max(It.width + 1, 0), height: Math.max(It.height + 1, 0), style: { overflow: "hidden" }, stroke: q, strokeWidth: xe }));
1211
+ const j = x?.cell ? e.getCellCoordsAsRangeCoords(x?.cell) : _o;
1212
+ !x || x.ranges && x.ranges.length !== 0 || (x = { ranges: [j], rangeIndex: 0, cell: x.cell });
1213
+ for (let K = 0; x && K < x.ranges.length; K++) {
1214
+ const N = x.ranges[K], dt = E(N, K, K === x.rangeIndex ? x.cell : null);
1215
+ dt && a.push(dt);
1216
+ const I = 2, pe = 0.5, Ct = e.toClipBounds(e.getRangeCoordsBounds(N, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1217
+ if (Ct) {
1218
+ const ge = (x.ranges.length, 4);
1219
+ a.push(we({ range: N, key: `selection-inside-edge-${K}`, x: Ct.x - 1, y: Ct.y - 1, width: Math.max(Ct.width + 1, 0), height: Math.max(Ct.height + 1, 0), style: { overflow: "hidden" }, stroke: J, strokeWidth: ge }));
1271
1220
  }
1272
1221
  if (x.ranges.length === 1) {
1273
- const xe = e.toClipBounds(e.getRangeCoordsBounds(K), Vt);
1274
- if (xe) {
1275
- Xe || d.push(pe({ range: K, key: `move-selection-hit-box-${j}`, x: xe.width > 1 ? xe.x : xe.x - (be / 2 + 1), y: xe.height > 1 ? xe.y : xe.y - (be / 2 + 1), width: Math.max(xe.width + 2, 1), height: Math.max(xe.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ye ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: be, ...ze }));
1276
- const ue = I;
1277
- d.push(pe({ range: K, key: `selection-single-${j}`, x: xe.x - ue / 2, y: xe.y - ue / 2, width: Math.max(xe.width + ue / 2, 1), height: Math.max(xe.height + ue / 2, 1), stroke: X, strokeWidth: ue }));
1222
+ const ge = e.toClipBounds(e.getRangeCoordsBounds(N), Vt);
1223
+ if (ge) {
1224
+ Xe || a.push(we({ range: N, key: `move-selection-hit-box-${K}`, x: ge.width > 1 ? ge.x : ge.x - (be / 2 + 1), y: ge.height > 1 ? ge.y : ge.y - (be / 2 + 1), width: Math.max(ge.width + 2, 1), height: Math.max(ge.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ye ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: be, ...Oe }));
1225
+ const de = I;
1226
+ a.push(we({ range: N, key: `selection-single-${K}`, x: ge.x - de / 2, y: ge.y - de / 2, width: Math.max(ge.width + de / 2, 1), height: Math.max(ge.height + de / 2, 1), stroke: q, strokeWidth: de }));
1278
1227
  }
1279
1228
  } else {
1280
- const xe = e.toClipBounds(e.getRangeCoordsBounds(K, { top: -1, left: -1, right: -2, bottom: -2 }), Vt);
1281
- xe && d.push(pe({ range: K, key: `selection-multi-${j}`, x: xe.width > 1 ? xe.x : xe.x - ve / 2, y: xe.height > 1 ? xe.y : xe.y - ve / 2, width: Math.max(xe.width, ve) + 1, height: Math.max(xe.height, ve) + 1, stroke: X, style: { overflow: "hidden" }, strokeWidth: 2 }));
1229
+ const ge = e.toClipBounds(e.getRangeCoordsBounds(N, { top: -1, left: -1, right: -2, bottom: -2 }), Vt);
1230
+ ge && a.push(we({ range: N, key: `selection-multi-${K}`, x: ge.width > 1 ? ge.x : ge.x - pe / 2, y: ge.height > 1 ? ge.y : ge.y - pe / 2, width: Math.max(ge.width, pe) + 1, height: Math.max(ge.height, pe) + 1, stroke: q, style: { overflow: "hidden" }, strokeWidth: 2 }));
1282
1231
  }
1283
- if (x.ranges.length > 1 && j === x.rangeIndex) {
1284
- const xe = e.getCellCoordsAsRangeCoords(x.cell), ue = e.toClipBounds(e.getRangeCoordsBounds(xe, { top: 1, left: 1, right: -1, bottom: -1 }), Vt);
1285
- ue && d.push(pe({ range: K, key: `selection-anchor-${j}`, x: ue.x, y: ue.y, width: Math.max(ue.width, ve), height: Math.max(ue.height, ve), stroke: X, style: { overflow: "hidden" }, strokeWidth: 2 }));
1232
+ if (x.ranges.length > 1 && K === x.rangeIndex) {
1233
+ const ge = e.getCellCoordsAsRangeCoords(x.cell), de = e.toClipBounds(e.getRangeCoordsBounds(ge, { top: 1, left: 1, right: -1, bottom: -1 }), Vt);
1234
+ de && a.push(we({ range: N, key: `selection-anchor-${K}`, x: de.x, y: de.y, width: Math.max(de.width, pe), height: Math.max(de.height, pe), stroke: q, style: { overflow: "hidden" }, strokeWidth: 2 }));
1286
1235
  }
1287
- if (j === x.ranges.length - 1) {
1288
- a = null, u = null;
1289
- const xe = K.rowStart === ge().top && K.rowEnd === ge().bottom, ue = K.colStart === ge().left && K.colEnd === ge().right, at = e.getRangeCoordsBounds(K);
1236
+ if (K === x.ranges.length - 1) {
1237
+ s = null, u = null;
1238
+ const ge = N.rowStart === he().top && N.rowEnd === he().bottom, de = N.colStart === he().left && N.colEnd === he().right, at = e.getRangeCoordsBounds(N);
1290
1239
  let Ft = null;
1291
- if (xe || ue) {
1240
+ if (ge || de) {
1292
1241
  if (Ft = e.toClipBounds(at, Vt), Object.keys(e.allViews()).length > 1) {
1293
- const Mn = e.getVisibleRangeCoords(), _n = e.allViews()[_e.TopLeft], Do = e.allViews()[_e.Top], To = e.allViews()[_e.Left], kn = e.getAnchor();
1294
- (ue && (kn === _e.Top && _n || kn === _e.Center && To || !V.isCellWithinRange({ colIndex: K.colStart, rowIndex: K.rowEnd }, Mn) && !V.isCellWithinRange({ colIndex: K.colStart, rowIndex: K.rowEnd + 1 }, Mn)) || xe && (kn === _e.Left && _n || kn === _e.Center && Do || !V.isCellWithinRange({ colIndex: K.colEnd, rowIndex: K.rowStart }, Mn) && !V.isCellWithinRange({ colIndex: K.colEnd + 1, rowIndex: K.rowStart }, Mn))) && (Ft = null);
1242
+ const Mn = e.getVisibleRangeCoords(), Jn = e.allViews()[Qe.TopLeft], ko = e.allViews()[Qe.Top], Po = e.allViews()[Qe.Left], kn = e.getAnchor();
1243
+ (de && (kn === Qe.Top && Jn || kn === Qe.Center && Po || !F.isCellWithinRange({ colIndex: N.colStart, rowIndex: N.rowEnd }, Mn) && !F.isCellWithinRange({ colIndex: N.colStart, rowIndex: N.rowEnd + 1 }, Mn)) || ge && (kn === Qe.Left && Jn || kn === Qe.Center && ko || !F.isCellWithinRange({ colIndex: N.colEnd, rowIndex: N.rowStart }, Mn) && !F.isCellWithinRange({ colIndex: N.colEnd + 1, rowIndex: N.rowStart }, Mn))) && (Ft = null);
1295
1244
  }
1296
1245
  } else Ft = e.toClipBounds(at, Vt);
1297
1246
  if (!Ft || Ft.width === 0 || Ft.height === 0) continue;
1298
- a = { x: Ft.x + Ft.width + 1, y: Ft.y + Ft.height + 1 }, Ft.width === 0 || Ft.height === 0 || K.rowStart === ge().top && K.colStart === ge().left && K.rowEnd === ge().bottom && K.colEnd === ge().right || (xe ? (a.y = I, u = "tr") : ue && (a.x = I, u = "bl"));
1247
+ s = { x: Ft.x + Ft.width + 1, y: Ft.y + Ft.height + 1 }, Ft.width === 0 || Ft.height === 0 || N.rowStart === he().top && N.colStart === he().left && N.rowEnd === he().bottom && N.colEnd === he().right || (ge ? (s.y = I, u = "tr") : de && (s.x = I, u = "bl"));
1299
1248
  }
1300
1249
  }
1301
- let F = null;
1302
- if (De) {
1303
- const j = e.toClipBounds(e.getRangeCoordsBounds(De, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1304
- j && (F = pe({ ...g, range: De, key: "remove-selection", x: j.x, y: j.y, width: j.width, height: j.height, strokeWidth: 2, stroke: Pt, fill: Et }));
1250
+ let B = null;
1251
+ if (Pe) {
1252
+ const K = e.toClipBounds(e.getRangeCoordsBounds(Pe, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1253
+ K && (B = we({ ...f, range: Pe, key: "remove-selection", x: K.x, y: K.y, width: K.width, height: K.height, strokeWidth: 2, stroke: Pt, fill: Et }));
1305
1254
  }
1306
- let N = null;
1307
- if (Dt) {
1308
- const j = e.toClipBounds(e.getRangeCoordsBounds(Dt, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1309
- j && (N = pe({ range: Dt, key: "selection-fill-outline", x: j.x - 2 / 2, y: j.y - 2 / 2, width: j.width + 2 / 2, height: j.height + 2 / 2, strokeWidth: 2, stroke: X, strokeDasharray: "3 2" }));
1255
+ let H = null;
1256
+ if (Tt) {
1257
+ const K = e.toClipBounds(e.getRangeCoordsBounds(Tt, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1258
+ K && (H = we({ range: Tt, key: "selection-fill-outline", x: K.x - 2 / 2, y: K.y - 2 / 2, width: K.width + 2 / 2, height: K.height + 2 / 2, strokeWidth: 2, stroke: q, strokeDasharray: "3 2" }));
1310
1259
  }
1311
- let ee = null;
1312
- !Y && a && !Ye && (ee = xo(Io, { ...a, corner: u, size: 7.5, borderStroke: `${q} solid`, style: { borderRadius: 1 }, background: X, ...ne, key: "fillHandle" }));
1313
- const Se = [...d];
1314
- if (F && Se.push(F), N && Se.push(N), ee && Se.push(ee), !xt && zt && x?.ranges.length === 1 && x.ranges[x.ranges.length - 1]) {
1315
- const j = x.ranges[x.ranges.length - 1], K = j.rowStart === ge().top && j.rowEnd === ge().bottom, dt = j.colStart === ge().left && j.colEnd === ge().right, I = { view: e, range: j, borderStroke: `${X} solid`, background: q, selectionTouchPointerHandler: $n, ...ht, onTouchSelectStart: (ve) => cn(ve), onTouchSelectEnd: () => cn(null), currentTouchAnchor: vn };
1316
- Se.push(Ce(Zn, { anchor: dt ? "b" : K ? "r" : "br", scrollableElement: t.current, ...I }, "touch-select-handle-after")), Se.push(Ce(Zn, { anchor: dt ? "t" : K ? "l" : "tl", scrollableElement: t.current, ...I }, "touch-select-handle-before"));
1260
+ let G = null;
1261
+ !le && s && !Ye && (G = wo(yo, { ...s, corner: u, size: 7.5, borderStroke: `${J} solid`, style: { borderRadius: 1 }, background: q, ...ee, key: "fillHandle" }));
1262
+ const Se = [...a];
1263
+ if (B && Se.push(B), H && Se.push(H), G && Se.push(G), !wt && zt && x?.ranges.length === 1 && x.ranges[x.ranges.length - 1]) {
1264
+ const K = x.ranges[x.ranges.length - 1], N = K.rowStart === he().top && K.rowEnd === he().bottom, dt = K.colStart === he().left && K.colEnd === he().right, I = { view: e, range: K, borderStroke: `${q} solid`, background: J, selectionTouchPointerHandler: Ln, ...ut, onTouchSelectStart: (pe) => cn(pe), onTouchSelectEnd: () => cn(null), currentTouchAnchor: vn };
1265
+ Se.push(Ce(Xn, { anchor: dt ? "b" : N ? "r" : "br", scrollableElement: t.current, ...I }, "touch-select-handle-after")), Se.push(Ce(Xn, { anchor: dt ? "t" : N ? "l" : "tl", scrollableElement: t.current, ...I }, "touch-select-handle-before"));
1317
1266
  }
1318
1267
  if (Ye) {
1319
- const j = e.toClipBounds(e.getRangeCoordsBounds(Ye, { top: 1, left: 1, right: 1, bottom: 1 }), Vt);
1320
- j && Se.push(pe({ range: Ye, key: "selection-move-outline", x: j.x - J / 2, y: j.y - J / 2, width: Math.max(j.width + J / 2, 1), height: Math.max(j.height + J / 2, 1), stroke: X, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: J }));
1268
+ const K = e.toClipBounds(e.getRangeCoordsBounds(Ye, { top: 1, left: 1, right: 1, bottom: 1 }), Vt);
1269
+ K && Se.push(we({ range: Ye, key: "selection-move-outline", x: K.x - Y / 2, y: K.y - Y / 2, width: Math.max(K.width + Y / 2, 1), height: Math.max(K.height + Y / 2, 1), stroke: q, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: Y }));
1321
1270
  }
1322
1271
  return Ce("div", { children: Se }, "selection");
1323
- }, [st, De, Y, Dt, Xe, Ye, ge, q, X, L, Pt, Et, xt, ht, vn]), Lt = Ae(() => {
1272
+ }, [st, Pe, le, Tt, Xe, Ye, he, J, q, D, Pt, Et, wt, ut, vn]), Lt = Ae(() => {
1324
1273
  const e = () => t.current;
1325
- return [new se("moveToPageDown", e, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => bn(!1)), new se("selectToPageDown", e, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [ae.Shift] }] }, () => bn(!0)), new se("moveToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ae.Alt] }] }, () => Cn(!1)), new se("selectToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ae.Alt, ae.Shift] }] }, () => Cn(!0)), new se("moveToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => At(!1)), new se("selectToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [ae.Shift] }] }, () => At(!0)), new se("moveToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ae.Alt] }] }, () => xn(!1)), new se("selectToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ae.Alt, ae.Shift] }] }, () => xn(!0)), new se("selectColumn", e, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [ae.Ctrl] } }, Bn), new se("selectRow", e, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [ae.Shift] } }, An), new se("selectToColumnStart", e, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Sn(!0)), new se("selectToColumnEnd", e, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yn(!0)), new se("moveToRowStart", e, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => fn(!1)), new se("selectToRowStart", e, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [ae.Shift] }] }, () => fn(!0)), new se("moveToSheetStart", e, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ae.Ctrl] }] }, () => an(!1)), new se("selectToSheetStart", e, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ae.Ctrl, ae.Shift] }] }, () => an(!0)), new se("moveToRowEnd", e, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => gn(!1)), new se("selectToRowEnd", e, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [ae.Shift] }] }, () => gn(!0)), new se("moveToSheetEnd", e, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ae.Ctrl] }] }, () => on(!1)), new se("selectToSheetEnd", e, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ae.Ctrl, ae.Shift] }] }, () => on(!0)), new se("scrollToActiveCoords", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [ae.Ctrl] } }, Qt), new se("scrollToActiveCoordsClearSelection", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [ae.Shift] } }, () => {
1326
- Jt(), et(v.cell, !0);
1327
- }), new se("traverseSelectionRight", e, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, En), new se("traverseSelectionLeft", e, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [ae.Shift] } }, In), new se("traverseSelectionDown", e, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Un), new se("traverseSelectionUp", e, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [ae.Shift] }, { key: "NumpadEnter", modifiers: [ae.Shift] }] }, Wn), new se("moveLeft", e, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Rn), new se("selectLeft", e, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [ae.Shift] }] }, f), new se("moveContentfulLeft", e, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ae.Ctrl] }] }, m), new se("selectContentfulLeft", e, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ae.Ctrl, ae.Shift] }] }, C), new se("moveRight", e, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, S), new se("selectRight", e, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [ae.Shift] }] }, y), new se("moveContentfulRight", e, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ae.Ctrl] }] }, B), new se("selectContentfulRight", e, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ae.Ctrl, ae.Shift] }] }, me), new se("moveUp", e, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, le), new se("selectUp", e, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [ae.Shift] }] }, we), new se("moveContentfulUp", e, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ae.Ctrl] }] }, H), new se("selectContentfulUp", e, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ae.Ctrl, ae.Shift] }] }, Re), new se("moveDown", e, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, je), new se("selectDown", e, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [ae.Shift] }] }, $e), new se("moveContentfulDown", e, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ae.Ctrl] }] }, Je), new se("selectContentfulDown", e, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ae.Ctrl, ae.Shift] }] }, Te), new se("selectVisible", e, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [ae.Alt] } }, Fn), new se("traverseSelectionPreviousRange", e, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [ae.Ctrl, ae.Alt] } }, pn), new se("traverseSelectionNextRange", e, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [ae.Ctrl, ae.Alt] } }, Hn), new se("traverseSelectionCorners", e, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [ae.Ctrl] } }, Nn)];
1274
+ return [new ie("moveToPageDown", e, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => bn(!1)), new ie("selectToPageDown", e, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Shift] }] }, () => bn(!0)), new ie("moveToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Alt] }] }, () => Cn(!1)), new ie("selectToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Alt, ce.Shift] }] }, () => Cn(!0)), new ie("moveToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => At(!1)), new ie("selectToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Shift] }] }, () => At(!0)), new ie("moveToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Alt] }] }, () => xn(!1)), new ie("selectToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Alt, ce.Shift] }] }, () => xn(!0)), new ie("selectColumn", e, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [ce.Ctrl] } }, $n), new ie("selectRow", e, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [ce.Shift] } }, Bn), new ie("selectToColumnStart", e, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Sn(!0)), new ie("selectToColumnEnd", e, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yn(!0)), new ie("moveToRowStart", e, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => fn(!1)), new ie("selectToRowStart", e, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [ce.Shift] }] }, () => fn(!0)), new ie("moveToSheetStart", e, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ce.Ctrl] }] }, () => an(!1)), new ie("selectToSheetStart", e, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ce.Ctrl, ce.Shift] }] }, () => an(!0)), new ie("moveToRowEnd", e, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => gn(!1)), new ie("selectToRowEnd", e, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [ce.Shift] }] }, () => gn(!0)), new ie("moveToSheetEnd", e, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ce.Ctrl] }] }, () => on(!1)), new ie("selectToSheetEnd", e, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ce.Ctrl, ce.Shift] }] }, () => on(!0)), new ie("scrollToActiveCoords", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [ce.Ctrl] } }, Jt), new ie("scrollToActiveCoordsClearSelection", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [ce.Shift] } }, () => {
1275
+ Zt(), et(v.cell, !0);
1276
+ }), new ie("traverseSelectionRight", e, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, En), new ie("traverseSelectionLeft", e, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [ce.Shift] } }, In), new ie("traverseSelectionDown", e, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Wn), new ie("traverseSelectionUp", e, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [ce.Shift] }, { key: "NumpadEnter", modifiers: [ce.Shift] }] }, Vn), new ie("moveLeft", e, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Rn), new ie("selectLeft", e, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Shift] }] }, h), new ie("moveContentfulLeft", e, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Ctrl] }] }, m), new ie("selectContentfulLeft", e, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Ctrl, ce.Shift] }] }, C), new ie("moveRight", e, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, S), new ie("selectRight", e, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Shift] }] }, y), new ie("moveContentfulRight", e, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Ctrl] }] }, z), new ie("selectContentfulRight", e, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Ctrl, ce.Shift] }] }, xe), new ie("moveUp", e, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, re), new ie("selectUp", e, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Shift] }] }, fe), new ie("moveContentfulUp", e, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Ctrl] }] }, U), new ie("selectContentfulUp", e, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Ctrl, ce.Shift] }] }, Ee), new ie("moveDown", e, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, qe), new ie("selectDown", e, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Shift] }] }, $e), new ie("moveContentfulDown", e, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Ctrl] }] }, Ze), new ie("selectContentfulDown", e, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Ctrl, ce.Shift] }] }, Te), new ie("selectVisible", e, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [ce.Alt] } }, An), new ie("traverseSelectionPreviousRange", e, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [ce.Ctrl, ce.Alt] } }, pn), new ie("traverseSelectionNextRange", e, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [ce.Ctrl, ce.Alt] } }, Un), new ie("traverseSelectionCorners", e, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [ce.Ctrl] } }, Hn)];
1328
1277
  }, []);
1329
1278
  return Ae(() => {
1330
1279
  n?.addCommands(Lt, !0);
1331
- }, [n]), { selection: st, setSelectionCell: et, setSelectionRanges: ft, overlay: Ct, cursor: ln, onPointerDown: Ln, clearLastSelection: de, newSelection: Rt, modifySelection: gt, appendSelection: Ee, clearSelections: Jt, isEntire: ct, navigate: rt, navigateSelection: Yt };
1280
+ }, [n]), { selection: st, setSelectionCell: et, setSelectionRanges: ht, overlay: bt, cursor: ln, onPointerDown: zn, clearLastSelection: ae, newSelection: Rt, modifySelection: ft, appendSelection: Ie, clearSelections: Zt, isEntire: ct, navigate: rt, navigateSelection: Yt };
1332
1281
  };
1333
- function Tn(t, n) {
1282
+ function Dn(t, n) {
1334
1283
  if (!t) throw new Error("Invariant failed");
1335
1284
  }
1336
- const uo = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, lr = Object.freeze({ top: 0, left: 0 }), ir = Object.freeze({ bottom: -4, right: -4 }), cr = Object.freeze({ horizontal: !0, vertical: !0 }), ho = [_e.TopLeft, _e.Top, _e.Left, _e.Center], Cr = 150, Xt = 3e3, Yn = {}, Ro = Kt(tn((t, n) => {
1337
- const { width: o, height: r, rowCount: c = 1, columnCount: s = 1, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: O, layout: z, onViewportScroll: M, onImmediateScroll: R, showGridLines: $ = !0, gridLineColor: Y = "rgb(224, 224, 224)", gridLineRowsProps: q, gridLineColumnsProps: _, clipCells: Ie = !0, cursor: Z, freezeLeft: k = 0, freezeTop: U = 0, freezeLeftProps: he, freezeTopProps: P, cellRenderer: ce, onViewportChange: Ve, onFirstRender: Pe, overlayRenderer: We, overlayProps: fe, overlays: ye, overlaysProps: A, allowOverlaysOverflow: p = !1, stageProps: Ne, stageWrapper: Xe = null, hiddenRowsAt: te, hiddenColumnsAt: be, hiddenCellAt: J, getVisibleCells: L, zoom: X = 1, enableMouseWheel: Pt = !0, onWheelScroll: Et, getCellCoordsAsRangeCoords: xt = V.cellToRange, scrollPoint: ht = lr, style: ge = {}, ...Wt } = t;
1338
- Tn(ce), Tn(!t?.children);
1339
- const D = T(R, [R]), b = T(Ve, [Ve]), Me = T(M, [M]), oe = T(Et, [Et]), pe = T(Pe, [Pe]), Ue = ie(null), lt = ie(null), Mt = ie(null), [it, jt] = zn((f) => f + 1, 0), [pt, v] = ut({ left: ht?.left ?? 0, top: ht?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), re = ie(null), He = ie(pt), { top: ft, left: Qe, verticalScrollDirection: ln, horizontalScrollDirection: Zt } = pt, Dt = ie(!1), hn = Ao({ rowCount: c, columnCount: s, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: O }), Gt = ie(null), De = Ae(() => {
1340
- const f = z || hn;
1341
- return Gt.current = null, { getColOffset: (m) => f.getColOffset(m) * X, getColIndex: (m) => f.getColIndex(m / X), getRowOffset: (m) => f.getRowOffset(m) * X, getRowIndex: (m) => f.getRowIndex(m / X) };
1342
- }, [hn, z, X]), Ut = (f, m, C) => {
1285
+ const so = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, Jo = Object.freeze({ top: 0, left: 0 }), Qo = Object.freeze({ bottom: -4, right: -4 }), er = Object.freeze({ horizontal: !0, vertical: !0 }), ao = [Qe.TopLeft, Qe.Top, Qe.Left, Qe.Center], vr = 150, Xt = 3e3, qn = {}, Co = Kt(tn((t, n) => {
1286
+ const { width: o, height: r, rowCount: c = 1, columnCount: d = 1, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: w, getColumnWidth: L, layout: O, onViewportScroll: R, onImmediateScroll: M, showGridLines: A = !0, gridLineColor: le = "rgb(224, 224, 224)", gridLineRowsProps: J, gridLineColumnsProps: te, clipCells: ze = !0, cursor: Q, freezeLeft: T = 0, freezeTop: _ = 0, freezeLeftProps: ve, freezeTopProps: W, cellRenderer: me, onViewportChange: Ve, onFirstRender: ke, overlayRenderer: We, overlayProps: ue, overlays: ye, overlaysProps: $, allowOverlaysOverflow: p = !1, stageProps: Ne, stageWrapper: Xe = null, hiddenRowsAt: Z, hiddenColumnsAt: be, hiddenCellAt: Y, getVisibleCells: D, zoom: q = 1, enableMouseWheel: Pt = !0, onWheelScroll: Et, getCellCoordsAsRangeCoords: wt = F.cellToRange, scrollPoint: ut = Jo, style: he = {}, ...Wt } = t;
1287
+ Dn(me), Dn(!t?.children);
1288
+ const k = P(M, [M]), b = P(Ve, [Ve]), Re = P(R, [R]), ne = P(Et, [Et]), we = P(ke, [ke]), Ue = se(null), lt = se(null), Mt = se(null), [it, qt] = Zn((h) => h + 1, 0), [xt, v] = gt({ left: ut?.left ?? 0, top: ut?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), oe = se(null), He = se(xt), { top: ht, left: Je, verticalScrollDirection: ln, horizontalScrollDirection: _t } = xt, Tt = se(!1), hn = Bo({ rowCount: c, columnCount: d, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: w, getColumnWidth: L }), Gt = se(null), Pe = Ae(() => {
1289
+ const h = O || hn;
1290
+ return Gt.current = null, { getColOffset: (m) => h.getColOffset(m) * q, getColIndex: (m) => h.getColIndex(m / q), getRowOffset: (m) => h.getRowOffset(m) * q, getRowIndex: (m) => h.getRowIndex(m / q) };
1291
+ }, [hn, O, q]), Ut = (h, m, C) => {
1343
1292
  const S = (m?.left ?? 0) + 0, y = (m?.top ?? 0) + 0;
1344
- return { getColOffset: (B) => f.getColOffset(B) - S, getColIndex: (B) => f.getColIndex(B + S), getRowOffset: (B) => f.getRowOffset(B) - y, getRowIndex: (B) => f.getRowIndex(B + y) };
1345
- }, St = T((f, m = !1) => On(f, m, De.getRowOffset, m ? 0 : c), [c, De?.getRowOffset]), Bt = T(te ?? St, [te]), vn = T((f, m = !1) => On(f, m, De.getColOffset, m ? s : 0), [s, De?.getColOffset]), cn = T(be ?? vn, [be]), Ge = Ae(() => Math.min(o ?? 800, De.getColOffset(s)), [De.getColOffset, s, o]), Ke = Ae(() => Math.min(r ?? 600, De.getRowOffset(c)), [De.getRowOffset, c, r]), nn = W((f) => {
1293
+ return { getColOffset: (z) => h.getColOffset(z) - S, getColIndex: (z) => h.getColIndex(z + S), getRowOffset: (z) => h.getRowOffset(z) - y, getRowIndex: (z) => h.getRowIndex(z + y) };
1294
+ }, vt = P((h, m = !1) => On(h, m, Pe.getRowOffset, m ? 0 : c), [c, Pe?.getRowOffset]), Bt = P(Z ?? vt, [Z]), vn = P((h, m = !1) => On(h, m, Pe.getColOffset, m ? d : 0), [d, Pe?.getColOffset]), cn = P(be ?? vn, [be]), Ge = Ae(() => Math.min(o ?? 800, Pe.getColOffset(d)), [Pe.getColOffset, d, o]), Ke = Ae(() => Math.min(r ?? 600, Pe.getRowOffset(c)), [Pe.getRowOffset, c, r]), nn = V((h) => {
1346
1295
  Nt.canUseDOM && setTimeout(() => {
1347
- Ue.current?.focus({ preventScroll: !0, ...f });
1296
+ Ue.current?.focus({ preventScroll: !0, ...h });
1348
1297
  }, 0);
1349
- }, []), yt = W((f) => Ue.current?.contains(f) || lt.current?.contains(f), []);
1350
- wt(() => {
1351
- Dt.current && (re.current && re.current.left !== He.current?.left && re.current.top !== He.current?.top || (re.current = null, Me?.({ left: Qe, top: ft })));
1352
- }, [Qe, ft]);
1353
- const qt = T(() => ({ top: ft, left: Qe }), [ft, Qe]), ke = Ae(() => {
1354
- const f = [];
1298
+ }, []), St = V((h) => Ue.current?.contains(h) || lt.current?.contains(h), []);
1299
+ It(() => {
1300
+ Tt.current && (oe.current && oe.current.left !== He.current?.left && oe.current.top !== He.current?.top || (oe.current = null, Re?.({ left: Je, top: ht })));
1301
+ }, [Je, ht]);
1302
+ const jt = P(() => ({ top: ht, left: Je }), [ht, Je]), Me = Ae(() => {
1303
+ const h = [];
1355
1304
  let m = 0, C = 0;
1356
- typeof U == "number" ? m = U : (m = U.index ?? 0, C = (U.scrollOffset ?? 0) * X);
1357
- const S = C, y = De.getRowOffset(m), B = y - S;
1305
+ typeof _ == "number" ? m = _ : (m = _.index ?? 0, C = (_.scrollOffset ?? 0) * q);
1306
+ const S = C, y = Pe.getRowOffset(m), z = y - S;
1358
1307
  if (m > 0) {
1359
- const je = Ut(De, { top: C + De.getRowOffset(0) }), $e = De.getRowIndex(S), Je = De.getRowIndex(y - 1);
1308
+ const qe = Ut(Pe, { top: C + Pe.getRowOffset(0) }), $e = Pe.getRowIndex(S), Ze = Pe.getRowIndex(y - 1);
1360
1309
  let Te;
1361
- f[1] = { minIndex: $e, maxIndex: Je, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: B, visibleIndices: () => Te || (Te = Object.freeze(Pn(Bt, $e, Je)), Te), layout: je, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
1310
+ h[1] = { minIndex: $e, maxIndex: Ze, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: z, visibleIndices: () => Te || (Te = Object.freeze(Pn(Bt, $e, Ze)), Te), layout: qe, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
1362
1311
  }
1363
- const me = Math.max(0, Ke - B), le = Ut(De, { top: ft + B }), we = le.getRowIndex(0), H = le.getRowIndex(me);
1364
- let Re;
1365
- return f[0] = { minIndex: we, maxIndex: H, minCoord: m, maxCoord: c - 1, minBounds: B, maxBounds: me, visibleIndices: () => Re || (Re = Object.freeze(Pn(Bt, we, H)), Re), layout: le, maxVirtualBounds: De.getRowOffset(c), scrollOffset: ft, freezeOffset: (m > 0 ? De.getRowOffset(m) : 0) - C }, f;
1366
- }, [De.getRowIndex, De.getRowOffset, Bt, Ke, c, U, ft, X]), Ze = Ae(() => {
1367
- const f = [];
1312
+ const xe = Math.max(0, Ke - z), re = Ut(Pe, { top: ht + z }), fe = re.getRowIndex(0), U = re.getRowIndex(xe);
1313
+ let Ee;
1314
+ return h[0] = { minIndex: fe, maxIndex: U, minCoord: m, maxCoord: c - 1, minBounds: z, maxBounds: xe, visibleIndices: () => Ee || (Ee = Object.freeze(Pn(Bt, fe, U)), Ee), layout: re, maxVirtualBounds: Pe.getRowOffset(c), scrollOffset: ht, freezeOffset: (m > 0 ? Pe.getRowOffset(m) : 0) - C }, h;
1315
+ }, [Pe.getRowIndex, Pe.getRowOffset, Bt, Ke, c, _, ht, q]), _e = Ae(() => {
1316
+ const h = [];
1368
1317
  let m = 0, C = 0;
1369
- typeof k == "number" ? m = k : (m = k.index ?? 0, C = (k.scrollOffset ?? 0) * X);
1370
- const S = C, y = De.getColOffset(m), B = y - S;
1318
+ typeof T == "number" ? m = T : (m = T.index ?? 0, C = (T.scrollOffset ?? 0) * q);
1319
+ const S = C, y = Pe.getColOffset(m), z = y - S;
1371
1320
  if (m > 0) {
1372
- const je = Ut(De, { left: C + De.getColOffset(0) }), $e = De.getColIndex(S), Je = De.getColIndex(y - 1);
1321
+ const qe = Ut(Pe, { left: C + Pe.getColOffset(0) }), $e = Pe.getColIndex(S), Ze = Pe.getColIndex(y - 1);
1373
1322
  let Te;
1374
- f[1] = { minIndex: $e, maxIndex: Je, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: B, visibleIndices: () => Te || (Te = Object.freeze(Pn(cn, $e, Je)), Te), layout: je, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
1323
+ h[1] = { minIndex: $e, maxIndex: Ze, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: z, visibleIndices: () => Te || (Te = Object.freeze(Pn(cn, $e, Ze)), Te), layout: qe, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
1375
1324
  }
1376
- const me = Math.max(0, Ge - B), le = Ut(De, { left: Qe + B }), we = le.getColIndex(0), H = le.getColIndex(me);
1377
- let Re;
1378
- return f[0] = { minIndex: we, maxIndex: H, minCoord: m, maxCoord: s - 1, minBounds: B, maxBounds: me, visibleIndices: () => Re || (Re = Object.freeze(Pn(cn, we, H)), Re), layout: le, maxVirtualBounds: De.getColOffset(s), scrollOffset: Qe, freezeOffset: (m > 0 ? De.getColOffset(m) : 0) - C }, f;
1379
- }, [De.getColIndex, De.getColOffset, cn, Ge, s, k, Qe, X]), gt = ie({}), Rt = ie([]), Ee = Ae(() => {
1380
- let f = {};
1381
- const m = (S, y, B, me, le) => {
1382
- const we = { vertical: me?.vertical || !1, horizontal: me?.horizontal || !1 };
1383
- if (S >= Ze.length || y >= ke.length) return null;
1384
- const H = { rowStart: ke[y].minIndex, colStart: Ze[S].minIndex, rowEnd: ke[y].maxIndex, colEnd: Ze[S].maxIndex };
1385
- if (H.rowStart > H.rowEnd || H.colStart > H.colEnd) return null;
1386
- const Re = { getColIndex: (ne) => Ze[S].layout.getColIndex(ne), getColOffset: (ne) => Ze[S].layout.getColOffset(ne), getRowIndex: (ne) => ke[y].layout.getRowIndex(ne), getRowOffset: (ne) => ke[y].layout.getRowOffset(ne) }, je = Object.freeze({ left: le?.left ?? 0, top: le?.top ?? 0, right: le?.right ?? 0, bottom: le?.bottom ?? 0 }), $e = Object.freeze({ x: Ze[S].minBounds, y: ke[y].minBounds, width: Ze[S].maxBounds, height: ke[y].maxBounds }), Je = (ne, Ye) => so(Re, ne ?? H, Ye), Te = { width: Ze[S].maxVirtualBounds, height: ke[y].maxVirtualBounds }, de = { left: Ze[S].scrollOffset, top: ke[y].scrollOffset }, ct = { left: Ze[S].freezeOffset, top: ke[y].freezeOffset }, et = { width: Ge, height: Ke };
1325
+ const xe = Math.max(0, Ge - z), re = Ut(Pe, { left: Je + z }), fe = re.getColIndex(0), U = re.getColIndex(xe);
1326
+ let Ee;
1327
+ return h[0] = { minIndex: fe, maxIndex: U, minCoord: m, maxCoord: d - 1, minBounds: z, maxBounds: xe, visibleIndices: () => Ee || (Ee = Object.freeze(Pn(cn, fe, U)), Ee), layout: re, maxVirtualBounds: Pe.getColOffset(d), scrollOffset: Je, freezeOffset: (m > 0 ? Pe.getColOffset(m) : 0) - C }, h;
1328
+ }, [Pe.getColIndex, Pe.getColOffset, cn, Ge, d, T, Je, q]), ft = se({}), Rt = se([]), Ie = Ae(() => {
1329
+ let h = {};
1330
+ const m = (S, y, z, xe, re) => {
1331
+ const fe = { vertical: xe?.vertical || !1, horizontal: xe?.horizontal || !1 };
1332
+ if (S >= _e.length || y >= Me.length) return null;
1333
+ const U = { rowStart: Me[y].minIndex, colStart: _e[S].minIndex, rowEnd: Me[y].maxIndex, colEnd: _e[S].maxIndex };
1334
+ if (U.rowStart > U.rowEnd || U.colStart > U.colEnd) return null;
1335
+ const Ee = { getColIndex: (ee) => _e[S].layout.getColIndex(ee), getColOffset: (ee) => _e[S].layout.getColOffset(ee), getRowIndex: (ee) => Me[y].layout.getRowIndex(ee), getRowOffset: (ee) => Me[y].layout.getRowOffset(ee) }, qe = Object.freeze({ left: re?.left ?? 0, top: re?.top ?? 0, right: re?.right ?? 0, bottom: re?.bottom ?? 0 }), $e = Object.freeze({ x: _e[S].minBounds, y: Me[y].minBounds, width: _e[S].maxBounds, height: Me[y].maxBounds }), Ze = (ee, Ye) => io(Ee, ee ?? U, Ye), Te = { width: _e[S].maxVirtualBounds, height: Me[y].maxVirtualBounds }, ae = { left: _e[S].scrollOffset, top: Me[y].scrollOffset }, ct = { left: _e[S].freezeOffset, top: Me[y].freezeOffset }, et = { width: Ge, height: Ke };
1387
1336
  let Be = null, tt = null;
1388
- const bt = (ct.top + (me.vertical ? de.top : 0)) / X, qe = (ct.left + (me.horizontal ? de.left : 0)) / X;
1389
- return { getStage: () => Ue.current ?? null, getVisibleRangeCoords: () => H, toClipBounds: (ne, Ye) => {
1390
- let mt, Oe = 0;
1391
- return Ye === void 0 || typeof Ye == "number" ? (mt = Je(H), Oe = Ye) : mt = Ye, ((nt, Le, ze = 0) => {
1337
+ const yt = (ct.top + (xe.vertical ? ae.top : 0)) / q, je = (ct.left + (xe.horizontal ? ae.left : 0)) / q;
1338
+ return { getStage: () => Ue.current ?? null, getVisibleRangeCoords: () => U, toClipBounds: (ee, Ye) => {
1339
+ let pt, De = 0;
1340
+ return Ye === void 0 || typeof Ye == "number" ? (pt = Ze(U), De = Ye) : pt = Ye, ((nt, Le, Oe = 0) => {
1392
1341
  if (nt.x > Le.width || nt.y > Le.height) return null;
1393
- const vt = { left: nt.x, top: nt.y, bottom: nt.height + nt.y, right: nt.width + nt.x }, st = { left: Le.x + ze, top: Le.y + ze, bottom: Le.height - 2 * ze + Le.y, right: Le.width - 2 * ze + Le.x }, Ct = { left: Math.max(vt.left, st.left), top: Math.max(vt.top, st.top), bottom: Math.min(vt.bottom, st.bottom), right: Math.min(vt.right, st.right) }, Lt = { x: Ct.left, y: Ct.top, width: Ct.right - Ct.left, height: Ct.bottom - Ct.top };
1342
+ const mt = { left: nt.x, top: nt.y, bottom: nt.height + nt.y, right: nt.width + nt.x }, st = { left: Le.x + Oe, top: Le.y + Oe, bottom: Le.height - 2 * Oe + Le.y, right: Le.width - 2 * Oe + Le.x }, bt = { left: Math.max(mt.left, st.left), top: Math.max(mt.top, st.top), bottom: Math.min(mt.bottom, st.bottom), right: Math.min(mt.right, st.right) }, Lt = { x: bt.left, y: bt.top, width: bt.right - bt.left, height: bt.bottom - bt.top };
1394
1343
  return Lt.height < 0 || Lt.width < 0 ? null : Lt;
1395
- })(ne ?? { x: 0, y: 0, width: $e.width, height: $e.height }, mt, Oe);
1396
- }, toViewBounds: (ne) => qe === 0 && bt === 0 && X === 1 ? ne : { x: (ne.x - qe) * X, y: (ne.y - bt) * X, width: ne.width * X, height: ne.height * X }, toAbsoluteBounds: (ne) => qe === 0 && bt === 0 && X === 1 ? ne : { x: ne.x / X + qe, y: ne.y / X + bt, width: ne.width / X, height: ne.height / X }, getRelativePointFromClient: (ne, Ye) => {
1397
- const mt = sn(ne, Ye);
1398
- return { x: mt.x - $e.x, y: mt.y - $e.y };
1399
- }, getLayout: () => Re, getCellCoordsAsRangeCoords: xt, getVisibleColumns: () => Ze[S].visibleIndices(), getVisibleRows: () => ke[y].visibleIndices(), getVisibleColumnOffsets: () => (Be || (Be = co(Ze[S].layout, !0, Ze[S].visibleIndices(), H.colStart, H.colEnd)), Be), getVisibleRowOffsets: () => (tt || (tt = co(ke[y].layout, !1, ke[y].visibleIndices(), H.rowStart, H.rowEnd)), tt), getTotalRangeCoords: () => ({ colStart: Ze[S].minCoord, colEnd: Ze[S].maxCoord, rowStart: ke[y].minCoord, rowEnd: ke[y].maxCoord }), getRangeCoordsBounds: Je, scrollCellCoordsIntoView: (ne, Ye) => fn(ne, Ye, B), getCellCoordsFromClient: (ne, Ye, mt = !1) => {
1400
- const Oe = sn(ne, Ye);
1401
- if (!Oe) return null;
1402
- const nt = Re.getColIndex(Oe.x - $e.x), Le = { rowIndex: Re.getRowIndex(Oe.y - $e.y), colIndex: nt };
1403
- if (mt) return Le;
1404
- const ze = xt(Le);
1405
- return { rowIndex: ze.rowStart, colIndex: ze.colStart };
1406
- }, getZoom: () => X, getAnchor: () => B, getBounds: () => $e, getInsets: () => je, getTotalSize: () => Te, getViewportSize: () => et, getScrollTopLeft: () => de, getFreezeTopLeft: () => ct, getScrollOrientation: () => we, allViews: () => f };
1344
+ })(ee ?? { x: 0, y: 0, width: $e.width, height: $e.height }, pt, De);
1345
+ }, toViewBounds: (ee) => je === 0 && yt === 0 && q === 1 ? ee : { x: (ee.x - je) * q, y: (ee.y - yt) * q, width: ee.width * q, height: ee.height * q }, toAbsoluteBounds: (ee) => je === 0 && yt === 0 && q === 1 ? ee : { x: ee.x / q + je, y: ee.y / q + yt, width: ee.width / q, height: ee.height / q }, getRelativePointFromClient: (ee, Ye) => {
1346
+ const pt = sn(ee, Ye);
1347
+ return { x: pt.x - $e.x, y: pt.y - $e.y };
1348
+ }, getLayout: () => Ee, getCellCoordsAsRangeCoords: wt, getVisibleColumns: () => _e[S].visibleIndices(), getVisibleRows: () => Me[y].visibleIndices(), getVisibleColumnOffsets: () => (Be || (Be = lo(_e[S].layout, !0, _e[S].visibleIndices(), U.colStart, U.colEnd)), Be), getVisibleRowOffsets: () => (tt || (tt = lo(Me[y].layout, !1, Me[y].visibleIndices(), U.rowStart, U.rowEnd)), tt), getTotalRangeCoords: () => ({ colStart: _e[S].minCoord, colEnd: _e[S].maxCoord, rowStart: Me[y].minCoord, rowEnd: Me[y].maxCoord }), getRangeCoordsBounds: Ze, scrollCellCoordsIntoView: (ee, Ye) => fn(ee, Ye, z), getCellCoordsFromClient: (ee, Ye, pt = !1) => {
1349
+ const De = sn(ee, Ye);
1350
+ if (!De) return null;
1351
+ const nt = Ee.getColIndex(De.x - $e.x), Le = { rowIndex: Ee.getRowIndex(De.y - $e.y), colIndex: nt };
1352
+ if (pt) return Le;
1353
+ const Oe = wt(Le);
1354
+ return { rowIndex: Oe.rowStart, colIndex: Oe.colStart };
1355
+ }, getZoom: () => q, getAnchor: () => z, getBounds: () => $e, getInsets: () => qe, getTotalSize: () => Te, getViewportSize: () => et, getScrollTopLeft: () => ae, getFreezeTopLeft: () => ct, getScrollOrientation: () => fe, allViews: () => h };
1407
1356
  };
1408
- let C = f[_e.Center] = m(0, 0, _e.Center, cr, ir);
1409
- return C && (f[_e.Center] = C), C = m(0, 1, _e.Top, { horizontal: !0 }), C && (f[_e.Top] = C), C = m(1, 0, _e.Left, { vertical: !0 }), C && (f[_e.Left] = C), C = m(1, 1, _e.TopLeft, {}), C && (f[_e.TopLeft] = C), gt.current = null, f = Object.freeze(f);
1410
- }, [ke, Ze, xt]), Jt = Object.keys(Ee), zt = Ze[0]?.maxVirtualBounds ?? 0, ot = ke[0]?.maxVirtualBounds ?? 0, kt = Ae(() => ({ left: Ze[1] ? Ze[1].layout.getColOffset(Ze[1].maxIndex + 1) : 0, top: ke[1] ? ke[1].layout.getRowOffset(ke[1].maxIndex + 1) : 0 }), [Ee]);
1411
- wt(() => {
1357
+ let C = h[Qe.Center] = m(0, 0, Qe.Center, er, Qo);
1358
+ return C && (h[Qe.Center] = C), C = m(0, 1, Qe.Top, { horizontal: !0 }), C && (h[Qe.Top] = C), C = m(1, 0, Qe.Left, { vertical: !0 }), C && (h[Qe.Left] = C), C = m(1, 1, Qe.TopLeft, {}), C && (h[Qe.TopLeft] = C), ft.current = null, h = Object.freeze(h);
1359
+ }, [Me, _e, wt]), Zt = Object.keys(Ie), zt = _e[0]?.maxVirtualBounds ?? 0, ot = Me[0]?.maxVirtualBounds ?? 0, kt = Ae(() => ({ left: _e[1] ? _e[1].layout.getColOffset(_e[1].maxIndex + 1) : 0, top: Me[1] ? Me[1].layout.getRowOffset(Me[1].maxIndex + 1) : 0 }), [Ie]);
1360
+ It(() => {
1412
1361
  if (Rt.current.length > 0) {
1413
- for (let f = 0; f < Rt.current.length; f++) Rt.current[f]();
1362
+ for (let h = 0; h < Rt.current.length; h++) Rt.current[h]();
1414
1363
  Rt.current = [];
1415
1364
  }
1416
- }, [Ee]);
1417
- const Tt = T(() => ({ containerWidth: Ge, containerHeight: Ke, totalWidth: zt, totalHeight: ot }), [Ge, Ke, De]);
1418
- wt(() => {
1419
- !re.current && Dt.current && b({ top: ft, left: Qe, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
1420
- }, [ft, Qe, zt, ot]), wt(() => {
1421
- Dt.current && b({ top: ft, left: Qe, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
1365
+ }, [Ie]);
1366
+ const Dt = P(() => ({ containerWidth: Ge, containerHeight: Ke, totalWidth: zt, totalHeight: ot }), [Ge, Ke, Pe]);
1367
+ It(() => {
1368
+ !oe.current && Tt.current && b({ top: ht, left: Je, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
1369
+ }, [ht, Je, zt, ot]), It(() => {
1370
+ Tt.current && b({ top: ht, left: Je, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
1422
1371
  }, [Ge, Ke]);
1423
- const sn = W((f, m) => {
1424
- Tn(typeof f == "number" && typeof m == "number");
1372
+ const sn = V((h, m) => {
1373
+ Dn(typeof h == "number" && typeof m == "number");
1425
1374
  const C = Ue.current?.getBoundingClientRect();
1426
- return C ? { x: f - C.x, y: m - C.y } : { x: f, y: m };
1427
- }, []), Ln = T((f) => Ee[f] || null, [Ee]), $n = T((f, m) => {
1428
- if (Object.keys(Ee).length === 1) return Ee[_e.Center];
1429
- const C = sn(f, m);
1375
+ return C ? { x: h - C.x, y: m - C.y } : { x: h, y: m };
1376
+ }, []), zn = P((h) => Ie[h] || null, [Ie]), Ln = P((h, m) => {
1377
+ if (Object.keys(Ie).length === 1) return Ie[Qe.Center];
1378
+ const C = sn(h, m);
1430
1379
  if (!C) return null;
1431
1380
  const { x: S, y } = C;
1432
- let B = null;
1433
- const me = ho, le = me.length;
1434
- for (let we = 0; !B && we < le; we++) {
1435
- const H = Ee[me[we]];
1436
- H && Qo(S, y, H.getBounds()) && (B = H);
1381
+ let z = null;
1382
+ const xe = ao, re = xe.length;
1383
+ for (let fe = 0; !z && fe < re; fe++) {
1384
+ const U = Ie[xe[fe]];
1385
+ U && qo(S, y, U.getBounds()) && (z = U);
1437
1386
  }
1438
- return B || (B = Ee[_e.Center]), B;
1439
- }, [Ee, xt]), rt = T(() => Ee[_e.Center].getVisibleRangeCoords(), [Ee[_e.Center]]), Yt = ie(null), Bn = W(() => {
1440
- Yt.current !== null && Nt.cancelTimeout(Yt.current), Yt.current = Nt.requestTimeout(An, 150);
1441
- }, []), An = W(() => {
1442
- Yt.current = null, v((f) => {
1443
- const m = { ...f, verticalScrollDirection: null, horizontalScrollDirection: null };
1387
+ return z || (z = Ie[Qe.Center]), z;
1388
+ }, [Ie, wt]), rt = P(() => Ie[Qe.Center].getVisibleRangeCoords(), [Ie[Qe.Center]]), Yt = se(null), $n = V(() => {
1389
+ Yt.current !== null && Nt.cancelTimeout(Yt.current), Yt.current = Nt.requestTimeout(Bn, 150);
1390
+ }, []), Bn = V(() => {
1391
+ Yt.current = null, v((h) => {
1392
+ const m = { ...h, verticalScrollDirection: null, horizontalScrollDirection: null };
1444
1393
  return He.current = m, m;
1445
1394
  });
1446
- }, []), Qt = T((f) => {
1447
- const m = f?.left ?? f?.[0], C = f?.top ?? f?.[1];
1395
+ }, []), Jt = P((h) => {
1396
+ const m = h?.left ?? h?.[0], C = h?.top ?? h?.[1];
1448
1397
  let S = He.current.left;
1449
- m !== void 0 && m !== S && (m > S ? (S = Math.max(Ze?.[1]?.scrollOffset ?? 0, m), S = Math.min(zt - Ge, S)) : S = Math.max(Ze?.[1]?.scrollOffset ?? 0, m));
1398
+ m !== void 0 && m !== S && (m > S ? (S = Math.max(_e?.[1]?.scrollOffset ?? 0, m), S = Math.min(zt - Ge, S)) : S = Math.max(_e?.[1]?.scrollOffset ?? 0, m));
1450
1399
  let y = He.current.top;
1451
- if (C !== void 0 && C !== y && (C > y ? (y = Math.max(ke?.[1]?.scrollOffset ?? 0, C), y = Math.min(ot - Ke, y)) : y = Math.max(ke?.[1]?.scrollOffset ?? 0, C)), He.current.left === S && He.current.top === y) return;
1452
- let B = null, me = null;
1453
- He.current.left > S ? B = w.Left : He.current.left < S && (B = w.Right), He.current.top > y ? me = w.Up : He.current.top < y && (me = w.Down), Nt.throttle(() => {
1454
- v((le) => {
1455
- const we = { ...le, left: S, top: y, horizontalScrollDirection: B, verticalScrollDirection: me };
1456
- return He.current = we, we;
1400
+ if (C !== void 0 && C !== y && (C > y ? (y = Math.max(Me?.[1]?.scrollOffset ?? 0, C), y = Math.min(ot - Ke, y)) : y = Math.max(Me?.[1]?.scrollOffset ?? 0, C)), He.current.left === S && He.current.top === y) return;
1401
+ let z = null, xe = null;
1402
+ He.current.left > S ? z = g.Left : He.current.left < S && (z = g.Right), He.current.top > y ? xe = g.Up : He.current.top < y && (xe = g.Down), Nt.throttle(() => {
1403
+ v((re) => {
1404
+ const fe = { ...re, left: S, top: y, horizontalScrollDirection: z, verticalScrollDirection: xe };
1405
+ return He.current = fe, fe;
1457
1406
  });
1458
- }, 17)(), re.current?.top === y && re.current?.left === S || (re.current = { left: S, top: y }, D({ left: S, top: y }), b({ left: S, top: y, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot })), Bn();
1459
- }, [zt, ot, ke, Ze]);
1460
- wt(() => {
1461
- re.current || Qt({ left: Qe, top: ft });
1462
- }, [Ge, Ke]), wt(() => {
1463
- let f, m, C = !1;
1464
- He.current.left > zt && (f = 0, C = !0), He.current.top > ot && (m = 0, C = !0), C && Qt({ left: f, top: m });
1407
+ }, 17)(), oe.current?.top === y && oe.current?.left === S || (oe.current = { left: S, top: y }, k({ left: S, top: y }), b({ left: S, top: y, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot })), $n();
1408
+ }, [zt, ot, Me, _e]);
1409
+ It(() => {
1410
+ oe.current || Jt({ left: Je, top: ht });
1411
+ }, [Ge, Ke]), It(() => {
1412
+ let h, m, C = !1;
1413
+ He.current.left > zt && (h = 0, C = !0), He.current.top > ot && (m = 0, C = !0), C && Jt({ left: h, top: m });
1465
1414
  }, [zt, ot]), en(() => {
1466
- re.current = { left: ht?.left, top: ht?.top }, Qt(re.current);
1467
- }, [ht?.left, ht?.top]);
1468
- const Sn = T((f) => {
1469
- let m = f?.left ?? f?.[0], C = f?.top ?? f?.[1];
1415
+ oe.current = { left: ut?.left, top: ut?.top }, Jt(oe.current);
1416
+ }, [ut?.left, ut?.top]);
1417
+ const Sn = P((h) => {
1418
+ let m = h?.left ?? h?.[0], C = h?.top ?? h?.[1];
1470
1419
  if (m === void 0 && C === void 0) return;
1471
- const S = f?.behavior ?? "auto";
1472
- m !== void 0 && (m = He.current.left + (m ?? 0)), C !== void 0 && (C = He.current.top + (C ?? 0)), !(He.current.left === m && He.current.top === C) && Qt({ left: m, top: C, behavior: S });
1473
- }, []), yn = W((f) => {
1420
+ const S = h?.behavior ?? "auto";
1421
+ m !== void 0 && (m = He.current.left + (m ?? 0)), C !== void 0 && (C = He.current.top + (C ?? 0)), !(He.current.left === m && He.current.top === C) && Jt({ left: m, top: C, behavior: S });
1422
+ }, []), yn = V((h) => {
1474
1423
  let m = null;
1475
- if (Object.keys(Ee).length > 1) {
1476
- const C = ho, S = C.length;
1424
+ if (Object.keys(Ie).length > 1) {
1425
+ const C = ao, S = C.length;
1477
1426
  for (let y = 0; !m && y < S; y++) {
1478
- const B = Ee[C[y]];
1479
- B && V.isCellWithinRange(f, B.getVisibleRangeCoords()) && (m = B);
1427
+ const z = Ie[C[y]];
1428
+ z && F.isCellWithinRange(h, z.getVisibleRangeCoords()) && (m = z);
1480
1429
  }
1481
1430
  }
1482
- return m || (m = Ee[_e.Center]), m;
1483
- }, [Ee]), fn = T((f, m = { inline: "nearest", block: "nearest" }, C = null) => {
1484
- const S = { rowIndex: 0, colIndex: 0, ...f };
1431
+ return m || (m = Ie[Qe.Center]), m;
1432
+ }, [Ie]), fn = P((h, m = { inline: "nearest", block: "nearest" }, C = null) => {
1433
+ const S = { rowIndex: 0, colIndex: 0, ...h };
1485
1434
  let y = null;
1486
1435
  if (C !== null) {
1487
- if (y = Ee[C], y === null) return new Promise((et, Be) => {
1436
+ if (y = Ie[C], y === null) return new Promise((et, Be) => {
1488
1437
  Be("Invalid view");
1489
1438
  });
1490
1439
  } else y = yn(S);
1491
- const B = xt(S), me = y.getLayout(), le = me.getColOffset(B.colStart), we = me.getRowOffset(B.rowStart), H = me.getColOffset(B.colEnd + 1), Re = me.getRowOffset(B.rowEnd + 1), je = y.getBounds(), $e = y.getTotalSize(), Je = y.getScrollTopLeft(), Te = ((et, Be, tt = !0) => {
1440
+ const z = wt(S), xe = y.getLayout(), re = xe.getColOffset(z.colStart), fe = xe.getRowOffset(z.rowStart), U = xe.getColOffset(z.colEnd + 1), Ee = xe.getRowOffset(z.rowEnd + 1), qe = y.getBounds(), $e = y.getTotalSize(), Ze = y.getScrollTopLeft(), Te = ((et, Be, tt = !0) => {
1492
1441
  tt = tt === !0 ? { block: "start", inline: "end" } : tt === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...tt };
1493
- const bt = ro(tt.inline, et.x, et.x + et.width, Be.left, Be.left + Be.width, Be.totalWidth), qe = ro(tt.block, et.y, et.y + et.height, Be.top, Be.top + Be.height, Be.totalHeight);
1494
- if (bt !== void 0 || qe !== void 0) return { left: bt, top: qe };
1495
- })({ x: le + Je.left, y: we + Je.top, width: H - le, height: Re - we }, { left: Je.left, top: Je.top, width: je.width, height: je.height, totalWidth: $e.width, totalHeight: $e.height }, m);
1496
- if (!Te) return Promise.resolve({ ...Je });
1497
- const de = { ...Te };
1498
- de.left > Qe ? de.left += 20 : de.left < Qe && (de.left -= 0), de.top > ft ? de.top += 20 : de.top < ft && (de.top -= 0);
1442
+ const yt = no(tt.inline, et.x, et.x + et.width, Be.left, Be.left + Be.width, Be.totalWidth), je = no(tt.block, et.y, et.y + et.height, Be.top, Be.top + Be.height, Be.totalHeight);
1443
+ if (yt !== void 0 || je !== void 0) return { left: yt, top: je };
1444
+ })({ x: re + Ze.left, y: fe + Ze.top, width: U - re, height: Ee - fe }, { left: Ze.left, top: Ze.top, width: qe.width, height: qe.height, totalWidth: $e.width, totalHeight: $e.height }, m);
1445
+ if (!Te) return Promise.resolve({ ...Ze });
1446
+ const ae = { ...Te };
1447
+ ae.left > Je ? ae.left += 20 : ae.left < Je && (ae.left -= 0), ae.top > ht ? ae.top += 20 : ae.top < ht && (ae.top -= 0);
1499
1448
  const ct = y.getScrollOrientation();
1500
- return ct.horizontal && f.colIndex !== void 0 || delete de.left, ct.vertical && f.rowIndex !== void 0 || delete de.top, new Promise((et, Be) => {
1449
+ return ct.horizontal && h.colIndex !== void 0 || delete ae.left, ct.vertical && h.rowIndex !== void 0 || delete ae.top, new Promise((et, Be) => {
1501
1450
  try {
1502
- Qt(de), et(de);
1451
+ Jt(ae), et(ae);
1503
1452
  } catch (tt) {
1504
1453
  Be(tt);
1505
1454
  }
1506
1455
  });
1507
- }, [zt, ot, Ee, xt]), an = T((f) => {
1508
- const m = f.shiftKey;
1509
- f.preventDefault();
1510
- const { deltaX: C, deltaY: S, deltaMode: y } = f;
1511
- if (Mt.current || oe?.(f) === !1) return;
1512
- let me = m ? S : C, le = S;
1513
- const we = m || Math.abs(me) > Math.abs(le);
1514
- y === 1 && (le *= 0), Mt.current = window.requestAnimationFrame(() => {
1515
- Mt.current = null, Sn(we ? { left: me } : { top: le });
1456
+ }, [zt, ot, Ie, wt]), an = P((h) => {
1457
+ const m = h.shiftKey;
1458
+ h.preventDefault();
1459
+ const { deltaX: C, deltaY: S, deltaMode: y } = h;
1460
+ if (Mt.current || ne?.(h) === !1) return;
1461
+ let xe = m ? S : C, re = S;
1462
+ const fe = m || Math.abs(xe) > Math.abs(re);
1463
+ y === 1 && (re *= 0), Mt.current = window.requestAnimationFrame(() => {
1464
+ Mt.current = null, Sn(fe ? { left: xe } : { top: re });
1516
1465
  });
1517
- }, [oe]), gn = W((f = null) => {
1518
- Gt.current = null, gt.current = null, jt();
1466
+ }, [ne]), gn = V((h = null) => {
1467
+ Gt.current = null, ft.current = null, qt();
1519
1468
  }, []);
1520
1469
  en(() => {
1521
1470
  gn();
1522
- }, [ce]);
1523
- const on = wo(n, () => ({ stage: Ue.current, focus: nn, contains: yt, invalidate: gn, scrollTo: Qt, scrollBy: Sn, scrollCellCoordsIntoView: fn, getScrollPosition: qt, getDimensions: Tt, getViewport: rt, handleWheel: an, rowCount: c, columnCount: s, getLayout: () => De, getRelativePointFromClient: sn, getViewFromClient: $n, getViewFromCellCoords: yn, getViewFromLocation: Ln, onViewChangeOnce: (f) => {
1524
- Rt.current.push(f);
1525
- } }), [c, s, Ee]);
1526
- wt(() => (Pt && on.current?.addEventListener("wheel", an, { passive: !1 }), Dt.current = !0, re.current = null, () => {
1471
+ }, [me]);
1472
+ const on = go(n, () => ({ stage: Ue.current, focus: nn, contains: St, invalidate: gn, scrollTo: Jt, scrollBy: Sn, scrollCellCoordsIntoView: fn, getScrollPosition: jt, getDimensions: Dt, getViewport: rt, handleWheel: an, rowCount: c, columnCount: d, getLayout: () => Pe, getRelativePointFromClient: sn, getViewFromClient: Ln, getViewFromCellCoords: yn, getViewFromLocation: zn, onViewChangeOnce: (h) => {
1473
+ Rt.current.push(h);
1474
+ } }), [c, d, Ie]);
1475
+ It(() => (Pt && on.current?.addEventListener("wheel", an, { passive: !1 }), Tt.current = !0, oe.current = null, () => {
1527
1476
  on.current?.removeEventListener("wheel", an);
1528
1477
  }), [Pt]);
1529
- const wn = ie([]), Fn = (f, m) => {
1530
- !f || !We || (wn.current = [], m.push(((C, S) => {
1531
- const y = `view:${C.getAnchor()}:overlay:${m.length}`, B = We?.({ key: y, view: C }, (le) => wn.current[S] = le);
1532
- if (!B) return null;
1533
- const me = C.getBounds();
1534
- return Ce("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${me.width}px`, height: `${me.height}px`, overflow: "hidden" }, children: B }, `overlay-${C.getAnchor()}-${S}`);
1535
- })(f, 0)));
1536
- }, Vn = Ae(() => {
1537
- const f = {}, m = Object.keys(Ee), C = m.length;
1478
+ const wn = se([]), An = (h, m) => {
1479
+ !h || !We || (wn.current = [], m.push(((C, S) => {
1480
+ const y = `view:${C.getAnchor()}:overlay:${m.length}`, z = We?.({ key: y, view: C }, (re) => wn.current[S] = re);
1481
+ if (!z) return null;
1482
+ const xe = C.getBounds();
1483
+ return Ce("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${xe.width}px`, height: `${xe.height}px`, overflow: "hidden" }, children: z }, `overlay-${C.getAnchor()}-${S}`);
1484
+ })(h, 0)));
1485
+ }, Fn = Ae(() => {
1486
+ const h = {}, m = Object.keys(Ie), C = m.length;
1538
1487
  for (let S = 0; S < C; S++) {
1539
- const y = m[S], B = [];
1540
- Fn(Ee[y], B), f[y] = { overlays: B };
1488
+ const y = m[S], z = [];
1489
+ An(Ie[y], z), h[y] = { overlays: z };
1541
1490
  }
1542
- return f;
1543
- }, [it, We, c, s, ke, Ze]), bn = (f, m, C, S, y, B, me) => {
1544
- if (!f) return;
1545
- const le = f.getVisibleColumns(), we = f.getVisibleRows();
1546
- if (le.length === 0 || we.length === 0) return;
1547
- let H = null;
1548
- if (L) H = L(f);
1491
+ return h;
1492
+ }, [it, We, c, d, Me, _e]), bn = (h, m, C, S, y, z, xe) => {
1493
+ if (!h) return;
1494
+ const re = h.getVisibleColumns(), fe = h.getVisibleRows();
1495
+ if (re.length === 0 || fe.length === 0) return;
1496
+ let U = null;
1497
+ if (D) U = D(h);
1549
1498
  else {
1550
- H = [];
1551
- const Oe = we.length, nt = le.length;
1552
- for (let Le = 0; Le < Oe; Le++) {
1553
- const ze = we[Le];
1554
- for (let vt = 0; vt < nt; vt++) {
1555
- const st = { rowIndex: ze, colIndex: le[vt] };
1556
- if (J?.(st)) continue;
1557
- const Ct = { coords: st, range: xt(st) };
1558
- H.push(Ct);
1499
+ U = [];
1500
+ const De = fe.length, nt = re.length;
1501
+ for (let Le = 0; Le < De; Le++) {
1502
+ const Oe = fe[Le];
1503
+ for (let mt = 0; mt < nt; mt++) {
1504
+ const st = { rowIndex: Oe, colIndex: re[mt] };
1505
+ if (Y?.(st)) continue;
1506
+ const bt = { coords: st, range: wt(st) };
1507
+ U.push(bt);
1559
1508
  }
1560
1509
  }
1561
1510
  }
1562
- const Re = f.getVisibleColumnOffsets(), je = f.getVisibleRowOffsets(), $e = f.getScrollTopLeft(), Je = f.getFreezeTopLeft(), Te = $e.left + Je.left, de = $e.top + Je.top, ct = Math.trunc(Te / Xt), et = Math.trunc(de / Xt), Be = {}, tt = (Oe, nt, Le, ze, vt) => {
1563
- const st = `view:${Oe.getAnchor()}:cell:${oo(nt.rowIndex, nt.colIndex)}`, Ct = ze.x, Lt = ze.y, e = Math.trunc((Te + Ct) / Xt) - ct, a = Math.trunc((de + Lt) / Xt) - et;
1564
- Be[a] || (Be[a] = {});
1565
- let u = Be[a][e];
1566
- u || (u = Be[a][e] = []);
1567
- let d = B?.get(st);
1568
- if (!d) {
1569
- const g = (Te + Ct) % Xt, E = (de + Lt) % Xt;
1570
- d = ce({ key: st, coords: nt, bounds: ze, zoom: X, range: Le, view: Oe, value: vt, style: { left: Q.boundPixel(g), top: Q.boundPixel(E), width: Q.boundPixel(ze.width, !0), height: Q.boundPixel(ze.height, !0) } });
1511
+ const Ee = h.getVisibleColumnOffsets(), qe = h.getVisibleRowOffsets(), $e = h.getScrollTopLeft(), Ze = h.getFreezeTopLeft(), Te = $e.left + Ze.left, ae = $e.top + Ze.top, ct = Math.trunc(Te / Xt), et = Math.trunc(ae / Xt), Be = {}, tt = (De, nt, Le, Oe, mt) => {
1512
+ const st = `view:${De.getAnchor()}:cell:${to(nt.rowIndex, nt.colIndex)}`, bt = Oe.x, Lt = Oe.y, e = Math.trunc((Te + bt) / Xt) - ct, s = Math.trunc((ae + Lt) / Xt) - et;
1513
+ Be[s] || (Be[s] = {});
1514
+ let u = Be[s][e];
1515
+ u || (u = Be[s][e] = []);
1516
+ let a = z?.get(st);
1517
+ if (!a) {
1518
+ const f = (Te + bt) % Xt, E = (ae + Lt) % Xt;
1519
+ a = me({ key: st, coords: nt, bounds: Oe, zoom: q, range: Le, view: De, value: mt, style: { left: X.boundPixel(f), top: X.boundPixel(E), width: X.boundPixel(Oe.width, !0), height: X.boundPixel(Oe.height, !0) } });
1571
1520
  }
1572
- me?.set(st, d), u.push(d);
1573
- }, bt = H.length;
1574
- for (let Oe = 0; H && Oe < bt; Oe++) {
1575
- const nt = H[Oe], Le = nt?.coords ?? nt;
1521
+ xe?.set(st, a), u.push(a);
1522
+ }, yt = U.length;
1523
+ for (let De = 0; U && De < yt; De++) {
1524
+ const nt = U[De], Le = nt?.coords ?? nt;
1576
1525
  if (!Le) continue;
1577
- const ze = nt?.range ?? { rowStart: Le.rowIndex, colStart: Le.colIndex, rowEnd: Le.rowIndex, colEnd: Le.colIndex }, vt = f.getVisibleRangeCoords();
1578
- if (!V.isRangesIntersect(ze, vt) && !V.isRangeWithinRange(ze, vt)) continue;
1579
- const st = ze && !V.isSingleCell(ze);
1580
- if (!st && J?.(Le)) continue;
1581
- const Ct = Le.rowIndex, Lt = Le.colIndex, e = je[Ct], a = Re[Lt];
1526
+ const Oe = nt?.range ?? { rowStart: Le.rowIndex, colStart: Le.colIndex, rowEnd: Le.rowIndex, colEnd: Le.colIndex }, mt = h.getVisibleRangeCoords();
1527
+ if (!F.isRangesIntersect(Oe, mt) && !F.isRangeWithinRange(Oe, mt)) continue;
1528
+ const st = Oe && !F.isSingleCell(Oe);
1529
+ if (!st && Y?.(Le)) continue;
1530
+ const bt = Le.rowIndex, Lt = Le.colIndex, e = qe[bt], s = Ee[Lt];
1582
1531
  let u = null;
1583
- e && a && (u = { x: a.offset, y: e.offset, width: a.size, height: e.size });
1584
- const d = oo(ze.rowStart, ze.colStart);
1532
+ e && s && (u = { x: s.offset, y: e.offset, width: s.size, height: e.size });
1533
+ const a = to(Oe.rowStart, Oe.colStart);
1585
1534
  if (st) {
1586
- if (y.has(d)) continue;
1587
- y.add(d), ze.rowEnd - ze.rowStart > 0 && C.push(ze), ze.colEnd - ze.colStart > 0 && S.push(ze);
1535
+ if (y.has(a)) continue;
1536
+ y.add(a), Oe.rowEnd - Oe.rowStart > 0 && C.push(Oe), Oe.colEnd - Oe.colStart > 0 && S.push(Oe);
1588
1537
  }
1589
- if (st && (u = so(f.getLayout(), ze)), !u) {
1590
- console.warn("no bounds for cell", d);
1538
+ if (st && (u = io(h.getLayout(), Oe)), !u) {
1539
+ console.warn("no bounds for cell", a);
1591
1540
  continue;
1592
1541
  }
1593
- const g = nt?.value;
1594
- tt(f, Le, ze, u, g);
1542
+ const f = nt?.value;
1543
+ tt(h, Le, Oe, u, f);
1595
1544
  }
1596
- const qe = Te % Xt, ne = de % Xt, Ye = Object.keys(Be), mt = Ye.length;
1597
- for (let Oe = 0; Oe < mt; Oe++) {
1598
- const nt = Ye[Oe], Le = Be[nt];
1545
+ const je = Te % Xt, ee = ae % Xt, Ye = Object.keys(Be), pt = Ye.length;
1546
+ for (let De = 0; De < pt; De++) {
1547
+ const nt = Ye[De], Le = Be[nt];
1599
1548
  if (!Le) continue;
1600
- const ze = Object.keys(Le), vt = ze.length;
1601
- for (let st = 0; st < vt; st++) {
1602
- const Ct = ze[st], Lt = Le[Ct];
1549
+ const Oe = Object.keys(Le), mt = Oe.length;
1550
+ for (let st = 0; st < mt; st++) {
1551
+ const bt = Oe[st], Lt = Le[bt];
1603
1552
  if (!Lt) continue;
1604
- const e = parseInt(nt), a = parseInt(Ct), u = e + et, d = a + ct, g = `view:${f.getAnchor()}:segment:${d}:${u}`;
1605
- m.push(Ce("div", { className: "cell-container", style: { transform: `translate(${Q.boundPixel(a * Xt - qe, !0)}px, ${Q.boundPixel(e * Xt - ne, !0)}px)`, willChange: "transform" }, children: Lt }, g));
1553
+ const e = parseInt(nt), s = parseInt(bt), u = e + et, a = s + ct, f = `view:${h.getAnchor()}:segment:${a}:${u}`;
1554
+ m.push(Ce("div", { className: "cell-container", style: { transform: `translate(${X.boundPixel(s * Xt - je, !0)}px, ${X.boundPixel(e * Xt - ee, !0)}px)`, willChange: "transform" }, children: Lt }, f));
1606
1555
  }
1607
1556
  }
1608
1557
  }, At = Ae(() => {
1609
- const f = Gt.current, m = /* @__PURE__ */ new Map(), C = {}, S = Object.keys(Ee), y = S.length;
1610
- for (let B = 0; B < y; B++) {
1611
- const me = S[B], le = [], we = [], H = [];
1612
- bn(Ee[me], H, le, we, /* @__PURE__ */ new Set(), f, m), C[me] = { cells: H, rangesH: le, rangesV: we };
1558
+ const h = Gt.current, m = /* @__PURE__ */ new Map(), C = {}, S = Object.keys(Ie), y = S.length;
1559
+ for (let z = 0; z < y; z++) {
1560
+ const xe = S[z], re = [], fe = [], U = [];
1561
+ bn(Ie[xe], U, re, fe, /* @__PURE__ */ new Set(), h, m), C[xe] = { cells: U, rangesH: re, rangesV: fe };
1613
1562
  }
1614
1563
  return Gt.current = m, C;
1615
- }, [it, c, s, ke, Ze, $, ge, Ie, J, L, be, te, xt]), Cn = (f, m, C, S, y) => {
1616
- if (!f) return;
1617
- const B = f.getLayout(), me = window.devicePixelRatio || 1, le = String(1 / me);
1564
+ }, [it, c, d, Me, _e, A, he, ze, Y, D, be, Z, wt]), Cn = (h, m, C, S, y) => {
1565
+ if (!h) return;
1566
+ const z = h.getLayout(), xe = window.devicePixelRatio || 1, re = String(1 / xe);
1618
1567
  if (m) {
1619
- const we = `view:${f.getAnchor()}:hl:`, H = f.getVisibleRows();
1620
- if ((H ? H.length : 0) === 0) return;
1621
- const Re = y.sort(V.rowFirstRangeComparator), je = f.getVisibleRangeCoords(), $e = 0, Je = Math.min(f.getBounds().width, B.getColOffset(je.colEnd + 1));
1568
+ const fe = `view:${h.getAnchor()}:hl:`, U = h.getVisibleRows();
1569
+ if ((U ? U.length : 0) === 0) return;
1570
+ const Ee = y.sort(F.rowFirstRangeComparator), qe = h.getVisibleRangeCoords(), $e = 0, Ze = Math.min(h.getBounds().width, z.getColOffset(qe.colEnd + 1));
1622
1571
  let Te = [];
1623
- for (let de = 0; de < H.length && H[de] <= je.rowEnd; de++) {
1624
- const ct = H[de];
1625
- if (ct < je.rowStart) continue;
1572
+ for (let ae = 0; ae < U.length && U[ae] <= qe.rowEnd; ae++) {
1573
+ const ct = U[ae];
1574
+ if (ct < qe.rowStart) continue;
1626
1575
  let et = !1;
1627
- for (; Re.length > 0 && Re[0].rowStart <= ct; ) {
1628
- const qe = Re.shift();
1629
- qe.rowEnd > ct && (Te.push(qe), et = !0);
1576
+ for (; Ee.length > 0 && Ee[0].rowStart <= ct; ) {
1577
+ const je = Ee.shift();
1578
+ je.rowEnd > ct && (Te.push(je), et = !0);
1630
1579
  }
1631
- et && (Te = Te.sort(V.columnFirstRangeComparator));
1632
- const Be = B.getRowOffset(ct + 1);
1580
+ et && (Te = Te.sort(F.columnFirstRangeComparator));
1581
+ const Be = z.getRowOffset(ct + 1);
1633
1582
  let tt = $e;
1634
- const bt = Te.length;
1635
- for (let qe = 0; qe < bt + 1; qe++) {
1636
- let ne = tt, Ye = Je;
1637
- const mt = Te[qe];
1638
- qe < bt && (Ye = Math.min(Je, B.getColOffset(mt.colStart)), tt = Math.min(Je, B.getColOffset(mt.colEnd + 1))), S.push(xo("path", { d: `M ${Q.boundPixel(ne)} ${Q.boundPixel(Be, !1, C)} L ${Q.boundPixel(Ye)} ${Q.boundPixel(Be, !1, C)}`, stroke: Y, strokeWidth: le, vectorEffect: "non-scaling-stroke", ...q, key: we + ct + ":" + qe }));
1583
+ const yt = Te.length;
1584
+ for (let je = 0; je < yt + 1; je++) {
1585
+ let ee = tt, Ye = Ze;
1586
+ const pt = Te[je];
1587
+ je < yt && (Ye = Math.min(Ze, z.getColOffset(pt.colStart)), tt = Math.min(Ze, z.getColOffset(pt.colEnd + 1))), S.push(wo("path", { d: `M ${X.boundPixel(ee)} ${X.boundPixel(Be, !1, C)} L ${X.boundPixel(Ye)} ${X.boundPixel(Be, !1, C)}`, stroke: le, strokeWidth: re, vectorEffect: "non-scaling-stroke", ...J, key: fe + ct + ":" + je }));
1639
1588
  }
1640
- for (let qe = bt - 1; qe >= 0; qe--) Te[qe].rowEnd <= H[de + 1] && Te.splice(qe, 1);
1589
+ for (let je = yt - 1; je >= 0; je--) Te[je].rowEnd <= U[ae + 1] && Te.splice(je, 1);
1641
1590
  }
1642
1591
  } else {
1643
- const we = `view:${f.getAnchor()}:vl:`, H = f.getVisibleColumns(), Re = H ? H.length : 0;
1644
- if (Re === 0) return;
1645
- const je = y.sort(V.columnFirstRangeComparator), $e = f.getVisibleRangeCoords(), Je = 0, Te = Math.min(f.getBounds().height, B.getRowOffset($e.rowEnd + 1));
1646
- let de = [];
1647
- for (let ct = 0; ct < Re && H[ct] <= $e.colEnd; ct++) {
1648
- const et = H[ct];
1592
+ const fe = `view:${h.getAnchor()}:vl:`, U = h.getVisibleColumns(), Ee = U ? U.length : 0;
1593
+ if (Ee === 0) return;
1594
+ const qe = y.sort(F.columnFirstRangeComparator), $e = h.getVisibleRangeCoords(), Ze = 0, Te = Math.min(h.getBounds().height, z.getRowOffset($e.rowEnd + 1));
1595
+ let ae = [];
1596
+ for (let ct = 0; ct < Ee && U[ct] <= $e.colEnd; ct++) {
1597
+ const et = U[ct];
1649
1598
  if (et < $e.colStart) continue;
1650
1599
  let Be = !1;
1651
- for (; je.length > 0 && je[0].colStart <= et; ) {
1652
- const ne = je.shift();
1653
- ne.colEnd > et && (de.push(ne), Be = !0);
1600
+ for (; qe.length > 0 && qe[0].colStart <= et; ) {
1601
+ const ee = qe.shift();
1602
+ ee.colEnd > et && (ae.push(ee), Be = !0);
1654
1603
  }
1655
- Be && (de = de.sort(V.rowFirstRangeComparator));
1656
- const tt = B.getColOffset(et + 1);
1657
- let bt = Je;
1658
- const qe = de.length;
1659
- for (let ne = 0; ne < qe + 1; ne++) {
1660
- let Ye = bt, mt = Te;
1661
- const Oe = de[ne];
1662
- ne < qe && (mt = Math.min(Te, B.getRowOffset(Oe.rowStart)), bt = Math.min(Te, B.getRowOffset(Oe.rowEnd + 1))), S.push(Ce("path", { d: `M ${Q.boundPixel(tt, !1, C)} ${Q.boundPixel(Ye)} L ${Q.boundPixel(tt, !1, C)} ${Q.boundPixel(mt)}`, stroke: Y, strokeWidth: le, vectorEffect: "non-scaling-stroke", ..._ }, we + et + ":" + ne));
1604
+ Be && (ae = ae.sort(F.rowFirstRangeComparator));
1605
+ const tt = z.getColOffset(et + 1);
1606
+ let yt = Ze;
1607
+ const je = ae.length;
1608
+ for (let ee = 0; ee < je + 1; ee++) {
1609
+ let Ye = yt, pt = Te;
1610
+ const De = ae[ee];
1611
+ ee < je && (pt = Math.min(Te, z.getRowOffset(De.rowStart)), yt = Math.min(Te, z.getRowOffset(De.rowEnd + 1))), S.push(Ce("path", { d: `M ${X.boundPixel(tt, !1, C)} ${X.boundPixel(Ye)} L ${X.boundPixel(tt, !1, C)} ${X.boundPixel(pt)}`, stroke: le, strokeWidth: re, vectorEffect: "non-scaling-stroke", ...te }, fe + et + ":" + ee));
1663
1612
  }
1664
- for (let ne = qe - 1; ne >= 0; ne--) de[ne].colEnd <= H[ct + 1] && de.splice(ne, 1);
1613
+ for (let ee = je - 1; ee >= 0; ee--) ae[ee].colEnd <= U[ct + 1] && ae.splice(ee, 1);
1665
1614
  }
1666
1615
  }
1667
- }, xn = (f) => {
1616
+ }, xn = (h) => {
1668
1617
  if (!At) return;
1669
- const m = {}, C = Jt.length;
1618
+ const m = {}, C = Zt.length;
1670
1619
  for (let S = 0; S < C; S++) {
1671
- const y = Jt[S], B = Ee[y], me = [];
1672
- Cn(B, f, 0, me, f ? At[y].rangesH : At[y].rangesV);
1673
- const le = B.getRangeCoordsBounds(), we = Math.ceil(le.width), H = Math.ceil(le.height);
1674
- m[y] = Ce("svg", { width: `${we}`, height: `${H}`, viewBox: `0 0 ${we} ${H}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: me });
1620
+ const y = Zt[S], z = Ie[y], xe = [];
1621
+ Cn(z, h, 0, xe, h ? At[y].rangesH : At[y].rangesV);
1622
+ const re = z.getRangeCoordsBounds(), fe = Math.ceil(re.width), U = Math.ceil(re.height);
1623
+ m[y] = Ce("svg", { width: `${fe}`, height: `${U}`, viewBox: `0 0 ${fe} ${U}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: xe });
1675
1624
  }
1676
1625
  return m;
1677
- }, In = Ae(() => $ === !0 || $?.horizontal === !0 ? xn(!0) : null, [it, $, ke, U, k, Y, q, c, s, Ge, zt, Ee, At]), En = Ae(() => $ === !0 || $?.vertical === !0 ? xn(!1) : null, [it, $, Ze, U, k, Y, _, c, s, Ke, ot, Ee, At]), Wn = Ae(() => kt.left === 0 ? null : Ce(ao, { linePoints: [0, 0, 0, Ke + 1], bounds: { x: kt.left, y: 0, width: 1, height: Ke + 1 }, ...he }), [it, kt.left, Ke, he]), Un = Ae(() => kt.top === 0 ? null : Ce(ao, { linePoints: [0, 0, Ge + 1, 0], bounds: { x: 0, y: kt.top, width: Ge + 1, height: 1 }, ...P }), [it, kt.top, Ge, P]), pn = Ae(() => {
1678
- const f = [], m = (S) => {
1679
- if (!S || !Ee[S]) return;
1680
- const y = Ee[S].getBounds();
1681
- return _t("div", { style: { position: "absolute", pointerEvents: "none", left: y.x, top: y.y, width: y.width, height: y.height, clip: `rect(0, ${y.width + 1}px, ${y.height + 1}px, 0)` }, className: `view view-${S}`, children: [In?.[S], En?.[S], At?.[S].cells] }, `view:${S}`);
1682
- }, C = Jt.length;
1683
- for (let S = 0; S < C; S++) f.push(m(Jt[S]));
1684
- return Ce(Qn, { children: f });
1685
- }, [Ee, In, En, At]), Hn = Ae(() => {
1626
+ }, In = Ae(() => A === !0 || A?.horizontal === !0 ? xn(!0) : null, [it, A, Me, _, T, le, J, c, d, Ge, zt, Ie, At]), En = Ae(() => A === !0 || A?.vertical === !0 ? xn(!1) : null, [it, A, _e, _, T, le, te, c, d, Ke, ot, Ie, At]), Vn = Ae(() => kt.left === 0 ? null : Ce(co, { linePoints: [0, 0, 0, Ke + 1], bounds: { x: kt.left, y: 0, width: 1, height: Ke + 1 }, ...ve }), [it, kt.left, Ke, ve]), Wn = Ae(() => kt.top === 0 ? null : Ce(co, { linePoints: [0, 0, Ge + 1, 0], bounds: { x: 0, y: kt.top, width: Ge + 1, height: 1 }, ...W }), [it, kt.top, Ge, W]), pn = Ae(() => {
1627
+ const h = [], m = (S) => {
1628
+ if (!S || !Ie[S]) return;
1629
+ const y = Ie[S].getBounds();
1630
+ return Qt("div", { style: { position: "absolute", pointerEvents: "none", left: y.x, top: y.y, width: y.width, height: y.height, clip: `rect(0, ${y.width + 1}px, ${y.height + 1}px, 0)` }, className: `view view-${S}`, children: [In?.[S], En?.[S], At?.[S].cells] }, `view:${S}`);
1631
+ }, C = Zt.length;
1632
+ for (let S = 0; S < C; S++) h.push(m(Zt[S]));
1633
+ return Ce(_n, { children: h });
1634
+ }, [Ie, In, En, At]), Un = Ae(() => {
1686
1635
  if (!n) return;
1687
- const f = (le, we, H, Re) => {
1688
- if (!Re || Re.length === 0) return;
1689
- const je = [], $e = Re.length;
1690
- for (let Je = 0; Je < $e; Je++) {
1691
- const Te = Re[Je];
1692
- let de = le?.get(Te);
1693
- de !== Yn && (de = Te(H) ?? Yn), we.set(Te, de), de && de !== Yn && je.push(de);
1636
+ const h = (re, fe, U, Ee) => {
1637
+ if (!Ee || Ee.length === 0) return;
1638
+ const qe = [], $e = Ee.length;
1639
+ for (let Ze = 0; Ze < $e; Ze++) {
1640
+ const Te = Ee[Ze];
1641
+ let ae = re?.get(Te);
1642
+ ae !== qn && (ae = Te(U) ?? qn), fe.set(Te, ae), ae && ae !== qn && qe.push(ae);
1694
1643
  }
1695
- return je;
1696
- }, m = (le, we, H) => {
1697
- if (!H) return;
1698
- const Re = H.getBounds(), je = H.getInsets(), $e = H.getAnchor();
1699
- return _t("div", { className: rn("view", `view-${$e}`, uo.view), style: { position: "absolute", pointerEvents: "none", left: Re.x - je.left, top: Re.y - je.top, width: Re.width - (je.left + je.right), height: Re.height - (je.top + je.bottom), clipPath: p ? "inset(-2px)" : "inset(0px)" }, children: [f(le, we, H, ye), Vn?.[$e].overlays] }, `view:${$e}`);
1700
- }, C = gt.current, S = {}, y = [], B = Object.keys(Ee), me = B.length;
1701
- for (let le = 0; le < me; le++) {
1702
- const we = B[le], H = C?.[we], Re = S[we] = /* @__PURE__ */ new Map();
1703
- y.push(m(H, Re, Ee[we]));
1644
+ return qe;
1645
+ }, m = (re, fe, U) => {
1646
+ if (!U) return;
1647
+ const Ee = U.getBounds(), qe = U.getInsets(), $e = U.getAnchor();
1648
+ return Qt("div", { className: rn("view", `view-${$e}`, so.view), style: { position: "absolute", pointerEvents: "none", left: Ee.x - qe.left, top: Ee.y - qe.top, width: Ee.width - (qe.left + qe.right), height: Ee.height - (qe.top + qe.bottom), clipPath: p ? "inset(-2px)" : "inset(0px)" }, children: [h(re, fe, U, ye), Fn?.[$e].overlays] }, `view:${$e}`);
1649
+ }, C = ft.current, S = {}, y = [], z = Object.keys(Ie), xe = z.length;
1650
+ for (let re = 0; re < xe; re++) {
1651
+ const fe = z[re], U = C?.[fe], Ee = S[fe] = /* @__PURE__ */ new Map();
1652
+ y.push(m(U, Ee, Ie[fe]));
1704
1653
  }
1705
- return gt.current = S, y;
1706
- }, [it, Ee, p, ye]), Nn = Ae(() => {
1707
- const { style: f, ...m } = Ne ?? {};
1708
- return Ce("div", { style: { width: Ge, height: Ke, ...f }, className: "sheetxl-stage", tabIndex: 0, ref: Ue, ...m, ...Wt, children: Xe ? Xe(pn) : pn });
1709
- }, [Ge, Ke, pn, Ne, Xe]), Rn = ie(!1);
1710
- return wt(() => {
1711
- !Rn.current && At && (Rn.current = !0, pe?.(on.current));
1712
- }, [At]), _t("div", { className: rn("sheetxl-grid", uo["sheetxl-grid"]), style: { overflow: "visible", cursor: Z, maxWidth: Ge, maxHeight: Ke, width: Ge, height: Ke, ...ge }, ref: on, children: [Nn, _t("div", { className: rn("sheetxl-overlays"), ref: lt, ...A, children: [Hn, Wn, Un] })] });
1654
+ return ft.current = S, y;
1655
+ }, [it, Ie, p, ye]), Hn = Ae(() => {
1656
+ const { style: h, ...m } = Ne ?? {};
1657
+ return Ce("div", { style: { width: Ge, height: Ke, ...h }, className: "sheetxl-stage", tabIndex: 0, ref: Ue, ...m, ...Wt, children: Xe ? Xe(pn) : pn });
1658
+ }, [Ge, Ke, pn, Ne, Xe]), Rn = se(!1);
1659
+ return It(() => {
1660
+ !Rn.current && At && (Rn.current = !0, we?.(on.current));
1661
+ }, [At]), Qt("div", { className: rn("sheetxl-grid", so["sheetxl-grid"]), style: { overflow: "visible", cursor: Q, maxWidth: Ge, maxHeight: Ke, width: Ge, height: Ke, ...he }, ref: on, children: [Hn, Qt("div", { className: rn("sheetxl-overlays"), ref: lt, ...$, children: [Un, Vn, Wn] })] });
1713
1662
  }));
1714
- Ro.displayName = "BaseGrid";
1715
- const Mo = Kt(tn((t, n) => {
1716
- const { width: o, height: r, style: c = {}, className: s, ...i } = t, [l, { width: h, height: O }] = yo();
1717
- return Ce("div", { className: s, style: { ...c }, children: Ce("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: l, children: Ce(Ro, { ref: n, width: o ?? h, height: r ?? O, ...i }) }) });
1663
+ Co.displayName = "BaseGrid";
1664
+ var tr = function() {
1665
+ }, Io = typeof window < "u", nr = Io ? en : It, uo = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
1666
+ const or = Io && window.ResizeObserver !== void 0 ? function() {
1667
+ var t = gt(null), n = t[0], o = t[1], r = gt(uo), c = r[0], d = r[1], i = Ae(function() {
1668
+ return new window.ResizeObserver(function(l) {
1669
+ if (l[0]) {
1670
+ var w = l[0].contentRect, L = w.x, O = w.y, R = w.width, M = w.height, A = w.top, le = w.left, J = w.bottom, te = w.right;
1671
+ d({ x: L, y: O, width: R, height: M, top: A, left: le, bottom: J, right: te });
1672
+ }
1673
+ });
1674
+ }, []);
1675
+ return nr(function() {
1676
+ if (n) return i.observe(n), function() {
1677
+ i.disconnect();
1678
+ };
1679
+ }, [n]), [o, c];
1680
+ } : function() {
1681
+ return [tr, uo];
1682
+ }, Eo = Kt(tn((t, n) => {
1683
+ const { width: o, height: r, style: c = {}, className: d, ...i } = t, [l, { width: w, height: L }] = or();
1684
+ return Ce("div", { className: d, style: { ...c }, children: Ce("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: l, children: Ce(Co, { ref: n, width: o ?? w, height: r ?? L, ...i }) }) });
1718
1685
  }));
1719
- Mo.displayName = "Grid";
1720
- const sr = Kt(tn((t, n) => {
1721
- const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: s, createScrollCorner: i, viewport: l, onScrollViewport: h, style: O = {}, className: z, onScroll: M, ...R } = t, [$, Y] = ut(null), q = ie(null), _ = ie(null);
1722
- Tn(!l), $o(n, () => _.current && q.current ? Object.assign(_.current, q.current) : null);
1723
- const Ie = W((Z) => {
1724
- _.current?.scrollTo(Z), h?.(Z);
1686
+ Eo.displayName = "Grid";
1687
+ const rr = Kt(tn((t, n) => {
1688
+ const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: d, createScrollCorner: i, viewport: l, onScrollViewport: w, style: L = {}, className: O, onScroll: R, ...M } = t, [A, le] = gt(null), J = se(null), te = se(null);
1689
+ Dn(!l), Lo(n, () => te.current && J.current ? Object.assign(te.current, J.current) : null);
1690
+ const ze = V((Q) => {
1691
+ te.current?.scrollTo(Q), w?.(Q);
1725
1692
  }, []);
1726
- return Ce(zo, { className: z, style: O, ref: q, showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: s, createScrollCorner: i, viewport: $, onScrollViewport: Ie, children: Ce(Mo, { style: { width: "100%", height: "100%" }, ...R, onViewportChange: (Z) => Y(Z), ref: _ }) });
1693
+ return Ce(Oo, { className: O, style: L, ref: J, showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: d, createScrollCorner: i, viewport: A, onScrollViewport: ze, children: Ce(Eo, { style: { width: "100%", height: "100%" }, ...M, onViewportChange: (Q) => le(Q), ref: te }) });
1727
1694
  }));
1728
- sr.displayName = "ScrollableGrid";
1729
- const fo = () => !1, ar = Kt((t) => {
1730
- const { index: n, value: o, zoom: r, zoomScale: c = 100, headerText: s = (ye) => `${ye}`, headerStyle: i, headerStyleSelect: l = i, headerStyleSelectAll: h = l, headerStyleHover: O = h, verticalPadding: z = 0, horizontalPadding: M = 0, isSelected: R = fo, isSelectedAll: $ = fo, coords: Y, bounds: q, range: _, orientation: Ie, view: Z, style: k, ...U } = t, he = c / 100, P = ie(null), [ce, Ve] = ut(!1), Pe = R?.(n) || !1, We = $?.(n) ? h : Pe ? l : i;
1731
- let fe = We;
1732
- if (ce) {
1733
- let ye = O;
1734
- typeof O == "function" && (ye = O(We)), fe = Nt.mergeContentful(We, ye);
1695
+ rr.displayName = "ScrollableGrid";
1696
+ const ho = () => !1, lr = Kt((t) => {
1697
+ const { index: n, value: o, zoom: r, zoomScale: c = 100, headerText: d = (ye) => `${ye}`, headerStyle: i, headerStyleSelect: l = i, headerStyleSelectAll: w = l, headerStyleHover: L = w, verticalPadding: O = 0, horizontalPadding: R = 0, isSelected: M = ho, isSelectedAll: A = ho, coords: le, bounds: J, range: te, orientation: ze, view: Q, style: T, ..._ } = t, ve = c / 100, W = se(null), [me, Ve] = gt(!1), ke = M?.(n) || !1, We = A?.(n) ? w : ke ? l : i;
1698
+ let ue = We;
1699
+ if (me) {
1700
+ let ye = L;
1701
+ typeof L == "function" && (ye = L(We)), ue = Nt.mergeContentful(We, ye);
1735
1702
  }
1736
- return Ce("div", { ref: P, style: { background: fe.fill, color: fe.text?.fill, fontFamily: fe.text?.fontFamily ?? i.text?.fontFamily, fontSize: 96 * (fe.text?.fontSize ?? 11) / 72 * he, fontStyle: fe.text?.fontStyle, fontWeight: fe.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${he}px`, ...k, left: k.left - (Ie === Ht.Column ? 1 : 0), top: k.top - (Ie === Ht.Row ? 1 : 0), width: k.width + 1, height: k.height + 1, overflow: "hidden" }, ...U, onMouseMove: (ye) => {
1737
- Q.detectIt().primaryInput !== "touch" && ye.buttons === 0 && Ve(!0);
1703
+ return Ce("div", { ref: W, style: { background: ue.fill, color: ue.text?.fill, fontFamily: ue.text?.fontFamily ?? i.text?.fontFamily, fontSize: 96 * (ue.text?.fontSize ?? 11) / 72 * ve, fontStyle: ue.text?.fontStyle, fontWeight: ue.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${ve}px`, ...T, left: T.left - (ze === Ht.Column ? 1 : 0), top: T.top - (ze === Ht.Row ? 1 : 0), width: T.width + 1, height: T.height + 1, overflow: "hidden" }, ..._, onMouseMove: (ye) => {
1704
+ X.detectIt().primaryInput !== "touch" && ye.buttons === 0 && Ve(!0);
1738
1705
  }, onMouseOut: (ye) => {
1739
1706
  Ve(!1);
1740
- }, children: s(n) });
1707
+ }, children: d(n) });
1741
1708
  });
1742
- ar.displayName = "HeaderRenderer";
1743
- const ko = "ew-resize", Po = "ns-resize", dr = Kt(tn((t, n) => {
1744
- const { orientation: o, view: r, index: c, className: s, style: i, disabled: l = !1, disabledResize: h = !1, isNextHidden: O, isHidden: z, isSelected: M, isSelectedAll: R, showTouchDivider: $, headerStyle: Y, headerStyleSelect: q, headerStyleSelectAll: _, headerStyleHover: Ie, bounds: Z, onPointerDown: k, onAutoFit: U, ...he } = t, P = o === Ht.Column;
1745
- let ce = Y;
1746
- M && q && (ce = q), R && _ && (ce = _);
1747
- const Ve = Q.detectIt().primaryInput === "touch";
1748
- let Pe = P ? 14 : 8, We = Pe / 2, fe = 0;
1749
- O && (fe = -2), z && (fe = 2), z && (Pe = Pe / 2 + fe, We = 2 * fe);
1750
- let ye = ce.dividerStrokeFill ?? ce.strokeFill;
1751
- return !(M || R) && fe === 0 && (ye = `linear-gradient(${P ? 180 : 90}deg, ${ce.fill}, ${ye} 55%, ${ye} 100%)`), _t("div", { className: rn("header-divider", { disabled: l }, s, `index-${c}`), ref: n, onPointerDown: Ve ? void 0 : k, onDoubleClick: Ve ? void 0 : () => U?.(), style: { top: (P ? 0 : -Pe / 2 + (fe - 1)) + "px", left: (P ? -Pe / 2 + (fe - 1) : 0) + "px", width: P ? Pe : "calc(100% + 1px)", height: P ? "calc(100% + 1px)" : Pe, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: l || h || Ve ? void 0 : P ? ko : Po, ...i }, ...he, children: [Ce("div", { style: { position: "relative", top: `${P ? 0 : We}px`, left: `${P ? We : 0}px`, width: P ? 1 : "100%", height: P ? "100%" : 1, background: ye }, onDoubleClick: () => U?.() }), $ && Ve ? Ce("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: P ? "-6px" : "2px", bottom: P ? "2px" : "-9px", height: "24px", width: P ? "24px" : "18px", maxHeight: P ? "calc(100% - 4px)" : void 0, maxWidth: P ? void 0 : "calc(100% - 4px)", background: ce.fill, border: `${_.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${Y.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: k, children: Ce("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(q.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: P ? void 0 : "rotate(90deg)" } }) }) : null] });
1752
- })), ur = (t, n) => Ce(dr, { ...t, ref: n }), Ir = Kt(tn((t, n) => {
1753
- const { orientation: o, view: r, index: c, disabled: s = !1, disabledResize: i = !1, resizeThreshold: l = 1, dividerRenderer: h = ur, onDividerMouseDown: O, onDividerResizeStart: z, onDividerResize: M, onDividerResizeEnd: R, onDividerMouseUp: $, onDividerAutoFit: Y, onPointerDown: q, ..._ } = t, Ie = T(q, [q]), Z = T(Y, [Y]), k = o === Ht.Column;
1754
- let U = k ? r.getVisibleColumns() : r.getVisibleRows(), he = null;
1755
- U.length > 0 && (k ? he = r.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: U[0], colEnd: U[U.length - 1] }) : r.getRangeCoordsBounds({ rowStart: U[0], rowEnd: U[U.length - 1], colStart: 0, colEnd: 0 }), he = r.toClipBounds(he, Vt));
1756
- const P = ie(null), [ce, Ve] = ut(null), Pe = (te, be) => k ? te.clientX - be.clientX : te.clientY - be.clientY, We = r.getLayout(), fe = k ? We.getColOffset(c + 1) : We.getRowOffset(c + 1), ye = un({ processTouch: !0, onPointerDown: (te) => {
1757
- if (Ie?.(te), !s && !i) {
1758
- const be = k ? We.getColOffset(c) : We.getRowOffset(c), J = fe - be;
1759
- P.current = { isResizing: !1, startSize: J, index: c, view: r, orientation: o, onDividerMouseDown: O, onDividerResizeStart: z, onDividerResize: M, onDividerResizeEnd: R, onDividerMouseUp: $ }, Ve(P.current), O?.(c, J);
1709
+ lr.displayName = "HeaderRenderer";
1710
+ const Ro = "ew-resize", Mo = "ns-resize", ir = Kt(tn((t, n) => {
1711
+ const { orientation: o, view: r, index: c, className: d, style: i, disabled: l = !1, disabledResize: w = !1, isNextHidden: L, isHidden: O, isSelected: R, isSelectedAll: M, showTouchDivider: A, headerStyle: le, headerStyleSelect: J, headerStyleSelectAll: te, headerStyleHover: ze, bounds: Q, onPointerDown: T, onAutoFit: _, ...ve } = t, W = o === Ht.Column;
1712
+ let me = le;
1713
+ R && J && (me = J), M && te && (me = te);
1714
+ const Ve = X.detectIt().primaryInput === "touch";
1715
+ let ke = W ? 14 : 8, We = ke / 2, ue = 0;
1716
+ L && (ue = -2), O && (ue = 2), O && (ke = ke / 2 + ue, We = 2 * ue);
1717
+ let ye = me.dividerStrokeFill ?? me.strokeFill;
1718
+ return !(R || M) && ue === 0 && (ye = `linear-gradient(${W ? 180 : 90}deg, ${me.fill}, ${ye} 55%, ${ye} 100%)`), Qt("div", { className: rn("header-divider", { disabled: l }, d, `index-${c}`), ref: n, onPointerDown: Ve ? void 0 : T, onDoubleClick: Ve ? void 0 : () => _?.(), style: { top: (W ? 0 : -ke / 2 + (ue - 1)) + "px", left: (W ? -ke / 2 + (ue - 1) : 0) + "px", width: W ? ke : "calc(100% + 1px)", height: W ? "calc(100% + 1px)" : ke, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: l || w || Ve ? void 0 : W ? Ro : Mo, ...i }, ...ve, children: [Ce("div", { style: { position: "relative", top: `${W ? 0 : We}px`, left: `${W ? We : 0}px`, width: W ? 1 : "100%", height: W ? "100%" : 1, background: ye }, onDoubleClick: () => _?.() }), A && Ve ? Ce("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: W ? "-6px" : "2px", bottom: W ? "2px" : "-9px", height: "24px", width: W ? "24px" : "18px", maxHeight: W ? "calc(100% - 4px)" : void 0, maxWidth: W ? void 0 : "calc(100% - 4px)", background: me.fill, border: `${te.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${le.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: T, children: Ce("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(J.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: W ? void 0 : "rotate(90deg)" } }) }) : null] });
1719
+ })), cr = (t, n) => Ce(ir, { ...t, ref: n }), Sr = Kt(tn((t, n) => {
1720
+ const { orientation: o, view: r, index: c, disabled: d = !1, disabledResize: i = !1, resizeThreshold: l = 1, dividerRenderer: w = cr, onDividerMouseDown: L, onDividerResizeStart: O, onDividerResize: R, onDividerResizeEnd: M, onDividerMouseUp: A, onDividerAutoFit: le, onPointerDown: J, ...te } = t, ze = P(J, [J]), Q = P(le, [le]), T = o === Ht.Column;
1721
+ let _ = T ? r.getVisibleColumns() : r.getVisibleRows(), ve = null;
1722
+ _.length > 0 && (T ? ve = r.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: _[0], colEnd: _[_.length - 1] }) : r.getRangeCoordsBounds({ rowStart: _[0], rowEnd: _[_.length - 1], colStart: 0, colEnd: 0 }), ve = r.toClipBounds(ve, Vt));
1723
+ const W = se(null), [me, Ve] = gt(null), ke = (Z, be) => T ? Z.clientX - be.clientX : Z.clientY - be.clientY, We = r.getLayout(), ue = T ? We.getColOffset(c + 1) : We.getRowOffset(c + 1), ye = un({ processTouch: !0, onPointerDown: (Z) => {
1724
+ if (ze?.(Z), !d && !i) {
1725
+ const be = T ? We.getColOffset(c) : We.getRowOffset(c), Y = ue - be;
1726
+ W.current = { isResizing: !1, startSize: Y, index: c, view: r, orientation: o, onDividerMouseDown: L, onDividerResizeStart: O, onDividerResize: R, onDividerResizeEnd: M, onDividerMouseUp: A }, Ve(W.current), L?.(c, Y);
1760
1727
  }
1761
- te.stopPropagation(), te.preventDefault();
1762
- }, onPointerUp: (te, be, J) => {
1763
- if (!P.current) return;
1764
- P.current.isResizing && P.current.onDividerResizeEnd?.(P.current.index, Math.max(0, P.current.startSize + Pe(te, J)), P.current.startSize);
1765
- const L = P.current;
1766
- P.current = null, Ve(P.current), L.onDividerMouseUp?.(L.index);
1767
- }, onPointerMoveOrWait: (te, be, J) => {
1768
- if (!P.current) return;
1769
- const L = Pe(te, J);
1770
- P.current.isResizing ? P.current.onDividerResize?.(P.current.index, Math.max(0, P.current.startSize + L), P.current.startSize) : Math.abs(L) > Math.max(1, l) && (P.current = { ...P.current, isResizing: !0 }, Ve(P.current), P.current.onDividerResizeStart?.(P.current.index, Math.max(0, P.current.startSize + L))), te.stopPropagation(), te.preventDefault();
1771
- } }), A = T(() => {
1772
- Z?.(c);
1728
+ Z.stopPropagation(), Z.preventDefault();
1729
+ }, onPointerUp: (Z, be, Y) => {
1730
+ if (!W.current) return;
1731
+ W.current.isResizing && W.current.onDividerResizeEnd?.(W.current.index, Math.max(0, W.current.startSize + ke(Z, Y)), W.current.startSize);
1732
+ const D = W.current;
1733
+ W.current = null, Ve(W.current), D.onDividerMouseUp?.(D.index);
1734
+ }, onPointerMoveOrWait: (Z, be, Y) => {
1735
+ if (!W.current) return;
1736
+ const D = ke(Z, Y);
1737
+ W.current.isResizing ? W.current.onDividerResize?.(W.current.index, Math.max(0, W.current.startSize + D), W.current.startSize) : Math.abs(D) > Math.max(1, l) && (W.current = { ...W.current, isResizing: !0 }, Ve(W.current), W.current.onDividerResizeStart?.(W.current.index, Math.max(0, W.current.startSize + D))), Z.stopPropagation(), Z.preventDefault();
1738
+ } }), $ = P(() => {
1739
+ Q?.(c);
1773
1740
  }, [c]);
1774
- if (!he) return;
1775
- const p = h({ bounds: he, orientation: o, view: r, index: c, disabled: s, disabledResize: i, onAutoFit: A, onPointerDown: ye, ..._ }, n);
1741
+ if (!ve) return;
1742
+ const p = w({ bounds: ve, orientation: o, view: r, index: c, disabled: d, disabledResize: i, onAutoFit: $, onPointerDown: ye, ...te }, n);
1776
1743
  if (!p) return;
1777
- const { getPortalContainer: Ne } = go();
1744
+ const { getPortalContainer: Ne } = fo();
1778
1745
  let Xe = null;
1779
- return ce && ce.isResizing && ce.index === c && (Xe = po(Ce("div", { style: { position: "absolute", cursor: k ? ko : Po, left: 0, top: 0, width: "100%", height: "100%" } }), Ne(), "divider:" + c)), _t(Qn, { children: [Xe, Ce("div", { className: rn("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${k ? he.y : fe}px`, left: `${k ? fe : he.x}px`, width: (k ? 0 : he.width - 1) + "px", height: (k ? he.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: p })] });
1746
+ return me && me.isResizing && me.index === c && (Xe = xo(Ce("div", { style: { position: "absolute", cursor: T ? Ro : Mo, left: 0, top: 0, width: "100%", height: "100%" } }), Ne(), "divider:" + c)), Qt(_n, { children: [Xe, Ce("div", { className: rn("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${T ? ve.y : ue}px`, left: `${T ? ue : ve.x}px`, width: (T ? 0 : ve.width - 1) + "px", height: (T ? ve.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: p })] });
1780
1747
  }));
1781
- class hr {
1748
+ class sr {
1782
1749
  naturalDimensions(n, o = {}) {
1783
1750
  const r = document.createElement("div");
1784
1751
  let c = o?.lineHeight ?? "1";
1785
1752
  !o?.lineHeight && o.paintableText?.fontSize && (c = Math.ceil(1.2 * o.paintableText.fontSize) + "px");
1786
- const s = document.createElement("div");
1787
- s.style.visibility = "hidden", s.style.position = "absolute", s.style.textRendering = "geometricprecision", s.style.display = "inline-grid", s.style.overflowWrap = "break-word", s.style.maxWidth = o.maxWidth ? o.maxWidth + "px" : "100%", s.style.lineHeight = c, s.style.letterSpacing = (o.paintableText?.letterSpacing ?? 0) + "px", s.style.fontSize = o.paintableText?.fontSize ? o.paintableText.fontSize + "px" : "unset", s.style.fontFamily = o.paintableText?.fontSize ? o.paintableText.fontFamily : "unset", s.style.fontWeight = o.paintableText?.fontWeight ? "" + o.paintableText.fontWeight : "400", s.style.fontStyle = o.paintableText?.fontStyle ? o.paintableText.fontStyle : "normal", s.style.whiteSpace = o.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", r.appendChild(s);
1753
+ const d = document.createElement("div");
1754
+ d.style.visibility = "hidden", d.style.position = "absolute", d.style.textRendering = "geometricprecision", d.style.display = "inline-grid", d.style.overflowWrap = "break-word", d.style.maxWidth = o.maxWidth ? o.maxWidth + "px" : "100%", d.style.lineHeight = c, d.style.letterSpacing = (o.paintableText?.letterSpacing ?? 0) + "px", d.style.fontSize = o.paintableText?.fontSize ? o.paintableText.fontSize + "px" : "unset", d.style.fontFamily = o.paintableText?.fontSize ? o.paintableText.fontFamily : "unset", d.style.fontWeight = o.paintableText?.fontWeight ? "" + o.paintableText.fontWeight : "400", d.style.fontStyle = o.paintableText?.fontStyle ? o.paintableText.fontStyle : "normal", d.style.whiteSpace = o.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", r.appendChild(d);
1788
1755
  const i = n.split(`
1789
1756
  `);
1790
- for (let h = 0; h < i.length; h++) {
1791
- let O = document.createElement("span");
1792
- s.appendChild(O), O.textContent = i[h];
1757
+ for (let w = 0; w < i.length; w++) {
1758
+ let L = document.createElement("span");
1759
+ d.appendChild(L), L.textContent = i[w];
1793
1760
  }
1794
- i.length !== 0 && i[i.length - 1].length !== 0 || s.appendChild(document.createElement("br")), document.body.appendChild(s);
1795
- let l = s.getBoundingClientRect();
1796
- return s.remove(), { width: l.width, height: l.height, maxLineHeight: 1.2 * (o.paintableText?.fontSize || 1056 / 72) };
1761
+ i.length !== 0 && i[i.length - 1].length !== 0 || d.appendChild(document.createElement("br")), document.body.appendChild(d);
1762
+ let l = d.getBoundingClientRect();
1763
+ return d.remove(), { width: l.width, height: l.height, maxLineHeight: 1.2 * (o.paintableText?.fontSize || 1056 / 72) };
1797
1764
  }
1798
1765
  }
1799
- const fr = (t = void 0) => Object.freeze({ clean: t, dirty: void 0, editMode: !1 }), gr = fr(), Er = Kt(tn((t, n) => {
1800
- const { editState: o = gr, defaultTextStyle: r, onStartEdit: c, onChangeEdit: s, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, containerBounds: O, setNaturalSize: z, onNavigate: M, textProperties: R, style: $, autoFocus: Y, ...q } = t, _ = ie(null), { width: Ie = 0 } = O ?? {}, [Z, k] = ut(() => o);
1801
- wt(() => {
1802
- k(o);
1766
+ const ar = (t = void 0) => Object.freeze({ clean: t, dirty: void 0, editMode: !1 }), dr = ar(), yr = Kt(tn((t, n) => {
1767
+ const { editState: o = dr, defaultTextStyle: r, onStartEdit: c, onChangeEdit: d, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: w, containerBounds: L, setNaturalSize: O, onNavigate: R, textProperties: M, style: A, autoFocus: le, ...J } = t, te = se(null), { width: ze = 0 } = L ?? {}, [Q, T] = gt(() => o);
1768
+ It(() => {
1769
+ T(o);
1803
1770
  }, [o]);
1804
- const U = R?.align || "left", he = R?.vAlign || "middle", P = R?.fill || "#040404", ce = R?.wrap || "wrap", Ve = R?.fontFamily || "Calibri", Pe = R?.fontSize || 11, We = R?.fontWeight || 400, fe = R?.fontStyle || "normal", ye = Z.dirty ?? Z.clean ?? "";
1805
- let A = 2;
1806
- const p = 96 * Pe / 72, Ne = 1.2 * p;
1807
- he === "right" && (A += 1);
1808
- const Xe = Ae(() => new hr().naturalDimensions(ye, { maxWidth: ce === "wrap" ? Ie - A : void 0, lineHeight: `${Ne}px`, paintableText: { fontStyle: fe, wrap: ce, letterSpacing: -0.25 } }), [ye, ce, A, p, Ve, We, fe, z, Ie]), te = W(() => Xe.maxLineHeight ? Xe.maxLineHeight + "px" : "1.2", [Xe]), [be, J] = ut(te);
1771
+ const _ = M?.align || "left", ve = M?.vAlign || "middle", W = M?.fill || "#040404", me = M?.wrap || "wrap", Ve = M?.fontFamily || "Calibri", ke = M?.fontSize || 11, We = M?.fontWeight || 400, ue = M?.fontStyle || "normal", ye = Q.dirty ?? Q.clean ?? "";
1772
+ let $ = 2;
1773
+ const p = 96 * ke / 72, Ne = 1.2 * p;
1774
+ ve === "right" && ($ += 1);
1775
+ const Xe = Ae(() => new sr().naturalDimensions(ye, { maxWidth: me === "wrap" ? ze - $ : void 0, lineHeight: `${Ne}px`, paintableText: { fontStyle: ue, wrap: me, letterSpacing: -0.25 } }), [ye, me, $, p, Ve, We, ue, O, ze]), Z = V(() => Xe.maxLineHeight ? Xe.maxLineHeight + "px" : "1.2", [Xe]), [be, Y] = gt(Z);
1809
1776
  en(() => {
1810
- J(te());
1811
- }, [O, Xe]), en(() => {
1812
- z?.({ width: ce === "wrap" ? void 0 : Xe.width + A, height: Xe.height });
1813
- }, [Xe, z]);
1814
- const L = T(s, [s]), X = T((b) => {
1815
- if (Z.dirty === b) return;
1816
- const Me = { ...Z };
1817
- Me.dirty = b, _.current, k(Me), L?.(Me);
1818
- }, [Z]), Pt = T((b) => {
1819
- if (Z.editMode === b) return;
1820
- const Me = { ...Z };
1821
- Me.editMode = b, k(Me), L?.(Me);
1822
- }, [Z]), Et = T(() => {
1777
+ Y(Z());
1778
+ }, [L, Xe]), en(() => {
1779
+ O?.({ width: me === "wrap" ? void 0 : Xe.width + $, height: Xe.height });
1780
+ }, [Xe, O]);
1781
+ const D = P(d, [d]), q = P((b) => {
1782
+ if (Q.dirty === b) return;
1783
+ const Re = { ...Q };
1784
+ Re.dirty = b, te.current, T(Re), D?.(Re);
1785
+ }, [Q]), Pt = P((b) => {
1786
+ if (Q.editMode === b) return;
1787
+ const Re = { ...Q };
1788
+ Re.editMode = b, T(Re), D?.(Re);
1789
+ }, [Q]), Et = P(() => {
1823
1790
  try {
1824
- return i?.(Z), h?.(), !0;
1791
+ return i?.(Q), w?.(), !0;
1825
1792
  } catch {
1826
1793
  return !1;
1827
1794
  }
1828
- }, [i, Z]), xt = T(() => {
1829
- k(o), l?.(), h?.();
1830
- }, [l, o]), ht = T((b) => {
1831
- if (!_.current) return;
1832
- if (b.isDefaultPrevented(), !(b.isTrusted || b.nativeEvent.ctrlKey || b.nativeEvent.metaKey || b.nativeEvent.altKey || b.nativeEvent.isComposing) && vo.indexOf(b.nativeEvent.key) !== -1) {
1833
- const oe = { ...Z };
1834
- return oe.dirty = b.nativeEvent.key === "Backspace" ? "" : (oe.dirty ?? "") + b.key, k(oe), L?.(oe), void b.preventDefault();
1795
+ }, [i, Q]), wt = P(() => {
1796
+ T(o), l?.(), w?.();
1797
+ }, [l, o]), ut = P((b) => {
1798
+ if (!te.current) return;
1799
+ if (b.isDefaultPrevented(), !(b.isTrusted || b.nativeEvent.ctrlKey || b.nativeEvent.metaKey || b.nativeEvent.altKey || b.nativeEvent.isComposing) && mo.indexOf(b.nativeEvent.key) !== -1) {
1800
+ const ne = { ...Q };
1801
+ return ne.dirty = b.nativeEvent.key === "Backspace" ? "" : (ne.dirty ?? "") + b.key, T(ne), D?.(ne), void b.preventDefault();
1835
1802
  }
1836
- const Me = b.nativeEvent.shiftKey;
1837
- if (b.which === Ot.Escape) return b.preventDefault(), void xt();
1803
+ const Re = b.nativeEvent.shiftKey;
1804
+ if (b.which === Ot.Escape) return b.preventDefault(), void wt();
1838
1805
  if (b.which === Ot.F2) return Pt(!0), void b.preventDefault();
1839
- if (b.which === Ot.Enter && (b.preventDefault(), Et() && M?.(Me ? w.Up : w.Down)), b.which === Ot.Tab) return b.preventDefault(), void (Et() && M?.(Me ? w.Left : w.Right));
1840
- if (!Z.editMode) {
1841
- let oe = null;
1806
+ if (b.which === Ot.Enter && (b.preventDefault(), Et() && R?.(Re ? g.Up : g.Down)), b.which === Ot.Tab) return b.preventDefault(), void (Et() && R?.(Re ? g.Left : g.Right));
1807
+ if (!Q.editMode) {
1808
+ let ne = null;
1842
1809
  switch (b.which) {
1843
1810
  case Ot.Left:
1844
- oe = w.Left;
1811
+ ne = g.Left;
1845
1812
  break;
1846
1813
  case Ot.Right:
1847
- oe = w.Right;
1814
+ ne = g.Right;
1848
1815
  break;
1849
1816
  case Ot.Up:
1850
- oe = w.Up;
1817
+ ne = g.Up;
1851
1818
  break;
1852
1819
  case Ot.Down:
1853
- oe = w.Down;
1820
+ ne = g.Down;
1854
1821
  }
1855
- if (oe) return void Et();
1822
+ if (ne) return void Et();
1856
1823
  }
1857
- }, [Z, M]), [ge, Wt] = ut(!Y);
1858
- wt(() => {
1824
+ }, [Q, R]), [he, Wt] = gt(!le);
1825
+ It(() => {
1859
1826
  Wt(!1);
1860
1827
  }, []);
1861
- const D = wo(n, () => ({ startEdit(b) {
1862
- let Me = b?.initialSelection;
1863
- if (!Me) {
1864
- const pe = _.current.value.length ?? 0;
1865
- Me = { start: pe, end: pe, direction: "forward" };
1828
+ const k = go(n, () => ({ startEdit(b) {
1829
+ let Re = b?.initialSelection;
1830
+ if (!Re) {
1831
+ const we = te.current.value.length ?? 0;
1832
+ Re = { start: we, end: we, direction: "forward" };
1866
1833
  }
1867
- _.current?.setSelectionRange(Me.start, Me.end, Me.direction);
1868
- const oe = { ...o, editMode: b?.editMode ?? !1 };
1869
- b?.text !== void 0 && (oe.dirty = b.text), oe.editMode === o.editMode && oe.dirty === o.dirty || (k(oe), L?.(oe));
1834
+ te.current?.setSelectionRange(Re.start, Re.end, Re.direction);
1835
+ const ne = { ...o, editMode: b?.editMode ?? !1 };
1836
+ b?.text !== void 0 && (ne.dirty = b.text), ne.editMode === o.editMode && ne.dirty === o.dirty || (T(ne), D?.(ne));
1870
1837
  }, submitEdit: () => Et(), cancelEdit() {
1871
- xt();
1838
+ wt();
1872
1839
  }, autoFocus() {
1873
- _.current?.focus();
1874
- }, getLineHeight: () => Xe?.maxLineHeight ?? Ne, dispatchEvent: (b) => _.current.dispatchEvent(b) }), [o, c]);
1875
- return Ce("div", { ref: D, ...q, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: Xe.height, maxWidth: "100%", maxHeight: "100%", ...$ }, children: Ce("textarea", { spellCheck: "false", ref: _, value: ye, autoFocus: !1, disabled: ge, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${p}px`, fontFamily: `${Ve}`, fontWeight: `${We}`, fontStyle: `${fe}`, padding: "0px", marginRight: U === "right" ? "3px" : "0px", marginLeft: U === "left" ? "2px" : "0px", lineHeight: be, height: Xe.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: U, background: "transparent", color: P, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: ce === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (b) => {
1876
- X(b.target.value);
1840
+ te.current?.focus();
1841
+ }, getLineHeight: () => Xe?.maxLineHeight ?? Ne, dispatchEvent: (b) => te.current.dispatchEvent(b) }), [o, c]);
1842
+ return Ce("div", { ref: k, ...J, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: Xe.height, maxWidth: "100%", maxHeight: "100%", ...A }, children: Ce("textarea", { spellCheck: "false", ref: te, value: ye, autoFocus: !1, disabled: he, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${p}px`, fontFamily: `${Ve}`, fontWeight: `${We}`, fontStyle: `${ue}`, padding: "0px", marginRight: _ === "right" ? "3px" : "0px", marginLeft: _ === "left" ? "2px" : "0px", lineHeight: be, height: Xe.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: _, background: "transparent", color: W, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: me === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (b) => {
1843
+ q(b.target.value);
1877
1844
  }, onDoubleClick: (b) => {
1878
1845
  b.isTrusted;
1879
1846
  }, onMouseDown: (b) => {
1880
1847
  Pt(!0);
1881
- }, onKeyDown: ht }) });
1882
- })), Rr = Kt((t) => {
1883
- const { value: n, view: o, bounds: r, range: c, zoom: s, children: i, style: l, ...h } = t;
1884
- return Ce("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...h, children: n });
1848
+ }, onKeyDown: ut }) });
1849
+ })), br = Kt((t) => {
1850
+ const { value: n, view: o, bounds: r, range: c, zoom: d, children: i, style: l, ...w } = t;
1851
+ return Ce("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...w, children: n });
1885
1852
  });
1886
1853
  export {
1887
- Ro as BaseGrid,
1888
- Er as DefaultCellEditor,
1889
- Rr as DefaultCellRenderer,
1890
- dr as DefaultHeaderDivider,
1891
- Io as FillHandle,
1892
- Mo as Grid,
1893
- Ir as HeaderDivider,
1894
- ar as HeaderRenderer,
1895
- Cr as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
1854
+ Co as BaseGrid,
1855
+ yr as DefaultCellEditor,
1856
+ br as DefaultCellRenderer,
1857
+ ir as DefaultHeaderDivider,
1858
+ yo as FillHandle,
1859
+ Eo as Grid,
1860
+ Sr as HeaderDivider,
1861
+ lr as HeaderRenderer,
1862
+ vr as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
1896
1863
  Vt as SELECTION_CLIP_INSETS,
1897
- vo as STANDARD_KEY_CHARS,
1898
- ao as SVGLine,
1899
- _o as SVGRect,
1900
- sr as ScrollableGrid,
1901
- bo as Selection,
1902
- Zn as TouchSelectHandle,
1903
- er as defaultSelectionRenderer,
1904
- fr as getDefaultStringEditState,
1864
+ mo as STANDARD_KEY_CHARS,
1865
+ co as SVGLine,
1866
+ jo as SVGRect,
1867
+ rr as ScrollableGrid,
1868
+ vo as Selection,
1869
+ Xn as TouchSelectHandle,
1870
+ Yo as defaultSelectionRenderer,
1871
+ ar as getDefaultStringEditState,
1905
1872
  $t as safeSelectionCoords,
1906
- Xo as useAnimatedMeasure,
1907
- Ao as useCellLayout,
1908
- yr as useHeaderSelection,
1909
- Sr as useKeyboardEditorOverlay,
1910
- br as useSelection
1873
+ Bo as useCellLayout,
1874
+ pr as useHeaderSelection,
1875
+ xr as useKeyboardEditorOverlay,
1876
+ mr as useSelection
1911
1877
  };