@sheetxl/sdk 0.7.28-beta.2 → 0.7.28-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/browser/cjs/{BREMLtxkQhtNSVra.cjs → BF14ZEAnaqxXroSj.cjs} +1 -1
  2. package/browser/cjs/{BG7YDVxiC4ErxvF1.cjs → BXtvdT1Z-MsB_o5F.cjs} +1 -1
  3. package/browser/cjs/Bc4JjVVZfFo3R4He.cjs +33 -0
  4. package/browser/cjs/{CQf4zxkBmheTVbjX.cjs → CD2RXdnfqSYNc6gX.cjs} +2 -2
  5. package/browser/cjs/DcLpXGexEtOxi-dD.cjs +1 -0
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{DN4d5bDBkti28wuc.mjs → 0Mj5WKM362q6CECb.mjs} +213 -207
  8. package/browser/esm/{BxIOX1TojvA-1ZZP.mjs → CHSahmMFYNB0Ajkf.mjs} +2 -2
  9. package/browser/esm/{CZO1RubmqnJV96rq.mjs → CKk58ZLcrllMzfou.mjs} +2 -2
  10. package/browser/esm/{DRWu3TmcE9JFf78V.mjs → CPTtL2f6_4iblmFM.mjs} +2 -2
  11. package/browser/esm/{DPOelA1J3WHbMXyh.mjs → CoA-sUxjiIUIpTUF.mjs} +2 -2
  12. package/browser/esm/{vHWuKF-ftK7LM1uw.mjs → DBIu6NUHIcxOOBQp.mjs} +1 -1
  13. package/browser/esm/{CB_4gdPPPruwremH.mjs → Dy4Sdpju1T2icURu.mjs} +4748 -3883
  14. package/browser/esm/index.mjs +419 -411
  15. package/node/esm/{XQhP3dYwF_tEuswB.mjs → BtGxbEbBm79YvF_k.mjs} +303 -297
  16. package/node/esm/{B-tgcZihStNV9CbZ.mjs → DUYP6faJJHCaW1Xf.mjs} +1 -1
  17. package/node/esm/{C8tfYGL3wHy9IDDc.mjs → DqgWsVXROpSgKq6c.mjs} +2 -2
  18. package/node/esm/index.mjs +8686 -7802
  19. package/package.json +6 -6
  20. package/resources/locales/de/model.msg.json +12 -0
  21. package/resources/locales/en/model.msg.json +12 -0
  22. package/types/scripting-enums.json +2 -0
  23. package/types/scripting.d.ts +341 -15
  24. package/types/src/anchored/IAnchored.d.ts +27 -0
  25. package/types/src/calculation/Calculation.d.ts +21 -12
  26. package/types/src/calculation/ICalculation.d.ts +183 -0
  27. package/types/src/calculation/compiler/CompilerUtils.d.ts +20 -0
  28. package/types/src/calculation/compiler/FormulaParser.d.ts +32 -6
  29. package/types/src/calculation/executor/CalcExecutor.d.ts +204 -13
  30. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
  31. package/types/src/calculation/executor/CircularReference.d.ts +81 -0
  32. package/types/src/calculation/functions/Operators.d.ts +1 -1
  33. package/types/src/calculation/grid/CalcGrid.d.ts +5 -1
  34. package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
  35. package/types/src/calculation/grid/ICalcGrid.d.ts +23 -1
  36. package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
  37. package/types/src/calculation/spatial/index.d.ts +1 -0
  38. package/types/src/calculation/state/CalcNode.d.ts +24 -17
  39. package/types/src/calculation/state/CalcState.d.ts +78 -15
  40. package/types/src/calculation/state/CalculationContext.d.ts +39 -0
  41. package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
  42. package/types/src/cell/ICell.d.ts +16 -0
  43. package/types/src/cellRange/ICellRange.d.ts +72 -6
  44. package/types/src/condition/AnchoredConditional.d.ts +26 -6
  45. package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
  46. package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
  47. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
  48. package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
  49. package/types/src/hyperlink/IHyperlink.d.ts +3 -1
  50. package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
  51. package/types/src/lib/utils/utils.browser.d.ts +5 -0
  52. package/types/src/license/LicenseDetails.d.ts +5 -0
  53. package/types/src/primitives/CalcSignal.d.ts +20 -0
  54. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
  55. package/types/src/scripting/_ScriptUtils.d.ts +13 -0
  56. package/types/src/sheet/Sheet.d.ts +33 -2
  57. package/types/src/sheet/SheetCell.d.ts +2 -0
  58. package/types/src/sheet/SheetRange.d.ts +12 -1
  59. package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
  60. package/types/src/style/IStyle.d.ts +5 -0
  61. package/types/src/table/AnchoredTable.d.ts +17 -1
  62. package/types/src/text/TextUtils.d.ts +18 -0
  63. package/browser/cjs/DoemwsUQoGCk0vBK.cjs +0 -33
  64. package/browser/cjs/_c2uwwpr03Y7lzIj.cjs +0 -1
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.2
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.4
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
6
  */
7
- import { n as e } from "./vHWuKF-ftK7LM1uw.mjs";
8
- import { $t as t, At as n, Bt as r, Cn as i, Ct as a, Dn as o, Dt as s, En as c, Et as l, Ft as u, H as d, Ht as f, It as p, J as m, Jt as h, Kt as g, Lt as _, Mt as v, Nt as y, Ot as ee, Pt as b, Qt as te, Rt as ne, Sn as x, St as re, Tn as ie, Tt as ae, Ut as S, Vt as oe, Wt as se, Xt as ce, Yt as C, Zt as le, _n as ue, _t as de, a as w, an as fe, at as pe, bn as T, bt as me, c as he, cn as ge, ct as _e, d as ve, dn as ye, dt as be, en as E, f as xe, fn as Se, ft as Ce, gn as we, gt as Te, h as Ee, hn as De, ht as Oe, i as ke, in as Ae, it as je, j as Me, jt as D, kt as Ne, l as O, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, nt as Ve, o as k, on as He, ot as Ue, p as We, pn as Ge, pt as Ke, qt as qe, r as Je, rn as A, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as et, u as tt, un as nt, ut as rt, vn as it, vt as at, wn as j, wt as ot, xn as M, xt as st, yn as ct, yt as lt, z as ut, zt as N } from "./CB_4gdPPPruwremH.mjs";
9
- import { t as dt } from "./DRWu3TmcE9JFf78V.mjs";
7
+ import { n as e } from "./DBIu6NUHIcxOOBQp.mjs";
8
+ import { $t as t, At as n, B as r, Bt as i, Cn as a, Ct as o, Dn as s, Dt as c, En as l, Et as u, Ft as d, Gt as f, Ht as p, It as m, Jt as h, Lt as g, M as _, Mt as v, Nt as y, On as ee, Ot as b, Pt as te, Qt as ne, Rt as re, Sn as x, St as ie, Tn as S, Tt as ae, U as oe, Ut as C, Vt as w, Wt as T, Xt as E, Y as se, Yt as ce, Zt as le, _n as ue, _t as de, a as D, an as fe, at as pe, bn as me, bt as he, c as ge, cn as _e, ct as ve, d as ye, dn as be, dt as xe, en as O, f as Se, fn as Ce, ft as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as ke, i as Ae, in as k, it as je, jt as Me, kt as Ne, l as A, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, o as j, on as Ve, ot as He, p as Ue, pn as We, pt as Ge, qt as Ke, r as qe, rn as Je, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as M, u as et, un as tt, ut as nt, vn as rt, vt as it, wn as at, wt as ot, xn as N, xt as st, yn as ct, yt as lt, zt as ut } from "./Dy4Sdpju1T2icURu.mjs";
9
+ import { t as dt } from "./CPTtL2f6_4iblmFM.mjs";
10
10
  import { FormulaError as P, ScalarType as F } from "@sheetxl/primitives";
11
11
  import { BufferUtils as ft, CommonUtils as I, CoordUtils as L, DOMUtils as pt, DefaultLanguagePackService as mt, ExpectedError as R, InvalidPasswordError as ht, MimeType as gt, Notifier as z, NullNotAllowedError as _t, OutOfBoundsError as B, PasswordRequiredError as vt, UndoManager as yt, messageKey as V, t as H } from "@sheetxl/utils";
12
12
  export * from "@sheetxl/primitives";
@@ -108,7 +108,7 @@ var xt = class extends yt {
108
108
  }
109
109
  }, St = class {
110
110
  constructor(e, t) {
111
- this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new j(this);
111
+ this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new S(this);
112
112
  let n = this;
113
113
  this._removeStoreListener = e.addListener({
114
114
  onCommitEnd() {
@@ -145,7 +145,7 @@ var xt = class extends yt {
145
145
  }
146
146
  }, U = class e {
147
147
  constructor(t, n = {}) {
148
- this._password = null, this._emitter = new j(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
148
+ this._password = null, this._emitter = new S(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
149
149
  }
150
150
  static _defaultCanWrite(e) {
151
151
  return !!e && !/^(https?:|data:|blob:)/i.test(e);
@@ -156,7 +156,7 @@ var xt = class extends yt {
156
156
  getName() {
157
157
  if (this._name !== null && this._name !== void 0) return this._name;
158
158
  let e = this._cleanPath();
159
- return e && T(e) || null;
159
+ return e && N(e) || null;
160
160
  }
161
161
  getPath() {
162
162
  return this._path;
@@ -167,7 +167,7 @@ var xt = class extends yt {
167
167
  getExtension() {
168
168
  let e = this._cleanPath();
169
169
  if (!e) return null;
170
- let t = M(e);
170
+ let t = x(e);
171
171
  return t ? t.toLowerCase() : null;
172
172
  }
173
173
  getEncryption() {
@@ -230,10 +230,10 @@ var xt = class extends yt {
230
230
  }
231
231
  switch (i) {
232
232
  case "file": {
233
- let e = n, t = e?.name, i = t ? `${T(t)}` : "";
233
+ let e = n, t = e?.name, i = t ? `${N(t)}` : "";
234
234
  a = await e.arrayBuffer(), o = {
235
235
  format: r,
236
- ext: M(t),
236
+ ext: x(t),
237
237
  name: i,
238
238
  absolutePath: t,
239
239
  size: e.size,
@@ -272,7 +272,7 @@ var xt = class extends yt {
272
272
  e = r.input, t = r.init, i = r.timeout;
273
273
  }
274
274
  }
275
- let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = M(u);
275
+ let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = x(u);
276
276
  try {
277
277
  let n = await fetch(e, {
278
278
  ...t,
@@ -284,7 +284,7 @@ var xt = class extends yt {
284
284
  a = i, o = {
285
285
  format: r,
286
286
  ext: d,
287
- name: T(u, !0),
287
+ name: N(u, !0),
288
288
  absolutePath: u
289
289
  };
290
290
  } catch (e) {
@@ -498,7 +498,7 @@ var Ot = class {
498
498
  "Trebuchet MS",
499
499
  "Verdana"
500
500
  ], W = /* @__PURE__ */ new Map();
501
- W.set(A.GenericName.Serif, ["Tahoma"]), W.set(A.GenericName.SanSerif, ["Calibri"]), W.set(A.GenericName.MonoSpace, ["Courier New"]), W.set(A.GenericName.Cursive, ["Comic Sans MS"]), W.set(A.GenericName.Fantasy, ["Luminari"]), W.set(A.GenericName.UISystem, ["Arial"]), W.set(A.GenericName.UISerif, ["Tahoma"]), W.set(A.GenericName.UISanSerif, ["Arial"]), W.set(A.GenericName.UIMonoSpace, ["Courier New"]), W.set(A.GenericName.UIRounded, ["Arial"]), W.set(A.GenericName.Math, []), W.set(A.GenericName.Emoji, []), W.set(A.GenericName.Fangsong, []);
501
+ W.set(k.GenericName.Serif, ["Tahoma"]), W.set(k.GenericName.SanSerif, ["Calibri"]), W.set(k.GenericName.MonoSpace, ["Courier New"]), W.set(k.GenericName.Cursive, ["Comic Sans MS"]), W.set(k.GenericName.Fantasy, ["Luminari"]), W.set(k.GenericName.UISystem, ["Arial"]), W.set(k.GenericName.UISerif, ["Tahoma"]), W.set(k.GenericName.UISanSerif, ["Arial"]), W.set(k.GenericName.UIMonoSpace, ["Courier New"]), W.set(k.GenericName.UIRounded, ["Arial"]), W.set(k.GenericName.Math, []), W.set(k.GenericName.Emoji, []), W.set(k.GenericName.Fangsong, []);
502
502
  var G = /* @__PURE__ */ new Map(), jt = [];
503
503
  K(At);
504
504
  var Mt = eval;
@@ -619,7 +619,7 @@ function Bt(e, t = !0, n = zt) {
619
619
  SoftEdge: "softEdge",
620
620
  Reflection: "reflection"
621
621
  };
622
- var Y = ne.BuiltInName, Vt = {
622
+ var Y = ut.BuiltInName, Vt = {
623
623
  [Y.Normal]: V("style.builtin.normal"),
624
624
  [Y.Comma]: V("style.builtin.comma"),
625
625
  [Y.Currency]: V("style.builtin.currency"),
@@ -660,52 +660,52 @@ function Jt(e) {
660
660
  }
661
661
  } : null));
662
662
  }
663
- var Yt, Xt, Zt, Qt, $t = (e, t, n, i, a) => {
664
- let o = JSON.parse(JSON.stringify(e.definition));
665
- o.adjs ||= [];
666
- let s = "", c = 0, l = 0;
667
- t > 0 ? (l = t, c = 100 - t, s = H("op.lighterPercent", { percent: t })) : t < 0 && (c = 100 + t, s = H("op.darkerPercent", { percent: -t })), c && o.adjs.push({ [f.AdjustmentType.LumMod]: c }), l && o.adjs.push({ [f.AdjustmentType.LumOff]: l });
668
- let u = new r({
669
- val: o.val,
670
- adjs: o.adjs
671
- }, n), d = u.toString();
672
- i?.set(d, u);
673
- let p = u.toRGBA().toString();
674
- return a?.set(p, u), {
675
- description: e.description + ", " + s,
676
- definition: o
663
+ var Yt, Xt, Zt, Qt, $t = (e, t, n, r, i) => {
664
+ let a = JSON.parse(JSON.stringify(e.definition));
665
+ a.adjs ||= [];
666
+ let o = "", s = 0, c = 0;
667
+ t > 0 ? (c = t, s = 100 - t, o = H("op.lighterPercent", { percent: t })) : t < 0 && (s = 100 + t, o = H("op.darkerPercent", { percent: -t })), s && a.adjs.push({ [C.AdjustmentType.LumMod]: s }), c && a.adjs.push({ [C.AdjustmentType.LumOff]: c });
668
+ let l = new w({
669
+ val: a.val,
670
+ adjs: a.adjs
671
+ }, n), u = l.toString();
672
+ r?.set(u, l);
673
+ let d = l.toRGBA().toString();
674
+ return i?.set(d, l), {
675
+ description: e.description + ", " + o,
676
+ definition: a
677
677
  };
678
678
  };
679
- function en(e, t, n, i) {
680
- let a = [];
681
- for (let o = 0; o < e.length; o++) {
682
- let s = [];
683
- a.push(s);
684
- let c = (r) => {
685
- for (let a = 0; a < r.length; a++) s.push($t(e[o], r[a], t, n, i));
686
- }, l = new r({
687
- val: e[o].definition.val,
688
- adjs: e[o].definition.adjs
679
+ function en(e, t, n, r) {
680
+ let i = [];
681
+ for (let a = 0; a < e.length; a++) {
682
+ let o = [];
683
+ i.push(o);
684
+ let s = (i) => {
685
+ for (let s = 0; s < i.length; s++) o.push($t(e[a], i[s], t, n, r));
686
+ }, c = new w({
687
+ val: e[a].definition.val,
688
+ adjs: e[a].definition.adjs
689
689
  }, t).toHSLA().lum;
690
- c(l === 0 ? [
690
+ s(c === 0 ? [
691
691
  50,
692
692
  35,
693
693
  25,
694
694
  15,
695
695
  5
696
- ] : l === 100 ? [
696
+ ] : c === 100 ? [
697
697
  -5,
698
698
  -15,
699
699
  -25,
700
700
  -35,
701
701
  -50
702
- ] : l <= 20 ? [
702
+ ] : c <= 20 ? [
703
703
  90,
704
704
  75,
705
705
  50,
706
706
  25,
707
707
  10
708
- ] : l >= 80 ? [
708
+ ] : c >= 80 ? [
709
709
  -10,
710
710
  -25,
711
711
  -50,
@@ -719,13 +719,13 @@ function en(e, t, n, i) {
719
719
  -50
720
720
  ]);
721
721
  }
722
- return a;
722
+ return i;
723
723
  }
724
724
  (Yt ||= {}).buildPalette = en, Xt ||= {}, Zt ||= {}, Qt ||= {};
725
725
  var X = null;
726
726
  function tn() {
727
727
  if (!X) {
728
- let e = import("./DPOelA1J3WHbMXyh.mjs").then(({ initializeFunctions: e }) => {
728
+ let e = import("./CoA-sUxjiIUIpTUF.mjs").then(({ initializeFunctions: e }) => {
729
729
  let t = e(() => null);
730
730
  return Object.freeze(Array.from(t.keys()));
731
731
  });
@@ -746,25 +746,25 @@ function nn(e) {
746
746
  } catch {
747
747
  return;
748
748
  }
749
- let r = 0, i = 0;
749
+ let i = 0, a = 0;
750
750
  if (n.length === 2) {
751
751
  let e = n[0].tokenType?.name;
752
- e === "MinOp" ? (r = -1, i = 1) : e === "PlusOp" && (r = 1, i = 1);
752
+ e === "MinOp" ? (i = -1, a = 1) : e === "PlusOp" && (i = 1, a = 1);
753
753
  }
754
- if (n.length - i !== 1) return;
755
- let a = n[i], o = a.image;
754
+ if (n.length - a !== 1) return;
755
+ let o = n[a], s = o.image;
756
756
  try {
757
- switch (a.tokenType?.name) {
757
+ switch (o.tokenType?.name) {
758
758
  case "NumberToken":
759
759
  case "ScientificDigit":
760
760
  case "DigitToken": {
761
- let e = d(o).value;
762
- return r === 0 ? e : r * e;
761
+ let e = oe(s).value;
762
+ return i === 0 ? e : i * e;
763
763
  }
764
- case "StringToken": return r === 0 ? m(o).value : void 0;
765
- case "BooleanToken": return r === 0 ? Me(o).value : void 0;
764
+ case "StringToken": return i === 0 ? se(s).value : void 0;
765
+ case "BooleanToken": return i === 0 ? _(s).value : void 0;
766
766
  case "LiteralError":
767
- case "RefError": return r === 0 ? ut(o).value : void 0;
767
+ case "RefError": return i === 0 ? r(s).value : void 0;
768
768
  default: return;
769
769
  }
770
770
  } catch {
@@ -836,7 +836,7 @@ var on = class {
836
836
  return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
837
837
  }
838
838
  _mergeFrequencies(e) {
839
- let t = e?.keyFn ?? Oe, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
839
+ let t = e?.keyFn ?? Ee, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
840
840
  for (let l = 0; l < a; l++) {
841
841
  let a = i[l].getFrequencies(e);
842
842
  o += a.getVisitedCount(), s += a.getTotalCount(), c ||= a.isTruncated();
@@ -849,7 +849,7 @@ var on = class {
849
849
  }) : c = !0, d = u.next();
850
850
  }
851
851
  }
852
- return Re.fromGroups(r, t, e, rn, o, s, c);
852
+ return ke.fromGroups(r, t, e, rn, o, s, c);
853
853
  }
854
854
  getTypedCounts(e) {
855
855
  let t = this._typedCounts;
@@ -899,7 +899,7 @@ var on = class {
899
899
  let a = n.numericalCount;
900
900
  a <= 0 || (r.numericalCount += a, r.sum += n.sum, r.sumSq += n.varP * a + n.sum * n.sum / a, (r.min === void 0 || n.min < r.min) && (r.min = n.min), (r.max === void 0 || n.max > r.max) && (r.max = n.max));
901
901
  }
902
- return Je(r);
902
+ return qe(r);
903
903
  }
904
904
  }, sn = Object.freeze([]);
905
905
  function cn(e, t) {
@@ -956,9 +956,9 @@ var ln = class {
956
956
  constructor(e) {
957
957
  this._closed = !1, this._options = { ...e };
958
958
  let t = this;
959
- this._transactions = this._options.transactions ?? new c({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
959
+ this._transactions = this._options.transactions ?? new s({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
960
960
  t._emitter.notify("onCollectionChange");
961
- } }), this._emitter = new j(this, this._transactions), this._initState(e?.initial);
961
+ } }), this._emitter = new S(this, this._transactions), this._initState(e?.initial);
962
962
  }
963
963
  add(e, t, n) {
964
964
  let r = this;
@@ -1075,7 +1075,7 @@ var ln = class {
1075
1075
  return `Script has ${i} compile error${i === 1 ? "" : "s"}:\n${r.join("\n")}`;
1076
1076
  }, pn = class {
1077
1077
  constructor(e) {
1078
- this._options = e, this._emitter = new j(this), this._initState();
1078
+ this._options = e, this._emitter = new S(this), this._initState();
1079
1079
  }
1080
1080
  _initState() {}
1081
1081
  getModules() {
@@ -1097,13 +1097,13 @@ var ln = class {
1097
1097
  builtInNames: this._builtInNames(),
1098
1098
  ...e
1099
1099
  });
1100
- return t.module ? await S("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1100
+ return t.module ? await T("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1101
1101
  }
1102
1102
  addModule(e, t, n) {
1103
1103
  this._modules.add(e, t, n);
1104
1104
  }
1105
1105
  async addModuleFromJSON(e, t, n) {
1106
- let r = await S(e, t);
1106
+ let r = await T(e, t);
1107
1107
  return this.addModule(e, r, n), r;
1108
1108
  }
1109
1109
  executeMacro(e, t, n) {
@@ -1119,7 +1119,7 @@ var ln = class {
1119
1119
  }
1120
1120
  async run(e, t) {
1121
1121
  try {
1122
- let n = typeof e == "string" ? await this.createModule({ source: e }) : await S("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1122
+ let n = typeof e == "string" ? await this.createModule({ source: e }) : await T("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1123
1123
  return await this._runModule(n, r, t);
1124
1124
  } catch (e) {
1125
1125
  return {
@@ -1189,7 +1189,7 @@ var ln = class {
1189
1189
  }
1190
1190
  if (!i || i.length === 0) return I.EmptyArray;
1191
1191
  let o = e?.text ? e.text.trim().toUpperCase() : null;
1192
- return o && t.length > 1 && se(i, o), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1192
+ return o && t.length > 1 && f(i, o), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1193
1193
  }
1194
1194
  async getFunctionCategories(e) {
1195
1195
  await this._emitter.notify("onBeforeSearch", { async: !0 });
@@ -1232,7 +1232,7 @@ var ln = class {
1232
1232
  for (let r = 0; r < e.length; r++) {
1233
1233
  let i = e[r], a = t[i];
1234
1234
  try {
1235
- n[i] = await S(i, a);
1235
+ n[i] = await T(i, a);
1236
1236
  } catch (e) {
1237
1237
  z.error(`Could not load script '${i}'; it will be unavailable.`, e);
1238
1238
  }
@@ -1276,7 +1276,7 @@ var ln = class {
1276
1276
  }
1277
1277
  }, mn = class {
1278
1278
  constructor(e, t, n, r) {
1279
- this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new O({
1279
+ this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new A({
1280
1280
  runtime: e,
1281
1281
  styles: this._styles,
1282
1282
  container: {
@@ -1288,36 +1288,36 @@ var ln = class {
1288
1288
  applyCSSStyle(e, t) {
1289
1289
  let r = !1;
1290
1290
  e.style || (e.style = {}, r = !0);
1291
- let i = e.style, a = { ...t };
1291
+ let o = e.style, s = { ...t };
1292
1292
  if (t.msoIgnore) {
1293
- let e = t.msoIgnore.split(","), n = Object.keys(a);
1293
+ let e = t.msoIgnore.split(","), n = Object.keys(s);
1294
1294
  for (let t = 0; t < n.length; t++) {
1295
1295
  let r = n[t];
1296
- e.includes(r) && delete a[r];
1296
+ e.includes(r) && delete s[r];
1297
1297
  }
1298
1298
  }
1299
- let o = n(a.fontFamily);
1300
- i.font = {}, o && (i.font.family = o.family, i.font.fallbacks = o.fallbacks, i.font.size = o.size), i.font.size = a.fontSize, i.font.weight = a.fontWeight, i.font.style = a.fontStyle, i.font.color = a.color;
1301
- let c = s(a.textDecoration);
1302
- i.font.underline = c.underline, i.font.strike = c.strike, a.textUnderlineStyle && (i.font.underline = ee(a.textUnderlineStyle)), i.alignment = {}, a?.textAlign && (i.alignment.horizontal = l(a.textAlign)), a?.textAlign && !i.alignment.horizontal && a?.textAlign !== "general" && (a.textAlign === "center-across" ? i.alignment.horizontal = x.HorizontalAlignment.CenterContinuous : a.textAlign === "fill" ? i.alignment.horizontal = x.HorizontalAlignment.Fill : a.textAlign === "121" || a.textAlign === "010" ? (i.alignment.horizontal = x.HorizontalAlignment.Distributed, i.alignment.justifyLastLine = a.textAlign === "121") : console.warn("unknown text-align", a.textAlign)), a.verticalAlign && (a.verticalAlign.toLowerCase() === "super" ? i.font.verticalAlign = A.VerticalAlignment.Super : a.verticalAlign.toLowerCase() === "sup" ? i.font.verticalAlign = A.VerticalAlignment.Sub : i.alignment.vertical = Ne(a.verticalAlign), i.alignment.vertical || (a.verticalAlign === "121" ? i.alignment.vertical = x.VerticalAlignment.Distributed : console.warn("unknown vertical-align", a.verticalAlign))), a.msoCharIndentCount && (i.alignment.indent = a.msoCharIndentCount), a.whiteSpace && (i.alignment.overflow = a.whiteSpace === "no-wrap" || a.whiteSpace === "nowrap" ? x.Overflow.Visible : x.Overflow.Wrap), a.msoTextControl === "shrinktofit" && (i.alignment.overflow = x.Overflow.Shrink);
1303
- let u = null;
1304
- if (a.background ? u = a.background : a.backgroundColor && (u = a.backgroundColor), u && (i.fill = { color: u }), a.msoPattern) {
1305
- let e = v(a.msoPattern);
1306
- e && (e.patternType === N.BuiltInSheetPattern.Solid ? i.fill = { color: e.foreground } : e.patternType !== N.BuiltInSheetPattern.None && (u && (e.background = u), i.fill = e));
1307
- }
1308
- a.msoRotate !== void 0 && (i.alignment.rotation = ae(a.msoRotate));
1309
- let d = (e, t) => {
1310
- e && (i.border ||= {}, i.border[e] = t);
1299
+ let l = Me(s.fontFamily);
1300
+ o.font = {}, l && (o.font.family = l.family, o.font.fallbacks = l.fallbacks, o.font.size = l.size), o.font.size = s.fontSize, o.font.weight = s.fontWeight, o.font.style = s.fontStyle, o.font.color = s.color;
1301
+ let d = b(s.textDecoration);
1302
+ o.font.underline = d.underline, o.font.strike = d.strike, s.textUnderlineStyle && (o.font.underline = Ne(s.textUnderlineStyle)), o.alignment = {}, s?.textAlign && (o.alignment.horizontal = c(s.textAlign)), s?.textAlign && !o.alignment.horizontal && s?.textAlign !== "general" && (s.textAlign === "center-across" ? o.alignment.horizontal = a.HorizontalAlignment.CenterContinuous : s.textAlign === "fill" ? o.alignment.horizontal = a.HorizontalAlignment.Fill : s.textAlign === "121" || s.textAlign === "010" ? (o.alignment.horizontal = a.HorizontalAlignment.Distributed, o.alignment.justifyLastLine = s.textAlign === "121") : console.warn("unknown text-align", s.textAlign)), s.verticalAlign && (s.verticalAlign.toLowerCase() === "super" ? o.font.verticalAlign = k.VerticalAlignment.Super : s.verticalAlign.toLowerCase() === "sup" ? o.font.verticalAlign = k.VerticalAlignment.Sub : o.alignment.vertical = n(s.verticalAlign), o.alignment.vertical || (s.verticalAlign === "121" ? o.alignment.vertical = a.VerticalAlignment.Distributed : console.warn("unknown vertical-align", s.verticalAlign))), s.msoCharIndentCount && (o.alignment.indent = s.msoCharIndentCount), s.whiteSpace && (o.alignment.overflow = s.whiteSpace === "no-wrap" || s.whiteSpace === "nowrap" ? a.Overflow.Visible : a.Overflow.Wrap), s.msoTextControl === "shrinktofit" && (o.alignment.overflow = a.Overflow.Shrink);
1303
+ let f = null;
1304
+ if (s.background ? f = s.background : s.backgroundColor && (f = s.backgroundColor), f && (o.fill = { color: f }), s.msoPattern) {
1305
+ let e = y(s.msoPattern);
1306
+ e && (e.patternType === i.BuiltInSheetPattern.Solid ? o.fill = { color: e.foreground } : e.patternType !== i.BuiltInSheetPattern.None && (f && (e.background = f), o.fill = e));
1307
+ }
1308
+ s.msoRotate !== void 0 && (o.alignment.rotation = u(s.msoRotate));
1309
+ let p = (e, t) => {
1310
+ e && (o.border ||= {}, o.border[e] = t);
1311
1311
  };
1312
- a.border && a.border !== "none" && (d("top", a.border), d("left", a.border), d("right", a.border), d("bottom", a.border)), a.borderTop && d("top", a.borderTop), a.borderLeft && d("left", a.borderLeft), a.borderRight && d("right", a.borderRight), a.borderBottom && d("bottom", a.borderBottom), a.msoDiagonalUp && d("diagonalUp", a.msoDiagonalUp), a.msoDiagonalDown && d("diagonalDown", a.msoDiagonalDown);
1313
- let f = i.numberFormat;
1314
- a.msoNumberFormat && (f = y(a.msoNumberFormat), f.includes("\\") ? f = null : f === "Fixed" ? f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Number ? null : E.Type.Number : f === "Percent" && (f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Percentage ? null : E.Type.Percentage)), f && (i.numberFormat = f), e.style = this._styles.normalize(i), r && Object.keys(e.style).length === 0 && delete e.style;
1312
+ s.border && s.border !== "none" && (p("top", s.border), p("left", s.border), p("right", s.border), p("bottom", s.border)), s.borderTop && p("top", s.borderTop), s.borderLeft && p("left", s.borderLeft), s.borderRight && p("right", s.borderRight), s.borderBottom && p("bottom", s.borderBottom), s.msoDiagonalUp && p("diagonalUp", s.msoDiagonalUp), s.msoDiagonalDown && p("diagonalDown", s.msoDiagonalDown);
1313
+ let m = o.numberFormat;
1314
+ s.msoNumberFormat && (m = te(s.msoNumberFormat), m.includes("\\") ? m = null : m === "Fixed" ? m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Number ? null : M.Type.Number : m === "Percent" && (m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Percentage ? null : M.Type.Percentage)), m && (o.numberFormat = m), e.style = this._styles.normalize(o), r && Object.keys(e.style).length === 0 && delete e.style;
1315
1315
  }
1316
1316
  onCell(e, t, n, r, i) {
1317
1317
  let a = r(i), o = { value: t === void 0 ? n ?? "" : t };
1318
1318
  if (typeof o.value == "string" && o.value.length === 0 && (o.value = void 0), a && this.applyCSSStyle(o, a), i?.tagName.toUpperCase() === "TD") {
1319
1319
  let e = o.style, t = e?.font ?? {};
1320
- (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = A.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = A.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = A.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = A.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1320
+ (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = k.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = k.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = k.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = k.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1321
1321
  let n = i.querySelectorAll("a");
1322
1322
  if (n.length > 0) {
1323
1323
  let e = n[0].getAttribute("href");
@@ -1364,8 +1364,8 @@ var ln = class {
1364
1364
  let i = n(r);
1365
1365
  if (i.msoHeightSource !== "userset" || !r) return;
1366
1366
  let a = r.getAttribute("height") ?? i.height, o = null;
1367
- if (a && (o = D(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1368
- let t = r.cells[e], i = D(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1367
+ if (a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1368
+ let t = r.cells[e], i = v(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1369
1369
  i !== null && (o = Math.max(i, o ?? 0));
1370
1370
  }
1371
1371
  o !== null && this._rowsReading.push({
@@ -1373,19 +1373,19 @@ var ln = class {
1373
1373
  min: this._topLeft.rowIndex + e,
1374
1374
  max: this._topLeft.rowIndex + e + t - 1
1375
1375
  },
1376
- update: { size: o * A.getDeviceScale() }
1376
+ update: { size: o * k.getDeviceScale() }
1377
1377
  });
1378
1378
  }
1379
1379
  onColumn(e, t, n, r) {
1380
1380
  let i = n(r);
1381
1381
  if (i.msoWidthSource !== "userset" || !r) return;
1382
1382
  let a = r.getAttribute("width") ?? i.width, o = null;
1383
- a && (o = D(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1383
+ a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1384
1384
  address: {
1385
1385
  min: this._topLeft.colIndex + e,
1386
1386
  max: this._topLeft.colIndex + e + t - 1
1387
1387
  },
1388
- update: { size: o * A.getDeviceScale() }
1388
+ update: { size: o * k.getDeviceScale() }
1389
1389
  });
1390
1390
  }
1391
1391
  onDone() {
@@ -1482,7 +1482,7 @@ var ln = class {
1482
1482
  let r = new mn(this._runtime, this._topLeft, this._styles, n ? "HTML" : "Text");
1483
1483
  await r.sheet().getCalculation().ready(), await r.sheet().getCalculation().stop();
1484
1484
  let i = await Promise.resolve(t ? Ie(t) : [[]]), a;
1485
- if (We(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) return this._parsed = {
1485
+ if (Ue(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) return this._parsed = {
1486
1486
  copyTo: async (e, t) => (await e.copyFrom(a, t))?.getCoords() ?? null,
1487
1487
  getCoords: () => a.getCoords(),
1488
1488
  getSource: () => e,
@@ -1519,7 +1519,7 @@ var ln = class {
1519
1519
  activeSheetId: 0
1520
1520
  }, Q = class {
1521
1521
  constructor(e) {
1522
- this._emitter = new j(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1522
+ this._emitter = new S(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1523
1523
  }
1524
1524
  isShowFormulaBar() {
1525
1525
  return this._state.showFormulaBar;
@@ -1599,7 +1599,7 @@ var ln = class {
1599
1599
  revision: !1,
1600
1600
  password: null,
1601
1601
  revisionsPassword: null
1602
- }), vn = class extends a {
1602
+ }), vn = class extends ot {
1603
1603
  isWindowsAllowed() {
1604
1604
  return this._isPropertyAllowed("windows");
1605
1605
  }
@@ -1662,7 +1662,7 @@ function wn(e, t) {
1662
1662
  return {
1663
1663
  ...Xe,
1664
1664
  getSheet: () => null,
1665
- toString: () => C(e, t)
1665
+ toString: () => E(e, t)
1666
1666
  };
1667
1667
  }
1668
1668
  function Tn(e, t = !1) {
@@ -1685,7 +1685,7 @@ function Tn(e, t = !1) {
1685
1685
  }
1686
1686
  return e;
1687
1687
  }
1688
- var En, Dn, $ = class e extends he {
1688
+ var En, Dn, $ = class e extends ge {
1689
1689
  constructor(e, t, n, r) {
1690
1690
  super(e, t, r), this._workbook = n;
1691
1691
  }
@@ -1696,23 +1696,23 @@ var En, Dn, $ = class e extends he {
1696
1696
  let r = this._options;
1697
1697
  return n && (r = {
1698
1698
  ...this._options,
1699
- getOptions: k(this._options?.getOptions, n)
1699
+ getOptions: j(this._options?.getOptions, n)
1700
1700
  }), new e(t, this._internal, this._workbook, r);
1701
1701
  }
1702
- _createRange(e, n) {
1703
- let r = e ? { ...e } : null, i = r ? this._workbook._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
1704
- if (!i) {
1702
+ _createRange(e, t) {
1703
+ let n = e ? { ...e } : null, r = n ? this._workbook._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
1704
+ if (!r) {
1705
1705
  let e = this._workbook.getSelectedSheet();
1706
- return delete r?.scope, wn(r, r ? {
1707
- scope: qe,
1706
+ return delete n?.scope, wn(n, n ? {
1707
+ scope: h,
1708
1708
  ...e.getEntireRange().getCoords()
1709
1709
  } : null);
1710
1710
  }
1711
- let a = this._options;
1712
- return n && (a = {
1711
+ let i = this._options;
1712
+ return t && (i = {
1713
1713
  ...this._options,
1714
- getOptions: k(this._options.getOptions, n)
1715
- }), new On(e, w(i.sheet), this._workbook, a);
1714
+ getOptions: j(this._options.getOptions, t)
1715
+ }), new On(e, D(r.sheet), this._workbook, i);
1716
1716
  }
1717
1717
  async select(e) {
1718
1718
  let t = [], n = null, r = this.getCoords();
@@ -1736,15 +1736,15 @@ var En, Dn, $ = class e extends he {
1736
1736
  }
1737
1737
  getAddress(e) {
1738
1738
  let t = this._internal.getSheet(), n = t.getEntireRange().getCoords();
1739
- return h(this.getCoords(), {
1739
+ return ce(this.getCoords(), {
1740
1740
  ...n,
1741
1741
  scope: t.getName()
1742
- }, C, le, e);
1742
+ }, E, ne, e);
1743
1743
  }
1744
1744
  toString() {
1745
1745
  return this.getAddress();
1746
1746
  }
1747
- }, On = class e extends je {
1747
+ }, On = class e extends pe {
1748
1748
  constructor(e, t, n, r) {
1749
1749
  super(e, t, r), this._workbook = n;
1750
1750
  }
@@ -1752,17 +1752,17 @@ var En, Dn, $ = class e extends he {
1752
1752
  let n = this._options;
1753
1753
  return t && (n = {
1754
1754
  ...this._options,
1755
- getOptions: k(this._options?.getOptions, t)
1755
+ getOptions: j(this._options?.getOptions, t)
1756
1756
  }), new $(e, this._internal, this._workbook, n);
1757
1757
  }
1758
1758
  _createRange(t, n) {
1759
1759
  let r = this._internal;
1760
- if (!t) return ke(r.getSheet(), r.getSheet().getEntireCoords());
1761
- if (r.validateCoords(t), r.getSheet().isClosed()) return ke(null, r.getSheet().getEntireCoords(), t);
1760
+ if (!t) return Ae(r.getSheet(), r.getSheet().getEntireCoords());
1761
+ if (r.validateCoords(t), r.getSheet().isClosed()) return Ae(null, r.getSheet().getEntireCoords(), t);
1762
1762
  let i = this._options;
1763
1763
  return n && (i = {
1764
1764
  ...this._options,
1765
- getOptions: k(this._options?.getOptions, n)
1765
+ getOptions: j(this._options?.getOptions, n)
1766
1766
  }), new e(t, this._internal, this._workbook, i);
1767
1767
  }
1768
1768
  addListener(e, t) {
@@ -1775,7 +1775,7 @@ var En, Dn, $ = class e extends he {
1775
1775
  }
1776
1776
  getAddress(e) {
1777
1777
  let t = this._internal.getSheet(), n = t?.getEntireRange().getCoords() ?? null;
1778
- return C(this.getCoords(), {
1778
+ return E(this.getCoords(), {
1779
1779
  ...n,
1780
1780
  scope: t.getName()
1781
1781
  });
@@ -1786,166 +1786,167 @@ var En, Dn, $ = class e extends he {
1786
1786
  }, kn = class {
1787
1787
  constructor(e) {
1788
1788
  this._lastTransactionUUID = null, this._closed = !1, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._isDate1904 = !1, this._locale = null, this._localeOverrides = null;
1789
- let n = typeof e == "string" ? { origin: e } : { ...e }, r = n.origin;
1790
- this._origin = typeof r == "string" ? new U(null, { name: r }) : r ?? new U(null), delete n.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1789
+ let t = typeof e == "string" ? { origin: e } : { ...e }, n = t.origin;
1790
+ this._origin = typeof n == "string" ? new U(null, { name: n }) : n ?? new U(null), delete t.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1791
1791
  if (this._closed) return;
1792
1792
  let e = this._origin.getName();
1793
1793
  e !== this._lastOriginName && (this._lastOriginName = e, this._emitter.notify("onNameChange"));
1794
1794
  } });
1795
- let i = n.json;
1796
- delete n.json, this._transactions = n.transactions ?? new c(), this._id = this._transactions.create(), this._ownTransactions = !n.transactions, this._emitter = new j(this, this._transactions), this._runtime = n.runtime ?? new Se("Workbook Runtime", {
1795
+ let r = t.json;
1796
+ delete t.json, this._transactions = t.transactions ?? new s(), this._id = this._transactions.create(), this._ownTransactions = !t.transactions, this._emitter = new S(this, this._transactions), this._runtime = t.runtime ?? new We("Workbook Runtime", {
1797
1797
  isDate1904: () => this._isDate1904,
1798
- getLocale: () => this._locale ?? Le() ?? Ge(),
1798
+ getLocale: () => this._locale ?? Oe() ?? Le(),
1799
1799
  getLocaleOverrides: () => this._localeOverrides
1800
1800
  }), this._listenerLanguage = mt.addChangeListener(() => {
1801
1801
  this._locale !== null || this._closed || this._notifyAllChange();
1802
1802
  });
1803
- let a = this, o = this._beginCommit({ description: V(i ? "op.openWorkbook" : "op.newWorkbook") });
1803
+ let i = this, a = this._beginCommit({ description: V(r ? "op.openWorkbook" : "op.newWorkbook") });
1804
1804
  try {
1805
- this._strings = n.strings ?? new lt(), this._ownStrings = !n.strings, this._externalBooks = new un({ json: i?.externalBooks }), this._resources = n.resources ?? new me(), this._ownResources = !n.resources, this._createSheetName = n.createSheetNameCallback ?? Cn;
1806
- let e = n.createSheetCallback;
1807
- e ||= (e) => new O(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (n, r, i, o, s) => {
1808
- let c = null, l = {
1809
- runtime: a._runtime,
1810
- readonly: a._options.readonly ?? !1,
1811
- disableLoadAutoFit: a._options.disableLoadAutoFit ?? !1,
1812
- formulaTransform: a._options.formulaTransform,
1813
- opener: a._options.opener,
1814
- transactions: a._transactions,
1815
- styles: a._styles,
1816
- strings: a._strings,
1817
- resources: a._resources,
1818
- names: a._names,
1819
- workbook: a,
1820
- calculation: a._calculation,
1821
- resolveRange: (e) => a._options.resolveRange?.(e) ?? a.getRange(e),
1805
+ this._strings = t.strings ?? new he(), this._ownStrings = !t.strings, this._externalBooks = new un({ json: r?.externalBooks }), this._resources = t.resources ?? new st(), this._ownResources = !t.resources, this._createSheetName = t.createSheetNameCallback ?? Cn;
1806
+ let e = t.createSheetCallback;
1807
+ e ||= (e) => new A(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (t, n, r, a, o) => {
1808
+ let s = null, c = {
1809
+ runtime: i._runtime,
1810
+ readonly: i._options.readonly ?? !1,
1811
+ disableLoadAutoFit: i._options.disableLoadAutoFit ?? !1,
1812
+ formulaTransform: i._options.formulaTransform,
1813
+ opener: i._options.opener,
1814
+ transactions: i._transactions,
1815
+ styles: i._styles,
1816
+ strings: i._strings,
1817
+ resources: i._resources,
1818
+ names: i._names,
1819
+ workbook: i,
1820
+ calculation: i._calculation,
1821
+ resolveRange: (e) => i._options.resolveRange?.(e) ?? i.getRange(e),
1822
1822
  container: {
1823
1823
  beforeFromJSON: (e) => {
1824
- c = e, a._addSheetRef({
1825
- name: r,
1826
- id: n,
1827
- visibility: i ?? t.Visibility.Visible,
1824
+ s = e, i._addSheetRef({
1825
+ name: n,
1826
+ id: t,
1827
+ visibility: r ?? O.Visibility.Visible,
1828
1828
  sheet: e
1829
- }, o);
1829
+ }, a);
1830
1830
  },
1831
1831
  getName: () => {
1832
- let e = a._getSheetRef(c);
1833
- return e ? e.name : r;
1832
+ let e = i._getSheetRef(s);
1833
+ return e ? e.name : n;
1834
1834
  },
1835
1835
  setName: (e, t) => {
1836
- a._getSheetRef(c) && a._setSheetName(c, e, t);
1836
+ i._getSheetRef(s) && i._setSheetName(s, e, t);
1837
1837
  },
1838
1838
  setNameChangeCallback: (e) => {
1839
- a._sheetOnNameChange.set(n, e);
1839
+ i._sheetOnNameChange.set(t, e);
1840
1840
  },
1841
1841
  getVisibility: () => {
1842
- let e = a._getSheetRef(c);
1843
- return e ? e.visibility : t.Visibility.Visible;
1842
+ let e = i._getSheetRef(s);
1843
+ return e ? e.visibility : O.Visibility.Visible;
1844
1844
  },
1845
1845
  setVisibility: (e, t) => {
1846
- a._setSheetVisibility(c, e, t);
1846
+ i._setSheetVisibility(s, e, t);
1847
1847
  },
1848
1848
  setVisibilityCallback: (e) => {
1849
- a._sheetOnVisibilityChange.set(n, e);
1849
+ i._sheetOnVisibilityChange.set(t, e);
1850
1850
  },
1851
- duplicate: () => a._duplicateSheet(c),
1851
+ duplicate: () => i._duplicateSheet(s),
1852
1852
  getIndex: () => {
1853
- let e = a._getSheetRef(c);
1854
- return e ? a._getOffsetForId(e.id, a._getSheetRefs(t.Visibility.VeryHidden)) : o;
1853
+ let e = i._getSheetRef(s);
1854
+ return e ? i._getOffsetForId(e.id, i._getSheetRefs(O.Visibility.VeryHidden)) : a;
1855
1855
  },
1856
- setIndex: (e, n) => {
1857
- let r = a._getSheetRef(c, t.Visibility.VeryHidden);
1858
- return !!r && (a._moveSheet(r, e, n), !0);
1856
+ setIndex: (e, t) => {
1857
+ let n = i._getSheetRef(s, O.Visibility.VeryHidden);
1858
+ return !!n && (i._moveSheet(n, e, t), !0);
1859
1859
  },
1860
1860
  setIndexCallback: (e) => {
1861
- a._sheetOnIndexChange.set(n, e);
1861
+ i._sheetOnIndexChange.set(t, e);
1862
1862
  },
1863
- requestSelect: async () => (a._setSelectedSheet(c), await this._emitter.notify("onRequestSelect", {
1864
- source: a,
1865
- params: c,
1863
+ requestSelect: async () => (i._setSelectedSheet(s), await this._emitter.notify("onRequestSelect", {
1864
+ source: i,
1865
+ params: s,
1866
1866
  async: !0
1867
- }), a.getSelectedSheet() === c)
1867
+ }), i.getSelectedSheet() === s)
1868
1868
  }
1869
1869
  };
1870
- return s && (l.json = s), c = e(l, r, o, i), c;
1871
- }, this._namedTableSource = new de({
1872
- getSheets: () => a._sheets ? a.getSheets().getItems() : I.EmptyArray,
1873
- addSheetsListener: (e, t) => a.addListeners({ onSheetsChange: e }, t)
1874
- }), this._names = n.names ?? new be({
1875
- addressToRanges: (e) => a.getRanges(e),
1876
- getCurrentScope: () => a.getSelectedSheet().getName(),
1877
- isReadOnly: () => a._options.readonly ?? !1,
1878
- transactions: a._transactions,
1879
- getSources: () => a._calculation ? [a._calculation.getNamedFormulas(), a._namedTableSource] : I.EmptyArray
1880
- }), this._ownNames = !n.names, this._calculation = n.calculation ?? new ve({
1881
- runtime: a._runtime,
1882
- functions: n.functions,
1870
+ return o && (c.json = o), s = e(c, n, a, r), s;
1871
+ }, this._namedTableSource = new it({
1872
+ getSheets: () => i._sheets ? i.getSheets().getItems() : I.EmptyArray,
1873
+ addSheetsListener: (e, t) => i.addListeners({ onSheetsChange: e }, t)
1874
+ }), this._names = t.names ?? new we({
1875
+ addressToRanges: (e) => i.getRanges(e),
1876
+ getCurrentScope: () => i.getSelectedSheet().getName(),
1877
+ isReadOnly: () => i._options.readonly ?? !1,
1878
+ transactions: i._transactions,
1879
+ getSources: () => i._calculation ? [i._calculation.getNamedFormulas(), i._namedTableSource] : I.EmptyArray
1880
+ }), this._ownNames = !t.names, this._calculation = t.calculation ?? new ye({
1881
+ runtime: i._runtime,
1882
+ functions: t.functions,
1883
+ json: r?.calc,
1883
1884
  getActiveCell: () => {
1884
- let e = a.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1885
+ let e = i.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1885
1886
  return t ? {
1886
1887
  rowIndex: t.rowStart,
1887
1888
  colIndex: t.colStart,
1888
1889
  scope: e.getId()
1889
1890
  } : null;
1890
1891
  },
1891
- getRange: a.getRange.bind(a),
1892
- getRanges: a.getRanges.bind(a),
1893
- createGraphRanges: (e, t) => a._createGraphRanges(e, t),
1892
+ getRange: i.getRange.bind(i),
1893
+ getRanges: i.getRanges.bind(i),
1894
+ createGraphRanges: (e, t) => i._createGraphRanges(e, t),
1894
1895
  getSheetIndex: (e) => {
1895
1896
  if (e === void 0) {
1896
- let e = a.getSelectedSheet();
1897
- return e ? this._getSheetRefs(t.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1897
+ let e = i.getSelectedSheet();
1898
+ return e ? this._getSheetRefs(O.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1898
1899
  }
1899
- let n = this._getSheetRefs(t.Visibility.VeryHidden);
1900
+ let t = this._getSheetRefs(O.Visibility.VeryHidden);
1900
1901
  e = e.toLowerCase();
1901
- let r = n.length;
1902
- for (let t = 0; t < r; t++) if (n[t].name.toLowerCase() === e) return t;
1902
+ let n = t.length;
1903
+ for (let r = 0; r < n; r++) if (t[r].name.toLowerCase() === e) return r;
1903
1904
  try {
1904
1905
  An.address = e;
1905
- let n = this._names.getItems(An);
1906
- if (!n || n.length === 0) return -1;
1907
- let r = n[0].getRanges?.()?.getCoords()?.[0]?.scope;
1908
- if (!r) return -1;
1909
- let i = this._getSheetRefs(t.Visibility.VeryHidden);
1910
- r = r.toLowerCase();
1911
- let a = i.length;
1912
- for (let e = 0; e < a; e++) if (i[e].name.toLowerCase() === r) return e;
1906
+ let t = this._names.getItems(An);
1907
+ if (!t || t.length === 0) return -1;
1908
+ let n = t[0].getRanges?.()?.getCoords()?.[0]?.scope;
1909
+ if (!n) return -1;
1910
+ let r = this._getSheetRefs(O.Visibility.VeryHidden);
1911
+ n = n.toLowerCase();
1912
+ let i = r.length;
1913
+ for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === n) return e;
1913
1914
  } catch {
1914
1915
  return -1;
1915
1916
  }
1916
1917
  return -1;
1917
1918
  },
1918
- getSheetCount: () => a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }).length,
1919
+ getSheetCount: () => i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }).length,
1919
1920
  getSheetById: (e) => {
1920
- let n = a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }), r = n.length;
1921
- for (let t = 0; t < r; t++) if (n[t].getId() === e) return n[t];
1921
+ let t = i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }), n = t.length;
1922
+ for (let r = 0; r < n; r++) if (t[r].getId() === e) return t[r];
1922
1923
  return null;
1923
1924
  },
1924
1925
  getSheetByName: (e) => {
1925
1926
  try {
1926
- return a.getSheets().getByName(e) ?? null;
1927
+ return i.getSheets().getByName(e) ?? null;
1927
1928
  } catch {
1928
1929
  return null;
1929
1930
  }
1930
1931
  },
1931
- namedCollection: a._names,
1932
- strings: a._strings,
1933
- transactions: a._transactions,
1934
- names: i?.names,
1935
- formulaTransform: n.formulaTransform
1936
- }), this._ownCalculation = !n.calculation, this._scripts = this._createScripts(), this._ownNames = !n.names, this._options = Object.freeze({ ...n });
1937
- let r = async () => {
1932
+ namedCollection: i._names,
1933
+ strings: i._strings,
1934
+ transactions: i._transactions,
1935
+ names: r?.names,
1936
+ formulaTransform: t.formulaTransform
1937
+ }), this._ownCalculation = !t.calculation, this._scripts = this._createScripts(), this._ownNames = !t.names, this._options = Object.freeze({ ...t });
1938
+ let n = async () => {
1938
1939
  this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
1939
1940
  };
1940
- this._starting = r(), this._starting?.catch(() => {}), i ? this._fromJSON(i) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => a._addSheetOptions(e), (e, t) => {
1941
+ this._starting = n(), this._starting?.catch(() => {}), r ? this._fromJSON(r) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => i._addSheetOptions(e), (e, t) => {
1941
1942
  if (e) {
1942
1943
  let n = this._getSheetRef(e, t);
1943
1944
  return n ? [n.sheet] : I.EmptyArray;
1944
1945
  }
1945
1946
  return this._getSheets(t);
1946
- }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), o.commit({ forceAmend: this._ownTransactions });
1947
+ }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), a.commit({ forceAmend: this._ownTransactions });
1947
1948
  } catch (e) {
1948
- throw o.rollback(), e;
1949
+ throw a.rollback(), e;
1949
1950
  }
1950
1951
  this._initializing = !1;
1951
1952
  }
@@ -1953,7 +1954,7 @@ var En, Dn, $ = class e extends he {
1953
1954
  let e = this._getSheetRefs();
1954
1955
  for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
1955
1956
  let t = this._options;
1956
- this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new p().getDefaultTheme(), this._styles = t?.styles ?? new ot(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Q()), this._listenerProtection?.(), this._protection = new vn(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1957
+ this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new g().getDefaultTheme(), this._styles = t?.styles ?? new ae(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Q()), this._listenerProtection?.(), this._protection = new vn(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1957
1958
  n._emitter.notify("onProtectionChange");
1958
1959
  } });
1959
1960
  let n = this;
@@ -2077,19 +2078,19 @@ var En, Dn, $ = class e extends he {
2077
2078
  let e = this._getSheetRef(this.getSelectedSheetIndex());
2078
2079
  return e ? e?.sheet : null;
2079
2080
  }
2080
- getSheet(e, n = t.Visibility.Visible) {
2081
+ getSheet(e, t = O.Visibility.Visible) {
2081
2082
  if (e === void 0) return this.getSelectedSheet();
2082
2083
  if (!e) throw Error(H("error.workbook.sheetNameNotProvided"));
2083
- let r = this._getSheetRef(e, n);
2084
- if (!r) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2085
- return r.sheet;
2084
+ let n = this._getSheetRef(e, t);
2085
+ if (!n) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2086
+ return n.sheet;
2086
2087
  }
2087
- getSheetAt(e, n = t.Visibility.Visible) {
2088
- let r = this._getSheetRef(e, n);
2089
- if (!r) throw new B(function(e) {
2088
+ getSheetAt(e, t = O.Visibility.Visible) {
2089
+ let n = this._getSheetRef(e, t);
2090
+ if (!n) throw new B(function(e) {
2090
2091
  return H("error.workbook.sheetIndexNotFound", { index: e });
2091
2092
  }(e));
2092
- return r.sheet;
2093
+ return n.sheet;
2093
2094
  }
2094
2095
  getSheets() {
2095
2096
  return this._sheets;
@@ -2097,18 +2098,18 @@ var En, Dn, $ = class e extends he {
2097
2098
  addSheet(e) {
2098
2099
  return this.getSheets().add(e);
2099
2100
  }
2100
- _getSheets(e = t.Visibility.Visible) {
2101
- let n = this._getSheetRefs(e), r = [], i = n.length;
2102
- for (let e = 0; e < i; e++) r.push(n[e].sheet);
2103
- return r;
2101
+ _getSheets(e = O.Visibility.Visible) {
2102
+ let t = this._getSheetRefs(e), n = [], r = t.length;
2103
+ for (let e = 0; e < r; e++) n.push(t[e].sheet);
2104
+ return n;
2104
2105
  }
2105
- _getSheetRefs(e = t.Visibility.Visible) {
2106
- let n = this._getState();
2107
- return n ? e === t.Visibility.Visible ? n.sheetRefsVisible : e === t.Visibility.Hidden ? n.sheetRefsVisibleAndHidden : e === t.Visibility.VeryHidden ? n.sheetRefsAll : I.EmptyArray : [];
2106
+ _getSheetRefs(e = O.Visibility.Visible) {
2107
+ let t = this._getState();
2108
+ return t ? e === O.Visibility.Visible ? t.sheetRefsVisible : e === O.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === O.Visibility.VeryHidden ? t.sheetRefsAll : I.EmptyArray : [];
2108
2109
  }
2109
- _getSheetRef(e, n = t.Visibility.Visible) {
2110
- let r = null;
2111
- return typeof e == "number" ? this._getSheetRefs(n)[e] : (typeof e == "string" ? r = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof O ? r = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (r = this._getState().refsById.get(e.id)), r);
2110
+ _getSheetRef(e, t = O.Visibility.Visible) {
2111
+ let n = null;
2112
+ return typeof e == "number" ? this._getSheetRefs(t)[e] : (typeof e == "string" ? n = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof A ? n = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (n = this._getState().refsById.get(e.id)), n);
2112
2113
  }
2113
2114
  _validateNewSheetName(e, t = !0) {
2114
2115
  if (e == null) return e;
@@ -2188,100 +2189,100 @@ var En, Dn, $ = class e extends he {
2188
2189
  }
2189
2190
  return this._updateState({ lastId: i }), e;
2190
2191
  }
2191
- _addSheet(e, n = null, r = null) {
2192
- n = this._nextSheetName(n);
2193
- let i = this._getState(), a = this._createSheet(i.lastId, n, t.Visibility.Visible, r, null);
2194
- if (!a) throw new R(H("error.workbook.sheetNameBlank"));
2195
- return e && this._emitter.notify("onSheetsChange"), a;
2192
+ _addSheet(e, t = null, n = null) {
2193
+ t = this._nextSheetName(t);
2194
+ let r = this._getState(), i = this._createSheet(r.lastId, t, O.Visibility.Visible, n, null);
2195
+ if (!i) throw new R(H("error.workbook.sheetNameBlank"));
2196
+ return e && this._emitter.notify("onSheetsChange"), i;
2196
2197
  }
2197
2198
  _updateSheetRefStates(e) {
2198
2199
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2199
2200
  if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2200
- let n = e, r = [], i = [], a = n.length;
2201
- for (let e = 0; e < a; e++) n[e].visibility === t.Visibility.Visible ? (r.push(n[e]), i.push(n[e])) : n[e].visibility === t.Visibility.Hidden && i.push(n[e]);
2201
+ let t = e, n = [], r = [], i = t.length;
2202
+ for (let e = 0; e < i; e++) t[e].visibility === O.Visibility.Visible ? (n.push(t[e]), r.push(t[e])) : t[e].visibility === O.Visibility.Hidden && r.push(t[e]);
2202
2203
  this._updateState({
2203
- sheetRefsAll: n,
2204
- sheetRefsVisible: r,
2205
- sheetRefsVisibleAndHidden: i
2204
+ sheetRefsAll: t,
2205
+ sheetRefsVisible: n,
2206
+ sheetRefsVisibleAndHidden: r
2206
2207
  });
2207
2208
  }
2208
- _addSheetRef(e, n = null) {
2209
- let r = this._getState(), i = r.sheetRefsAll, a = Math.max(0, Math.min(i.length, n ?? i.length)), o = [
2210
- ...i.slice(0, a),
2209
+ _addSheetRef(e, t = null) {
2210
+ let n = this._getState(), r = n.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length)), a = [
2211
+ ...r.slice(0, i),
2211
2212
  e,
2212
- ...i.slice(a)
2213
+ ...r.slice(i)
2213
2214
  ];
2214
- this._updateSheetRefStates(o);
2215
- let s = e.sheet, c = e.name.toLowerCase(), l = new Map(r.refsById);
2216
- l.set(e.id, e);
2217
- let u = new Map(r.refsByLowerCaseName);
2218
- u.set(c, e);
2219
- let d = new Map(r.refsByInstance);
2220
- d.set(s, e);
2221
- let f = new Map(r.sheetsById);
2222
- f.set(e.id, s);
2223
- let p = new Map(r.sheetsByLowerCaseName);
2224
- p.set(c, s);
2225
- let m = this, h = r.listenersSheets;
2226
- if (s !== void 0) {
2227
- let n = s.addListeners({
2215
+ this._updateSheetRefStates(a);
2216
+ let o = e.sheet, s = e.name.toLowerCase(), c = new Map(n.refsById);
2217
+ c.set(e.id, e);
2218
+ let l = new Map(n.refsByLowerCaseName);
2219
+ l.set(s, e);
2220
+ let u = new Map(n.refsByInstance);
2221
+ u.set(o, e);
2222
+ let d = new Map(n.sheetsById);
2223
+ d.set(e.id, o);
2224
+ let f = new Map(n.sheetsByLowerCaseName);
2225
+ f.set(s, o);
2226
+ let p = this, m = n.listenersSheets;
2227
+ if (o !== void 0) {
2228
+ let t = o.addListeners({
2228
2229
  onBeforeDelete: (e) => {
2229
- m._validateDeleteSheet(e);
2230
+ p._validateDeleteSheet(e);
2230
2231
  },
2231
2232
  onDelete(e) {
2232
- let n = m._getSheetRef(e, t.Visibility.VeryHidden);
2233
- if (!n) return;
2234
- let r = m._beginCommit({ description: H("op.deleteSheet", { name: n.name }) });
2233
+ let t = p._getSheetRef(e, O.Visibility.VeryHidden);
2234
+ if (!t) return;
2235
+ let n = p._beginCommit({ description: H("op.deleteSheet", { name: t.name }) });
2235
2236
  try {
2236
- let t = m._getState(), i = t.sheetRefsAll, a = m._getOffsetForId(n.id, i), o = [...i];
2237
- o.splice(a, 1), m._updateSheetRefStates(o);
2238
- let c = new Map(t.refsById);
2239
- c.delete(n.id);
2240
- let l = new Map(t.sheetsById);
2241
- l.delete(n.id);
2242
- let u = n.name.toLowerCase(), d = new Map(t.refsByLowerCaseName);
2237
+ let r = p._getState(), i = r.sheetRefsAll, a = p._getOffsetForId(t.id, i), s = [...i];
2238
+ s.splice(a, 1), p._updateSheetRefStates(s);
2239
+ let c = new Map(r.refsById);
2240
+ c.delete(t.id);
2241
+ let l = new Map(r.sheetsById);
2242
+ l.delete(t.id);
2243
+ let u = t.name.toLowerCase(), d = new Map(r.refsByLowerCaseName);
2243
2244
  d.delete(u);
2244
- let f = new Map(t.sheetsByLowerCaseName);
2245
+ let f = new Map(r.sheetsByLowerCaseName);
2245
2246
  f.delete(u);
2246
- let p = new Map(t.refsByInstance);
2247
- p.delete(e), t.listenersSheets.get(n.id)();
2248
- let h = new Map(t.listenersSheets);
2249
- h.delete(n.id), m._adjustRemoveSelectionIfRequired(a, n.id), m._adjustSheetNamesIfRequired(), m._sheetOnNameChange.delete(n.id), m._sheetOnVisibilityChange.delete(n.id), m._sheetOnIndexChange.delete(n.id), m._emitter.notify("onSheetsChange");
2250
- let g = new Set(t.sheetsCreated);
2251
- g.has(s) && g.delete(s), m._updateState({
2247
+ let m = new Map(r.refsByInstance);
2248
+ m.delete(e), r.listenersSheets.get(t.id)();
2249
+ let h = new Map(r.listenersSheets);
2250
+ h.delete(t.id), p._adjustRemoveSelectionIfRequired(a, t.id), p._adjustSheetNamesIfRequired(), p._sheetOnNameChange.delete(t.id), p._sheetOnVisibilityChange.delete(t.id), p._sheetOnIndexChange.delete(t.id), p._emitter.notify("onSheetsChange");
2251
+ let g = new Set(r.sheetsCreated);
2252
+ g.has(o) && g.delete(o), p._updateState({
2252
2253
  refsById: c,
2253
2254
  sheetsById: l,
2254
2255
  refsByLowerCaseName: d,
2255
2256
  sheetsByLowerCaseName: f,
2256
- refsByInstance: p,
2257
+ refsByInstance: m,
2257
2258
  sheetsCreated: g,
2258
2259
  listenersSheets: h
2259
- }), r.commit();
2260
+ }), n.commit();
2260
2261
  } catch (e) {
2261
- throw r.rollback(), e;
2262
+ throw n.rollback(), e;
2262
2263
  }
2263
2264
  }
2264
- }), i = s.addListeners({ onSelectionChange: (e) => {
2265
- m.getView().getActiveSheetId() === m._getSheetRef(e)?.id && m._emitter.notify("onSelectionChange", {
2266
- source: m,
2265
+ }), r = o.addListeners({ onSelectionChange: (e) => {
2266
+ p.getView().getActiveSheetId() === p._getSheetRef(e)?.id && p._emitter.notify("onSelectionChange", {
2267
+ source: p,
2267
2268
  params: e
2268
2269
  });
2269
2270
  } }, { transactional: !1 });
2270
- h = new Map(r.listenersSheets), h.set(e.id, () => {
2271
- n(), i();
2271
+ m = new Map(n.listenersSheets), m.set(e.id, () => {
2272
+ t(), r();
2272
2273
  });
2273
2274
  }
2274
- let g = r.lastId;
2275
- g !== -1 && (g = Math.max(g, e.id)), this._updateState({ lastId: g }), this._updateState({
2276
- refsById: l,
2277
- refsByLowerCaseName: u,
2278
- refsByInstance: d,
2279
- sheetsById: f,
2280
- sheetsByLowerCaseName: p,
2281
- listenersSheets: h
2275
+ let h = n.lastId;
2276
+ h !== -1 && (h = Math.max(h, e.id)), this._updateState({ lastId: h }), this._updateState({
2277
+ refsById: c,
2278
+ refsByLowerCaseName: l,
2279
+ refsByInstance: u,
2280
+ sheetsById: d,
2281
+ sheetsByLowerCaseName: f,
2282
+ listenersSheets: m
2282
2283
  }), this._adjustSheetNamesIfRequired();
2283
- let _ = new Set(this._getState().sheetsCreated);
2284
- return _.add(e.sheet), this._updateState({ sheetsCreated: _ }), e;
2284
+ let g = new Set(this._getState().sheetsCreated);
2285
+ return g.add(e.sheet), this._updateState({ sheetsCreated: g }), e;
2285
2286
  }
2286
2287
  _adjustRemoveSelectionIfRequired(e, t) {
2287
2288
  if (this._view.getActiveSheetId() === t) {
@@ -2290,12 +2291,12 @@ var En, Dn, $ = class e extends he {
2290
2291
  }
2291
2292
  }
2292
2293
  _adjustSheetNamesIfRequired() {
2293
- let e = this._getState(), n = e.lastId;
2294
- if (n === -1) return;
2295
- let r = this._view.getActiveSheetId();
2296
- r ??= (this._view.setActiveSheetId(n), n);
2297
- let i = e.refsById.get(r);
2298
- i || (this._view.setActiveSheetId(n), i = e.refsById.get(n), r = n), i.visibility === t.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(r, e.sheetRefsVisible));
2294
+ let e = this._getState(), t = e.lastId;
2295
+ if (t === -1) return;
2296
+ let n = this._view.getActiveSheetId();
2297
+ n ??= (this._view.setActiveSheetId(t), t);
2298
+ let r = e.refsById.get(n);
2299
+ r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), n = t), r.visibility === O.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(n, e.sheetRefsVisible));
2299
2300
  }
2300
2301
  _validateDeleteSheet(e) {
2301
2302
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
@@ -2340,7 +2341,7 @@ var En, Dn, $ = class e extends he {
2340
2341
  }
2341
2342
  if (!d && s && a === i && (u.done || !c || !u.done && f(u.value.getCoords(), c) >= 0) && (d = !0), d) {
2342
2343
  let e = u;
2343
- return u = ye, e;
2344
+ return u = Ce, e;
2344
2345
  }
2345
2346
  let p = u;
2346
2347
  return u = l.next(), p;
@@ -2352,7 +2353,7 @@ var En, Dn, $ = class e extends he {
2352
2353
  } };
2353
2354
  }
2354
2355
  replace(e, t, n) {
2355
- let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? ct(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2356
+ let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? me(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2356
2357
  try {
2357
2358
  let u = null, f = null, p = e.next();
2358
2359
  for (; !p.done && r < o;) {
@@ -2416,21 +2417,21 @@ var En, Dn, $ = class e extends he {
2416
2417
  }
2417
2418
  return c;
2418
2419
  }
2419
- _createRange(e, n) {
2420
- let r = e ? { ...e } : null, i = r ? this._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
2421
- if (!i) {
2420
+ _createRange(e, t) {
2421
+ let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
2422
+ if (!r) {
2422
2423
  let e = this.getSelectedSheet();
2423
- return e ? (delete r?.scope, wn(r, r ? {
2424
- scope: qe,
2424
+ return e ? (delete n?.scope, wn(n, n ? {
2425
+ scope: h,
2425
2426
  ...e.getEntireRange().getCoords()
2426
2427
  } : null)) : void console.warn(H("error.workbook.noVisibleRefs"));
2427
2428
  }
2428
- let a = i.sheet, o = null;
2429
- return n && (o = { getOptions: n }), new On(e, w(a), this, o);
2429
+ let i = r.sheet, a = null;
2430
+ return t && (a = { getOptions: t }), new On(e, D(i), this, a);
2430
2431
  }
2431
2432
  _createRanges(e, t) {
2432
2433
  let n = this.getSelectedSheet(), r = null;
2433
- return t && (r = { getOptions: t }), new $(e, w(n), this, r);
2434
+ return t && (r = { getOptions: t }), new $(e, D(n), this, r);
2434
2435
  }
2435
2436
  getRange(e, t) {
2436
2437
  if (e === void 0) return this.getSelectedRange(t);
@@ -2439,7 +2440,7 @@ var En, Dn, $ = class e extends he {
2439
2440
  if (n.length !== 1) throw new R(H("error.address.singleRangeOnlyAlt"));
2440
2441
  return this._createRange(n[0], t);
2441
2442
  } catch (t) {
2442
- throw t instanceof B ? new B(t.message) : new R(t.message ?? re(e));
2443
+ throw t instanceof B ? new B(t.message) : new R(t.message ?? o(e));
2443
2444
  }
2444
2445
  }
2445
2446
  getCell(e) {
@@ -2450,25 +2451,25 @@ var En, Dn, $ = class e extends he {
2450
2451
  }
2451
2452
  getRanges(e, t) {
2452
2453
  let n = this._rangesAddressToCoords(e);
2453
- if (n.length === 0) throw new R(re(e));
2454
+ if (n.length === 0) throw new R(o(e));
2454
2455
  return this._createRanges(n, t);
2455
2456
  }
2456
- _createGraphRanges(e, n) {
2457
- let r = [];
2458
- for (let e = 0; e < n.length; e++) {
2459
- let i = n[e], a = (i.sheetName ? this._getSheetRef(i.sheetName, t.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2460
- a && r.push(new Ye(i, w(a), null));
2457
+ _createGraphRanges(e, t) {
2458
+ let n = [];
2459
+ for (let e = 0; e < t.length; e++) {
2460
+ let r = t[e], i = (r.sheetName ? this._getSheetRef(r.sheetName, O.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2461
+ i && n.push(new je(r, D(i), null));
2461
2462
  }
2462
- for (let t = 0; t < e.length; t++) r.push(e[t]);
2463
- return r.length === 0 ? null : new $(r, w(this.getSelectedSheet()), this, null);
2463
+ for (let t = 0; t < e.length; t++) n.push(e[t]);
2464
+ return n.length === 0 ? null : new $(n, D(this.getSelectedSheet()), this, null);
2464
2465
  }
2465
2466
  getStats(e) {
2466
2467
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2467
- let n = this._getSheets(t.Visibility.VeryHidden), r = n.length;
2468
- if (r === 1) return n[0].getStats(e);
2469
- let i = Array(r);
2470
- for (let t = 0; t < r; t++) i[t] = n[t].getStats(e);
2471
- return new on(i);
2468
+ let t = this._getSheets(O.Visibility.VeryHidden), n = t.length;
2469
+ if (n === 1) return t[0].getStats(e);
2470
+ let r = Array(n);
2471
+ for (let i = 0; i < n; i++) r[i] = t[i].getStats(e);
2472
+ return new on(r);
2472
2473
  }
2473
2474
  _activeRangeCoords() {
2474
2475
  let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
@@ -2493,7 +2494,7 @@ var En, Dn, $ = class e extends he {
2493
2494
  getSelectedCell() {
2494
2495
  return this.getSelectedSheet().getSelectedCell();
2495
2496
  }
2496
- _rangesAddressToCoords(e, n = !0, r = t.Visibility.Hidden) {
2497
+ _rangesAddressToCoords(e, n = !0, r = O.Visibility.Hidden) {
2497
2498
  if (!e) throw new R(H("error.address.noAddress"));
2498
2499
  let i = this.getSelectedSheet(), a = { ...i?.getEntireRange().getCoords() }, o = i?.getName();
2499
2500
  if (o && (a.scope = o), typeof e == "string") {
@@ -2503,7 +2504,7 @@ var En, Dn, $ = class e extends he {
2503
2504
  t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
2504
2505
  }
2505
2506
  }
2506
- let s = this, c = ce(e, a, te, (e) => {
2507
+ let s = this, c = le(e, a, t, (e) => {
2507
2508
  if (!n) return null;
2508
2509
  if (typeof e == "string") {
2509
2510
  let t = s.getNames().getByName(e)?.getRanges?.();
@@ -2514,10 +2515,10 @@ var En, Dn, $ = class e extends he {
2514
2515
  for (let e = 0; e < l; e++) this._validateCoords(c[e], r);
2515
2516
  return c;
2516
2517
  }
2517
- _validateCoords(e, n = t.Visibility.Visible, r = H("error.sheet.oobRange")) {
2518
+ _validateCoords(e, t = O.Visibility.Visible, n = H("error.sheet.oobRange")) {
2518
2519
  if (e === null) return;
2519
- let i = this.getSheet(e.scope, n).getEntireRange().getCoords();
2520
- if (!L.isRangeWithinRange(e, i)) throw new B(r);
2520
+ let r = this.getSheet(e.scope, t).getEntireRange().getCoords();
2521
+ if (!L.isRangeWithinRange(e, r)) throw new B(n);
2521
2522
  if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new R(H("error.address.invalidRangeInverted"));
2522
2523
  }
2523
2524
  _updateSheetRef(e, t) {
@@ -2558,29 +2559,29 @@ var En, Dn, $ = class e extends he {
2558
2559
  }
2559
2560
  return a;
2560
2561
  }
2561
- _setSheetVisibility(e, n = t.Visibility.Visible, r) {
2562
+ _setSheetVisibility(e, t = O.Visibility.Visible, n) {
2562
2563
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2563
2564
  if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2564
- let i = this._getSheetRef(e, t.Visibility.VeryHidden);
2565
- if (!i) return null;
2566
- if (n === i.visibility) return;
2567
- let a = null, o = "";
2568
- n === t.Visibility.Visible ? o = V("op.unhideSheet") : n === t.Visibility.Hidden ? o = V("op.hideSheet") : n === t.Visibility.VeryHidden && (o = V("op.veryHideSheet"));
2569
- let s = this.beginCommit(o);
2565
+ let r = this._getSheetRef(e, O.Visibility.VeryHidden);
2566
+ if (!r) return null;
2567
+ if (t === r.visibility) return;
2568
+ let i = null, a = "";
2569
+ t === O.Visibility.Visible ? a = V("op.unhideSheet") : t === O.Visibility.Hidden ? a = V("op.hideSheet") : t === O.Visibility.VeryHidden && (a = V("op.veryHideSheet"));
2570
+ let o = this.beginCommit(a);
2570
2571
  try {
2571
2572
  let e = this._getState().sheetRefsVisible;
2572
- if (n !== t.Visibility.Visible && e.length === 1 && e[0].id === i.id) throw new R(H("error.workbook.sheetOne"));
2573
- let o = {
2574
- ...i,
2575
- visibility: n
2576
- }, c = -1;
2577
- n !== t.Visibility.Visible && (c = this._getOffsetForId(i.id, e)), a = this._updateSheetRef(i, o).sheet, n !== t.Visibility.Visible && this._adjustRemoveSelectionIfRequired(c, i.id), this._adjustSheetNamesIfRequired(), s.commit(r);
2573
+ if (t !== O.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new R(H("error.workbook.sheetOne"));
2574
+ let a = {
2575
+ ...r,
2576
+ visibility: t
2577
+ }, s = -1;
2578
+ t !== O.Visibility.Visible && (s = this._getOffsetForId(r.id, e)), i = this._updateSheetRef(r, a).sheet, t !== O.Visibility.Visible && this._adjustRemoveSelectionIfRequired(s, r.id), this._adjustSheetNamesIfRequired(), o.commit(n);
2578
2579
  } catch (e) {
2579
- throw s.rollback(), e;
2580
+ throw o.rollback(), e;
2580
2581
  }
2581
2582
  return this._sheetOnVisibilityChange.forEach((e, t) => {
2582
- i.id === t && e();
2583
- }), this._emitter.notify("onSheetsChange"), a;
2583
+ r.id === t && e();
2584
+ }), this._emitter.notify("onSheetsChange"), i;
2584
2585
  }
2585
2586
  _moveSheet(e, t, n) {
2586
2587
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
@@ -2612,10 +2613,10 @@ var En, Dn, $ = class e extends he {
2612
2613
  }
2613
2614
  _setSelectedSheet(e) {
2614
2615
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2615
- let n = this._getSheetRef(e);
2616
- if (!n) throw new R(yn(e));
2617
- let r = null;
2618
- return n.visibility !== t.Visibility.Visible && this._setSheetVisibility(n, t.Visibility.Visible), this._view.setActiveSheetId(n.id), r = n.sheet, r;
2616
+ let t = this._getSheetRef(e);
2617
+ if (!t) throw new R(yn(e));
2618
+ let n = null;
2619
+ return t.visibility !== O.Visibility.Visible && this._setSheetVisibility(t, O.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
2619
2620
  }
2620
2621
  getProtection() {
2621
2622
  return this._protection;
@@ -2683,24 +2684,24 @@ var En, Dn, $ = class e extends he {
2683
2684
  }
2684
2685
  _fromJSON(e) {
2685
2686
  if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new R(H("error.workbook.sheetOne"));
2686
- e.theme && (this._theme = new u(e.theme), this._styles.setTheme(this._theme));
2687
- let n = this._strings.beginPersist(), r = this._resources.beginPersist(), i = this._styles.beginPersist();
2687
+ e.theme && (this._theme = new m(e.theme), this._styles.setTheme(this._theme));
2688
+ let t = this._strings.beginPersist(), n = this._resources.beginPersist(), r = this._styles.beginPersist();
2688
2689
  try {
2689
- n.fromJSON(e.strings), r.fromJSON(e.resources), i.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2690
- let a = e.sheets, o = a.length, s = e.view.activeSheetId ?? null;
2691
- s !== null && (s = Math.min(Math.max(0, s), o - 1));
2692
- let c = null, l = null, u = -1;
2693
- for (let e = 0; e < o; e++) {
2694
- let n = a[e], r = n.visibility || t.Visibility.Visible, i = e;
2695
- l = i, r === t.Visibility.Visible ? (u++, c === null && (c = i)) : s !== null && s === i && (s = null), this._createSheet(i, n.name, r, u, n.sheet);
2690
+ t.fromJSON(e.strings), n.fromJSON(e.resources), r.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2691
+ let i = e.sheets, a = i.length, o = e.view.activeSheetId ?? null;
2692
+ o !== null && (o = Math.min(Math.max(0, o), a - 1));
2693
+ let s = null, c = null, l = -1;
2694
+ for (let e = 0; e < a; e++) {
2695
+ let t = i[e], n = t.visibility || O.Visibility.Visible, r = e;
2696
+ c = r, n === O.Visibility.Visible ? (l++, s === null && (s = r)) : o !== null && o === r && (o = null), this._createSheet(r, t.name, n, l, t.sheet);
2696
2697
  }
2697
- this._updateState({ lastId: l }), e.view.activeSheetId = s ?? c, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2698
- let d = this;
2698
+ this._updateState({ lastId: c }), e.view.activeSheetId = o ?? s, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2699
+ let u = this;
2699
2700
  this._protection = new vn(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2700
- d._emitter.notify("onProtectionChange", { source: e });
2701
+ u._emitter.notify("onProtectionChange", { source: e });
2701
2702
  } }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
2702
2703
  } finally {
2703
- i.endPersist(), r.endPersist(), n.endPersist();
2704
+ r.endPersist(), n.endPersist(), t.endPersist();
2704
2705
  }
2705
2706
  }
2706
2707
  _createScripts(e) {
@@ -2712,7 +2713,7 @@ var En, Dn, $ = class e extends he {
2712
2713
  getBuiltInFunctions: () => t._calculation?.getFunctions(),
2713
2714
  onAdd: (e, n) => {
2714
2715
  let r = t._calculation;
2715
- r.getStatus() !== Ve.Status.Off && r.start().then(async () => {
2716
+ r.getStatus() !== Ye.Status.Off && r.start().then(async () => {
2716
2717
  let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
2717
2718
  for (let n = 0; n < t; n++) {
2718
2719
  let t = e[n];
@@ -2730,47 +2731,49 @@ var En, Dn, $ = class e extends he {
2730
2731
  async toJSON(e) {
2731
2732
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2732
2733
  await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
2733
- let n = { sheets: [] }, r = e?.ignoreStyles ?? !1;
2734
- if (!r) {
2734
+ let t = { sheets: [] }, n = e?.ignoreStyles ?? !1;
2735
+ if (!n) {
2735
2736
  let e = this._theme.toJSON();
2736
- (e ? Object.keys(e).length : 0) > 0 && (n.theme = e);
2737
+ (e ? Object.keys(e).length : 0) > 0 && (t.theme = e);
2737
2738
  }
2738
2739
  if (this._scripts) {
2739
2740
  let e = this._scripts.toJSON();
2740
- e && Object.keys(e).length > 0 && (n.scripts = e);
2741
+ e && Object.keys(e).length > 0 && (t.scripts = e);
2741
2742
  }
2742
- this._isDate1904 && (n.date1904 = !0), this._locale && (n.locale = this._locale), this._localeOverrides && (n.localeOverrides = this._localeOverrides);
2743
- let i = e?.ignoreResources ?? !1, a = this._strings.beginPersist(), o = i ? null : this._resources.beginPersist(), s = this._styles.beginPersist();
2743
+ this._isDate1904 && (t.date1904 = !0), this._locale && (t.locale = this._locale), this._localeOverrides && (t.localeOverrides = this._localeOverrides);
2744
+ let r = e?.ignoreResources ?? !1, i = this._strings.beginPersist(), a = r ? null : this._resources.beginPersist(), o = this._styles.beginPersist();
2744
2745
  try {
2745
- let c = this._getSheetRef(this.getSelectedSheetIndex()).id, l = c, u = null, d = this._getState(), f = d.sheetRefsAll, p = d.sheetsById, m = f.length;
2746
- for (let r = 0; r < m; r++) {
2747
- let i = f[r], a = r + 1, o = await p.get(i.id).toJSON(e), s = {
2748
- name: i.name,
2749
- sheet: o
2746
+ let s = this._getSheetRef(this.getSelectedSheetIndex()).id, c = s, l = null, u = this._getState(), d = u.sheetRefsAll, f = u.sheetsById, p = d.length;
2747
+ for (let n = 0; n < p; n++) {
2748
+ let r = d[n], i = n + 1, a = await f.get(r.id).toJSON(e), o = {
2749
+ name: r.name,
2750
+ sheet: a
2750
2751
  };
2751
- i.visibility === t.Visibility.Visible ? u === null && (u = a) : s.visibility = i.visibility, i.id === c && (l = a), n.sheets.push(s);
2752
+ r.visibility === O.Visibility.Visible ? l === null && (l = i) : o.visibility = r.visibility, r.id === s && (c = i), t.sheets.push(o);
2752
2753
  }
2753
- if (!r) {
2754
- let e = s.toJSON();
2755
- e && Object.keys(e).length > 0 && (n.styles = e);
2754
+ if (!n) {
2755
+ let e = o.toJSON();
2756
+ e && Object.keys(e).length > 0 && (t.styles = e);
2756
2757
  }
2757
- let h = this.getProtection().toJSON();
2758
- h && (n.protection = h);
2759
- let g = await a.toJSONAsync();
2760
- g && g.length > 0 && (n.strings = g);
2758
+ let m = this.getProtection().toJSON();
2759
+ m && (t.protection = m);
2760
+ let h = this._calculation.toJSON();
2761
+ Object.keys(h).length > 0 && (t.calc = h);
2762
+ let g = await i.toJSONAsync();
2763
+ g && g.length > 0 && (t.strings = g);
2761
2764
  let _ = this._externalBooks.toJSON();
2762
- if (_ && (n.externalBooks = _), !i) {
2763
- let e = await o.toJSONAsync();
2764
- e && e.length > 0 && (n.resources = e);
2765
+ if (_ && (t.externalBooks = _), !r) {
2766
+ let e = await a.toJSONAsync();
2767
+ e && e.length > 0 && (t.resources = e);
2765
2768
  }
2766
2769
  let v = this._calculation.getNamedFormulas().toJSON();
2767
- v && v.length > 0 && (n.names = v);
2770
+ v && v.length > 0 && (t.names = v);
2768
2771
  let y = this._view.toJSON();
2769
- y && (l === u ? delete y.activeSheetId : y.activeSheetId = l, Object.keys(y).length > 0 && (n.view = y));
2772
+ y && (c === l ? delete y.activeSheetId : y.activeSheetId = c, Object.keys(y).length > 0 && (t.view = y));
2770
2773
  } finally {
2771
- s.endPersist(), i || o.endPersist(), a.endPersist();
2774
+ o.endPersist(), r || a.endPersist(), i.endPersist();
2772
2775
  }
2773
- return this._emitter.notify("onSave", { params: n }), n;
2776
+ return this._emitter.notify("onSave", { params: t }), t;
2774
2777
  }
2775
2778
  isClosed() {
2776
2779
  return this._closed;
@@ -2911,7 +2914,7 @@ var En, Dn, $ = class e extends he {
2911
2914
  }
2912
2915
  }, Mn = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Nn = class {
2913
2916
  constructor() {
2914
- this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new j(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
2917
+ this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new S(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
2915
2918
  }
2916
2919
  getBackingStore() {
2917
2920
  return this._backingStore ?? this._defaultStore;
@@ -2970,7 +2973,7 @@ var En, Dn, $ = class e extends he {
2970
2973
  search: i,
2971
2974
  ext: a
2972
2975
  }))[0];
2973
- if (!o) throw Error(`No read format available for '${i ?? a}' input.`);
2976
+ if (!o) throw new R(H("error.io.readFormatUnavailable", { format: i ?? a }));
2974
2977
  let s = n?.typedCreateWorkbookOptions, c = s ? Object.keys(s).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, l = {
2975
2978
  ...n,
2976
2979
  ...c === void 0 ? void 0 : s[c]
@@ -3031,7 +3034,10 @@ var En, Dn, $ = class e extends he {
3031
3034
  bytes: i,
3032
3035
  password: n.password
3033
3036
  };
3034
- if (!n?.onPassword) throw new vt(`'${t.getName() ?? "This file"}' is encrypted. Supply options.password or options.onPassword to open it.`);
3037
+ if (!n?.onPassword) {
3038
+ let e = t.getName();
3039
+ throw new vt(e ? H("error.io.passwordRequired", { name: e }) : H("error.io.passwordRequiredUnnamed"));
3040
+ }
3035
3041
  let o = await Promise.resolve(n.onPassword({
3036
3042
  origin: t,
3037
3043
  encryption: r.key,
@@ -3042,12 +3048,12 @@ var En, Dn, $ = class e extends he {
3042
3048
  bytes: i,
3043
3049
  password: o
3044
3050
  };
3045
- throw new ht();
3051
+ throw new ht(H("error.io.passwordIncorrect"));
3046
3052
  }
3047
3053
  async writeArrayBuffer(e, t) {
3048
3054
  if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3049
3055
  let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
3050
- if (!n) throw Error(`No write format available for '${t.format}'.`);
3056
+ if (!n) throw new R(H("error.io.writeFormatUnavailable", { format: t.format }));
3051
3057
  return this._writeArrayBuffer(e, n, t);
3052
3058
  }
3053
3059
  async write(e, t, n) {
@@ -3056,16 +3062,19 @@ var En, Dn, $ = class e extends he {
3056
3062
  let r = n, i = null;
3057
3063
  typeof t == "string" ? i = this.getOrigin(t) : Mn(t) ? i = t : t && (r = t);
3058
3064
  let a = !i, o = i ?? e.getOrigin(), s = o.getFormat(), c;
3059
- if ((r?.format || s) && (c = (await this._registry.getWriteFormats({ search: r?.format ?? s ?? void 0 }))[0]), c || o.getPath() && o.canWrite() && o.getExtension() || (c = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !c) throw Error("Unable to determine a write format. Specify options.format, or a destination with a known extension.");
3065
+ if ((r?.format || s) && (c = (await this._registry.getWriteFormats({ search: r?.format ?? s ?? void 0 }))[0]), c || o.getPath() && o.canWrite() && o.getExtension() || (c = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !c) throw new R(H("error.io.writeFormatUnresolved"));
3060
3066
  if (i && typeof t == "string") {
3061
3067
  let e = i.getPath();
3062
- e && !M(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3068
+ e && !x(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3063
3069
  }
3064
3070
  let l = o.getEncryption(), u = e.getOrigin?.(), d = (o instanceof U ? o.getPassword() : null) ?? (u instanceof U ? u.getPassword() : null), f = o.isEncrypted() || (u?.isEncrypted() ?? !1), p = r?.password === void 0 ? d ?? (f ? void 0 : null) : r.password, m = null;
3065
3071
  if (p === void 0) {
3066
- if (f) throw new vt(`'${o.getName() ?? "This file"}' is encrypted. Supply options.password to re-encrypt it, or options.password = null to write it without a password.`);
3067
- } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw Error("No encryption support is installed, so this workbook cannot be password protected.");
3068
- let h = `${o.getName() ?? "workbook"}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3072
+ if (f) {
3073
+ let e = o.getName();
3074
+ throw new vt(e ? H("error.io.passwordRequiredSave", { name: e }) : H("error.io.passwordRequiredSaveUnnamed"));
3075
+ }
3076
+ } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw new R(H("error.io.encryptionUnavailable"));
3077
+ let h = `${o.getName() ?? H("workbook.defaultName")}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3069
3078
  workbook: e,
3070
3079
  format: c,
3071
3080
  origin: o,
@@ -3098,7 +3107,7 @@ var En, Dn, $ = class e extends he {
3098
3107
  g?.onComplete && await Promise.resolve(g.onComplete(b));
3099
3108
  } catch (e) {
3100
3109
  let t = e instanceof Error ? e : Error(String(e));
3101
- throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), Error("Unable to write workbook.", { cause: e });
3110
+ throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), t instanceof R ? t : Error(H("error.io.writeFailed", { reason: t.message }), { cause: e });
3102
3111
  }
3103
3112
  return b;
3104
3113
  }
@@ -3106,7 +3115,7 @@ var En, Dn, $ = class e extends he {
3106
3115
  if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3107
3116
  let r = e?.getOrigin?.();
3108
3117
  if (!(r instanceof U)) return this.write(e, t, n);
3109
- let i = typeof t == "string" ? t : t.getPath(), a = i && M(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3118
+ let i = typeof t == "string" ? t : t.getPath(), a = i && x(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3110
3119
  path: r.getPath(),
3111
3120
  name: r.getName(),
3112
3121
  format: r.getFormat(),
@@ -3127,7 +3136,7 @@ var En, Dn, $ = class e extends he {
3127
3136
  return c;
3128
3137
  }
3129
3138
  _stripExtension(e) {
3130
- let t = M(e);
3139
+ let t = x(e);
3131
3140
  return t ? e.slice(0, e.length - t.length - 1) : e;
3132
3141
  }
3133
3142
  _baseName(e) {
@@ -3136,29 +3145,28 @@ var En, Dn, $ = class e extends he {
3136
3145
  return this._stripExtension(n) || null;
3137
3146
  }
3138
3147
  async _writeArrayBuffer(e, t, n) {
3139
- if (!t) throw Error(`Invalid write type for '${t}'.`);
3140
- try {
3141
- let r = t.handler;
3142
- if (!r) throw Error(`Unable to resolve handler for type: ${t.description ?? t}.`);
3143
- return r(e, {
3144
- ...n,
3145
- format: t.key
3146
- });
3147
- } catch (e) {
3148
- throw Error(`Unable to load handler for '${t}.'`, { cause: e });
3149
- }
3148
+ if (!t) throw Error("A write format must be provided.");
3149
+ let r = t.handler;
3150
+ if (!r) throw Error(`Unable to resolve a write handler for '${t.key}'.`);
3151
+ return r(e, {
3152
+ ...n,
3153
+ format: t.key
3154
+ });
3150
3155
  }
3151
3156
  async _readArrayBuffer(e, t, n) {
3152
3157
  if (!e) throw Error("ArrayBuffer must be specified.");
3153
3158
  if (!t) throw Error("format must be specified.");
3154
3159
  if (e.byteLength === 0) return new kn(n?.createWorkbookOptions);
3155
3160
  let r = t.handler;
3156
- if (!r) throw Error(`Unable to resolve handler for format type: ${t?.description ?? t}.`);
3161
+ if (!r) throw Error(`Unable to resolve a read handler for '${t.key}'.`);
3157
3162
  let i;
3158
3163
  try {
3159
3164
  i = await r(e, n);
3160
3165
  } catch (e) {
3161
- throw Error(`Unable to read ${t.description ?? t.key} — ${e?.message ?? String(e)}`, { cause: e });
3166
+ throw e instanceof R ? e : new R(H("error.io.readFailed", {
3167
+ format: t.description ?? t.key,
3168
+ reason: e?.message ?? String(e)
3169
+ }), { cause: e });
3162
3170
  }
3163
3171
  return i;
3164
3172
  }
@@ -3208,7 +3216,7 @@ function Vn(e = 6e4) {
3208
3216
  return new Date(Math.floor(Date.now() / e) * e);
3209
3217
  }
3210
3218
  zn ||= {};
3211
- var Hn = class extends Ce {
3219
+ var Hn = class extends Ge {
3212
3220
  constructor(e) {
3213
3221
  super(e);
3214
3222
  }
@@ -3224,5 +3232,5 @@ var Hn = class extends Ce {
3224
3232
  getRanges: (e) => null
3225
3233
  }, super._initializeOptions(e);
3226
3234
  }
3227
- }, Un = "0.7.28-beta.2", Wn = "Mon Aug 24 2026";
3228
- export { _e as AddressUtils, Fn as ArrayBackingStore, xe as AutoFill, Wn as BUILD_DATE, r as Color, Ke as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, Ee as GeomUtils, at as IAnchored, Be as IBorder, Ve as ICalculation, rt as ICell, Qt as ICellHeaderRange, Fe as ICellRange, Zt as ICellRanges, f as IColor, Te as ICondition, Qe as IConditionalFormat, Ue as IDataValidation, Lt as IEffect, N as IFill, A as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, t as ISheet, pe as ISheetView, Ft as ISort, It as IStroke, ne as IStyle, b as ITableStyle, i as IText, x as ITextFrame, Yt as ITheme, _ as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, g as LicenseManager, E as NumberFormat, hn as RangeClipboardItem, o as Registry, st as Resource, me as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, oe as SYSTEM_COLOR_CSS_PREFIX, O as Sheet, Ot as SimpleFontFace, et as Sort, lt as StringCollection, ot as StyleCollection, Hn as Table, ue as TextRotation, it as TextUtils, u as Theme, p as ThemeCollection, ie as TransactionConflictError, St as TransactionSaveStateManager, c as TransactionStore, xt as TransactionUndoManager, nt as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, tt as createCellRangeCounts, tn as getBuiltInFunctionNames, fe as getLanguagePack, De as getLocaleProfile, He as localizeBoolean, Ze as localizeErrorLabel, we as makeLocaleProfile, ge as parseBooleanLocal, Pe as parseErrorLocal, nn as parseFormulaLiteral, Ae as registerSdkLocales };
3235
+ }, Un = "0.7.28-beta.4", Wn = "Wed Aug 26 2026";
3236
+ export { Fe as AddressUtils, Fn as ArrayBackingStore, Se as AutoFill, Wn as BUILD_DATE, w as Color, Re as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, De as GeomUtils, lt as IAnchored, Je as IBorder, Ye as ICalculation, xe as ICell, Qt as ICellHeaderRange, nt as ICellRange, Zt as ICellRanges, C as IColor, de as ICondition, ve as IConditionalFormat, Qe as IDataValidation, Lt as IEffect, i as IFill, k as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, O as ISheet, He as ISheetView, Ft as ISort, It as IStroke, ut as IStyle, d as ITableStyle, at as IText, a as ITextFrame, Yt as ITheme, re as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, Ke as LicenseManager, M as NumberFormat, hn as RangeClipboardItem, ee as Registry, ie as Resource, st as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, p as SYSTEM_COLOR_CSS_PREFIX, A as Sheet, Ot as SimpleFontFace, Be as Sort, he as StringCollection, ae as StyleCollection, Hn as Table, rt as TextRotation, ct as TextUtils, m as Theme, g as ThemeCollection, l as TransactionConflictError, St as TransactionSaveStateManager, s as TransactionStore, xt as TransactionUndoManager, be as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, et as createCellRangeCounts, tn as getBuiltInFunctionNames, Ve as getLanguagePack, Te as getLocaleProfile, Ze as localizeBoolean, _e as localizeErrorLabel, ue as makeLocaleProfile, Pe as parseBooleanLocal, tt as parseErrorLocal, nn as parseFormulaLiteral, fe as registerSdkLocales };