@sheetxl/grid-react 0.7.19 → 0.7.21

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