UNPKG

sheetxl

Version:

SheetXL - Command line tool

1,141 lines 2.19 MB
#!/usr/bin/env node /** * @license sheetxl - SheetXL - Command line tool - v0.7.26 * * (C) 2025-present SheetXL Inc. & Michael T. Ford * License: The license can be found at https://www.sheetxl.com/license. */ import e from "chalk"; import t from "fs"; import n from "path"; import { createCommand as r, Option as s, Argument as o } from "commander"; const i = { Number: "n", String: "s", Boolean: "b", Error: "e", RichData: "r", Null: "z" }; var a, l, c; (l = a || (a = {})).Orientation = { Column: "column", Row: "row" }, l.Orientations = { ...l.Orientation, Both: "both" }, l.Direction = { Up: "up", Down: "down", Left: "left", Right: "right" }, ((e6) => { e6.Code = { Parse: 0, Null: 1, Div0: 2, Value: 3, Ref: 4, Name: 5, Num: 6, NA: 7, GettingData: 8, Spill: 9, Connect: 10, Blocked: 11, Unknown: 12, Field: 13, Calc: 14, Busy: 16, Python: 19, Timeout: 20 }, e6.Label = { Parse: "#PARSE!", Null: "#NULL!", Div0: "#DIV/0!", Value: "#VALUE!", Ref: "#REF!", Name: "#NAME?", Num: "#NUM!", NA: "#N/A", GettingData: "#GETTING_DATA", Spill: "#SPILL!", Connect: "#CONNECT!", Blocked: "#BLOCKED!", Unknown: "#UNKNOWN!", Field: "#FIELD!", Calc: "#CALC!", Busy: "#BUSY!", Python: "#PYTHON!", Timeout: "#TIMEOUT!" }; class t2 extends Error { constructor(e7, t3, n3, r3) { super(n3, r3), this._label = t3, this._code = e7, this.details = r3; } static { this.code = e6.Code.Unknown; } get isFormulaError() { return true; } getLabel() { return this._label; } getCode() { return this._code; } equals(e7) { return !!e7 && (this._code === e7._code || this._code === e7.code); } get [Symbol.toStringTag]() { return "[FormulaError]"; } toString() { return this.message || this._label; } } e6.Known = t2; class n2 extends t2 { constructor(t3, n3) { super(e6.Code.Parse, e6.Label.Parse, t3, n3); } static { this.code = e6.Code.Parse; } getDetails() { const e7 = this.details; return { line: e7?.line ?? 1, column: e7?.column ?? 1, offset: e7?.offset ?? 0, length: e7?.length ?? 0 }; } } e6.Parse = n2; class r2 extends t2 { constructor(t3, n3) { super(e6.Code.Null, e6.Label.Null, t3, n3); } static { this.code = e6.Code.Null; } } e6.Null = r2; class s2 extends t2 { constructor(t3, n3) { super(e6.Code.Div0, e6.Label.Div0, t3, n3); } static { this.code = e6.Code.Div0; } } e6.Div0 = s2; class o2 extends t2 { constructor(t3, n3) { super(e6.Code.Value, e6.Label.Value, t3, n3); } static { this.code = e6.Code.Value; } } e6.Value = o2; class i2 extends t2 { constructor(t3, n3) { super(e6.Code.Ref, e6.Label.Ref, t3, n3); } static { this.code = e6.Code.Ref; } } e6.Ref = i2; class a2 extends t2 { constructor(t3, n3) { super(e6.Code.Name, e6.Label.Name, t3, n3); } static { this.code = e6.Code.Name; } } e6.Name = a2; class l2 extends t2 { constructor(t3, n3) { super(e6.Code.Num, e6.Label.Num, t3, n3); } static { this.code = e6.Code.Num; } } e6.Num = l2; class c2 extends t2 { constructor(t3, n3) { super(e6.Code.NA, e6.Label.NA, t3, n3); } static { this.code = e6.Code.NA; } } e6.NA = c2; class h2 extends t2 { constructor(t3, n3) { super(e6.Code.GettingData, e6.Label.GettingData, t3, n3); } static { this.code = e6.Code.GettingData; } } e6.GettingData = h2; class u2 extends t2 { constructor(t3, n3) { super(e6.Code.Spill, e6.Label.Spill, t3, n3); } static { this.code = e6.Code.Spill; } } e6.Spill = u2; class d2 extends t2 { constructor(t3, n3) { super(e6.Code.Connect, e6.Label.Connect, t3, n3); } static { this.code = e6.Code.Connect; } } e6.Connect = d2; class g2 extends t2 { constructor(t3, n3) { super(e6.Code.Blocked, e6.Label.Blocked, t3, n3); } static { this.code = e6.Code.Blocked; } } e6.Blocked = g2; class f2 extends t2 { constructor(t3, n3) { super(e6.Code.Unknown, e6.Label.Unknown, t3, n3); } static { this.code = e6.Code.Unknown; } } e6.Unknown = f2; class p2 extends t2 { constructor(t3, n3) { super(e6.Code.Field, e6.Label.Field, t3, n3); } static { this.code = e6.Code.Field; } } e6.Field = p2; class m2 extends t2 { constructor(t3, n3) { super(e6.Code.Calc, e6.Label.Calc, t3, n3); } static { this.code = e6.Code.Calc; } } e6.Calc = m2; class w2 extends t2 { constructor(t3, n3) { super(e6.Code.Busy, e6.Label.Busy, t3, n3); } static { this.code = e6.Code.Busy; } } e6.Busy = w2; class _2 extends t2 { constructor(t3, n3) { super(e6.Code.Python, e6.Label.Python, t3, n3); } static { this.code = e6.Code.Python; } } e6.Python = _2; class S2 extends t2 { constructor(t3, n3) { super(e6.Code.Timeout, e6.Label.Timeout, t3, n3); } static { this.code = e6.Code.Timeout; } } e6.Timeout = S2; })(c || (c = {})); const h = {}; h[c.Code.Parse] = c.Parse, h[c.Code.Null] = c.Null, h[c.Code.Div0] = c.Div0, h[c.Code.Value] = c.Value, h[c.Code.Ref] = c.Ref, h[c.Code.Name] = c.Name, h[c.Code.Num] = c.Num, h[c.Code.NA] = c.NA, h[c.Code.GettingData] = c.GettingData, h[c.Code.Spill] = c.Spill, h[c.Code.Connect] = c.Connect, h[c.Code.Blocked] = c.Blocked, h[c.Code.Unknown] = c.Unknown, h[c.Code.Field] = c.Field, h[c.Code.Calc] = c.Calc, h[c.Code.Busy] = c.Busy, h[c.Code.Python] = c.Python, h[c.Code.Timeout] = c.Timeout; const u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = Object.keys(h); for (let e6 = 0; e6 < p.length; e6++) { const t2 = p[e6], n2 = h[t2]; g.set(c.Label[t2], n2), f.set(c.Code[t2], n2); const r2 = new n2(); u.set(r2.getLabel(), r2), d.set(r2.getCode(), r2); } const m = d.get(c.Code.Unknown); var w; (w = c || (c = {})).BuiltIn = { Parse: new w.Parse(), Null: new w.Null(), Div0: new w.Div0(), Value: new w.Value(), Ref: new w.Ref(), Name: new w.Name(), Num: new w.Num(), NA: new w.NA(), GettingData: new w.GettingData(), Spill: new w.Spill(), Connect: new w.Connect(), Blocked: new w.Blocked(), Unknown: new w.Unknown(), Field: new w.Field(), Calc: new w.Calc(), Busy: new w.Busy(), Python: new w.Python(), Timeout: new w.Timeout() }, w.getBuiltInByLabel = (e6) => u.get(e6), w.newTypedError = (e6, t2, n2) => { let r2; return r2 = "string" == typeof e6 ? g.get(e6) : f.get(e6), r2 || (r2 = w.Unknown), new r2(t2, n2); }, w.getBuiltInById = (e6) => d.get(e6) || m; let _ = class { constructor(e6) { this._subscribeFn = e6; } subscribe(e6, t2, n2) { const r2 = "object" == typeof e6 ? { next: e6.next || (() => { }), error: e6.error || (() => { }), complete: e6.complete || (() => { }), unsubscribe: () => { } } : { next: e6 || (() => { }), error: t2 || (() => { }), complete: n2 || (() => { }), unsubscribe: () => { } }, s2 = this._subscribeFn(r2); return r2.unsubscribe = () => { "function" == typeof s2 && s2(); }, r2; } }, S = class { getRange(e6) { throw new y(); } getReference(e6, t2) { throw new y(); } getNumberFormat(e6, t2) { return t2?.toString() ?? ""; } fromOADate(e6) { return new Date(e6); } toOADate(e6) { return e6.getTime(); } getValueAt(e6, t2) { return null; } getEntireCoords() { return v; } isValidDate(e6) { return (e6 instanceof Date || "[object Date]" === Object.prototype.toString.call(e6)) && !isNaN(e6.getTime()); } getPosition() { return b; } getFormulaAt(e6, t2) { return null; } getSpillAt(e6, t2) { return null; } getSheetIndex(e6) { return -1; } getSheetCount() { return 1; } markVolatile() { } formatResults(e6) { } getFunction(e6) { return null; } getAddress(e6, t2) { throw new y(); } parseAsDateTime(e6, t2) { throw new y(); } getRuntime() { return C; } }, y = class extends Error { constructor(e6 = "Not implemented in StubbedFormulaContext") { super(e6), this.name = "NotImplementedError"; } }; const b = Object.freeze({ colIndex: 0, rowIndex: 0 }), v = Object.freeze({ colStart: 0, rowStart: 0, colEnd: Math.pow(2, 14) - 1, rowEnd: Math.pow(2, 20) - 1 }), C = { getCurrencySymbol: () => "$", getNumberDecimalSeparator: () => ".", getNumberGroupSeparator: () => ",", isDate1904: () => false, getLocation: () => "unknown", getVersion: () => "1.0.0", getOS: () => "unknown", getUser: () => "unidentified", getDescription: () => "Stubbed Formula Context" }, x = new S(), E = { Column: "column", Row: "row" }, I = { ...E, Both: "both" }, A = Object.freeze({ colIndex: 0, rowIndex: 0 }), R = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), k = (e6, t2) => e6.colStart === t2.colStart ? e6.rowStart - t2.rowStart : e6.colStart - t2.colStart, T = (e6, t2) => e6.rowStart === t2.rowStart ? e6.colStart - t2.colStart : e6.rowStart - t2.rowStart, M = (e6, t2) => e6.rowEnd === t2.rowEnd ? t2.colEnd - e6.colEnd : t2.rowEnd - e6.rowEnd, F = (e6, t2) => e6.colEnd === t2.colEnd ? t2.rowEnd - e6.rowEnd : t2.colEnd - e6.colEnd, N = (e6, t2) => e6.colIndex === t2.colIndex ? e6.rowIndex - t2.rowIndex : e6.colIndex - t2.colIndex, O = (e6, t2) => e6.rowIndex === t2.rowIndex ? e6.colIndex - t2.colIndex : e6.rowIndex - t2.rowIndex, L = (e6, t2) => e6.rowIndex === t2.rowIndex ? t2.colIndex - e6.colIndex : t2.rowIndex - e6.rowIndex, D = (e6, t2) => e6.colIndex === t2.colIndex ? t2.rowIndex - e6.rowIndex : t2.colIndex - e6.colIndex, B = (e6 = E.Row, t2 = false) => t2 ? e6 !== E.Column ? M : F : e6 !== E.Column ? T : k, P = (e6, t2) => e6 === t2 || !(!e6 || !t2) && e6.rowIndex === t2.rowIndex && e6.colIndex === t2.colIndex, z = (e6, t2) => e6 === t2 || !(!e6 || !t2) && e6.rowStart === t2.rowStart && e6.rowEnd === t2.rowEnd && e6.colStart === t2.colStart && e6.colEnd === t2.colEnd, j = (e6, t2) => !(!e6 || !t2 || e6.colStart > t2.colEnd || t2.colStart > e6.colEnd || e6.rowStart > t2.rowEnd || t2.rowStart > e6.rowEnd), V = (e6, t2) => { if (e6 === t2) return true; if (!e6 || !t2) return false; if (e6.length !== t2.length) return false; for (let n2 = 0; n2 < e6.length; n2++) if (!z(e6[n2], t2[n2])) return false; return true; }, W = (e6, t2, n2) => { if (!e6 && !t2) return null; if (!e6) return n2 ? t2 : { ...t2 }; if (!t2) return n2 ? e6 : { ...e6 }; const r2 = Math.min(e6.colStart, t2.colStart), s2 = Math.min(e6.rowStart, t2.rowStart), o2 = Math.max(e6.colEnd, t2.colEnd), i2 = Math.max(e6.rowEnd, t2.rowEnd); let a2 = n2; return a2 ? (a2.colStart = r2, a2.rowStart = s2, a2.colEnd = o2, a2.rowEnd = i2) : a2 = { colStart: r2, rowStart: s2, colEnd: o2, rowEnd: i2 }, a2; }, G = (e6, t2) => { if (!t2 || 0 === t2.length) return e6; const n2 = { ...e6 }; for (let e7 = 0; e7 < t2.length; e7++) { const r2 = t2[e7]; j(n2, r2) && (n2.rowStart = Math.min(n2.rowStart, r2.rowStart), n2.colStart = Math.min(n2.colStart, r2.colStart), n2.rowEnd = Math.max(n2.rowEnd, r2.rowEnd), n2.colEnd = Math.max(n2.colEnd, r2.colEnd)); } return n2; }, U = [null, null], H = (e6, t2, n2) => { if (e6[0].value === e6[1].value) return t2; }; function q(e6, t2 = 2, n2, r2 = E.Row, s2) { let o2 = [...e6]; if (t2 <= 0 || e6.length <= 1) return o2; let i2 = r2 === E.Column, a2 = 0, l2 = false; do { const e7 = o2.sort(B(i2 ? E.Row : E.Column)); o2 = [], o2.push(e7[0]); const t3 = e7.length; let c2 = 0, h2 = e7[0], u2 = h2.colStart, d2 = h2.rowStart, g2 = h2.colEnd, f2 = h2.rowEnd; for (let a3 = 1; a3 < t3; a3++) { const t4 = e7[a3]; let p2 = false; if (p2 = i2 ? h2 && d2 === t4.rowStart && f2 === t4.rowEnd && g2 + 1 === t4.colStart : h2 && u2 === t4.colStart && g2 === t4.colEnd && f2 + 1 === t4.rowStart, p2) { let e8 = { colStart: u2, rowStart: d2, colEnd: i2 ? t4.colEnd : g2, rowEnd: i2 ? f2 : t4.rowEnd }; if (void 0 !== h2.value && (e8.value = h2.value), n2) { const o3 = s2 ?? [null, null]; o3[0] = h2, o3[1] = t4, e8 = n2(o3, e8, r2); } if (e8) { o2[c2] = e8, l2 = true, h2 = e8, u2 = h2.colStart, d2 = h2.rowStart, g2 = h2.colEnd, f2 = h2.rowEnd; continue; } } o2[++c2] = t4, h2 = t4, u2 = h2.colStart, d2 = h2.rowStart, g2 = h2.colEnd, f2 = h2.rowEnd; } a2++, i2 = !i2, 1 === a2 && (l2 = true); } while (a2 < t2 && l2 && o2.length > 1); return o2; } const $ = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: A, EmptyRange: R, cellToRange: (e6, t2) => { if (!e6) return null; let n2 = t2; return n2 || (n2 = { ...e6 }, delete n2.colIndex, delete n2.rowIndex), n2.colStart = e6.colIndex ?? 0, n2.rowStart = e6.rowIndex ?? 0, n2.colEnd = e6.colIndex ?? 0, n2.rowEnd = e6.rowIndex ?? 0, n2; }, columnFirstCellComparator: N, columnFirstRangeComparator: k, createCellComparator: (e6 = E.Row, t2 = false) => t2 ? e6 !== E.Column ? L : D : e6 !== E.Column ? O : N, createConflatingRanges: (e6, t2 = false) => { const n2 = []; let r2, s2, o2 = Number.MIN_SAFE_INTEGER, i2 = Number.MIN_SAFE_INTEGER; return { append: (a2, l2, c2) => { let h2 = true; const u2 = void 0 !== c2; if (u2) { const n3 = e6 ? e6(s2, c2, t2) : s2 === c2 ? c2 : void 0; void 0 === n3 ? h2 = false : c2 = n3; } if (h2 && l2 === i2 + 1 && a2 === o2) return t2 ? r2.rowEnd = l2 : r2.colEnd = l2, i2 = l2, void (s2 = c2); r2 && n2.push(r2); const d2 = t2 ? a2 : l2, g2 = t2 ? l2 : a2; r2 = { colStart: d2, rowStart: g2, colEnd: d2, rowEnd: g2 }, u2 && (r2.value = c2), o2 = a2, i2 = l2, s2 = c2; }, done: (e7) => (r2 && (n2.push(r2), r2 = null), e7 ? q(n2, 3, true === e7 ? H : e7, t2 ? E.Column : E.Row, U) : n2) }; }, createRangeComparator: B, defaultRange: (e6, t2, n2) => e6 ? n2 ? (n2.colStart = e6.colStart ?? t2.colStart, n2.rowStart = e6.rowStart ?? t2.rowStart, n2.colEnd = e6.colEnd ?? t2.colEnd, n2.rowEnd = e6.rowEnd ?? t2.rowEnd, n2) : { colStart: e6.colStart ?? t2.colStart, rowStart: e6.rowStart ?? t2.rowStart, colEnd: e6.colEnd ?? t2.colEnd, rowEnd: e6.rowEnd ?? t2.rowEnd } : t2, extendRangeToIntersectingRanges: G, extendRangeToUnionRanges: (e6, t2) => { if (!t2 || 0 === t2.length) return e6; let n2 = e6, r2 = null; for (; !z(n2, r2); ) r2 = n2, n2 = G(r2, t2); return n2; }, indexOfCoords: (e6, t2) => { const n2 = { colStart: e6.colIndex, rowStart: e6.rowIndex, colEnd: e6.colIndex, rowEnd: e6.rowIndex }; for (let e7 = t2.length - 1; e7 >= 0; e7--) if (j(n2, t2[e7])) return e7; return -1; }, intersectRanges: (e6, t2, n2) => { if (!e6) return n2 ? t2 : { ...t2 }; if (!t2) return n2 ? e6 : { ...e6 }; if (!e6 && !t2) return null; if (e6.rowStart > t2.rowEnd || e6.rowEnd < t2.rowStart || e6.colStart > t2.colEnd || e6.colEnd < t2.colStart) return null; const r2 = Math.max(e6.colStart, t2.colStart), s2 = Math.max(e6.rowStart, t2.rowStart), o2 = Math.min(e6.colEnd, t2.colEnd), i2 = Math.min(e6.rowEnd, t2.rowEnd); let a2 = n2; return a2 ? (a2.colStart = r2, a2.rowStart = s2, a2.colEnd = o2, a2.rowEnd = i2) : a2 = { colStart: r2, rowStart: s2, colEnd: o2, rowEnd: i2 }, a2; }, isCellWithinRange: (e6, t2) => { if (!e6 || !t2) return false; const n2 = e6.rowIndex; if (n2 < t2.rowStart || n2 > t2.rowEnd) return false; const r2 = e6.colIndex; return !(r2 < t2.colStart || r2 > t2.colEnd); }, isEqualCells: P, isEqualRanges: z, isEqualRangesArrays: V, isEqualSelectionCoords: (e6, t2) => e6 === t2 || !(!e6 || !t2) && e6.rangeIndex === t2.rangeIndex && !!P(e6.cell, t2.cell) && V(e6.ranges, t2.ranges), isRangeWithinRange: (e6, t2) => !(e6.rowStart < t2.rowStart || e6.rowEnd > t2.rowEnd || e6.colStart < t2.colStart || e6.colEnd > t2.colEnd), isRangesIntersect: j, isSingleCell: (e6) => !!e6 && e6.rowEnd === e6.rowStart && e6.colStart === e6.colEnd, isValidRange: (e6) => !(!e6 || "number" != typeof e6.colStart || e6.colStart < 0 || "number" != typeof e6.colEnd || e6.colEnd < e6.colStart || "number" != typeof e6.rowStart || e6.rowStart < 0 || "number" != typeof e6.rowEnd || e6.rowEnd < e6.rowStart), mergeRangedValues: q, reverseColumnFirstCellComparator: D, reverseRowFirstCellComparator: L, rowFirstCellComparator: O, rowFirstRangeComparator: T, sanitizeRange: (e6) => e6 ? { colStart: e6.colIndex ?? e6.colStart ?? 0, rowStart: e6.rowIndex ?? e6.rowStart ?? 0, colEnd: e6.colIndex ?? e6.colEnd ?? 0, rowEnd: e6.rowIndex ?? e6.rowEnd ?? 0 } : null, translateRange: (e6, t2 = -e6.rowStart, n2 = -e6.colStart, r2) => r2 ? (r2.colStart = e6.colStart + n2, r2.rowStart = e6.rowStart + t2, r2.colEnd = e6.colEnd + n2, r2.rowEnd = e6.rowEnd + t2, r2) : { colStart: e6.colStart + n2, rowStart: e6.rowStart + t2, colEnd: e6.colEnd + n2, rowEnd: e6.rowEnd + t2 }, unionRanges: W, unionRangesArrays: (e6, t2, n2) => { if (!e6 || 0 === e6.length) return null; if (1 === e6.length && !t2) return e6[0]; let r2 = e6[0]; for (let t3 = 1; t3 < e6.length; t3++) r2 = W(r2, e6[t3], n2); return t2 && (r2 = W(r2, t2, n2)), r2; } }, Symbol.toStringTag, { value: "Module" })); class X { constructor() { this._onceMessageKeys = /* @__PURE__ */ new Set(); } setOverrides(e6) { this._overrides = e6 ?? null; } getOverrides() { return this._overrides; } _write(e6, t2, n2) { if (n2?.onceKey) { const e7 = this._onceMessageKeys; if (e7.has(n2.onceKey)) return; e7.add(n2.onceKey); } const r2 = n2?.details, s2 = this._overrides; if (s2) { const r3 = s2[e6]; if (r3) return void r3.bind(s2)(t2, n2); } void 0 === r2 ? console[e6](t2) : console[e6](t2, r2); } log(e6, t2) { return this._write("log", e6, t2); } error(e6, t2) { return this._write("error", e6, t2); } warn(e6, t2) { return this._write("warn", e6, t2); } debug(e6, t2) { return this._write("debug", e6, t2); } } const J = new X(), K = { Up: "up", Down: "down", Left: "left", Right: "right" }, Y = { TopLeft: "tl", Top: "t", TopRight: "tr", Left: "l", Center: "c", Right: "r", BottomLeft: "bl", Bottom: "b", BottomRight: "br" }, Z = { html: "text/html", plain: "text/plain", png: "image/png" }, Q = Object.freeze({ left: 0, top: 0 }), ee = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), te = Object.freeze({ x: 0, y: 0, width: 0, height: 0 }), ne = Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: te, EmptyRect: ee, EmptyTopLeft: Q }, Symbol.toStringTag, { value: "Module" })); const re = "function" == typeof Symbol && Symbol.for ? Symbol.for("react.element") : 60103; function se(e6) { return /* @__PURE__ */ (function(e7) { return !!e7 && "object" == typeof e7; })(e6) && !(function(e7) { const t2 = Object.prototype.toString.call(e7); return "[object RegExp]" === t2 || "[object Date]" === t2 || e7.$$typeof === re; })(e6); } function oe(e6, t2) { return false !== t2.clone && t2.isMergeableObject(e6) ? ce((n2 = e6, Array.isArray(n2) ? [] : {}), e6, t2) : e6; var n2; } function ie(e6, t2, n2) { return e6.concat(t2).map(function(e7) { return oe(e7, n2); }); } function ae(e6) { return Object.keys(e6).concat((t2 = e6, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t2).filter(function(e7) { return Object.propertyIsEnumerable.call(t2, e7); }) : [])); var t2; } function le(e6, t2) { try { return t2 in e6; } catch (e7) { return false; } } function ce(e6, t2, n2) { (n2 = n2 || {}).arrayMerge = n2.arrayMerge || ie, n2.isMergeableObject = n2.isMergeableObject || se, n2.cloneUnlessOtherwiseSpecified = oe; const r2 = Array.isArray(t2); return r2 === Array.isArray(e6) ? r2 ? n2.arrayMerge(e6, t2, n2) : (function(e7, t3, n3) { const r3 = {}; return n3.isMergeableObject(e7) && ae(e7).forEach(function(t4) { r3[t4] = oe(e7[t4], n3); }), ae(t3).forEach(function(s2) { var o2, i2; le(o2 = e7, i2 = s2) && (!Object.hasOwnProperty.call(o2, i2) || !Object.propertyIsEnumerable.call(o2, i2)) || (le(e7, s2) && n3.isMergeableObject(t3[s2]) ? r3[s2] = (function(e8, t4) { if (!t4.customMerge) return ce; const n4 = t4.customMerge(e8); return "function" == typeof n4 ? n4 : ce; })(s2, n3)(e7[s2], t3[s2], n3) : r3[s2] = oe(t3[s2], n3)); }), r3; })(e6, t2, n2) : oe(t2, n2); } ce.all = function(e6, t2) { if (!Array.isArray(e6)) throw new Error("first argument should be an array"); return e6.reduce(function(e7, n2) { return ce(e7, n2, t2); }, {}); }; const he = Object.freeze([]), ue = Object.freeze({}), de = (e6) => e6, ge = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e6) { let t2 = 16 * Math.random() | 0; return ("x" === e6 ? t2 : 3 & t2 | 8).toString(16); }), fe = (e6, t2) => e6 === t2 || !(!Array.isArray(e6) || !Array.isArray(t2) || e6.length !== t2.length) && e6.every((e7, n2) => e7 === t2[n2]), pe = (e6) => "object" == typeof e6 && !Array.isArray(e6) && null !== e6, me = (e6) => "object" != typeof e6 || Array.isArray(e6) || null === e6 ? e6 : (Object.keys(e6).forEach(function(t2) { e6[t2] && "object" == typeof e6[t2] ? me(e6[t2]) : null !== e6[t2] && void 0 !== e6[t2] || delete e6[t2], "object" == typeof e6[t2] && 0 === Object.keys(e6[t2]).length && delete e6[t2]; }), 0 === Object.keys(e6).length ? null : e6), we = (e6, t2) => !(e6 !== t2 && !fe(e6, t2) && !e6.isEqual?.(t2)), _e = (e6, t2, n2 = we) => { if (null == e6 || e6 === t2) return null; if (!e6 || "object" != typeof e6 || Array.isArray(e6) || e6.isImmutable?.()) return n2(e6, t2) ? null : e6; const r2 = Object.keys(e6), s2 = r2.length; if (0 === s2) return null; let o2 = false; for (let i2 = 0; i2 < s2; i2++) { const s3 = r2[i2]; null === _e(e6[s3], t2?.[s3], n2) && (o2 = true, delete e6[s3]); } return o2 && 0 === Object.keys(e6).length ? null : void 0; }, Se = "object" == typeof performance && "function" == typeof performance.now ? () => performance.now() : () => Date.now(), ye = (e6) => null == e6, be = (e6, t2) => !(t2.left > e6.right || t2.right < e6.left || t2.top > e6.bottom || t2.bottom < e6.top), ve = !("undefined" == typeof window || !window.document || !window.document.createElement), Ce = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, xe = () => { if (Ee()) return Ce.Node; const e6 = void 0 !== globalThis.navigator && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : ""; return e6 ? /(win32|win64|windows|wince)/i.test(e6) ? Ce.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e6) ? Ce.MacOS : /(iphone|ipad|ipod)/i.test(e6) ? Ce.IOS : /android/.test(e6) ? Ce.Android : /linux/.test(e6) ? Ce.Linux : /^((?!chrome|android|).)*safari/i.test(e6) ? Ce.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e6) ? Ce.Firefox : Ce.Unknown : Ce.Unknown; }; function Ee() { return "undefined" != typeof process && "node" === process.release?.name || ("undefined" != typeof process && process.browser, false); } const Ie = (e6, t2 = false) => (document.hasFocus() || t2) && (e6 === document.activeElement || e6?.contains(document.activeElement)), Ae = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: he, EmptyObject: ue, OSType: Ce, arrayMove: function(e6, t2, n2) { const r2 = e6.slice(); return r2.splice(n2 < 0 ? r2.length + n2 : n2, 0, r2.splice(t2, 1)[0]), r2; }, asNumber: (e6) => { const t2 = ((e7) => 1 * e7)(e6); return Number.isFinite(t2) ? t2 : 0; }, camelToPrettyCase: (e6) => 1 === e6.length ? e6.toUpperCase() : e6.replace(/([A-Z])/g, " $1").replace(/^./, function(e7) { return e7.toUpperCase(); }).trim(), canUseDOM: ve, cancelTimeout: (e6) => { cancelAnimationFrame(e6.id); }, castToString: (e6) => null == e6 || void 0 === e6 ? "" : "string" != typeof e6 ? "" + e6 : e6, cloneObject: (e6) => ye(e6) ? e6 : JSON.parse(JSON.stringify(e6)), consoleWithNoSource: (...e6) => new Promise((t2) => { setTimeout(() => { Function("console.log.apply(console, arguments)").apply(null, e6), t2(); }); }), debounce: function(e6, t2 = 300, n2 = false) { let r2, s2, o2, i2, a2 = 0; function l2() { let c3 = Date.now() - a2; c3 < t2 && c3 >= 0 ? r2 = setTimeout(l2, t2 - c3) : (r2 = null, n2 || (i2 = e6.apply(o2, s2), o2 = s2 = null)); } null == t2 && (t2 = 100); const c2 = function() { o2 = globalThis, s2 = arguments, a2 = Date.now(); var c3 = n2 && !r2; return r2 || (r2 = setTimeout(l2, t2)), c3 && (i2 = e6.apply(o2, s2), o2 = s2 = null), i2; }; return c2.clear = function() { r2 && (clearTimeout(r2), r2 = null); }, c2.flush = function() { r2 && (i2 = e6.apply(o2, s2), o2 = s2 = null, clearTimeout(r2), r2 = null); }, c2; }, deepEqual: function e2(t2, n2) { if (t2 === n2) return true; if (t2 && n2 && "object" == typeof t2 && "object" == typeof n2) { if (t2.constructor !== n2.constructor) return false; let r2, s2, o2; if (Array.isArray(t2)) { if (r2 = t2.length, r2 != n2.length) return false; for (s2 = r2; 0 !== s2--; ) if (!e2(t2[s2], n2[s2])) return false; return true; } if (t2 instanceof Map && n2 instanceof Map) { if (t2.size !== n2.size) return false; for (s2 of t2.entries()) if (!n2.has(s2[0])) return false; for (s2 of t2.entries()) if (!e2(s2[1], n2.get(s2[0]))) return false; return true; } if (t2 instanceof Set && n2 instanceof Set) { if (t2.size !== n2.size) return false; for (s2 of t2.entries()) if (!n2.has(s2[0])) return false; return true; } if (ArrayBuffer.isView(t2) && ArrayBuffer.isView(n2)) { if (r2 = t2.length, r2 != n2.length) return false; for (s2 = r2; 0 !== s2--; ) if (t2[s2] !== n2[s2]) return false; return true; } if (t2.constructor === RegExp) return t2.source === n2.source && t2.flags === n2.flags; if (t2.valueOf !== Object.prototype.valueOf) return t2.valueOf() === n2.valueOf(); if (t2.toString !== Object.prototype.toString) return t2.toString() === n2.toString(); if (o2 = Object.keys(t2), r2 = o2.length, r2 !== Object.keys(n2).length) return false; for (s2 = r2; 0 !== s2--; ) if (!Object.prototype.hasOwnProperty.call(n2, o2[s2])) return false; for (s2 = r2; 0 !== s2--; ) { let r3 = o2[s2]; if (!("_owner" === r3 && t2.$$typeof || e2(t2[r3], n2[r3]))) return false; } return true; } return t2 != t2 && n2 != n2; }, deepFreeze: function e3(t2) { return Object.freeze(t2), Object.keys(t2).forEach((n2) => { "object" != typeof t2[n2] || null === t2[n2] || Object.isFrozen(t2[n2]) || e3(t2[n2]); }), t2; }, deepMerge: ce, diffValues: (e6, t2) => { const n2 = {}, r2 = Object.keys(t2), s2 = r2.length; for (let o2 = 0; o2 < s2; o2++) { const s3 = r2[o2], i2 = e6[s3], a2 = t2[s3]; i2 !== a2 && (n2[s3] = void 0 === i2 ? a2 : i2); } return 0 === Object.keys(n2).length ? null : n2; }, findEqualOrGreater: function(e6, t2, n2 = de) { let r2 = 0, s2 = e6.length - 1; for (; r2 <= s2; ) { let o2 = Math.floor((r2 + s2) / 2), i2 = n2(e6[o2]); if (i2 === t2) return o2; i2 < t2 ? r2 = o2 + 1 : s2 = o2 - 1; } return r2; }, findEqualOrLesser: function(e6, t2, n2 = de) { let r2 = e6.length - 1, s2 = 0; for (; r2 >= s2; ) { let o2 = Math.floor((r2 + s2) / 2), i2 = n2(e6[o2]); if (i2 === t2) return o2; i2 > t2 ? r2 = o2 - 1 : s2 = o2 + 1; } return r2; }, findNextStep: (e6, t2 = true, n2 = 15, r2 = 10, s2 = 400) => { const o2 = Math.max(e6 - r2, 0) + (t2 ? 1 : -1); return Math.min(s2, Math[t2 ? "ceil" : "floor"](o2 / n2) * n2 + r2); }, getDPI: () => { let e6 = 1; return "object" == typeof window && (e6 = window.devicePixelRatio || 1), e6; }, getFromPath: (e6, t2) => { const n2 = t2.split("."); let r2 = e6; const s2 = n2.length; for (let e7 = 0; e7 < s2; e7++) { const t3 = n2[e7]; if (!r2) return null; let s3 = r2[t3]; if ("function" == typeof s3 && (s3 = s3.bind(r2)()), !s3 || !pe(s3)) return s3; r2 = s3; } return r2 ?? null; }, getOS: xe, hasFocus: Ie, isDefined: (e6) => !(null == e6), isEmpty: (e6) => null == e6 || "" === e6, isEqualArrays: fe, isEqualBounds: (e6, t2) => e6 === t2 || !(e6 && !t2 || t2 && !e6) && e6.x === t2.x && e6.y === t2.y && e6.width === t2.width && e6.height === t2.height, isEqualObjectKeys: (e6, t2) => { if (e6 === t2) return true; if (e6 && !t2 || t2 && !e6) return false; const n2 = Object.keys(e6), r2 = n2.length; if (r2 !== Object.keys(t2).length) return false; for (let s2 = 0; s2 < r2; s2++) { const r3 = n2[s2]; if (e6[r3] !== t2[r3]) return false; } return true; }, isNode: Ee, isNullOrUndefined: ye, isNumeric: (e6) => { const t2 = 1 * e6; return Number.isFinite(t2) && "number" == typeof t2; }, isObject: pe, isPromiseLike: (e6) => !!e6 && "function" == typeof e6.then, isRectInsideRect: (e6, t2) => e6.top >= t2.top && e6.bottom <= t2.bottom && e6.left >= t2.left && e6.right <= t2.right, isRectIntersect: be, mergeContentful: (...e6) => { const t2 = e6.length; if (t2 > 0 && void 0 !== e6[t2 - 1] && !pe(e6[t2 - 1])) return e6[t2 - 1]; let n2 = e6[0] || {}; for (let r2 = 1; r2 < t2; r2++) n2 = ce(n2, e6[r2] || {}, { arrayMerge: (e7, t3) => [...t3] }); return n2; }, nextTick: (e6) => { "undefined" != typeof window && "function" == typeof window.requestAnimationFrame ? window.requestAnimationFrame(() => { e6(); }) : ("function" == typeof setImmediate ? setImmediate : setTimeout)(() => { e6(); }); }, openFileDialog: (e6 = "*.*") => new Promise((t2, n2) => { if (!ve) return void n2("Unable to open dialog with no dom."); const r2 = document.createElement("input"); r2.type = "file", r2.accept = e6; let s2 = null, o2 = false; globalThis.addEventListener?.("focus", () => { setTimeout(() => { s2 || o2 || (o2 = true, t2(null)); }, 1e3); }, { once: true, passive: true }), r2.onchange = () => { if (s2 = r2.files[0], s2) { if (o2) return void console.warn("File open detected after faux cancel.", s2); t2(s2); } }, r2.autofocus = true, r2.click(); }), rafThrottle: (e6) => { let t2, n2 = false, r2 = function() { n2 = false, e6(t2); }; return function(e7) { t2 = e7, t2 && t2.persist && t2.persist(), n2 || (n2 = true, requestAnimationFrame(r2)); }; }, removeEmptyProperties: me, removeEqualValues: _e, removeListenerAll: (e6) => { if (!e6) return he; const t2 = e6.length; for (let n2 = 0; n2 < t2; n2++) { const t3 = e6[n2]; t3 && t3(); } return he; }, requestTimeout: (e6, t2) => { const n2 = Se(), r2 = { id: requestAnimationFrame(function s2() { Se() - n2 >= t2 ? e6.call(null) : r2.id = requestAnimationFrame(s2); }) }; return r2; }, roundAccurately: (e6, t2 = 0) => { if (null == e6 || !isFinite(e6)) return null; const n2 = 10 ** t2; return Number(Math.round(e6 * n2) / n2); }, setToPath: (e6, t2, n2) => { const r2 = t2.split("."); let s2 = e6; if (!s2) throw new Error("Can not set path to a null path."); const o2 = r2.length; for (let e7 = 0; s2 && e7 < o2 - 1; e7++) { const t3 = r2[e7]; let n3 = s2[t3]; if (null == n3 && (n3 = {}, s2[t3] = n3), !pe(n3)) throw new Error("Can not set path to a non object path."); s2 = n3; } if ("number" != typeof n2 && "boolean" != typeof n2 && "string" != typeof n2 && !pe(n2)) throw new Error(`Can not set path to ${n2} that is not a a supported primitive.`); return s2[r2[o2 - 1]] = n2, e6; }, splitNumber: (e6) => { let t2 = Math.abs(e6); if (isNaN(t2) || !isFinite(e6)) return null; let n2 = 0 | t2, r2 = t2 - n2, s2 = 0, o2 = 0, i2 = 1; if (r2 > 5e-8) for (; o2 < 8 && Math.abs(s2 / i2 - r2) > 5e-8; ) o2++, i2 *= 10, s2 = Math.round(r2 * i2); return { ip: Math.trunc(e6), fp: s2, ipLength: Math.ceil(Math.log10(n2 + 1)), fpLength: o2 }; }, subtractRect: (e6, t2, n2 = false) => { if (!t2) return [e6]; if (!be(e6, t2)) return []; const r2 = []; let s2 = e6; const o2 = () => { t2.top > s2.top && t2.top < s2.bottom && (r2.push({ ...s2, bottom: t2.top }), s2 = { ...s2, top: t2.top }); }, i2 = () => { t2.bottom > s2.top && t2.bottom < s2.bottom && (r2.push({ ...s2, top: t2.bottom }), s2 = { ...s2, bottom: t2.bottom }); }, a2 = () => { t2.right > s2.left && t2.right < s2.right && (r2.push({ ...s2, left: t2.right }), s2 = { ...s2, right: t2.right }); }, l2 = () => { t2.left > s2.left && t2.left < s2.right && (r2.push({ ...s2, right: t2.left }), s2 = { ...s2, left: t2.left }); }; return n2 ? (l2(), a2(), o2(), i2()) : (o2(), i2(), a2(), l2()), r2; }, textToKey: (e6) => e6.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e6, t2) { let n2 = null; return (...r2) => { const s2 = Date.now(); (!n2 || s2 - n2 >= t2) && (n2 = s2, e6(...r2)); }; }, toSafeJSON: function e4(t2) { if (null === t2 || "object" != typeof t2) return t2; if ("function" == typeof t2.toJSON) return t2.toJSON(); if (Array.isArray(t2)) return t2.map((t3) => e4(t3)); if ("function" == typeof t2.toString && t2.toString !== Object.prototype.toString) return t2.toString(); const n2 = {}; for (const r2 in t2) t2.hasOwnProperty(r2) && (n2[r2] = e4(t2[r2])); return n2; }, transpose: (e6) => { if (!e6) return e6; const t2 = e6.length, n2 = e6[0].length, r2 = []; for (let e7 = 0; e7 < n2; e7++) r2[e7] = Array(t2); for (let s2 = 0; s2 < t2; s2++) for (let t3 = 0; t3 < n2; t3++) r2[t3][s2] = e6[s2][t3]; return r2; }, uuidV4: ge, validEnumValue: (e6, t2) => { if (!Object.values(e6).includes(t2)) throw new Error(`Invalid type: ${t2 ?? "null"}. Must be one of: ${Object.values(t2).join(", ")}.`); }, whenFocus: async (e6, t2 = false) => new Promise((n2) => { Ie(e6, t2) ? n2(true) : e6.addEventListener("focusin", () => { n2(true); }, { once: true }), e6.focus(); }) }, Symbol.toStringTag, { value: "Module" })), Re = Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e6) => `Invalid argument: '${e6}'.` }, Symbol.toStringTag, { value: "Module" })), ke = (e6) => { const t2 = new Uint8Array(e6), n2 = t2.byteLength; let r2 = ""; for (let e7 = 0; e7 < n2; e7++) r2 += String.fromCharCode(t2[e7]); if ("undefined" != typeof window && "function" == typeof globalThis.btoa) return globalThis.btoa(r2); if ("undefined" != typeof Buffer) return Buffer.from(r2, "binary").toString("base64"); throw new Error("Unsupported environment"); }, Te = (e6) => new Promise((t2, n2) => { if (e6) if ("undefined" != typeof FileReader) { const r2 = new FileReader(); r2.onload = () => { t2(r2.result); }, r2.onerror = () => { n2(r2.error); }, r2.readAsText(e6); } else if ("undefined" != typeof Buffer) { const r2 = (e7) => Buffer.from(e7).toString("utf-8"); e6.arrayBuffer().then((e7) => { t2(r2(e7)); }).catch((e7) => { n2(e7); }); } else n2(new Error("Unsupported environment")); else t2(""); }), Me = Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: ke, base64ToArrayBuffer: (e6) => { const t2 = "undefined" != typeof window && "function" == typeof globalThis.atob ? globalThis.atob(e6) : Buffer.from(e6, "base64").toString("binary"), n2 = t2.length, r2 = new Uint8Array(n2); for (let e7 = 0; e7 < n2; e7++) r2[e7] = t2.charCodeAt(e7); return r2.buffer; }, blobToString: Te }, Symbol.toStringTag, { value: "Module" })), Fe = "data:image/png;base64,", Ne = "Unable to resolve image.", Oe = (e6) => new Promise(async (t2, n2) => { let r2 = null; try { r2 = new Image(), r2.src = e6, r2.addEventListener("load", function() { t2({ width: r2.naturalWidth, height: r2.naturalHeight }); }, { once: true }), r2.addEventListener("error", function() { URL.revokeObjectURL(e6), n2("Invalid Image"); }, { once: true }), await r2.decode("sync"); } catch (e7) { r2?.src && URL.revokeObjectURL(r2.src); } r2 || n2(Ne); }), Le = "image/svg+xml", De = Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: Fe, getImageDataUrl: (e6, t2 = 1) => new Promise(async (n2, r2) => { let s2 = null; try { s2 = new Image(), s2.src = e6, s2.addEventListener("load", function() { try { const e7 = document.createElement("canvas"); e7.width = s2.naturalWidth, e7.height = s2.naturalHeight, e7.getContext("2d").drawImage(s2, 0, 0); const r3 = e7.toDataURL("image/png", t2); n2({ elemImg: s2, dataUrl: r3 }); } catch (t3) { URL.revokeObjectURL(e6), r2(t3); } }, { once: true }), s2.addEventListener("error", function() { URL.revokeObjectURL(e6), r2("Invalid Image"); }, { once: true }), await s2.decode("sync"); } catch (e7) { s2?.src && URL.revokeObjectURL(s2.src); } s2 || r2(Ne); }), loadImageDetails: async (e6, t2 = null) => { let n2 = null; const r2 = async () => { try { const r3 = t2 ?? "image/*", s3 = URL.createObjectURL(new Blob([e6], { type: r3 })), o2 = await Oe(s3); n2 = { mimeType: r3, naturalSize: o2, asUrl: s3 }; } catch (e7) { } }, s2 = async () => { try { const r3 = new TextDecoder().decode(e6), s3 = URL.createObjectURL(new Blob([r3], { type: Le })), o2 = await Oe(s3); n2 = { mimeType: t2 ?? Le, naturalSize: o2, asUrl: s3, asSVGText: r3 }; } catch (e7) { } }; if (t2 === Le ? await s2() : t2.startsWith("image/") ? await r2() : (await r2(), n2 || await s2()), !n2) throw new Error("Failed to load image"); return n2; } }, Symbol.toStringTag, { value: "Module" })); function Be(e6, t2) { t2 || (t2 = {}), "function" == typeof t2 && (t2 = { cmp: t2 }); let n2 = "boolean" == typeof t2.cycles && t2.cycles; const r2 = t2.cmp && /* @__PURE__ */ (function(e7) { return function(t3) { return function(n3, r3) { const s3 = { key: n3, value: t3[n3] }, o2 = { key: r3, value: t3[r3] }; return e7(s3, o2); }; }; })(t2.cmp); let s2 = []; return (function e7(t3) { if (t3 && t3.toJSON && "function" == typeof t3.toJSON && (t3 = t3.toJSON()), void 0 === t3) return; if ("number" == typeof t3) return isFinite(t3) ? "" + t3 : "null"; if ("object" != typeof t3) return JSON.stringify(t3); let o2; if (Array.isArray(t3)) { o2 = "["; for (let n3 = 0; n3 < t3.length; n3++) n3 && (o2 += ","), o2 += e7(t3[n3]) || "null"; return o2 + "]"; } if (null === t3) return "null"; if (-1 !== s2.indexOf(t3)) { if (n2) return JSON.stringify("__cycle__"); throw new TypeError("Converting circular structure to JSON"); } const i2 = s2.push(t3) - 1, a2 = Object.keys(t3).sort(r2 && r2(t3)); o2 = ""; for (let n3 = 0; n3 < a2.length; n3++) { const r3 = a2[n3], s3 = e7(t3[r3]); s3 && (o2 && (o2 += ","), o2 += JSON.stringify(r3) + ":" + s3); } return s2.splice(i2, 1), "{" + o2 + "}"; })(e6); } var Pe, ze; (ze = Pe || (Pe = {})).resolveTypedUpdates = (e6, t2, n2, r2) => { if (null === e6) return e6; if (void 0 === e6) return r2; let s2 = e6; if (t2?.shorthand) { const r3 = t2?.shorthand(e6, n2); void 0 !== r3 && (s2 = r3); } if (null !== s2 && t2?.getSubType) { const e7 = t2.getSubType(s2); e7 && (t2 = e7); } const o2 = t2?.properties, i2 = t2?.arrayType ?? false; let a2 = s2; if (t2 && t2.merge && a2 && r2) a2 = t2.merge(a2, r2, n2); else if (i2) ; else if (o2) { const e7 = Object.keys({ ...s2, ...r2 }); a2 = null; const t3 = e7.length; for (let i3 = 0; i3 < t3; i3++) { const t4 = e7[i3]; let l2, c2 = s2[t4]; if (void 0 !== c2) { const e8 = o2[t4]; l2 = e8 ? (0, ze.resolveTypedUpdates)(c2, e8, n2, r2?.[t4]) : c2; } else l2 = r2?.[t4]; null != l2 && (a2 = a2 ?? {}, a2[t4] = l2); } } return a2; }; let je = class extends Error { constructor(e6, t2 = null) { super(e6, t2), this.name = "ChainedError", this._cause = t2; } get cause() { return this._cause; } }, Ve = class extends Error { constructor(e6, t2) { super(e6, t2); } }, We = class extends Ve { constructor(e6 = "Out of bounds", t2 = null) { super(e6, t2), this.name = "OutOfBoundsError"; } }, Ge = class extends je { constructor(e6 = "Partial Error", t2 = null) { super(e6, t2); } }, Ue = class extends je { constructor(e6 = "Null not supported", t2 = null) { super(e6, t2); } }, He = class extends Error { constructor(e6 = "Null not supported", t2) { super(e6), this._type = t2; } get type() { return this._type; } }, qe = class extends je { constructor(e6 = "Not implemented", t2 = null) { super(e6, t2); } }; const $e = { collectErrorChain: (e6, t2 = false) => { const n2 = [], r2 = (e7, s2 = 0) => { if (!e7) return; if (n2.push({ error: e7, depth: s2 }), t2 && e7 instanceof Ve) return; const o2 = e7.cause; o2 && o2 instanceof Error && r2(o2, s2 + 1); }; return r2(e6), n2.reverse(); } }, Xe = "The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.", Je = "You do not have permissions to access the clipboard.\nAll copy and paste operations will be limited to the browser tab.", Ke = { Safari: "The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.", Perms: Je, PermsWrite: xe() === Ce.Safari ? Xe : Je, PermsRead: xe() === Ce.Safari ? Xe : Je }, Ye = async () => new Promise((e6) => { document.hasFocus() ? e6() : globalThis.addEventListener?.("focus", () => { e6(); }, { once: true }), document.activeElement.focus?.(); }), Ze = async (e6, t2, n2) => { if (xe() === Ce.Safari) return await n2(new Error(Ke.Safari)); try { const r2 = async (e7) => { try { return await e7(); } catch (e8) { if (e8.message?.includes("Document is not focused")) return false; throw e8; } }, s2 = await globalThis?.navigator?.permissions?.query({ name: e6, allowWithoutGesture: true, allowWithoutSanitization: true }); let o2 = false; if ("prompt" === s2.state && (o2 = await r2(t2)), o2 || "granted" !== s2.state || (o2 = await t2()), !o2) return await n2(new Error(s2.state)); } catch (e7) { if ("No valid data on clipboard" === e7.message || "DataError" === e7.name) return; return await n2(e7); } }, Qe = async (e6) => { try { return await e6.read({ unsanitized: [Z.html] }); } catch (e7) { } return await e6.read(); }, et = async (e6, t2) => { if (!e6) return null; const n2 = await Qe(e6); let r2 = false; for (let e7 = 0; !r2 && n2 && e7 < n2.length; e7++) if (r2 = n2[e7].types.includes(t2), r2) return await n2[e7].getType(t2); return r2 ? void 0 : null; }; if (!globalThis.ClipboardItem) { const e6 = (e7, t3) => new Blob([t3], { type: e7 }); class t2 { constructor(t3, n2) { this._items = {}, this._types = Object.keys(t3); const r2 = {}, s2 = Object.keys(t3); for (let n3 = 0; n3 < s2.length; n3++) { const o2 = s2[n3]; let i2 = t3[o2]; r2[o2] = "string" == typeof i2 ? e6(o2, i2) : i2; } this._items = r2, this._presentationStyle = n2?.presentationStyle ?? "unspecified"; } get types() { return this._types; } getType(e7) { return Promise.resolve(this._items[e7]); } supports(e7) { return true; } } globalThis.ClipboardItem = t2; } const tt = async (e6, t2 = Z.html) => new Promise(async (n2, r2) => { try { const r3 = await et(e6, t2); if (r3) { const e7 = new FileReader(); e7.onload = () => { n2(e7.result); }, e7.onerror = () => { n2(""); }, e7.readAsText(r3); } else n2(""); } catch (e7) { r2(e7); } }), nt = async (e6, t2 = Z.html) => { const n2 = await tt(e6, t2); if (!n2) return null; let r2 = null; try { r2 = new DOMParser().parseFromString(n2, Z.html); } catch (e7) { console.warn("Can't parse html from clipboard."); } return r2; }, rt = async (e6) => { e6 && await e6.writeText(""); }, st = { readBlobFromClipboard: et, readStringFromClipboard: tt, readHTMLFromClipboard: nt, clearClipboard: rt }, ot = "clipboard-uuid", it = "web text/uuid", at = (e6) => `<div style="display:none" ${ot}="${e6}"/>`, lt = (e6, t2) => { let n2 = null; try { const r2 = new DOMParser().parseFromString(t2, Z.html); r2.body.firstElementChild.setAttribute(ot, e6), n2 = r2.getElementsByTagName("body")[0].innerHTML; } catch (e7) { console.warn("Can't embed uuid.", e7); } return n2; }, ct = (e6, t2) => { if (!t2 || !e6) return false; try { const n2 = t2.querySelectorAll(`[${ot}="${e6}"]`); if (n2 && 1 === n2.length) return true; if (t2.querySelector("parsererror")) throw new Error("We are unable to parse node"); return false; } catch (e7) { return false; } }; let ht = class { constructor(e6) { if (void 0 === e6?.nativeClipboard || true === e6?.nativeClipboard) try { this._nativeClipboard = globalThis?.navigator.clipboard; } catch (t2) { true === e6?.nativeClipboard && console.warn("NativeClipboard option set to true but no native clipboard available."); } else this._nativeClipboard = false === e6?.nativeClipboard ? null : e6?.nativeClipboard; this._disableCheckOnFocus = e6?.disableCheckOnFocus ?? false, this._init(); } async _checkForChanges() { this._nativeClipboard && this._state && !this._disableCheckOnFocus && await Ze("clipboard-read", async () => { await Ye(); const e6 = await tt(this._nativeClipboard, it); if (!this._state) return true; if (e6 && e6 === this._state.uuid) return true; const t2 = await nt(this._nativeClipboard, Z.html); return !this._state || (ct(this._state.uuid, t2) || this.clear(), true); }, async (e6) => { "denied" === e6?.message || e6.message?.includes("Document is not focused") || xe() === Ce.Safari || console.warn("Unable to detect clipboard changes: ", e6); }); } _init() { const e6 = this; this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => { e6._checkForChanges(); }, this._onBlur = () => { globalThis.addEventListener?.("focus", e6._onFocus, { once: true }); }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (t2) => { e6._checkForChanges(); })); } async read() { if (!this._nativeClipboard) return this._state?.items ?? null; const e6 = this; return await Ze("clipboard-read", async () => { if (await Ye(), this._state?.uuid) { const t2 = await tt(this._nativeClipboard, it); if (t2 && t2 === e6._state.uuid) return true; const n2 = await nt(this._nativeClipboard, Z.html); if (ct(e6._state?.uuid, n2)) return true; } return e6._state = { items: await Qe(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), true; }, async (e7) => { this.dispatchEvent(new Event("clipboarderrorread")); }), this._state?.items ?? []; } async write(e6) { return this._write({ uuid: ge(), items: e6, ref: null }); } async _write(e6) { if (!this._nativeClipboard) return this._state = e6, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null; const t2 = this, n2 = [], r2 = e6.uuid; let s2 = e6.items ?? []; const o2 = () => { t2._state = { uuid: r2, ref: e6.ref, items: n2 }, t2.dispatchEvent(new Event("clipboardwrite")), t2.dispatchEvent(new Event("clipboardchange")); }; await Ze("clipboard-write", async () => { await Ye(), r2 && 0 === s2.length && (s2.push(new ClipboardItem({ [it]: new Blob([r2], { type: it }) })), s2.push(new ClipboardItem({ [Z.html]: new Blob([at(r2)], { type: Z.html }) }))); for (let e7 = 0; e7 < Math.min(1, s2.length); e7++) { const t3 = s2[e7]; let o3 = t3.types.indexOf(Z.html), i2 = null; if (-1 !== o3) { const e8 = await t3.getType(Z.html); i2 = await Te(e8), i2 && (i2 = lt(r2, i2)); } if (!i2 && t3.types.includes(Z.plain)) { const e8 = await t3.getType(Z.plain); if (e8) { let t4 = null; "string" == typeof e8 ? (console.warn("text as string", e8), t4 = e8) : t4 = await Te(e8), t4 && (i2 = `<div ${ot}="${r2}">${t4}</div>`); } } if (!i2 && t3.types.includes(Z.png)) { const e8 = await t3.getType(Z.png), n3 = ke(await e8.arrayBuffer()); i2 = `<div ${ot}="${r2}"><img src="${Fe + n3}"/></div>`; } !i2 && r2 && (i2 = at(r2)); const a2 = new Blob([i2 ?? ""], { type: Z.html }), l2 = {}; for (let e8 = 0; e8 < t3.types.length; e8++) { const n3 = t3.types[e8]; l2[n3] = e8 === o3 ? a2 : t3.getType(n3); } i2 && -1 === o3 && (l2[Z.html] = a2), r2 && (l2[it] = new Blob([r2], { type: it })), n2.push(new ClipboardItem(l2)); } try { n2 && 0 !== n2.length ? await this._nativeClipboard.write(n2) : await rt(this._nativeClipboard); } catch (e7) { e7.message?.includes("Document is not focused"