UNPKG

@sheetxl/utils-react

Version:

Utils React - Utilities for React capabilities needed for all SheetXL components.

957 lines 103 kB
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode("._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}:root{--icon-size-sm: calc(var(--icon-size, 1rem), * .875);--icon-size-md: var(--icon-size, 1rem);--icon-size-lg: calc(var(--icon-size, 1rem) * 1.25);--icon-size-xl: calc(var(--icon-size, 1rem) * 1.5)}._Icon_17dpm_10{font-size:var(--icon-size, var(--icon-size-md));min-width:var(--icon-size, var(--icon-size-md));min-height:var(--icon-size, var(--icon-size-md));--icon-stroke-em: .085em;--icon-color: currentColor;--icon-secondary-color: color-mix(in oklab, currentColor 65%, transparent);--icon-tertiary-color: color-mix(in oklab, currentColor 40%, transparent);--icon-line-color: currentColor;--icon-main-opacity: 1;--icon-secondary-opacity: .45;--icon-tertiary-opacity: .25;--icon-line-opacity: 1;--icon-filter: none;filter:var(--icon-filter);display:inline-flex;align-items:center;justify-content:center;line-height:1;vertical-align:middle;flex:0 0 auto}._Icon_17dpm_10 .sm{--font-size: var(--icon-size-sm)}._Icon_17dpm_10 .md{--font-size: var(--icon-size-md)}._Icon_17dpm_10 .lg{--font-size: var(--icon-size-lg)}._Icon_17dpm_10 .xl{--font-size: var(--icon-size-xl)}._Icon_17dpm_10>svg{width:var(--icon-size);height:var(--icon-size)}._Icon_17dpm_10>img{aspect-ratio:1 / 1;display:block;line-height:1}._Icon_17dpm_10 .fill,._Icon_17dpm_10 .line{--layer-color: var(--icon-color);--layer-opacity: var(--icon-main-opacity)}._Icon_17dpm_10 .secondary{--layer-color: var(--icon-secondary-color)}._Icon_17dpm_10 .tertiary{--layer-color: var(--icon-tertiary-color)}._Icon_17dpm_10 .primary{--layer-color: var(--sxl-app-color-primary, var(--icon-primary, #595b5e))}._Icon_17dpm_10 .secondary{--layer-color: var(--sxl-app-color-secondary, #9c27b0)}._Icon_17dpm_10 .secondary.light{--layer-color: var(--sxl-app-color-secondary-light, #a060ac)}._Icon_17dpm_10 .success{--layer-color: var(--sxl-app-color-success, #22c55e)}._Icon_17dpm_10 .success.light{--layer-color: var(--sxl-app-color-success-light, #22c55e)}._Icon_17dpm_10 .info{--layer-color: var(--sxl-app-color-info, #3b82f6)}._Icon_17dpm_10 .warn{--layer-color: var(--sxl-app-color-warn, #f59e0b)}._Icon_17dpm_10 .error{--layer-color: var(--sxl-app-color-error, #ef4444)}._Icon_17dpm_10 .error.light{--layer-color: var(--sxl-app-color-error-light, #f87171)}._Icon_17dpm_10 .grey{--layer-color: var(--sxl-app-color-grey, #cccccc)}._Icon_17dpm_10 .shadow{--layer-color: var(--sxl-app-color-shadow, #cccccc)}._Icon_17dpm_10 .fill:not(.fixed):not([fill]){fill:var(--layer-color);opacity:var(--layer-opacity);stroke:none}._Icon_17dpm_10 .line:not(.fixed):not([stroke]){fill:none;stroke:var(--layer-color, var(--icon-line-color));stroke-width:var(--icon-stroke-em);opacity:var(--layer-opacity, var(--icon-line-opacity));vector-effect:non-scaling-stroke;pointer-events:none;stroke-linecap:var(--icon-linecap, round);stroke-linejoin:var(--icon-linejoin, round);stroke-miterlimit:var(--icon-miter, 4)}@media (prefers-color-scheme: dark){._Icon_17dpm_10 .invert-dark{filter:invert(1) hue-rotate(180deg)}}._Icon_17dpm_10 .muted{opacity:calc(var(--layer-opacity, 1) * .6)}@keyframes _sxl-walk_17dpm_1{to{stroke-dashoffset:0}}.icon.walking .walkable.line{stroke-dasharray:var(--walk-dash-length, 5px) var(--walk-dash-gap, 2px);stroke-dashoffset:calc(var(--walk-dash-length, 5px) + var(--walk-dash-gap, 2px));animation:_sxl-walk_17dpm_1 var(--walk-duration, .96s) linear infinite;will-change:stroke-dashoffset}:root{--scrollbar-track-color: rgba(0,0,0,.06);--scrollbar-thumb-color: rgba(0,0,0,.35);--scrollbar-button-color: var(--scrollbar-thumb-color);--scrollbar-active-color: rgba(0,0,0,.55);--scrollbar-corner-color: transparent;--scrollbar-border-color: transparent}:root .has-touch-thumb,:root .has-touch-thumb *{--scrollbar-size: 4px;--scrollbar-border-width: 0px;--scrollbar-width: var(--scrollbar-size);--scrollbar-height: var(--scrollbar-size)}:root{--scrollbar-width: var(--scrollbar-size);--scrollbar-height: var(--scrollbar-size);--scrollbar-border-radius: 9999px;--scrollbar-border-width: 2px;--scrollbar-min-thumb-size: 24px}._scrollbar_gqxsx_24 ::-webkit-scrollbar-button{background:transparent}._scrollbar_gqxsx_24{display:flex;flex:1 1 100%;overflow:hidden;border-radius:var(--scrollbar-border-radius);align-items:center;border:var(--scrollbar-border-width) solid transparent}._scrollbar_gqxsx_24 ._track_gqxsx_35{background:var(--scrollbar-track-color);border-radius:var(--scrollbar-border-radius);position:relative;flex:1 1 100%;border:var(--scrollbar-border-width) solid transparent;touch-action:none;box-sizing:border-box;overflow:hidden}._scrollbar_gqxsx_24 ._thumb_gqxsx_47{background:var(--scrollbar-thumb-color);border-radius:var(--scrollbar-border-radius);transition:background .12s;touch-action:none}._scrollbar_gqxsx_24 ._thumb_gqxsx_47:hover{background:var(--scrollbar-active-color)}._scrollbar_gqxsx_24.vertical{flex-direction:column;min-width:var(--scrollbar-width, 0px);max-width:var(--scrollbar-width, 100%)}._scrollbar_gqxsx_24.vertical ._thumb_gqxsx_47{min-height:var(--scrollbar-min-thumb-size)}._scrollbar_gqxsx_24.vertical ._track_gqxsx_35{width:100%}._scrollbar_gqxsx_24.horizontal{flex-direction:row;min-height:var(--scrollbar-height, 0px);max-height:var(--scrollbar-height, 100%)}._scrollbar_gqxsx_24.horizontal ._thumb_gqxsx_47{min-width:var(--scrollbar-min-thumb-size)}._scrollbar_gqxsx_24.horizontal ._track_gqxsx_35{height:100%}._scrollbar_gqxsx_24.dragging ._thumb_gqxsx_47{background:var(--scrollbar-active-color)}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89{display:flex;align-items:center;justify-content:center;border:none;background:transparent;padding:0}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89>*{fill:var(--scrollbar-button-color);transition:fill .12s ease}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89:hover:not([disabled])>*{fill:var(--scrollbar-active-color)}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89[disabled]>*{fill:var(--scrollbar-button-color);opacity:.5}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89.vertical{width:var(--scrollbar-width)}._scrollbar_gqxsx_24 ._scrollbar-button_gqxsx_89.horizontal{height:var(--scrollbar-height)}._touch-thumb_gqxsx_124{position:absolute;cursor:grab;pointer-events:all;transition-property:opacity;border-radius:9999px;will-change:opacity;opacity:.7}._touch-thumb_gqxsx_124:hover,._touch-thumb_gqxsx_124.dragging{opacity:1}._scrollpane_1fbi8_2{position:relative;display:flex}._vertical-container_1fbi8_7{display:flex;flex:0}._horizontal-corner-container_1fbi8_12{display:flex;flex:none;flex-direction:row;align-items:stretch;justify-content:center}._horizontal-container_1fbi8_20{display:flex;flex:1 1 100%;flex-direction:column}._scrollbar-sizer_1fbi8_26{display:flex;flex:1 1 100%;align-items:stretch;justify-content:stretch}._scrollpane-content_1fbi8_34{position:relative;width:100%;flex:1 1 100%;display:flex;flex-direction:column;box-sizing:border-box}._scrollpane-content-element_1fbi8_43{display:flex;flex:1 1 100%;overflow:hidden}")),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})(); import ae, { useRef as K, useReducer as Yt, useMemo as R, useEffect as W, useState as q, version as vn, memo as _e, forwardRef as Le, useCallback as U, useLayoutEffect as Mt, createContext as Gt, useContext as qt, createElement as bn, useImperativeHandle as wn, Component as xn } from "react"; import { CommonUtils as te, DefaultNotifier as Sn, Notifier as xe, InternalClipboard as rt, ClipboardUtils as pt, MimeType as ft } from "@sheetxl/utils"; import { jsx as P, jsxs as fe, Fragment as me } from "react/jsx-runtime"; import { createRoot as En } from "react-dom/client"; import { unstable_batchedUpdates as Ln, createPortal as Mn } from "react-dom"; /** * @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.7.27 * * (C) 2025-present SheetXL Inc. & Michael T. Ford * License: The license can be found at https://www.sheetxl.com/license. */ const $o = { General: "general", Left: "left", Right: "right", Center: "center", Justify: "justify", Fill: "fill", Distributed: "distributed", CenterContinuous: "centerContinuous" }, Q = { Shift: "shift", Alt: "alt", Ctrl: "ctrl", Meta: "meta" }, Ko = { BackSpace: 8, Tab: 9, Clear: 12, Enter: 13, Shift: 16, Control: 17, Alt: 18, Pause: 19, CapsLock: 20, Escape: 27, Space: 32, PageUp: 33, PageDown: 34, End: 35, Home: 36, Left: 37, Up: 38, Right: 39, Down: 40, Insert: 45, Delete: 46, Digit_8: 56, Y: 89, Z: 90, Meta: 91, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123, NumLock: 144, ScrollLock: 145, BackSlash: 220, Slash: 191, BracketRight: 221, BracketLeft: 219, Composition: 229 }, No = { Left: 1, Middle: 2, Right: 3 }; class bt { constructor(e, t, n, r) { this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = e, this._target = t, this._applyProps(n || {}), this._callback = r, r === void 0 && (this._callback = () => { console.log(`implement: ${this.getLabel()} : ${this.getDescription()}`); }); } getKey() { return this._key; } _resolve(e, t) { if (typeof e == "function") { const n = t ?? this._context; return e(typeof n == "function" ? n() : n); } return e; } getTarget() { return typeof this._target == "function" ? this._target() : this._target; } getLabel(e, t) { const n = this._scopedLabels?.[e] || this._label; let r = null; if (typeof n == "function") { const i = t ?? this._context; r = n(typeof i == "function" ? i() : i); } else r = n; return r; } getDescription(e) { return this._resolve(this._description, e); } getTags(e) { return this._resolve(this._tags, e); } getIcon(e) { return this._resolve(this._icon, e); } getShortcut() { return this._resolve(this._shortcut); } disabled() { return this._resolve(this._disabled) || !this._callback; } getState() { return this._resolve(this._state); } getContext() { return typeof this._context == "function" ? this._context() : this._context; } async execute(e, t) { if (!this.disabled() && this._callback) { try { let n = !0; if (t?.beforeExecute && (n = t?.beforeExecute(this, e)), await Promise.resolve(n) === !1) return !1; const r = this._callback.bind(this)(e, this); if (await Promise.resolve(r) === !1) return !1; t?.onExecute?.(this, e), this._notifyExecute(e); } catch (n) { return console.warn(n), t?.onError(this, n, e), this._notifyError(e, n), !1; } return !0; } } addPropertyListener(e, t = !1) { if (!e) throw new Error("listener must be specified"); const n = this._listenersProperties; return n.add(e), t && e({}, this), () => { n.delete(e); }; } addExecuteListener(e) { if (!e) throw new Error("listener must be specified"); const t = this._listenersExecute; return t.add(e), function() { t.delete(e); }; } _notifyExecute(e) { const t = this; this._listenersExecute.forEach((n) => { n.onExecute(t, e); }); } _notifyError(e, t) { const n = this; this._listenersExecute.forEach((r) => { r.onError?.(n, e, t); }); } updateCallback(e) { return this._callback = e || null, this; } update(e) { if (!e) return; const t = this._applyProps(e); return Object.keys(t).length > 0 && this._notifyPropertyChange(t), this; } _notifyPropertyChange(e) { const t = this; this._listenersProperties.forEach((n) => { n(e, t); }); } _applyProps(e) { let t = {}, n = this; return Object.keys(e).forEach((r) => { let i = e[r]; n["_" + r] !== i && (n["_" + r] = t[r] = i); }), t; } } class mt extends bt { } function Ro(o, e = null) { const t = K(e); t.current = e; const [n, r] = Yt((c) => c + 1, 0), i = R(() => Array.isArray(o) ? o : [o], [o]); return W(() => { const c = i ? i.length : 0; if (c === 0) return; const h = (a, u) => { t.current?.onChange?.(u), r(); }; let s = null; e && (s = { onExecute(a, u) { t.current?.onExecute?.(a, u); }, onError(a, u, d) { t.current?.onError?.(a, u, d); } }); const l = /* @__PURE__ */ new Set(); for (let a = 0; a < c; a++) { const u = i[a]; u && (l.add(u.addPropertyListener(te.debounce(h, 0), !0)), e && l.add(u.addExecuteListener(s))); } return () => { l.forEach((a) => { a?.(); }); }; }, [o]), n; } var re = typeof window < "u" ? window : { screen: {}, navigator: {} }, ze = (re.matchMedia || function() { return { matches: !1 }; }).bind(re), Zt = !1, Cn = { get passive() { return Zt = !0; } }, zt = function() { }; re.addEventListener && re.addEventListener("p", zt, Cn), re.removeEventListener && re.removeEventListener("p", zt, !1); var Tn = Zt, kn = "PointerEvent" in re, Ct = "ontouchstart" in re, Jt = Ct || "TouchEvent" in re && ze("(any-pointer: coarse)").matches, At = (re.navigator.maxTouchPoints || 0) > 0 || Jt, Qt = re.navigator.userAgent || "", Pn = ze("(pointer: coarse)").matches && /iPad|Macintosh/.test(Qt) && Math.min(re.screen.width || 0, re.screen.height || 0) >= 768, en = (ze("(pointer: coarse)").matches || !ze("(pointer: fine)").matches && Ct) && !/Windows.*Firefox/.test(Qt), Dn = ze("(any-pointer: fine)").matches || ze("(any-hover: hover)").matches || Pn || !Ct, wt = !At || !Dn && en ? At ? "touchOnly" : "mouseOnly" : "hybrid", zn = wt === "mouseOnly" ? "mouse" : wt === "touchOnly" || en ? "touch" : "mouse"; const An = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: wt, primaryInput: zn, supportsPassiveEvents: Tn, supportsPointerEvents: kn, supportsTouchEvents: Jt }, Symbol.toStringTag, { value: "Module" })), Bn = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), tn = {}; function Ke() { return An; } const nn = (o) => o === "BracketLeft" ? "[" : o === "BracketRight" ? "]" : te.camelToPrettyCase(o), tt = (o, e) => { let t = !1, n = !1; const r = { nativeEvent: o, currentTarget: e || o.currentTarget, target: o.target, bubbles: o.bubbles, cancelable: o.cancelable, defaultPrevented: o.defaultPrevented, eventPhase: o.eventPhase, isTrusted: o.isTrusted, preventDefault: () => { t = !0, o.preventDefault(); }, isDefaultPrevented: () => t, stopPropagation: () => { n = !0, o.stopPropagation(); }, isPropagationStopped: () => n, persist: () => { }, timeStamp: o.timeStamp, type: o.type }; for (const i in o) i in r || typeof o[i] == "function" || (r[i] = o[i]); return r; }, Ho = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: tn, boundPixel: function(o, e = !1, t = 0) { return o; }, createSyntheticEvent: tt, detectIt: Ke, focusableNodeNames: Bn, toPrettyKeyCode: nn }, Symbol.toStringTag, { value: "Module" })); class on { constructor(e, t) { this._target = null, this._groupKey = null, this._root = null, this._parent = null, this._uuid = te.uuidV4(), this._target = e, this._groupKey = t ?? null, this._root = this, this._nodes = /* @__PURE__ */ new Map(), this._nodes.set(t, this), this._children = /* @__PURE__ */ new Map(), this._listeners = /* @__PURE__ */ new Set(), this._commandsByKey = /* @__PURE__ */ new Map(), this._commandsByShortcut = /* @__PURE__ */ new Map(); const n = this; this._unListenersByCommand = /* @__PURE__ */ new Map(), this._listenersByKey = /* @__PURE__ */ new Map(), this._commandsPropertyListener = (r, i) => { const c = n._root._listenersByKey, h = i.getKey(), s = c.get(h); s && n._notifyCommands(s, "onCommandChange", i); }; } _getCommand(e) { return this._commandsByKey.get(e) || (this._parent?._getCommand(e) ?? null); } getCommand(e, t = !1) { const n = this._root._focused; let r = n, i = n === this; for (; !i && r; ) r === this && (i = !0), r = r._parent; return (i ? n : this)._getCommand(e); } createChildGroup(e, t, n) { let r; if (!n) { let h = this; for (; h && !r; ) { let s = h._nodes.get(t); s && (r = s), h = h._parent; } } r || (r = new on(e, t), r._parent = this, r._root = this._root, r._unListenersByCommand = null, r._listenersByKey = null, r._commandsPropertyListener = null); const i = (h, s) => { !h.has(t) || n ? h.set(t, s) : n === void 0 && console.warn("commandGroup already registered", t); }; i(this._root._nodes, r); let c = this._parent; for (; c; ) i(this._nodes, r), c = c._parent; return this._children.set(t, r), this._notify("onGroupChange"), r; } getKey() { return this._groupKey; } getGroup(e) { return this._nodes.get(e); } _addCommands(e, t = void 0) { const n = this._commandsByKey, r = this._commandsByShortcut, i = this._root._commandsPropertyListener, c = this._root._unListenersByCommand, h = e.length; for (let s = 0; s < h; s++) { const l = e[s], a = l.getKey(); if (n.has(a) && !t) { t === void 0 && console.warn("command already registered", a); continue; } n.set(a, l); let u = c.get(l); u && (u(), c.delete(l)); const d = l.addPropertyListener(i); c.set(l, d); const p = l.getShortcut(); if (!p) continue; const m = Array.isArray(p) ? p : [p], f = m.length; for (let x = 0; x < f; x++) { const S = Ie(m[x]), g = r.get(S); g && !t && t === void 0 && console.warn(`Shortcut already registered: ${S}, ${a}, ${g}.`), r.set(S, a); } } } removeFromParent() { if (!this._parent) return; let e = this._parent, t = []; const n = this._groupKey; for (; e; ) t.push(e._nodes), e._nodes.delete(n), e = e._parent; e = this._parent; const r = (i) => { i._children.forEach((c) => { const h = t.length, s = c._nodes; for (let l = 0; l < h; l++) s.delete(t[l]); r(c); }); }; r(this), this._parent = null, this._notify("onGroupChange"); } addCommands(e, t) { this._addCommands(e, t), this._notify("onGroupChange"); } getActive() { return this._root._focused ?? this._root; } activate(e) { let t = this; if (e && (t = this._nodes.get(e), !t)) return void console.warn("group not found", e); let n = this._root._focused ?? this._root; for (; n; ) n = n._parent; this._root._focused !== t && (this._root._focused = t, this._notify("onGroupChange"), this._notify("onActiveChange")); } findCommandByEvent(e) { const t = []; e.altKey && t.push(Q.Alt), e.shiftKey && t.push(Q.Shift), e.ctrlKey && t.push(Q.Ctrl), e.metaKey && t.push(Q.Meta); let n = Ie({ key: e.code, modifiers: t }); const r = this._commandsByShortcut; let i = r.get(n); i || (n = Ie({ key: e.key, modifiers: t }), i = r.get(n)), !i && e.code.startsWith("Digit") && (n = Ie({ key: e.code.substring(5, e.code.length), modifiers: t }), i = this._commandsByShortcut.get(n)), !i && e.code.startsWith("Key") && (i = Ie({ key: e.code.substring(3, e.code.length), modifiers: t }), i = r.get(n)); let c = null; return i && (c = this._commandsByKey.get(i), c && c.disabled() && (c = null), !c || c.getTarget() && c.getTarget().contains(e.target) || (c = null)), c || (this._parent?.findCommandByEvent(e) ?? null); } dispatchToFocusedCommand(e) { const t = this.getActive(); if (!t || e.isDefaultPrevented()) return !1; const n = t.findCommandByEvent?.(e); return !!n && (n.execute(), e.preventDefault(), !0); } getRoot() { return this._parent ? this._parent.getRoot() : this; } getParent() { return this._parent; } addListener(e, t) { const n = this._listeners, r = t?.keys, i = this._root._listenersByKey; if (r && !e.onCommandChange) throw new Error("keys were provided but the listener does not contain 'onCommandChange'."); let c = null; if (r) { const h = r.length; for (let s = 0; s < h; s++) { const l = r[s]; if (!l) continue; let a = i.get(l); a || (a = /* @__PURE__ */ new Set(), i.set(l, a)), c || (c = []), c.push(a), a.add(e); } } return n.add(e), () => { if (c) { const h = c.length; for (let s = 0; s < h; s++) c[s].delete(e); } n.delete(e); }; } _notifyCommands(e, t, n) { const r = this; setTimeout(() => { e.forEach((i) => { i[t]?.(r, n); }); }, 0); } _notify(e, t) { const n = this; setTimeout(() => { n._listeners.forEach((r) => { r[e]?.(n, t); }), n._parent && n._parent._notify(e, t); }, 0); } getAllCommands() { const e = [], t = this._groupKey; return this._commandsByKey.forEach((n) => { e.push({ command: n, groupKey: t }); }), this._children.forEach((n) => { e.push(...n.getAllCommands()); }), e; } } const On = te.getOS() === te.OSType.MacOS || te.getOS() === te.OSType.IOS ? "Cmd" : "Ctrl", In = te.getOS() === te.OSType.MacOS || te.getOS() === te.OSType.IOS ? "⌘" : "^", Ie = (o, e = !1) => { const t = {}; for (let r = 0; o.modifiers && r < o.modifiers.length; r++) t[o.modifiers[r]] = !0; let n = ""; return (t?.[Q.Ctrl] || t?.[Q.Meta]) && (n += (n.length > 0 ? "+" : "") + (e ? In : On)), t?.[Q.Alt] && (n += e ? "⌥" : "Alt"), t?.[Q.Shift] && (n += (n.length > 0 ? "+" : "") + (e ? "⇧" : "Shift")), n += (n.length > 0 ? "+" : "") + nn(o.key), n; }, Ze = (o, e) => { if (!e || !o || e.length === 0) return te.EmptyArray; const t = e.length, n = new Array(t); for (let r = 0; r < t; r++) { const i = e[r], c = i ? o.getCommand(i) : null; n[r] = c; } return n; }; function Wo(o, e = null, t = null, n) { const r = K(t); r.current = t, e && !Array.isArray(e) && (e = [e]); const [i, c] = q(Ze(o, e)), h = n ? [...n, o] : [o]; return W(() => { const s = { onGroupChange: () => { const d = Ze(o, e); c(d), r.current?.onChange?.(this); } }; let l; e && e.length > 0 && (l = { keys: e }, s.onCommandChange = (d, p) => { r.current?.onChange?.(o), c(Ze(o, e)); }); const a = o?.addListener(s, l), u = Ze(o, e); return c(u), r.current?.onChange && r.current?.onChange(o), () => { a?.(); }; }, h), i; } const Vo = { Toolbar: "toolbar", Menuitem: "menuitem" }, Fo = { BottomEnd: "bottom-end", BottomStart: "bottom-start", Bottom: "bottom", LeftEnd: "left-end", LeftStart: "left-start", Left: "left", RightEnd: "right-end", RightStart: "right-start", Right: "right", TopEnd: "top-end", TopStart: "top-start", Top: "top" }; function _t(o, e) { if (typeof o == "function") return o(e); o && (o.current = e); } var Ae = parseInt(vn.split(".")[0], 10) >= 19 ? function(o) { return (e) => { const t = []; for (const n of o) { const r = _t(n, e), i = typeof r == "function"; t.push(i ? r : () => _t(n, null)); } return () => { for (const n of t) n(); }; }; } : function(o) { return (e) => { for (const t of o) _t(t, e); }; }; const jo = _e(Le((o, e) => { const { refFocusStart: t, ...n } = o, r = K(null), i = U(() => { if (t) return void t?.current?.focus(); const c = r.current.parentElement.children; let h = []; const s = c.length; for (let l = 0; l < s && c[l] !== r.current; l++) { const a = c[l], u = a.getAttribute("tabindex"); u == null || u === "-1" || a.getAttribute("disabled") !== "true" && a.focus && h.push({ tabindex: parseInt(u), child: a }); } h.length !== 0 && (h.sort(function(l, a) { return l.tabindex - a.tabindex; }), h[0].child.focus()); }, [t]); return P("div", { tabIndex: 0, ref: Ae([r, e]), onFocus: i, ...n }); })); var $n = function() { }, rn = typeof window < "u", Kn = rn ? Mt : W, Bt = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 }; const Ee = rn && window.ResizeObserver !== void 0 ? function() { var o = q(null), e = o[0], t = o[1], n = q(Bt), r = n[0], i = n[1], c = R(function() { return new window.ResizeObserver(function(h) { if (h[0]) { var s = h[0].contentRect, l = s.x, a = s.y, u = s.width, d = s.height, p = s.top, m = s.left, f = s.bottom, x = s.right; i({ x: l, y: a, width: u, height: d, top: p, left: m, bottom: f, right: x }); } }); }, []); return Kn(function() { if (e) return c.observe(e), function() { c.disconnect(); }; }, [e]), [t, r]; } : function() { return [$n, Bt]; }, Uo = _e(Le((o, e) => { const { className: t, style: n, children: r, radius: i = 4, strokeWidth: c = 1, strokeColor: h = "grey", ...s } = o, [l, { width: a, height: u }] = Ee(), d = K(null), p = (S, g = 0) => { const _ = S / 2, v = u - _ + g; return (function(B, E, O = !1) { if (E === 0) return B; function I(T, y, z) { let H = y.x - T.x, X = y.y - T.y, D = Math.sqrt(H * H + X * X); return M(T, y, Math.min(1, z / D)); } function M(T, y, z) { return { x: T.x + (y.x - T.x) * z, y: T.y + (y.y - T.y) * z }; } function b(T, y) { T.length > 2 && (T[T.length - 2] = y.x, T[T.length - 1] = y.y); } function C(T) { return { x: parseFloat(T[T.length - 2]), y: parseFloat(T[T.length - 1]) }; } let L = B.split(/[,\s]/).reduce(function(T, y) { let z = y.match("([a-zA-Z])(.+)"); return z ? (T.push(z[1]), T.push(z[2])) : T.push(y), T; }, []).reduce(function(T, y) { return parseFloat(y) == y && T.length ? T[T.length - 1].push(y) : T.push([y]), T; }, []), $ = []; if (L.length > 1) { let T = C(L[0]), y = null; L[L.length - 1][0] === "Z" && L[0].length > 2 && (y = ["L", T.x, T.y], L[L.length - 1] = y), $.push(L[0]); for (let z = 1; z < L.length; z++) { let H = $[$.length - 1], X = L[z], D = X === y ? L[1] : L[z + 1]; if (D && H && H.length > 2 && X[0] === "L" && D.length > 2 && D[0] === "L") { let F, V, Y = C(H), ee = C(X), Me = C(D); O ? (F = M(ee, H.origPoint || Y, E), V = M(ee, D.origPoint || Me, E)) : (F = I(ee, Y, E), V = I(ee, Me, E)), b(X, F), X.origPoint = ee, $.push(X); let ge = M(F, ee, 0.5), Ce = M(ee, V, 0.5), ye = ["C", ge.x, ge.y, Ce.x, Ce.y, V.x, V.y]; ye.origPoint = ee, $.push(ye); } else $.push(X); } if (y) { let z = C($[$.length - 1]); $.push(["Z"]), b($[0], z); } } else $ = L; return $.reduce(function(T, y) { return T + y.join(" ") + " "; }, ""); })(`${`M 0 ${_} L ${i - 0.5} ${_} L ${i - 0.5} ${v} L ${2 * i} ${v}`} ${`L ${a - 2 * i} ${v}`} ${`M ${a - 2 * i} ${v} L ${a - i} ${v} L ${a - i} ${_} L ${a} ${_}`}`, i); }, m = R(() => p(c), [a, u, i, c]), f = R(() => { if (i === 0) return; const S = i / 2; return p(i) + `L ${a} 0 L 0 0 L 0 ${S}`; }, [m, i, c]), x = R(() => ({ style: { clipPath: `path('${f}')` } }), [f]); return fe("div", { className: t, style: { display: "flex", flexDirection: "row", ...n }, ...s, ref: Ae([d, l, e]), children: [ae.isValidElement(r) ? ae.cloneElement(r, x) : P(me, {}), P("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: a, height: u, viewBox: `0 0 ${a} ${u}`, children: P("path", { d: m, stroke: h, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: c }) })] }); })), Ot = { Default: "default", Error: "error", Success: "success", Warning: "warning", Info: "info" }; class Nn extends Sn { setOverrides(e) { super.setOverrides(e); } getDelegate() { return this._overrides; } showMessage(e, t) { const n = this.getDelegate(); if (n?.showMessage) return n.showMessage(e, t); t?.type !== Ot.Warning ? t?.type !== Ot.Error ? xe.log(e) : xe.error(e) : xe.warn(e); } showBusy(e, t) { const n = this.getDelegate(); return n?.showBusy ? n.showBusy(e, t) : new Promise((r) => { r(() => { }); }); } showWindow(e, t) { const n = this.getDelegate(); if (n?.showWindow) return n.showWindow(e, t); } showError(e) { const t = this.getDelegate(); t?.showError ? t.showError(e) : xe.error(e); } showOptions(e) { const t = this.getDelegate(); return t?.showOptions ? t.showOptions(e) : Promise.resolve(""); } showInput(e) { const t = this.getDelegate(); return t?.showInput ? t.showInput(e) : Promise.resolve({ input: "", option: "" }); } } const sn = Gt(new Nn()), Xo = ({ children: o, notifier: e }) => (ae.useEffect(() => { const t = xe.getOverrides(); return xe.setOverrides(e), () => { xe.setOverrides(t); }; }, [e]), ae.createElement(sn.Provider, { value: e }, o)), lt = () => qt(sn), Rn = 3, Hn = 0.5, Wn = 50, gt = (o) => ({ x: o.x, y: o.y, width: o.width, height: o.height, top: o.top, left: o.left, right: o.right, bottom: o.bottom }); function Vn(o = {}) { const { threshold: e = Hn, stillnessThreshold: t = Rn, maxHierarchyDepth: n = Wn } = o, [r, i] = Ee(), c = K(null), [h, s] = Yt((m) => m + 1, 0), l = K(void 0), a = K({ x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 }), u = U((m) => { c.current = m, typeof r == "function" && r(m); }, [r]), [d, p] = q(i); return W(() => { i && !d && p(i); }, [i, d]), W(() => { const m = c.current; if (!m) return; let f = !1, x = 0; const S = () => { if (!m) return; const E = m.getBoundingClientRect(), O = a.current; Math.abs(E.x - O.x) > e || Math.abs(E.y - O.y) > e || Math.abs(E.width - O.width) > e || Math.abs(E.height - O.height) > e ? (f || (f = !0, p(gt(E)), s()), x = 0) : x++, f && x >= t && (f = !1, p(gt(E)), s()), a.current = gt(E), l.current = requestAnimationFrame(S); }; l.current = requestAnimationFrame(S); const g = (E) => { f = !0, s(); }, _ = (E) => { f = !1, x = t, s(); }; let v = m; const B = []; for (; v && v !== document.documentElement && (v.addEventListener("animationstart", g, !0), v.addEventListener("animationend", _, !0), v.addEventListener("transitionstart", g, !0), v.addEventListener("transitionend", _, !0), B.push(v), v = v.parentElement, !(B.length > n)); ) ; return () => { l.current && cancelAnimationFrame(l.current), B.forEach((E) => { E.removeEventListener("animationstart", g, !0), E.removeEventListener("animationend", _, !0), E.removeEventListener("transitionstart", g, !0), E.removeEventListener("transitionend", _, !0); }); }; }, [h, i, e, t, n]), [u, d]; } const k = (o, e) => { const t = U((...i) => o?.(...i), e), n = K(null); n.current = t; const r = U((...i) => n.current?.(...i), []); if (n.current) return r; }; function Yo(o) { const [e, t] = q(typeof window < "u" ? window.devicePixelRatio : 1), n = K(null); return W(() => { if (!(typeof window < "u" && "matchMedia" in window)) return; const r = () => { const i = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`); i.addEventListener("change", r, { once: !0, passive: !0 }), t(window.devicePixelRatio), n.current = { mediaMatcher: i, listener: r }; }; return r(), () => { n.current && n.current.mediaMatcher.removeEventListener("change", n.current.listener); }; }, [o]), e; } function Go(o) { if (typeof window > "u") return 1; const { defaultDpr: e = 1, maxDpr: t = 3, round: n = !0 } = o || {}, r = typeof window < "u" && typeof window.devicePixelRatio == "number" ? window.devicePixelRatio : e; return Math.min(Math.max(1, n ? Math.floor(r) : r), t); } function qo(o, e, t) { const n = k(e, [e]); W(() => { const r = (i) => { o.current && !o.current.contains(i.target) && n(i); }; return t && t.mouseEvents === !1 || (document.addEventListener("mousedown", r), document.addEventListener("touchstart", r)), t && t.focusEvents === !1 || document.addEventListener("focus", r), () => { document.removeEventListener("mousedown", r), document.removeEventListener("touchstart", r), document.removeEventListener("focus", r); }; }, [o]); } let Je = 0; function Fn() { const [o, e] = q(!!document.fullscreenElement), t = U(() => { const n = document.fullscreenElement; return n ? n.querySelector(".fullscreen-portal-root") || n : document.body; }, []); return W(() => { function n() { const r = document.fullscreenElement; if (e(!!r), !r) return; let i = r.querySelector(".fullscreen-portal-root"); i || (i = document.createElement("div"), i.className = "fullscreen-portal-root _fullscreen-portal-root_1mjsr_4", r.appendChild(i)); } return Je++, n(), document.addEventListener("fullscreenchange", n), () => { document.removeEventListener("fullscreenchange", n), Je--, Je <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((r) => { r.parentNode && r.parentNode.removeChild(r); }), Je = 0); }; }, []), { getPortalContainer: t, isFullscreen: o }; } function ln(o) { if (!o) throw new Error("must have a PointerHandlerOptions"); const { onPointerDown: e, onPointerUp: t, onPointerMoveOrWait: n, processTouch: r = !1, consumeTouch: i = !0 } = o, c = k(e, [e]), h = k(t, [t]), s = k(n, [n]), l = K(!1), a = o?.timerInitial ?? 230, u = o?.timerContinuous ?? a / 2, d = K(null), p = K(null), m = K(null), f = K(null), x = U(() => { f.current && (clearTimeout(f.current), f.current = null); }, []), S = U((b) => { f.current = setTimeout(() => { window.requestAnimationFrame(() => { if (l.current === !1) return; const C = p.current, L = d.current, $ = tt(C, L.currentTarget); s?.($, m.current, L); }), S(u); }, b ?? a); }, []); W(() => () => x(), []); const g = r ? "pointer" : "mouse", _ = U((b) => { b.stopPropagation(), b.stopImmediatePropagation(), b.preventDefault(); }, []), v = k((b) => { document.removeEventListener(`${g}move`, O), document.removeEventListener(`${g}up`, v), document.removeEventListener("keydown", I), document.removeEventListener("keyup", M), document.removeEventListener("touchstart", _, { capture: !0 }), document.removeEventListener("touchmove", _, { capture: !0 }), window.removeEventListener("blur", B), x(), window.requestAnimationFrame(() => { if (l.current === !1) return; l.current = !1; const C = b, L = d.current, $ = tt(C, L.currentTarget); h?.($, m.current, L), m.current = null; }); }, []), B = U(() => { l.current !== !1 && (l.current = !1, v(p.current)); }, []), E = k(() => { x(), S(u), window.requestAnimationFrame(() => { if (l.current === !1) return; const b = p.current, C = d.current, L = tt(b, C.currentTarget); s?.(L, m.current, C); }); }, [u]), O = k((b) => { p.current = b, E(); }, []), I = k((b) => { m.current = { ctrlKey: b.ctrlKey, shiftKey: b.shiftKey, altKey: b.altKey, metaKey: b.metaKey }, E(); }, []), M = k((b) => { m.current = { ctrlKey: b.ctrlKey, shiftKey: b.shiftKey, altKey: b.altKey, metaKey: b.metaKey }, E(); }, [u]); return k((b) => { b.isDefaultPrevented() || (m.current = { ctrlKey: b.ctrlKey, shiftKey: b.shiftKey, altKey: b.altKey, metaKey: b.metaKey }, c(b, m.current) !== !1 && (d.current = b, p.current = b.nativeEvent, document.addEventListener(`${g}up`, v, { passive: !1 }), document.addEventListener(`${g}move`, O, { passive: !1 }), document.addEventListener("keydown", I, { passive: !1 }), document.addEventListener("keyup", M, { passive: !1 }), window.addEventListener("blur", B, { passive: !0 }), r && i && (document.addEventListener("touchstart", _, { passive: !1, capture: !0 }), document.addEventListener("touchmove", _, { passive: !1, capture: !0 })), l.current = !0, S(a))); }, [a, r]); } function Zo(o, e) { return ln({ onPointerDown: o, onPointerMoveOrWait: (t, n, r) => { o?.(r); }, ...e }); } const jn = ({ initValue: o, useHookBody: e, applyStateChange: t }) => { const n = K(o); if (typeof e != "function") throw new Error("function expected as hook body parameter. got " + typeof e); const r = e(); return Mt(() => { n.current !== r && (n.current = r, t(r)); }, [t, r]), null; }, xt = (o) => { console && console.warn && console.warn(o); }, yt = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0; let Un = 1, St = !1, an = !1; const nt = [], De = [], it = () => { De.forEach((o) => o()); }, Xn = ({ automaticContainerInternalUseOnly: o }) => { const [e, t] = q([]), n = K([]); return n.current = e, o || St !== !1 || (an = !0), W(() => { let r = !0; function i() { if (r) return De[0] !== i ? (o || St !== !0 || xt("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void t((c) => [])) : void t([...nt]); } return De.push(i), it(), () => { r = !1, n.current?.length > 0 && xt("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), De.splice(De.indexOf(i), 1), it(); }; }, [o]), P(me, { children: e.map(({ hook: r, key: i }) => bn(jn, { ...r, key: i })) }); }, Yn = (o) => { const e = Un++; return nt.push({ hook: o, key: e }), De.length === 0 && an === !1 && (St = !0, ((t) => { if (yt.document && yt.document.createElement) { const n = yt.document.createElement("div"); En(n).render(P(t, { automaticContainerInternalUseOnly: !0 })); } else xt("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually."); })(Xn)), it(), () => { nt.splice(nt.findIndex((t) => t.key === e), 1), it(); }; }; let Et = null; Et || (Et = (o, e, t = {}) => { let n, r, i = !1, c = !1, h = [], { unmountIfNoConsumers: s = !1 } = t; const l = (u) => { r = u, Ln(() => h.forEach((d) => d(u))); }, a = () => (c || (r = typeof o == "function" ? o() : o, c = !0), r); return () => { const [u, d] = q(a); return W(() => (i || (i = !0, n = Yn({ initValue: o, useHookBody: e, applyStateChange: l })), h.push(d), r !== u && d(r), () => { h.splice(h.indexOf(d), 1), h.length === 0 && s && (n(), i = !1); }), []), u; }; }); const cn = Et; let un = () => { console.warn("You must call useEditMode before setting its state."); }; const Gn = cn(null, () => { const [o, e] = q(null); return un = e, o; }), Jo = () => { const o = Gn(); return R(() => ({ setMode: (e) => { un((t) => (typeof e == "function" && (e = e(t)), e?.onModeChange?.(e ?? null), e)); }, getMode: () => o }), [o]); }, qn = cn({ setClipboard: (o) => { throw new Error("This is only available via the useClipboard."); }, getClipboard: () => rt.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => { const [o, e] = q(rt.Global); return { setClipboard: (t) => e(t), getClipboard: () => o, refNativeCopy: K(null), refNativeLastKey: K(null) }; }), Qo = (o) => { const { source: e, target: t, onPaste: n, onClipboardUpdate: r, commands: i } = o, c = lt(), h = k(r, [r]), s = k(n, [n]), { getClipboard: l, refNativeCopy: a } = qn(), u = l(); R(() => { const g = e?.element, _ = t?.element ?? e?.element; if (!i) return; const v = [new mt("cut", g, { label: "Cut", description: "Remove the selection and put it on the clipboard so you can paste it somewhere else.", icon: "cut", shortcut: { key: "X", modifiers: [Q.Ctrl] } }), new mt("copy", g, { label: "Copy", description: "Put a copy of the selection on the clipboard so you can paste it somewhere else.", icon: "copy", shortcut: { key: "C", modifiers: [Q.Ctrl] } }), new mt("paste", _, { label: "Paste", description: "Add content on the clipboard to your document.", icon: "paste.yellow", shortcut: [{ key: "V", modifiers: [Q.Ctrl] }, { key: "F8", modifiers: [Q.Ctrl] }] })]; i?.addCommands(v, !0); }, [i]); const d = k(async (g) => { if (!e?.element) return; let _ = null; try { _ = e.doCopy?.(g), typeof _ == "string" ? await u.writeText(_) : await u.writeReference(_); } catch (v) { throw v; } }, [e, c]), p = k(async (g) => { const _ = e?.element?.(); if (_) { a.current = { sourceElement: _, args: g }; try { await d(g); } catch (v) { c.showError?.(v); } } }, [e?.element, c]), m = U(() => { p({ isCut: !0 }); }, []), f = k(async (g, _, v) => { try { if (await g.doPaste(_, v) === !1) return; s?.(_, v); } catch (B) { c.showError?.(B); } }, [s]), x = k(async (g, _, v) => { const B = t?.element?.(); if (B && await te.whenFocus(B), !g && !_) return; const E = await c.showBusy?.("Pasting..."); if (_) try { return await f(t, _, v), void E?.(); } catch (M) { E?.(), c.showError?.(M); } let O, I = t.importFromExternal; I || (I = (M, b) => ({ getItemType: () => "text", toText: () => g.text, isClipboardItem: !0 })); try { O = await I(g, { isCut: !1 }); } catch (M) { E?.(), c.showError?.(M); } if (O) try { const M = await Promise.resolve(O); await f(t, M, v), E?.(); } catch (M) { E?.(), c.showError?.(M); } else E?.(); }, [f, t, c]), S = k(async (g) => { if (t?.element) try { const _ = await u.readReference(); if (_) return void await x(null, _, g); const v = []; v[0] = await pt.readStringFromClipboard(u, ft.plain), v[1] = await pt.readHTMLFromClipboard(u, ft.html), v[2] = await pt.readBlobFromClipboard(u, ft.png); const B = { text: v[0] ?? null, html: v[1] ?? null, image: v[2] ?? null }; await x(B, null, g); } catch (_) { if (_?.message === "Document is not focused.") return; c.showError?.(_); } }, [x, t?.element, c]); return k(async (g) => { }, [e?.element]), k(async (g) => { }, [t?.element, x, c]), W(() => { if (!u) return; const g = async (B) => { const E = await u.readReference(); h?.(E); }, _ = (B) => { c.showMessage?.(rt.ErrorMessages.PermsRead, { onceKey: "clipboard.features" }); }, v = (B) => { c.showMessage?.(rt.ErrorMessages.PermsWrite, { onceKey: "clipboard.features" }); }; return u.addEventListener("clipboardchange", g), u.addEventListener("clipboarderrorread", _), u.addEventListener("clipboarderrorwrite", v), () => { u.removeEventListener("clipboardchange", g), u.removeEventListener("clipboarderrorread", _), u.removeEventListener("clipboarderrorwrite", v); }; }, [u, c]), W(() => { }, [d, x, e, t]), W(() => { i?.getCommand("cut")?.updateCallback(m).update({ disabled: !e || !t }), i?.getCommand("copy")?.updateCallback(p).update({ disabled: !e }), i?.getCommand("paste")?.updateCallback(S).update({ disabled: !t }); }, [e, t, i]), { paste: S, copy: p, clipboard: u }; }; function er(o, e = !0) { const t = K(o); W(() => { if (e) { const n = Object.entries(o).reduce((r, [i, c]) => (t.current[i] !== c && (r[i] = [t.current[i], c]), r), {}); Object.keys(n).length > 0 && console.log("Changed props:", n); } t.current = o; }); } let vt = !1, Zn = 0; var Jn = typeof document < "u" ? Mt : W; const It = () => "sheetxl-ui-" + Zn++, $t = ae.useId, tr = $t ?? function() { const [o, e] = ae.useState(() => vt ? It() : void 0); return Jn(() => { o == null && e(It()); }, []), ae.useEffect(() => { vt || (vt = !0); }, []), o; }, Qn = []; function Tt(o, e, t = Qn) { const n = K(null); return wn(o, () => { if (!n.current) return; const r = n.current, i = e?.(); if (!i || typeof i != "object") throw new Error("attributes must return a plain object of values"); const c = Object.keys(i), h = c.length; for (let s = 0; s < h; s++) { const l = c[s], a = i[l]; Object.defineProperty(r, l, { value: a, writable: !0, configurable: !0, enumerable: !0 }); } return r; }, t), n; } const Kt = "Undo the last action.", Nt = "Repeat the last action or undo the redo.", eo = (o) => `Redo ${o}`, nr = ({ manager: o, commands: e, disabled: t }) => { const n = lt(), r = k((c) => { try { o?.undo(c); } catch (h) { n.error(h); } }, [o]), i = k((c) => { try { o?.redo(c); } catch (h) { n.error(h); } }, [o]); return R(() => { if (!e) return; const c = { contains: (s) => !0, focus() { } }, h = [new bt("undo", c, { label: "Undo", description: Kt, shortcut: { key: "z", modifiers: [Q.Ctrl] }, disabled: !0 }, r), new bt("redo", c, { label: "Redo", description: Nt, shortcut: [{ key: "y", modifiers: [Q.Ctrl] }, { key: "F4" }, { key: "Enter", modifiers: [Q.Alt] }], disabled: !0 }, i)]; e?.addCommands(h, !0); }, [e]), W(() => { if (!e) return; const c = () => { const s = o?.getTopUndoDescription(), l = {}; var a; e.getCommand("undo").update({ disabled: t || !o || !o.hasUndo(), description: s ? (a = s, `Undo ${a}`) : Kt, state: l, context: { undoManager: o } }); const u = o?.getTopRedoDescription(); e.getCommand("redo").update({ disabled: t || !o || !o.hasRedo(), description: u ? eo(u) : Nt, state: l, context: { undoManager: o } }); }; if (c(), !o) return; const h = o.addListener({ onStackChange() { c(); } }); return () => h?.(); }, [o, e, t]), { undo: r, redo: i }; }; class to extends xn { static getDerivedStateFromError() { return { hasError: !0 }; } componentDidCatch(e) { this.props.onError?.(e); } render() { return this.props.children; } } const or = ({ children: o }) => { const e = lt(), t = U((n) => { e.showError(n); }, [e]); return P(to, { onError: t, children: o }); }; class no { constructor(e) { this.notifier = e, this.handleUnhandledRejection = (t) => { const n = t.reason; n instanceof DOMException && n.name === "AbortError" || this.notifier.showError(n); }, this.handleGlobalError = (t) => { this.notifier.showError(t.error); }, this.setupGlobalHandlers(); } setupGlobalHandlers() { window.addEventListener("unhandledrejection", this.handleUnhandledRejection), window.addEventListener("error", this.handleGlobalError); } cleanup() { window.removeEventListener("unhandledrejection", this.handleUnhandledRejection), window.removeEventListener("error", this.handleGlobalError); } } const rr = ({ children: o }) => { const e = lt(); return W(() => { const t = new no(e); return () => { t.cleanup(); }; }, [e]), P(me, { children: o }); }, ir = () => null; function hn(o) { var e, t, n = ""; if (typeof o == "string" || typeof o == "number") n += o; else if (typeof o == "object") if (Array.isArray(o)) { var r = o.length; for (e = 0; e < r; e++) o[e] && (t = hn(o[e])) && (n && (n += " "), n += t); } else for (t in o) o[t] && (n && (n += " "), n += t); return n; } function G() { for (var o, e, t = 0, n = "", r = arguments.length; t < r; t++) (o = arguments[t]) && (e = hn(o)) && (n && (n += " "), n += e); return n; } const oo = {}, ro = (o) => { const { onPointerDown: e, style: t, splitDirection: n, paddingBefore: r = 0, paddingAfter: i = 0, disabled: c, key: h, propsHitArea: s = oo, ...l } = o, a = n === "row", { style: u, className: d, ...p } = s; return P("div", { style: { ...t, position: "relative" }, ...l, children: P("div", { className: G("hit-box", d), style: { left: (a ? -r : 0) + "px", width: `calc(100% + ${a ? r + i : 0}px)`, top: (a ? 0 : -r) + "px", height: `calc(100% + ${a ? 0 : r + i}px)`, position: "absolute", ...u }, onPointerDown: c ? void 0 : e, ...p }) }, h); }, Qe = {}, we = (o, e, t = !0) => o === null ? null : o.pixels !== null ? t ? o.pixels : e - o.pixels : (t ? o.percent : 100 - o.percent) / 100 * e, et = (o, e = !0) => o?.percent ? `${e ? o.percent : 100 - o.percent}%` : o?.pixels ? `${o.pixels}px` : void 0, he = (o, e) => { if (o == null) return null; const t = { percent: null, pixels: null }; let n = e; return typeof o == "string" && ((o = o.trim().toLowerCase()).endsWith("px") ? (o = o.substring(0, o.length - 2), n = !1) : o.endsWith("%") && (o = o.substring(0, o.length - 1), n = !0), o = parseFloat(o)), n ? t.percent = o : t.pixels = o, Object.freeze(t); }, io = _e(Le((o, e) => { const { elementBefore: t, elementAfter: n, splitDirection: r = "row", fixedPane: i = null, position: c, onPositionChange: h, minBefore: s, maxBefore: l, minAfter: a, maxAfter: u, children: d, className: p, style: m, disabled: f = !1, onDragStart: x, onDragResize: S, onDragFinish: g, propsResizer: _ = Qe, propsPane: v = Qe, propsPaneBefore: B = Qe, propsPaneAfter: E = Qe, renderResizer: O = ro } = o; if (d) throw new Error("Use elementBefore and elementAfter instead of children."); const I = R(() => ae.isValidElement(n) && ae.isValidElement(t), [n, t]), M = R(() => { let A = null; i && (i === "before" ? A = 0 : i === "after" && (A = 1)); const j = A === null; return { fixedPaneOffset: A, isPercent: j, minBefore: he(s, j), maxBefore: he(l, j), minAfter: he(a, j), maxAfter: he(u, j) }; }, [s, l, a, u]), b = k(h, [h]), [C, L] = q(() => he(c, i === null)); W(() => { L(he(c, i === null)); }, [c, i]); const [$, { width: T, height: y }] = Ee(), [z, { width: H, height: X }] = Ee(), D = r === "row" ? H : X, F = r === "row" ? T : y, V = R(() => ((A, j, oe, J) => { const ce = [null, null], le = [null