@sheetxl/io-xlsx 0.8.0-beta.1 → 0.8.0-beta.3

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 (88) hide show
  1. package/browser/cjs/BGFXHa9DqD7qfj7K.cjs +5 -0
  2. package/browser/cjs/C8oC1tPbhgR0Dqtx.cjs +2 -0
  3. package/browser/cjs/CIQ0CyhkW02G7UhX.cjs +1 -0
  4. package/browser/cjs/{D5Y4KQhKdukOkjvA.cjs → D3EWCPfCu-qMOIGd.cjs} +1 -2
  5. package/browser/cjs/{BAtEL-5TLyoaPFDP.cjs → DULsYP_GcPGLVYSE.cjs} +10 -1
  6. package/browser/cjs/DtBN3UOzNJjYBwJ6.cjs +1 -0
  7. package/browser/cjs/index.cjs +1 -1
  8. package/browser/cjs/sNZR19Wk-XQ2xZ9E.cjs +1 -0
  9. package/browser/esm/{BkNXyG6NC-w5Xo92.mjs → 9kAH9485xCkOzN_I.mjs} +28 -13
  10. package/browser/esm/{Cok_fBIUCHDSrKw0.mjs → B8BqrWUHPa06PzmO.mjs} +446 -347
  11. package/browser/esm/{Dj7D2nVdAZ3TiUks.mjs → BdmxnPd0ptyqOCaM.mjs} +1595 -1124
  12. package/browser/esm/BzlhIt5zSG0Ts4xd.mjs +3324 -0
  13. package/browser/esm/CED9M7CASY6R5LBH.mjs +159 -0
  14. package/browser/esm/{4BWLu134ABlCQEtM.mjs → DNwAYvPHH1G27K-w.mjs} +1824 -1051
  15. package/browser/esm/{ijQzHH-bvDfUHIi1.mjs → DbSKfjIyE4a1YHoX.mjs} +1 -1
  16. package/browser/esm/{Dz1Dp8DDJvhd09RR.mjs → DtypWHI_cwfAvvyR.mjs} +1 -1
  17. package/browser/esm/PpS5wqbPAZ9D3W7c.mjs +67 -0
  18. package/browser/esm/{Ctqql4O-3xj2K8vv.mjs → aL7oQqItresvrEf2.mjs} +2 -2
  19. package/browser/esm/{CLWzJJyoSrykkVLX.mjs → h9ucGRwzGRA2N44D.mjs} +2 -2
  20. package/browser/esm/index.mjs +3 -3
  21. package/node/esm/{fOnuUjpPCAzmuIXN.mjs → A5sK8gK9ymQOyChG.mjs} +2 -2
  22. package/node/esm/CCD1vEduHhKax_d_.mjs +170 -0
  23. package/node/esm/{CF1R5ovFsRNu--Rw.mjs → CJGTDWKH_yrWAW8o.mjs} +1934 -1143
  24. package/node/esm/{CEAmv36xpTNgFwl_.mjs → CsTuNxyS02vBz0Tk.mjs} +49 -35
  25. package/node/esm/{Ctcl4jN52INWpKWC.mjs → DOXXVsfrZi_6L0V7.mjs} +607 -506
  26. package/node/esm/OkoETXoPSSH3gQxa.mjs +2959 -0
  27. package/node/esm/TERvDGVSsvCefEiX.mjs +3410 -0
  28. package/node/esm/index.mjs +40 -25
  29. package/node/esm/{CEV7nKotMpeRRnQC.mjs → mlCt7xhd97xcwrEr.mjs} +1 -1
  30. package/package.json +3 -3
  31. package/types/src/ConditionalFormatRules.d.ts +3 -3
  32. package/types/src/DataValidationRules.d.ts +18 -2
  33. package/types/src/ExcelCalcStamp.d.ts +39 -0
  34. package/types/src/ExcelCompat.d.ts +197 -42
  35. package/types/src/LegacyFormula.d.ts +28 -7
  36. package/types/src/Plugin.d.ts +16 -5
  37. package/types/src/ProtectionAttributes.d.ts +38 -0
  38. package/types/src/SourcePackage.d.ts +31 -12
  39. package/types/src/Types.d.ts +17 -0
  40. package/types/src/reader/HiddenFormulas.d.ts +16 -0
  41. package/types/src/reader/Warning.d.ts +29 -0
  42. package/types/src/reader/dom/DOMTransformer.d.ts +1 -1
  43. package/types/src/reader/dom/ExecutionContext.d.ts +16 -3
  44. package/types/src/reader/dom/Types.d.ts +19 -3
  45. package/types/src/reader/domVisitors/CommentVisitor.d.ts +18 -1
  46. package/types/src/reader/domVisitors/CommentsVisitor.d.ts +2 -2
  47. package/types/src/reader/domVisitors/ExternalLinkVisitor.d.ts +21 -3
  48. package/types/src/reader/domVisitors/SheetColorContainerVisitor.d.ts +2 -2
  49. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +6 -1
  50. package/types/src/reader/domVisitors/ThreadedCommentVisitor.d.ts +9 -1
  51. package/types/src/reader/domVisitors/ThreadedCommentsVisitor.d.ts +2 -2
  52. package/types/src/reader/domVisitors/WorkbookVisitor.d.ts +11 -1
  53. package/types/src/reader/sax/LeanSaxParser.d.ts +58 -0
  54. package/types/src/reader/sax/SaxParser.d.ts +11 -1
  55. package/types/src/reader/sax/SaxVisitor.d.ts +3 -2
  56. package/types/src/reader/saxVisitors/ContentTypesVisitor.d.ts +9 -0
  57. package/types/src/reader/saxVisitors/WorksheetVisitor.d.ts +11 -4
  58. package/types/src/utils/VmlNoteShapes.d.ts +75 -0
  59. package/types/src/vba/VBAProject.d.ts +52 -4
  60. package/types/src/writer/builder/ContentTypes.d.ts +13 -0
  61. package/types/src/writer/builder/Emitter.d.ts +6 -6
  62. package/types/src/writer/builder/OpcXmlUtils.d.ts +2 -0
  63. package/types/src/writer/builder/PackageBuilder.d.ts +70 -22
  64. package/types/src/writer/builder/PartWriter.d.ts +5 -0
  65. package/types/src/writer/builder/RelationshipSet.d.ts +3 -0
  66. package/types/src/writer/builder/Types.d.ts +107 -38
  67. package/types/src/writer/builder/_Types.d.ts +17 -0
  68. package/types/src/writer/emitters/CommentsEmitter.d.ts +52 -0
  69. package/types/src/writer/emitters/EmbeddedPartEmitter.d.ts +60 -0
  70. package/types/src/writer/emitters/ExternalLinkEmitter.d.ts +19 -0
  71. package/types/src/writer/emitters/LegacyDrawingEmitter.d.ts +18 -0
  72. package/types/src/writer/emitters/PersonsEmitter.d.ts +17 -0
  73. package/types/src/writer/emitters/PivotTableEmitter.d.ts +45 -0
  74. package/types/src/writer/emitters/ThreadedCommentsEmitter.d.ts +21 -0
  75. package/types/src/writer/emitters/WorkbookEmitter.d.ts +16 -3
  76. package/types/src/writer/utils/DrawMLUtils.d.ts +16 -1
  77. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +28 -0
  78. package/browser/cjs/Bg0e53JZa8vhmm5a.cjs +0 -1
  79. package/browser/cjs/CK5FFUvet6FnIYO_.cjs +0 -5
  80. package/browser/cjs/DV6LeTEiiFUrZoxj.cjs +0 -1
  81. package/browser/cjs/DWkuoJSgvcXJTdN1.cjs +0 -1
  82. package/browser/cjs/Db8YjGM6TG34c8aT.cjs +0 -1
  83. package/browser/esm/BzQ_lPzc8C4OTIGZ.mjs +0 -99
  84. package/browser/esm/CJknI8BYGSZr-4zS.mjs +0 -52
  85. package/browser/esm/D-m_kQLaewdwuXaF.mjs +0 -2685
  86. package/node/esm/CvnRSooxEQdlJgMn.mjs +0 -2766
  87. package/node/esm/DQd0vxzTaPt2qSL-.mjs +0 -108
  88. package/node/esm/ssSlRCbCqxvZ9IX8.mjs +0 -2481
@@ -1,42 +1,42 @@
1
1
  /**
2
- * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.1
2
+ * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.3
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 "./CJknI8BYGSZr-4zS.mjs";
8
- import { D as e, E as t, F as n, H as r, I as i, K as a, L as o, M as s, N as c, O as l, P as u, U as d, _ as f, a as p, b as m, f as h, g, h as _, i as v, k as y, l as b, n as x, s as S, u as ee, w as C, z as w } from "./Dj7D2nVdAZ3TiUks.mjs";
9
- import { AddressUtils as T, BufferUtils as E, Color as te, CommonUtils as D, CoordUtils as O, FormulaError as ne, IColor as k, ICondition as A, IConditionalFormat as j, IEffect as M, IFill as N, ISheet as P, IStroke as F, IStyle as I, ITextFrame as L, LicenseManager as re, NumberFormat as R, ScalarType as z } from "@sheetxl/sdk";
10
- var B = class {
7
+ import "./PpS5wqbPAZ9D3W7c.mjs";
8
+ import { $ as e, A as t, C as n, E as r, G as i, J as a, L as o, P as s, Q as c, R as l, S as u, U as d, W as f, X as p, Y as m, Z as h, _ as g, a as _, at as v, b as y, c as b, ct as x, f as S, h as C, i as w, it as T, j as E, k as D, l as O, m as ee, n as k, o as A, r as j, s as te, t as M, tt as ne, u as re, w as ie, y as N } from "./BdmxnPd0ptyqOCaM.mjs";
9
+ import { AddressUtils as P, BufferUtils as F, Color as ae, CommonUtils as I, CoordUtils as oe, FormulaError as se, FormulaText as ce, IColor as L, ICondition as R, IConditionalFormat as z, IEffect as le, IFill as B, ISheet as ue, IStroke as de, IStyle as V, ITextFrame as H, LicenseManager as fe, NumberFormat as pe, ScalarType as me } from "@sheetxl/sdk";
10
+ var he = "resourcesById", U = class {
11
11
  constructor(e) {
12
12
  this._kind = e.kind, this._contentType = e.contentType, this._relTypeUri = e.relTypeUri, this._path = e.path;
13
13
  }
14
- get kind() {
14
+ getKind() {
15
15
  return this._kind;
16
16
  }
17
- get contentType() {
17
+ getContentType(e) {
18
18
  return this._contentType;
19
19
  }
20
- get relTypeUri() {
20
+ getRelTypeUri(e) {
21
21
  return this._relTypeUri;
22
22
  }
23
23
  getPath(e) {
24
24
  return typeof this._path == "function" ? this._path(e) : this._path;
25
25
  }
26
- }, ie = class e {
26
+ }, ge = class e {
27
27
  constructor(e, t, n) {
28
28
  this.zipWriter = e, this.outputKind = t, this.outWritable = n;
29
29
  }
30
30
  static createUint8Array(t) {
31
- let r = new y(new n(), t);
32
- return new e(r, "uint8array");
31
+ let n = new i(new h(), t);
32
+ return new e(n, "uint8array");
33
33
  }
34
34
  static createBlob(t) {
35
- let n = new y(new s("application/zip"), t);
35
+ let n = new i(new a("application/zip"), t);
36
36
  return new e(n, "blob");
37
37
  }
38
38
  static createWritableStream(t, n) {
39
- let r = new y(t, n);
39
+ let r = new i(t, n);
40
40
  return new e(r, "writable", t);
41
41
  }
42
42
  async add(e, t, n) {
@@ -57,10 +57,10 @@ var B = class {
57
57
  compressionMethod: n?.compressionMethod,
58
58
  signature: n?.signature
59
59
  };
60
- if (typeof t == "string") return void await this.zipWriter.add(r, new c(t), i);
60
+ if (typeof t == "string") return void await this.zipWriter.add(r, new m(t), i);
61
61
  if (t instanceof Uint8Array || ArrayBuffer.isView(t) || t && typeof t.byteLength == "number" && typeof t.byteOffset == "number") {
62
62
  try {
63
- await this.zipWriter.add(r, new u(t), i);
63
+ await this.zipWriter.add(r, new p(t), i);
64
64
  } catch (e) {
65
65
  throw console.log("Error adding Uint8Array source to zip:", r, i), e;
66
66
  }
@@ -88,7 +88,7 @@ var B = class {
88
88
  return this.outputKind === "writable" ? this.outWritable ?? n : n;
89
89
  }
90
90
  };
91
- function ae(e) {
91
+ function _e(e) {
92
92
  let t = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), n = (e) => t(e).replace(/"/g, "&quot;"), r = (e) => {
93
93
  if (!e) return "";
94
94
  let t = "";
@@ -149,13 +149,13 @@ function ae(e) {
149
149
  }
150
150
  };
151
151
  }
152
- function oe(e) {
152
+ function ve(e) {
153
153
  switch (e.kind) {
154
154
  case "bytes": return e.bytes;
155
155
  case "text": return e.text;
156
156
  case "stream": return e.stream;
157
157
  case "xmlStream": {
158
- let t = [], n = ae({ write: (e) => t.push(e) });
158
+ let t = [], n = _e({ write: (e) => t.push(e) });
159
159
  return e.writeXml(n), n.close(), function(e) {
160
160
  let t = 0;
161
161
  for (let n of e) t += n.byteLength;
@@ -167,32 +167,36 @@ function oe(e) {
167
167
  case "xmlStreamed": return e.write();
168
168
  }
169
169
  }
170
- function se(e) {
171
- let t = V(e);
170
+ function ye(e) {
171
+ let t = be(e);
172
172
  if (!t) return "_rels/.rels";
173
173
  let n = t.lastIndexOf("/"), r = n >= 0 ? t.slice(0, n) : "";
174
174
  return `${r ? `${r}/_rels` : "_rels"}/${n >= 0 ? t.slice(n + 1) : t}.rels`;
175
175
  }
176
- function V(e) {
176
+ function be(e) {
177
177
  let t = (e ?? "").replace(/\\/g, "/").trim();
178
178
  for (; t.startsWith("/");) t = t.slice(1);
179
179
  return t;
180
180
  }
181
- function ce(e) {
181
+ function xe(e) {
182
+ let t = (e ?? "").replace(/\\/g, "/").trim();
183
+ return t.startsWith("/") || (t = "/" + t), t;
184
+ }
185
+ function Se(e) {
182
186
  let t = /^rId(\d+)$/.exec(e);
183
187
  return t ? parseInt(t[1], 10) : 2 ** 53 - 1;
184
188
  }
185
- function H(e) {
189
+ function W(e) {
186
190
  return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;").replace(/>/g, "&gt;");
187
191
  }
188
- function le(e, t, n, r = !1) {
192
+ function Ce(e, t, n, r = !1) {
189
193
  let i = t;
190
194
  if (t.startsWith("/")) i = t.slice(1);
191
195
  else {
192
196
  if (!e) throw Error(`Relative path "${t}" cannot be used at root level. Use an absolute path starting with "/" (e.g., "/xl/workbook.xml").`);
193
197
  i = (e.includes("/") ? e.slice(0, e.lastIndexOf("/") + 1) : "") + t;
194
198
  }
195
- if (i = ue(i), !i.includes("{n}")) {
199
+ if (i = we(i), !i.includes("{n}")) {
196
200
  if (!r && n.has(i)) throw Error(`Path already existing path: ${i}`);
197
201
  return i;
198
202
  }
@@ -202,7 +206,7 @@ function le(e, t, n, r = !1) {
202
206
  while (n.has(a));
203
207
  return a;
204
208
  }
205
- function ue(e) {
209
+ function we(e) {
206
210
  let t = e.split("/"), n = [];
207
211
  for (let r of t) if (r !== "" && r !== ".") if (r === "..") {
208
212
  if (n.length === 0) throw Error(`Invalid path: too many ".." segments in "${e}"`);
@@ -210,17 +214,17 @@ function ue(e) {
210
214
  } else n.push(r);
211
215
  return n.join("/");
212
216
  }
213
- function de(e, t) {
217
+ function Te(e, t) {
214
218
  if (!e) return t;
215
219
  let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = n ? n.split("/") : [], i = t.split("/"), a = 0, o = Math.min(r.length, i.length - 1);
216
220
  for (let e = 0; e < o && r[e] === i[e]; e++) a++;
217
221
  let s = r.length - a;
218
222
  return "../".repeat(s) + i.slice(a).join("/");
219
223
  }
220
- function fe(e) {
224
+ function Ee(e) {
221
225
  return new TextEncoder().encode(e);
222
226
  }
223
- function pe(e, t) {
227
+ function De(e, t) {
224
228
  return function(e, t = " ") {
225
229
  let n = "", r = 0, i = e.split(/(<[^>]+>)/g).filter(Boolean);
226
230
  for (let e = 0; e < i.length; e++) {
@@ -237,46 +241,15 @@ function pe(e, t) {
237
241
  return new TextDecoder("utf-8").decode(e);
238
242
  }(e), t);
239
243
  }
240
- var me = /&(amp|lt|gt|quot|apos|#x[0-9a-fA-F]+|#[0-9]+);/g;
241
- function he(e, t) {
242
- switch (t) {
243
- case "amp": return "&";
244
- case "lt": return "<";
245
- case "gt": return ">";
246
- case "quot": return "\"";
247
- case "apos": return "'";
248
- default: return t.startsWith("#x") ? String.fromCodePoint(parseInt(t.slice(2), 16)) : t.startsWith("#") ? String.fromCodePoint(parseInt(t.slice(1), 10)) : e;
249
- }
250
- }
251
- function ge(e) {
252
- return e.replace(me, he);
253
- }
254
- function _e(e) {
255
- let t = {}, n = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*"([^"]*)"/g, r;
256
- for (; r = n.exec(e);) t[r[1]] = ge(r[2]);
257
- return t;
258
- }
259
- function ve(e, t) {
260
- let n = [], r = RegExp(`<${t}\\b([^>]*)/?>`, "g"), i;
261
- for (; i = r.exec(e);) n.push(_e(i[1]));
262
- return n;
263
- }
264
- function ye(e) {
265
- return ve(new TextDecoder("utf-8").decode(e), "Relationship").filter((e) => e.Type && e.Target).map((e) => ({
266
- type: e.Type,
267
- target: e.Target,
268
- external: e.TargetMode === "External"
269
- }));
270
- }
271
- var be = class {
244
+ var Oe = class {
272
245
  constructor(e) {
273
- this.rels = [], this.usedIds = /* @__PURE__ */ new Set(), this.nextId = 1, this.sourcePart = V(e);
246
+ this.rels = [], this.usedIds = /* @__PURE__ */ new Set(), this.reservedIds = /* @__PURE__ */ new Set(), this.nextId = 1, this.sourcePart = be(e);
274
247
  }
275
248
  add(e, t, n) {
276
249
  let r = n?.idHint && !this.usedIds.has(n.idHint) ? n.idHint : void 0;
277
250
  if (!r) do
278
251
  r = "rId" + this.nextId++;
279
- while (this.usedIds.has(r));
252
+ while (this.usedIds.has(r) || this.reservedIds.has(r));
280
253
  let i = /^rId(\d+)$/.exec(r);
281
254
  return i && (this.nextId = Math.max(this.nextId, parseInt(i[1], 10) + 1)), this.usedIds.add(r), this.rels.push({
282
255
  id: r,
@@ -285,23 +258,31 @@ var be = class {
285
258
  targetMode: n?.external ? "External" : void 0
286
259
  }), r;
287
260
  }
261
+ reserve(e) {
262
+ for (let t of e) {
263
+ if (!t) continue;
264
+ this.reservedIds.add(t);
265
+ let e = /^rId(\d+)$/.exec(t);
266
+ e && (this.nextId = Math.max(this.nextId, parseInt(e[1], 10) + 1));
267
+ }
268
+ }
288
269
  list() {
289
270
  return this.rels;
290
271
  }
291
272
  toXmlBytes() {
292
- let e = [...this.rels].sort((e, t) => ce(t.id) - ce(e.id) || e.id.localeCompare(t.id)), t = [];
293
- t.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), t.push(`<Relationships xmlns="${xe}">`);
273
+ let e = [...this.rels].sort((e, t) => Se(t.id) - Se(e.id) || e.id.localeCompare(t.id)), t = [];
274
+ t.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), t.push(`<Relationships xmlns="${ke}">`);
294
275
  for (let n of e) {
295
276
  let e = [
296
- `Id="${H(n.id)}"`,
297
- `Type="${H(n.type)}"`,
298
- `Target="${H(n.target)}"`
277
+ `Id="${W(n.id)}"`,
278
+ `Type="${W(n.type)}"`,
279
+ `Target="${W(n.target)}"`
299
280
  ];
300
281
  n.targetMode === "External" && e.push("TargetMode=\"External\""), t.push(`<Relationship ${e.join(" ")}/>`);
301
282
  }
302
- return t.push("</Relationships>"), fe(t.join(""));
283
+ return t.push("</Relationships>"), Ee(t.join(""));
303
284
  }
304
- }, xe = "http://schemas.openxmlformats.org/package/2006/relationships", Se = class {
285
+ }, ke = "http://schemas.openxmlformats.org/package/2006/relationships", Ae = class {
305
286
  constructor() {
306
287
  this._defaultsSet = /* @__PURE__ */ new Set(), this._overridesSet = /* @__PURE__ */ new Set(), this._defaults = [], this._overrides = [];
307
288
  }
@@ -316,38 +297,44 @@ var be = class {
316
297
  }));
317
298
  }
318
299
  addOverride(e, t) {
319
- let n = function(e) {
320
- let t = (e ?? "").replace(/\\/g, "/").trim();
321
- return t.startsWith("/") || (t = "/" + t), t;
322
- }(e);
300
+ let n = xe(e);
323
301
  this._overridesSet.has(n) || (this._overridesSet.add(n), this._overrides.push({
324
302
  key: n,
325
303
  content: t
326
304
  }));
327
305
  }
306
+ replaceOverride(e, t) {
307
+ let n = xe(e);
308
+ if (!this._overridesSet.has(n)) return;
309
+ let r = this._overrides.find((e) => e.key === n);
310
+ r && (r.content = t);
311
+ }
328
312
  toXmlBytes() {
329
313
  let e = [];
330
- e.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), e.push(`<Types xmlns="${Ce}">`);
314
+ e.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"), e.push(`<Types xmlns="${je}">`);
331
315
  let t = this._defaults.reverse();
332
316
  this.addDefault("rels", "application/vnd.openxmlformats-package.relationships+xml"), this.addDefault("xml", "application/xml");
333
- for (let { key: n, content: r } of t) e.push(`<Default Extension="${H(n)}" ContentType="${H(r)}"/>`);
317
+ for (let { key: n, content: r } of t) e.push(`<Default Extension="${W(n)}" ContentType="${W(r)}"/>`);
334
318
  let n = this._overrides;
335
- for (let { key: t, content: r } of n) e.push(`<Override PartName="${H(t)}" ContentType="${H(r)}"/>`);
336
- return e.push("</Types>"), fe(e.join(""));
319
+ for (let { key: t, content: r } of n) e.push(`<Override PartName="${W(t)}" ContentType="${W(r)}"/>`);
320
+ return e.push("</Types>"), Ee(e.join(""));
337
321
  }
338
- }, Ce = "http://schemas.openxmlformats.org/package/2006/content-types", we = class {
322
+ }, je = "http://schemas.openxmlformats.org/package/2006/content-types", Me = class {
339
323
  constructor(e) {
340
- this.parts = [], this.relsRoot = new be(""), this.relsByPart = /* @__PURE__ */ new Map(), this.contentTypes = new Se(), this.zip = e;
324
+ this.parts = [], this.relsRoot = new Oe(""), this.relsByPart = /* @__PURE__ */ new Map(), this.contentTypes = new Ae(), this.zip = e;
341
325
  }
342
326
  addContentType(e, t) {
343
- let n = V(e);
327
+ let n = be(e);
344
328
  this.contentTypes.addOverride("/" + n, t);
345
329
  }
346
330
  addDefaultType(e, t) {
347
331
  this.contentTypes.addDefault(e, t);
348
332
  }
333
+ replaceContentType(e, t) {
334
+ this.contentTypes.replaceOverride("/" + be(e), t);
335
+ }
349
336
  addPart(e, t, n, r) {
350
- let i = V(e);
337
+ let i = be(e);
351
338
  this.parts.push({
352
339
  path: i,
353
340
  body: t,
@@ -355,22 +342,22 @@ var be = class {
355
342
  }), n && this.contentTypes.addOverride("/" + i, n);
356
343
  }
357
344
  rels(e) {
358
- let t = V(e || "");
345
+ let t = be(e || "");
359
346
  if (!t) return this.relsRoot;
360
347
  let n = this.relsByPart.get(t);
361
- return n || (n = new be(t), this.relsByPart.set(t, n)), n;
348
+ return n || (n = new Oe(t), this.relsByPart.set(t, n)), n;
362
349
  }
363
350
  async emit() {
364
351
  let e = [...this.parts].sort((e, t) => e.path.localeCompare(t.path));
365
352
  for (let t of e) {
366
- let e = oe(t.body);
353
+ let e = ve(t.body);
367
354
  await this.zip.add(t.path, e, t.optionsZip);
368
355
  }
369
356
  let t = this.relsRoot.toXmlBytes();
370
357
  await this.zip.add("_rels/.rels", t, {});
371
358
  let n = [...this.relsByPart.values()].sort((e, t) => e.sourcePart.localeCompare(t.sourcePart));
372
359
  for (let e of n) {
373
- let t = se(e.sourcePart), n = e.toXmlBytes();
360
+ let t = ye(e.sourcePart), n = e.toXmlBytes();
374
361
  await this.zip.add(t, n, {});
375
362
  }
376
363
  let r = this.contentTypes.toXmlBytes();
@@ -379,31 +366,39 @@ var be = class {
379
366
  async build(e) {
380
367
  return await this.emit(), await this.zip.close(e);
381
368
  }
382
- }, Te = /* @__PURE__ */ new Set(["xl/calcChain.xml"]), Ee = [
383
- /^xl\/drawings\/vmlDrawing\d+\.vml$/i,
384
- /^xl\/ctrlProps\//i,
385
- /^xl\/slicers\//i,
386
- /^xl\/slicerCaches\//i,
387
- /^xl\/pivotCache\//i,
388
- /^xl\/pivotTables\//i
389
- ];
390
- function De(e) {
391
- return Ee.some((t) => t.test(e));
392
- }
393
- function Oe(e) {
394
- return e === "[Content_Types].xml" || ke.test(e);
369
+ }, Ne = /* @__PURE__ */ new Set(["xl/calcChain.xml"]), Pe = [/^xl\/slicers\//i, /^xl\/slicerCaches\//i];
370
+ function Fe(e) {
371
+ return e === "[Content_Types].xml" || Ie.test(e);
395
372
  }
396
- var ke = /^(?:(.*)\/)?_rels\/(.*)\.rels$/;
397
- function Ae(e) {
373
+ var Ie = /^(?:(.*)\/)?_rels\/(.*)\.rels$/;
374
+ function Le(e) {
398
375
  if (e === "_rels/.rels") return "";
399
- let t = ke.exec(e);
376
+ let t = Ie.exec(e);
400
377
  if (!t) return null;
401
378
  let n = t[1] ?? "", r = t[2];
402
379
  return n ? `${n}/${r}` : r;
403
380
  }
404
- var je = class {
381
+ function Re(e) {
382
+ return e.startsWith("#");
383
+ }
384
+ function ze(e, t) {
385
+ if (t.startsWith("/")) return we(t);
386
+ let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
387
+ return we((n ? n + "/" : "") + t);
388
+ }
389
+ var Be = class {
405
390
  constructor(e, t, n) {
406
- this._queue = [], this._scheduledByNodeKey = /* @__PURE__ */ new Map(), this._nodesByPath = /* @__PURE__ */ new Map(), this._writtenPaths = /* @__PURE__ */ new Set(), this._explicitRelTargets = /* @__PURE__ */ new Set(), this._partWriter = new we(e), this._registry = t, this._options = n ?? {}, this._mapState = this._options.mapState ?? /* @__PURE__ */ new Map(), this._sourcePackage = this._options.sourcePackage ?? null;
391
+ this._queue = [], this._scheduledByNodeKey = /* @__PURE__ */ new Map(), this._nodesByPath = /* @__PURE__ */ new Map(), this._writtenPaths = /* @__PURE__ */ new Set(), this._explicitRelTargets = /* @__PURE__ */ new Set(), this._partWriter = new Me(e), this._registry = t, this._options = n ?? {}, this._mapState = this._options.mapState ?? /* @__PURE__ */ new Map(), this._sourcePackage = this._options.sourcePackage ?? null, this._macroEnabled = this._options.macroEnabled ?? !1, this._reserveSourceRelIds("");
392
+ }
393
+ _isSourcePartCarried(e) {
394
+ let t = this._sourcePackage;
395
+ return !(!t || !t.has(e)) && !Ne.has(e) && !t.isAbsorbed(e) && !(!this._macroEnabled && e === "xl/vbaProject.bin") && !Fe(e) && (!t.hasStructuralChange() || !function(e) {
396
+ return Pe.some((t) => t.test(e));
397
+ }(e));
398
+ }
399
+ _reserveSourceRelIds(e) {
400
+ let t = this._sourcePackage?.getPart(ye(e));
401
+ t && this._partWriter.rels(e).reserve(f(t.data).map((e) => e.id));
407
402
  }
408
403
  async waitEmit() {
409
404
  let e = this._queue;
@@ -413,29 +408,19 @@ var je = class {
413
408
  }
414
409
  }
415
410
  async build(e) {
416
- return await this.waitEmit(), this._passthroughSourceParts(), await this._partWriter.build(e ?? {});
411
+ return await this.waitEmit(), this._passthroughSourceParts(), this._applyWorkbookContentTypeVariant(), await this._partWriter.build(e ?? {});
417
412
  }
418
413
  _passthroughSourceParts() {
419
414
  let e = this._sourcePackage;
420
415
  if (!e) return;
421
- let t = new Set(this._writtenPaths), n = e.hasStructuralChange(), r = [];
422
- for (let i of e.getNames()) t.has(i) || Te.has(i) || Oe(i) || n && De(i) || r.push(i);
423
- let i = new Set(t);
424
- for (let e of r) i.add(e);
425
- let a = e.getPart("[Content_Types].xml"), o = a ? function(e) {
426
- let t = new TextDecoder("utf-8").decode(e), n = ve(t, "Default").map((e) => ({
427
- ext: (e.Extension ?? "").toLowerCase(),
428
- contentType: e.ContentType ?? ""
429
- })).filter((e) => e.ext && e.contentType), r = /* @__PURE__ */ new Map();
430
- for (let e of ve(t, "Override")) e.PartName && e.ContentType && r.set(e.PartName, e.ContentType);
431
- return {
432
- defaults: n,
433
- overrides: r
434
- };
435
- }(a.data) : null;
436
- if (o) for (let { ext: e, contentType: t } of o.defaults) this._partWriter.addDefaultType(e, t);
437
- for (let t of r) {
438
- let n = e.getPart(t), r = o?.overrides.get("/" + t);
416
+ let t = new Set(this._writtenPaths), n = [];
417
+ for (let r of e.getNames()) t.has(r) || this._isSourcePartCarried(r) && n.push(r);
418
+ let r = new Set(t);
419
+ for (let e of n) r.add(e);
420
+ let i = e.getPart("[Content_Types].xml"), a = i ? d(i.data) : null;
421
+ if (a) for (let { ext: e, contentType: t } of a.defaults) this._partWriter.addDefaultType(e, t);
422
+ for (let t of n) {
423
+ let n = e.getPart(t), r = a?.overrides.get("/" + t);
439
424
  n.raw ? this._partWriter.addPart(t, {
440
425
  kind: "bytes",
441
426
  bytes: n.raw.compressedData
@@ -450,100 +435,92 @@ var je = class {
450
435
  }, r), this._writtenPaths.add(t);
451
436
  }
452
437
  for (let n of e.getNames()) {
453
- if (n === "[Content_Types].xml" || !Oe(n)) continue;
454
- let r = Ae(n);
455
- r !== null && (r === "" || i.has(r)) && this._mergeSourceRelsInto(r, e.getPart(n).data, t, i);
438
+ if (n === "[Content_Types].xml" || !Fe(n)) continue;
439
+ let i = Le(n);
440
+ i !== null && (i === "" || r.has(i)) && (e.isAbsorbed(i) || this._mergeSourceRelsInto(i, e.getPart(n).data, t, r));
456
441
  }
457
442
  }
443
+ _applyWorkbookContentTypeVariant() {
444
+ this._macroEnabled && this._partWriter.replaceContentType("xl/workbook.xml", "application/vnd.ms-excel.sheet.macroEnabled.main+xml");
445
+ }
458
446
  _mergeSourceRelsInto(e, t, n, r) {
459
- let i = this._partWriter.rels(e), a = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
460
- for (let o of ye(t)) {
461
- if (o.external) {
462
- i.add(o.type, o.target, { external: !0 });
447
+ let i = this._partWriter.rels(e), a = e === "" || n.has(e);
448
+ for (let o of f(t)) {
449
+ if (o.external || Re(o.target)) {
450
+ i.add(o.type, o.target, {
451
+ external: o.external,
452
+ idHint: o.id
453
+ });
463
454
  continue;
464
455
  }
465
- let t = ue((a ? a + "/" : "") + o.target);
466
- n.has(t) || this._explicitRelTargets.has(`${e}::${t}`) || (r.has(t) ? i.add(o.type, o.target) : this._registry.ownsRelType(o.type) || console.warn(`Dropping preserved relationship to missing part '${t}'`, e || "(root)"));
467
- }
468
- }
469
- addPart(e, t, n) {
470
- return this._addPartInternal("", e, t, n);
471
- }
472
- _addPartInternal(e, t, n, r) {
473
- let i = this._registry.get(t);
474
- if (!i) throw Error(`No emitter registered for kind '${t}'.`);
475
- let a = r ?? i.getPath?.(n);
476
- if (!a) throw Error("No path provided in either argument or emitter.");
477
- let o = this._writtenPaths, s = le(e, a, o), c = `${t}:${s}`, l = this._scheduledByNodeKey.get(c);
478
- if (!l) {
479
- let e, r = new Promise((t) => {
480
- e = t;
481
- });
482
- l = {
456
+ let t = ze(e, o.target);
457
+ a && (n.has(t) || this._explicitRelTargets.has(`${e}::${t}`)) || (r.has(t) ? i.add(o.type, o.target, { idHint: o.id }) : this._registry.ownsRelType(o.type) || Ne.has(t) || this._sourcePackage?.isAbsorbed(t) || console.warn(`Dropping preserved relationship to missing part '${t}'`, e || "(root)"));
458
+ }
459
+ }
460
+ addPart(e, t, n, r) {
461
+ return this._addPartInternal("", e, t, n, r);
462
+ }
463
+ _addPartInternal(e, t, n, r, i) {
464
+ let a = this._registry.get(t);
465
+ if (!a) throw Error(`No emitter registered for kind '${t}'.`);
466
+ let o = a.getContentType(n), s = a.getRelTypeUri(n), c = r ?? a.getPath?.(n);
467
+ if (!c) throw Error("No path provided in either argument or emitter.");
468
+ let l = this._writtenPaths, u = Ce(e, c, l), d = `${t}:${u}`, f = this._scheduledByNodeKey.get(d);
469
+ if (!f) {
470
+ let e;
471
+ this._reserveSourceRelIds(u), f = {
483
472
  kind: t,
484
- key: c,
473
+ key: d,
485
474
  payload: n,
486
- path: s,
487
- contentType: i.contentType,
488
- promise: r,
475
+ path: u,
476
+ contentType: o,
477
+ promise: new Promise((t) => {
478
+ e = t;
479
+ }),
489
480
  resolve: e
490
- }, this._scheduledByNodeKey.set(c, l), this._queue.push(l);
491
- }
492
- let u = this._nodesByPath.get(e);
493
- u || (u = /* @__PURE__ */ new Set(), this._nodesByPath.set(e, u)), u.add(c), !i.contentType || i.relTypeUri || e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", s);
494
- let d = null;
495
- if (i.relTypeUri) {
496
- let t = de(e, l.path);
497
- d = this._partWriter.rels(e).add(i.relTypeUri, t);
498
- }
499
- return o.add(s), {
500
- path: s,
501
- contentTypeUri: i.contentType,
502
- relId: d
481
+ }, this._scheduledByNodeKey.set(d, f), this._queue.push(f);
482
+ }
483
+ let p = this._nodesByPath.get(e);
484
+ p || (p = /* @__PURE__ */ new Set(), this._nodesByPath.set(e, p)), p.add(d), !o || s || e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", u);
485
+ let m = null;
486
+ if (s) {
487
+ let t = Te(e, f.path);
488
+ m = this._partWriter.rels(e).add(s, t, { idHint: i });
489
+ }
490
+ return l.add(u), {
491
+ path: u,
492
+ contentTypeUri: o,
493
+ relId: m
503
494
  };
504
495
  }
505
- addBinary(e, t, n, r, i = !1) {
506
- return this._addBinaryInternal("", e, t, n, r, i);
496
+ addBinary(e, t, n, r, i = !1, a) {
497
+ return this._addBinaryInternal("", e, t, n, r, i, a);
507
498
  }
508
- _addBinaryInternal(e, t, n, r, i, a = !1) {
499
+ _addBinaryInternal(e, t, n, r, i, a = !1, o) {
509
500
  if (!i) throw Error("No path provided for binary.");
510
501
  if (!n) throw Error("No content type provided for binary.");
511
- let o = this._writtenPaths, s = le(e, i, o, a), c = null;
502
+ let s = this._writtenPaths, c = Ce(e, i, s, a), l = null;
512
503
  if (r) {
513
- let t = de(e, s);
514
- c = this._partWriter.rels(e).add(r, t);
504
+ let t = Te(e, c);
505
+ l = this._partWriter.rels(e).add(r, t, { idHint: o });
515
506
  }
516
- if (e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", s), !o.has(s)) {
517
- let e = s.split(".").pop() || "";
518
- e && this._partWriter.addDefaultType(e, n), this._partWriter.addPart(s, {
507
+ if (e || this._partWriter.rels("").add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", c), !s.has(c)) {
508
+ let e = c.split(".").pop() || "";
509
+ e && this._partWriter.addDefaultType(e, n), this._partWriter.addPart(c, {
519
510
  kind: "bytes",
520
511
  bytes: t
521
512
  }, void 0, {
522
513
  level: 0,
523
514
  uncompressedSize: t.byteLength,
524
515
  dataDescriptor: !1
525
- }), o.add(s);
516
+ }), s.add(c);
526
517
  }
527
518
  return {
528
- path: s,
519
+ path: c,
529
520
  contentTypeUri: n,
530
- relId: c
521
+ relId: l
531
522
  };
532
523
  }
533
- _forkPreservedPart(e, t, n, r, i) {
534
- let a = this._sourcePackage;
535
- if (!a) return null;
536
- let o = a.getPart(t);
537
- if (!o) return null;
538
- let s = new Set(this._writtenPaths);
539
- for (let e of a.getNames()) s.add(e);
540
- let c = le(e, i, s), l = this._addBinaryInternal(e, o.data, n, r, "/" + c), u = a.getPart(se(t));
541
- if (u) {
542
- let e = this._partWriter.rels(l.path);
543
- for (let t of ye(u.data)) e.add(t.type, t.target, t.external ? { external: !0 } : void 0);
544
- }
545
- return l;
546
- }
547
524
  async _waitForDescendants(e) {
548
525
  let t = this._nodesByPath.get(e);
549
526
  if (!t || t.size === 0) return;
@@ -567,24 +544,31 @@ var je = class {
567
544
  r.push(e);
568
545
  } }, a;
569
546
  await t.emit(e.payload, {
570
- getXMLWriter: () => a || (a = ae(i), a),
571
- addPart: (e, t, r) => this._addPartInternal(n, e, t, r),
572
- addBinary: (e, t, r, i, a = !1) => this._addBinaryInternal(n, e, t, r, i, a),
573
- addExternal: (e, t) => ({
547
+ getXMLWriter: () => a || (a = _e(i), a),
548
+ addPart: (e, t, r, i) => this._addPartInternal(n, e, t, r, i),
549
+ addBinary: (e, t, r, i, a = !1, o) => this._addBinaryInternal(n, e, t, r, i, a, o),
550
+ addExternal: (e, t, r) => ({
574
551
  path: t,
575
552
  contentTypeUri: null,
576
- relId: this._partWriter.rels(n).add(e, t, { external: !0 })
553
+ relId: this._partWriter.rels(n).add(e, t, {
554
+ external: !0,
555
+ idHint: r
556
+ })
577
557
  }),
578
- addPreservedRelationship: (e, t, r) => {
579
- let i = de(n, t), a = this._partWriter.rels(n).add(e, i, { idHint: r });
558
+ addRelationship: (e, t, r) => {
559
+ if (!this._writtenPaths.has(t) && !this._isSourcePartCarried(t)) return null;
560
+ let i = Te(n, t), a = this._partWriter.rels(n).add(e, i, { idHint: r });
580
561
  return this._explicitRelTargets.add(`${n}::${t}`), a;
581
562
  },
582
- forkPreservedPart: (e, t, r, i) => this._forkPreservedPart(n, e, t, r, i),
583
563
  waitEmit: () => this._waitForDescendants(e.path),
584
564
  getPath: () => e.path,
585
565
  getSharedStates: () => this._mapState,
586
- warn: (e, t) => {
587
- console.warn(e, t);
566
+ warn: (t, n, r) => {
567
+ let i = n ?? e.path, a = this._options.onWarning;
568
+ a ? a(t, i, r) : console.warn(t, i);
569
+ },
570
+ log: (t, n) => {
571
+ console.warn(t, n ?? e.path);
588
572
  }
589
573
  });
590
574
  let o = function(e) {
@@ -594,7 +578,7 @@ var je = class {
594
578
  for (let t of e) n.set(t, r), r += t.byteLength;
595
579
  return n;
596
580
  }(r), s = this._options.onPartEmitted;
597
- s && await s(e.kind, e.path, o), Me && (console.log(`\n=== ${e.path} ===`), console.log(pe(o))), this._partWriter.addPart(e.path, {
581
+ s && await s(e.kind, e.path, o), Ve && (console.log(`\n=== ${e.path} ===`), console.log(De(o))), this._partWriter.addPart(e.path, {
598
582
  kind: "bytes",
599
583
  bytes: o
600
584
  }, e.contentType);
@@ -604,13 +588,14 @@ var je = class {
604
588
  this._nodesByPath.delete(e.path), this._scheduledByNodeKey.delete(e.key), e.resolve();
605
589
  }
606
590
  }
607
- }, Me = !1, Ne = class {
591
+ }, Ve = !1, He = class {
608
592
  constructor() {
609
593
  this.map = /* @__PURE__ */ new Map();
610
594
  }
611
595
  register(e) {
612
- if (this.map.has(e.kind)) throw Error(`Duplicate part kind: ${e.kind}`);
613
- this.map.set(e.kind, e);
596
+ let t = e.getKind();
597
+ if (this.map.has(t)) throw Error(`Duplicate part kind: ${t}`);
598
+ this.map.set(t, e);
614
599
  }
615
600
  get(e) {
616
601
  let t = this.map.get(e);
@@ -621,14 +606,31 @@ var je = class {
621
606
  return this.map.has(e);
622
607
  }
623
608
  ownsRelType(e) {
624
- for (let t of this.map.values()) if (t.relTypeUri === e) return !0;
609
+ for (let t of this.map.values()) if (t.getRelTypeUri() === e) return !0;
625
610
  return !1;
626
611
  }
627
612
  };
628
- function Pe(e, t, n) {
613
+ function Ue(e, t, n) {
629
614
  e && (e.algorithm && (t[n ? `${n}AlgorithmName` : "algorithmName"] = e.algorithm), e.hash && (t[n ? `${n}HashValue` : "hashValue"] = e.hash), e.salt && (t[n ? `${n}SaltValue` : "saltValue"] = e.salt), e.spinCount !== void 0 && (t[n ? `${n}SpinCount` : "spinCount"] = e.spinCount));
630
615
  }
631
- var Fe = class {
616
+ var We = "hiddenFormulaXfs", Ge = class {
617
+ constructor(e, t) {
618
+ this._variants = /* @__PURE__ */ new Map(), this._sources = [], this._json = e, this._styles = t, this._directCount = Math.max(1, e?.direct?.length ?? 0);
619
+ }
620
+ getHiddenXf(e) {
621
+ let t = this._variants.get(e);
622
+ return t !== void 0 || (this._isShown(e) ? t = e : (t = this._directCount + this._sources.length, this._sources.push(e)), this._variants.set(e, t)), t;
623
+ }
624
+ getSources() {
625
+ return this._sources;
626
+ }
627
+ _isShown(e) {
628
+ let t = this._json?.direct?.[e], n = t?.protection?.showFormulas;
629
+ if (n !== void 0) return n;
630
+ let r = (e === 0 ? void 0 : t?.named) ?? V.BuiltInName.Normal;
631
+ return this._styles.getNamedStyles().getByName(r)?.toJSON().style?.protection?.showFormulas ?? !1;
632
+ }
633
+ }, Ke = class {
632
634
  constructor() {
633
635
  this._daprFMBks = [], this._daprFMBkMap = /* @__PURE__ */ new Map(), this._rvFMBks = [], this._rvFMBkMap = /* @__PURE__ */ new Map(), this._valueMeta = [];
634
636
  }
@@ -663,20 +665,20 @@ var Fe = class {
663
665
  getValueMeta() {
664
666
  return this._valueMeta;
665
667
  }
666
- }, Ie = class {
668
+ }, qe = class {
667
669
  constructor(e, t = console.warn) {
668
670
  this._entries = [], this._keyMap = /* @__PURE__ */ new Map(), this._metaCollector = e, this._onWarn = t;
669
671
  }
670
672
  add(e) {
671
673
  if (e == null) return this._onWarn?.("RichValueCollector.add: null/undefined value — falling back to #UNKNOWN!"), this._registerFallback();
672
- if (ne.isError(e)) {
673
- let t = e.getCode(), n = this._register(`_error:${t}`, { errorType: "" + (t - 1) }, Le);
674
+ if (se.isError(e)) {
675
+ let t = e.getCode(), n = this._register(`_error:${t}`, { errorType: "" + (t - 1) }, Je);
674
676
  return this._metaCollector.registerRichValueCell(n);
675
677
  }
676
678
  return e.isIRichData && e.getType(), this._onWarn?.("RichValueCollector.add: unsupported rich value type — falling back to #UNKNOWN!", e), this._registerFallback();
677
679
  }
678
680
  _registerFallback() {
679
- let e = this._register("_error:fallback", { errorType: ne.Code.Unknown - 1 }, Le);
681
+ let e = this._register("_error:fallback", { errorType: se.Code.Unknown - 1 }, Je);
680
682
  return this._metaCollector.registerRichValueCell(e);
681
683
  }
682
684
  _register(e, t, n) {
@@ -708,7 +710,7 @@ var Fe = class {
708
710
  }
709
711
  return -1;
710
712
  }
711
- }, Le = new class {
713
+ }, Je = new class {
712
714
  constructor(e, t) {
713
715
  this.type = e, this.props = t;
714
716
  }
@@ -726,58 +728,91 @@ var Fe = class {
726
728
  "subType",
727
729
  "i",
728
730
  "0"
729
- ]]), Re = {
731
+ ]]), Ye = "application/xml", Xe = async (e, t) => {
732
+ let n = e.parts, r = n ? n.length : 0;
733
+ for (let i = 0; i < r; i++) {
734
+ let r = n[i];
735
+ try {
736
+ await Ze(r, t);
737
+ } catch (n) {
738
+ t.log(`Unable to write the part '${r.name ?? r.id}' referenced by '${e.name ?? e.id}'`, n);
739
+ }
740
+ }
741
+ }, Ze = async (e, t, n) => {
742
+ let r = e.resId === void 0 ? void 0 : t.getSharedStates().get(he)?.get(e.resId);
743
+ if (!r) return e.resId === void 0 ? t.addPart("embeddedPart", e, n, e.id) : (t.log(`The part '${e.name ?? e.id}' cites resource ${e.resId}, which is not in the workbook.`), null);
744
+ let i = await r.getExternalURI();
745
+ if (i) {
746
+ let n = t.addExternal(e.type, i, e.id);
747
+ return n.relId !== e.id && t.log(`The external reference '${e.id}' was written as '${n.relId}'; the markup will not find it.`), n;
748
+ }
749
+ let a = await r.toBuffer();
750
+ return t.addBinary(new Uint8Array(a), e.contentType || Ye, e.type, n ?? `./${Qe(e.name)}`, !1, e.id);
751
+ }, Qe = (e) => {
752
+ let t = e && /^[\w.\-~%]+$/.test(e) ? e : "part.xml", n = t.lastIndexOf("."), r = n > 0 ? t.slice(0, n) : t, i = n > 0 ? t.slice(n) : "";
753
+ return `${r.replace(/\d+$/, "")}{n}${i}`;
754
+ }, $e = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml", et = (e, t) => e.getSharedStates().get("pivotCachePaths")?.get(t) ?? null, tt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink", nt = "fileVersion", rt = "sheetParts", it = "externalLinkParts";
755
+ function at(e) {
756
+ if (!e || e.indexOf("[") === -1) return [];
757
+ let t = [], n = e.replace(/"(?:[^"]|"")*"/g, "");
758
+ for (let e of n.matchAll(/\[(\d+)\]/g)) {
759
+ let n = Number(e[1]);
760
+ n > 0 && !t.includes(n) && t.push(n);
761
+ }
762
+ return t;
763
+ }
764
+ var ot = {
730
765
  auto: "auto",
731
766
  automaticExceptTables: "autoNoTable",
732
767
  manual: "manual"
733
768
  };
734
- function U(e, t, n, r) {
769
+ function G(e, t, n, r) {
735
770
  if (!n) return;
736
771
  let i = typeof n == "string" ? t.parseColor(n) : n;
737
772
  r && e.start(r);
738
773
  let a = i.getType(), o = i.getVal(), s = i.getAdjustments(), c = s && s.length > 0;
739
774
  switch (a) {
740
775
  case "scheme":
741
- c ? (e.start("schemeClr", { val: o }), W(e, s), e.end("schemeClr")) : e.empty("schemeClr", { val: o });
776
+ c ? (e.start("schemeClr", { val: o }), K(e, s), e.end("schemeClr")) : e.empty("schemeClr", { val: o });
742
777
  break;
743
778
  case "named":
744
- if (te.isSystem(o)) {
779
+ if (ae.isSystem(o)) {
745
780
  let t = i.getLastColor() ?? i.getBaseColor().toHex().toString(!1).replace("#", "");
746
781
  c ? (e.start("sysClr", {
747
782
  val: o,
748
783
  lastClr: t
749
- }), W(e, s), e.end("sysClr")) : e.empty("sysClr", {
784
+ }), K(e, s), e.end("sysClr")) : e.empty("sysClr", {
750
785
  val: o,
751
786
  lastClr: t
752
787
  });
753
- } else c ? (e.start("prstClr", { val: o }), W(e, s), e.end("prstClr")) : e.empty("prstClr", { val: o });
788
+ } else c ? (e.start("prstClr", { val: o }), K(e, s), e.end("prstClr")) : e.empty("prstClr", { val: o });
754
789
  break;
755
790
  case "auto": {
756
791
  let t = i.getLastColor() ?? i.getBaseColor().toHex().toString(!1).replace("#", "");
757
792
  c ? (e.start("sysClr", {
758
793
  val: "windowText",
759
794
  lastClr: t
760
- }), W(e, s), e.end("sysClr")) : e.empty("sysClr", {
795
+ }), K(e, s), e.end("sysClr")) : e.empty("sysClr", {
761
796
  val: "windowText",
762
797
  lastClr: t
763
798
  });
764
799
  break;
765
800
  }
766
801
  case "index":
767
- c ? (e.start("srgbClr", { val: o }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: o });
802
+ c ? (e.start("srgbClr", { val: o }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: o });
768
803
  break;
769
804
  case "hsl":
770
805
  let t = i.toHex().toString();
771
- c ? (e.start("srgbClr", { val: t }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: t });
806
+ c ? (e.start("srgbClr", { val: t }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: t });
772
807
  break;
773
808
  case "rgb":
774
809
  case "lrgb":
775
810
  let n = i.toHex().toString();
776
- c ? (e.start("srgbClr", { val: n }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: n });
811
+ c ? (e.start("srgbClr", { val: n }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: n });
777
812
  break;
778
813
  case "hex":
779
814
  let r = o.replace("#", "").toUpperCase();
780
- c ? (e.start("srgbClr", { val: r }), W(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: r });
815
+ c ? (e.start("srgbClr", { val: r }), K(e, s), e.end("srgbClr")) : e.empty("srgbClr", { val: r });
781
816
  break;
782
817
  default:
783
818
  let a = o.replace("#", "").toUpperCase();
@@ -785,7 +820,7 @@ function U(e, t, n, r) {
785
820
  }
786
821
  r && e.end(r);
787
822
  }
788
- function W(e, t) {
823
+ function K(e, t) {
789
824
  if (t && t.length !== 0) for (let n of t) for (let [t, r] of Object.entries(n)) {
790
825
  if (r == null) continue;
791
826
  let n = t;
@@ -808,47 +843,47 @@ function W(e, t) {
808
843
  }
809
844
  }
810
845
  }
811
- function G(e, t, n, r, i = !1, a = !1) {
846
+ function q(e, t, n, r, i = !1, a = !1) {
812
847
  if (!n) return;
813
848
  let o = typeof n == "string" ? t.parseColor(n) : n, s = () => {
814
- e.empty(r, { rgb: Ke(o.toHex().toString(!0)) });
849
+ e.empty(r, { rgb: mt(o.toHex().toString(!0)) });
815
850
  }, c = o.getAdjustments(), l = c && c.length > 0, u = o.getType();
816
- if (u !== k.Type.Auto) {
817
- if (u === k.Type.Scheme) {
818
- let t = o.getVal(), n = ze[t] ?? t, i = He.get(n);
851
+ if (u !== L.Type.Auto) {
852
+ if (u === L.Type.Scheme) {
853
+ let t = o.getVal(), n = st[t] ?? t, i = ut.get(n);
819
854
  if (i === void 0 && n !== "phClr") return console.warn(`Color scheme not in theme. schemeVal=${t} themeKey=${n}`), s();
820
855
  let a = {};
821
856
  if (a.theme = i, l) {
822
857
  if (!function(e) {
823
858
  for (let t of e) switch (Object.keys(t)[0]) {
824
- case k.AdjustmentType.Tint:
825
- case k.AdjustmentType.ETint:
826
- case k.AdjustmentType.Shade:
827
- case k.AdjustmentType.Lum:
828
- case k.AdjustmentType.LumOff:
829
- case k.AdjustmentType.LumMod:
830
- case k.AdjustmentType.Alpha:
831
- case k.AdjustmentType.AlphaOff:
832
- case k.AdjustmentType.AlphaMod: continue;
859
+ case L.AdjustmentType.Tint:
860
+ case L.AdjustmentType.ETint:
861
+ case L.AdjustmentType.Shade:
862
+ case L.AdjustmentType.Lum:
863
+ case L.AdjustmentType.LumOff:
864
+ case L.AdjustmentType.LumMod:
865
+ case L.AdjustmentType.Alpha:
866
+ case L.AdjustmentType.AlphaOff:
867
+ case L.AdjustmentType.AlphaMod: continue;
833
868
  default: return !1;
834
869
  }
835
870
  return !0;
836
871
  }(c)) return s();
837
- let e = c.length === 1 ? c[0][k.AdjustmentType.ETint] : void 0, t;
838
- if (e !== void 0) t = We(e);
872
+ let e = c.length === 1 ? c[0][L.AdjustmentType.ETint] : void 0, t;
873
+ if (e !== void 0) t = ft(e);
839
874
  else {
840
875
  let e = o.getBaseColor().toHex().toString(!0), n = o.toHex().toString(!0);
841
- t = We(function(e, t) {
842
- let n = Ue(e, 0, 255), r = Ue(t, 0, 255);
843
- return Math.abs(r - n) < 1e-9 ? 0 : r < n ? n <= 1e-9 ? -1 : Ue(r / n - 1, -1, 0) : 255 - n <= 1e-9 ? 0 : Ue((r - n) / (255 - n), 0, 1);
844
- }(Ge(e), Ge(n)));
876
+ t = ft(function(e, t) {
877
+ let n = dt(e, 0, 255), r = dt(t, 0, 255);
878
+ return Math.abs(r - n) < 1e-9 ? 0 : r < n ? n <= 1e-9 ? -1 : dt(r / n - 1, -1, 0) : 255 - n <= 1e-9 ? 0 : dt((r - n) / (255 - n), 0, 1);
879
+ }(pt(e), pt(n)));
845
880
  }
846
881
  t !== 0 && (a.tint = t);
847
882
  }
848
883
  e.empty(r, a);
849
884
  return;
850
885
  }
851
- if (u === k.Type.Index) {
886
+ if (u === L.Type.Index) {
852
887
  let t = o.getVal(), n = t.substring(5, t.length);
853
888
  e.empty(r, { indexed: Number(n) });
854
889
  return;
@@ -857,7 +892,7 @@ function G(e, t, n, r, i = !1, a = !1) {
857
892
  }
858
893
  e.empty(r, { auto: 1 });
859
894
  }
860
- var ze = {
895
+ var st = {
861
896
  bg1: "lt1",
862
897
  tx1: "dk1",
863
898
  bg2: "lt2",
@@ -870,7 +905,7 @@ var ze = {
870
905
  accent6: "accent6",
871
906
  hlink: "hlink",
872
907
  folHlink: "folHlink"
873
- }, Be = Object.freeze([
908
+ }, ct = Object.freeze([
874
909
  "lt1",
875
910
  "dk1",
876
911
  "lt2",
@@ -883,7 +918,7 @@ var ze = {
883
918
  "accent6",
884
919
  "hlink",
885
920
  "folHlink"
886
- ]), Ve = Object.freeze([
921
+ ]), lt = Object.freeze([
887
922
  "dk1",
888
923
  "lt1",
889
924
  "dk2",
@@ -896,15 +931,15 @@ var ze = {
896
931
  "accent6",
897
932
  "hlink",
898
933
  "folHlink"
899
- ]), He = new Map(Be.map((e, t) => [e, t]));
900
- function Ue(e, t, n) {
934
+ ]), ut = new Map(ct.map((e, t) => [e, t]));
935
+ function dt(e, t, n) {
901
936
  return Math.max(t, Math.min(n, e));
902
937
  }
903
- function We(e) {
904
- let t = Ue(e, -1, 1);
938
+ function ft(e) {
939
+ let t = dt(e, -1, 1);
905
940
  return Math.abs(t) < 1e-12 ? 0 : t;
906
941
  }
907
- function Ge(e) {
942
+ function pt(e) {
908
943
  let t = function(e) {
909
944
  let t = e.replace(/^#/, "").toUpperCase();
910
945
  if (t.length === 8) return t.slice(2);
@@ -913,31 +948,58 @@ function Ge(e) {
913
948
  }(e), n = parseInt(t.slice(0, 2), 16) / 255, r = parseInt(t.slice(2, 4), 16) / 255, i = parseInt(t.slice(4, 6), 16) / 255;
914
949
  return (Math.max(n, r, i) + Math.min(n, r, i)) / 2 * 255;
915
950
  }
916
- function Ke(e) {
951
+ function mt(e) {
917
952
  let t = e.replace(/^#/, "").toUpperCase();
918
953
  if (t.length === 8) return t;
919
954
  if (t.length === 6) return "FF" + t;
920
955
  throw Error(`Invalid hex: ${e}`);
921
956
  }
922
- function qe(e, t = !1) {
957
+ function ht(e, t = !1) {
923
958
  let n = e;
924
959
  return n.length === 8 && (n = n.substring(2, 8)), n.length === 6 && (n = (t ? "00" : "FF") + n), n.toUpperCase();
925
960
  }
926
- function K(e, t, n, r, i = !1, a = !1) {
961
+ function gt(e) {
962
+ return `[Threaded comment]\n\nYour version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924\n\nComment:\n ${e.getContent()}`;
963
+ }
964
+ function _t(e, t) {
965
+ if (typeof t == "string") return void vt(e, t);
966
+ let n = t.runs;
967
+ for (let t = 0; t < n.length; t++) {
968
+ let r = n[t];
969
+ e.start("r"), (r.bold || r.italic || r.size !== void 0 || r.font || r.color) && (e.start("rPr"), r.bold && e.empty("b"), r.italic && e.empty("i"), r.size !== void 0 && e.empty("sz", { val: r.size }), r.color && e.empty("color", { rgb: "FF" + r.color.replace(/^#/, "").toUpperCase() }), r.font && e.empty("rFont", { val: r.font }), e.end("rPr")), vt(e, r.text ?? ""), e.end("r");
970
+ }
971
+ }
972
+ function vt(e, t) {
973
+ e.start("t", ie.test(t) || /[\n\r]/.test(t) ? n : void 0), e.text(t), e.end("t");
974
+ }
975
+ function yt(e) {
976
+ let t = e.getRanges();
977
+ if (t.isInvalid()) return null;
978
+ let n = t.getCoords()[0];
979
+ return n ? {
980
+ ref: P.cellToString({
981
+ rowIndex: n.rowStart,
982
+ colIndex: n.colStart
983
+ }),
984
+ row: n.rowStart,
985
+ col: n.colStart
986
+ } : null;
987
+ }
988
+ function J(e, t, n, r, i = !1, a = !1) {
927
989
  let o = r.getTheme();
928
990
  if (i && t.start("fill"), typeof n == "string" && (n = {
929
- type: N.Type.Solid,
991
+ type: B.Type.Solid,
930
992
  color: n
931
- }), n.type === N.Type.None) i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
932
- else if (n.type === N.Type.Solid) {
993
+ }), n.type === B.Type.None) i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
994
+ else if (n.type === B.Type.Solid) {
933
995
  let e = n;
934
- i ? t.start("patternFill", { patternType: "solid" }) : t.start("solidFill"), e.color && (i ? G(t, o, e.color, "fgColor") : U(t, o, e.color)), i ? t.end("patternFill") : t.end("solidFill");
935
- } else if (n.type === N.Type.Pattern) {
996
+ i ? t.start("patternFill", { patternType: "solid" }) : t.start("solidFill"), e.color && (i ? q(t, o, e.color, "fgColor") : G(t, o, e.color)), i ? t.end("patternFill") : t.end("solidFill");
997
+ } else if (n.type === B.Type.Pattern) {
936
998
  let e = n, r = e.patternType || "solid";
937
- t.start("patternFill", { patternType: r }), e.foreground && (i ? G(t, o, a ? e.background : e.foreground, "fgColor") : U(t, o, a ? e.background : e.foreground)), e.background && (i ? G(t, o, a ? e.foreground : e.background, "bgColor") : U(t, o, a ? e.foreground : e.background)), t.end("patternFill");
938
- } else if (n.type === N.Type.Gradient && i) {
999
+ t.start("patternFill", { patternType: r }), e.foreground && (i ? q(t, o, a ? e.background : e.foreground, "fgColor") : G(t, o, a ? e.background : e.foreground)), e.background && (i ? q(t, o, a ? e.foreground : e.background, "bgColor") : G(t, o, a ? e.foreground : e.background)), t.end("patternFill");
1000
+ } else if (n.type === B.Type.Gradient && i) {
939
1001
  let e = n, r = {}, i = e.gradientType;
940
- if (i !== N.GradientType.Path && i !== N.GradientType.Linear || (r.type = i), e.angle !== void 0) {
1002
+ if (i !== B.GradientType.Path && i !== B.GradientType.Linear || (r.type = i), e.angle !== void 0) {
941
1003
  let t = (e.angle - 90) % 360;
942
1004
  t !== 0 && (r.degree = String(t));
943
1005
  }
@@ -951,10 +1013,10 @@ function K(e, t, n, r, i = !1, a = !1) {
951
1013
  let t = e;
952
1014
  r = t.offset || 0, n = t.color;
953
1015
  }
954
- t.start("stop", { position: String(r) }), n && G(t, o, n, "color"), t.end("stop");
1016
+ t.start("stop", { position: String(r) }), n && q(t, o, n, "color"), t.end("stop");
955
1017
  }
956
1018
  t.end("gradientFill");
957
- } else if (n.type === N.Type.Gradient) {
1019
+ } else if (n.type === B.Type.Gradient) {
958
1020
  let e = n, r = {};
959
1021
  e.isRotatedWithShape !== void 0 && (r.rotWithShape = e.isRotatedWithShape ? "1" : "0"), t.start("gradFill", r), t.start("gsLst");
960
1022
  let i = e.stops;
@@ -965,22 +1027,22 @@ function K(e, t, n, r, i = !1, a = !1) {
965
1027
  let t = e;
966
1028
  r = t.offset || 0, n = t.color;
967
1029
  }
968
- t.start("gs", { pos: String(D.roundAccurately(1e3 * r, 0)) }), n && U(t, o, n), t.end("gs");
1030
+ t.start("gs", { pos: String(I.roundAccurately(1e3 * r, 0)) }), n && G(t, o, n), t.end("gs");
969
1031
  }
970
1032
  t.end("gsLst");
971
1033
  let a = e.gradientType;
972
- if (a && a !== N.GradientType.Linear) {
1034
+ if (a && a !== B.GradientType.Linear) {
973
1035
  let n = a === "radial" ? "circle" : a;
974
1036
  t.start("path", { path: n });
975
1037
  let r = e.focus;
976
1038
  if (r) {
977
1039
  let e = {};
978
- r.t !== void 0 && (e.t = String(D.roundAccurately(1e3 * r.t, 0))), r.l !== void 0 && (e.l = String(D.roundAccurately(1e3 * r.l, 0))), r.b !== void 0 && (e.b = String(D.roundAccurately(1e3 * r.b, 0))), r.r !== void 0 && (e.r = String(D.roundAccurately(1e3 * r.r, 0))), t.empty("fillToRect", e);
1040
+ r.t !== void 0 && (e.t = String(I.roundAccurately(1e3 * r.t, 0))), r.l !== void 0 && (e.l = String(I.roundAccurately(1e3 * r.l, 0))), r.b !== void 0 && (e.b = String(I.roundAccurately(1e3 * r.b, 0))), r.r !== void 0 && (e.r = String(I.roundAccurately(1e3 * r.r, 0))), t.empty("fillToRect", e);
979
1041
  }
980
1042
  t.end("path");
981
1043
  } else {
982
1044
  let n = {};
983
- e.angle !== void 0 && (n.ang = String(D.roundAccurately(6e4 * e.angle, 0)));
1045
+ e.angle !== void 0 && (n.ang = String(I.roundAccurately(6e4 * e.angle, 0)));
984
1046
  let r = e.scaled;
985
1047
  r !== void 0 && (n.scaled = r ? "1" : "0"), t.empty("lin", n);
986
1048
  }
@@ -988,70 +1050,70 @@ function K(e, t, n, r, i = !1, a = !1) {
988
1050
  } else i ? t.empty("patternFill", { patternType: "none" }) : t.empty("noFill");
989
1051
  i && t.end("fill");
990
1052
  }
991
- var Je = (e, t, n, r) => {
1053
+ var bt = (e, t, n, r) => {
992
1054
  if (!n) return t.start("ln"), t.empty("noFill"), void t.end("ln");
993
1055
  typeof n == "string" && (n = { fill: n });
994
1056
  let i = n, a = {};
995
- if (i.width !== void 0 && (a.w = String(q(i.width))), i.lineCap !== void 0 && (a.cap = Ye(i.lineCap)), i.compound !== void 0 && (a.cmpd = i.compound), i.align !== void 0 && (a.algn = i.align), t.start("ln", a), K(0, t, i.fill ?? $e, r), Array.isArray(i.dash)) {
1057
+ if (i.width !== void 0 && (a.w = String(Y(i.width))), i.lineCap !== void 0 && (a.cap = xt(i.lineCap)), i.compound !== void 0 && (a.cmpd = i.compound), i.align !== void 0 && (a.algn = i.align), t.start("ln", a), J(0, t, i.fill ?? Tt, r), Array.isArray(i.dash)) {
996
1058
  t.start("custDash");
997
1059
  for (let e = 0; e < i.dash.length; e += 2) t.empty("ds", {
998
- d: String(D.roundAccurately(1e3 * i.dash[e], 0)),
999
- sp: String(D.roundAccurately(1e3 * (i.dash[e + 1] ?? 0), 0))
1060
+ d: String(I.roundAccurately(1e3 * i.dash[e], 0)),
1061
+ sp: String(I.roundAccurately(1e3 * (i.dash[e + 1] ?? 0), 0))
1000
1062
  });
1001
1063
  t.end("custDash");
1002
1064
  } else typeof i.dash == "string" && t.empty("prstDash", { val: i.dash });
1003
- if (i.lineJoin === F.LineJoin.Round) t.empty("round");
1004
- else if (i.lineJoin === F.LineJoin.Bevel) t.empty("bevel");
1005
- else if (i.lineJoin === F.LineJoin.Miter) {
1065
+ if (i.lineJoin === de.LineJoin.Round) t.empty("round");
1066
+ else if (i.lineJoin === de.LineJoin.Bevel) t.empty("bevel");
1067
+ else if (i.lineJoin === de.LineJoin.Miter) {
1006
1068
  let e = {};
1007
- i.miterLimit !== void 0 && (e.lim = String(D.roundAccurately(1e5 * i.miterLimit, 0))), t.empty("miter", e);
1069
+ i.miterLimit !== void 0 && (e.lim = String(I.roundAccurately(1e5 * i.miterLimit, 0))), t.empty("miter", e);
1008
1070
  }
1009
1071
  t.end("ln");
1010
- }, Ye = (e) => e === "round" ? "rnd" : e === "butt" ? "flat" : e === "square" ? "sq" : e, Xe = (e, t, n, r = void 0, i = !1) => {
1072
+ }, xt = (e) => e === "round" ? "rnd" : e === "butt" ? "flat" : e === "square" ? "sq" : e, St = (e, t, n, r = void 0, i = !1) => {
1011
1073
  if (!n || !(n.fill || n.stroke || n.effects?.length || i)) return;
1012
1074
  let a = e.getXMLWriter();
1013
- r && a.start(r), a.pushDefaultNamespace("a"), n.fill && K(0, a, n.fill, t), n.stroke && Je(0, a, n.stroke, t), n.effects?.length ? Ze(e, a, t.getTheme(), n.effects) : i && a.empty("effectLst"), a.popDefaultNamespace(), r && a.end(r);
1014
- }, Ze = (e, t, n, r) => {
1075
+ r && a.start(r), a.pushDefaultNamespace("a"), n.fill && J(0, a, n.fill, t), n.stroke && bt(0, a, n.stroke, t), n.effects?.length ? Ct(e, a, t.getTheme(), n.effects) : i && a.empty("effectLst"), a.popDefaultNamespace(), r && a.end(r);
1076
+ }, Ct = (e, t, n, r) => {
1015
1077
  t.start("effectLst");
1016
- for (let e of r) Qe(t, n, e);
1078
+ for (let e of r) wt(t, n, e);
1017
1079
  t.end("effectLst");
1018
- }, Qe = (e, t, n) => {
1080
+ }, wt = (e, t, n) => {
1019
1081
  switch (n.type) {
1020
- case M.Type.OuterShadow: {
1082
+ case le.Type.OuterShadow: {
1021
1083
  let r = n, i = {};
1022
- r.blur !== void 0 && (i.blurRad = String(q(r.blur))), r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), r.alignment !== void 0 && (i.algn = r.alignment), r.isRotatedWithShape !== void 0 && (i.rotWithShape = r.isRotatedWithShape ? "1" : "0"), r.scaleX !== void 0 && (i.sx = String(D.roundAccurately(1e3 * r.scaleX, 0))), r.scaleY !== void 0 && (i.sy = String(D.roundAccurately(1e3 * r.scaleY, 0))), r.skewX !== void 0 && (i.kx = String(Y(r.skewX))), r.skewY !== void 0 && (i.ky = String(Y(r.skewY))), e.start("outerShdw", i), U(e, t, r.color), e.end("outerShdw");
1084
+ r.blur !== void 0 && (i.blurRad = String(Y(r.blur))), r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), r.alignment !== void 0 && (i.algn = r.alignment), r.isRotatedWithShape !== void 0 && (i.rotWithShape = r.isRotatedWithShape ? "1" : "0"), r.scaleX !== void 0 && (i.sx = String(I.roundAccurately(1e3 * r.scaleX, 0))), r.scaleY !== void 0 && (i.sy = String(I.roundAccurately(1e3 * r.scaleY, 0))), r.skewX !== void 0 && (i.kx = String(Z(r.skewX))), r.skewY !== void 0 && (i.ky = String(Z(r.skewY))), e.start("outerShdw", i), G(e, t, r.color), e.end("outerShdw");
1023
1085
  break;
1024
1086
  }
1025
- case M.Type.InnerShadow: {
1087
+ case le.Type.InnerShadow: {
1026
1088
  let r = n, i = {};
1027
- r.blur !== void 0 && (i.blurRad = String(q(r.blur))), r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), e.start("innerShdw", i), U(e, t, r.color), e.end("innerShdw");
1089
+ r.blur !== void 0 && (i.blurRad = String(Y(r.blur))), r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), e.start("innerShdw", i), G(e, t, r.color), e.end("innerShdw");
1028
1090
  break;
1029
1091
  }
1030
- case M.Type.PresetShadow: {
1092
+ case le.Type.PresetShadow: {
1031
1093
  let r = n, i = { prst: r.preset };
1032
- r.distance !== void 0 && (i.dist = String(q(r.distance))), r.angle !== void 0 && (i.dir = String(Y(r.angle))), e.start("prstShdw", i), U(e, t, r.color), e.end("prstShdw");
1094
+ r.distance !== void 0 && (i.dist = String(Y(r.distance))), r.angle !== void 0 && (i.dir = String(Z(r.angle))), e.start("prstShdw", i), G(e, t, r.color), e.end("prstShdw");
1033
1095
  break;
1034
1096
  }
1035
- case M.Type.Glow: {
1097
+ case le.Type.Glow: {
1036
1098
  let r = n, i = {};
1037
- r.radius !== void 0 && (i.rad = String(q(r.radius))), e.start("glow", i), U(e, t, r.color), e.end("glow");
1099
+ r.radius !== void 0 && (i.rad = String(Y(r.radius))), e.start("glow", i), G(e, t, r.color), e.end("glow");
1038
1100
  break;
1039
1101
  }
1040
- case M.Type.SoftEdge: {
1102
+ case le.Type.SoftEdge: {
1041
1103
  let t = n, r = {};
1042
- t.radius !== void 0 && (r.rad = String(q(t.radius))), e.empty("softEdge", r);
1104
+ t.radius !== void 0 && (r.rad = String(Y(t.radius))), e.empty("softEdge", r);
1043
1105
  break;
1044
1106
  }
1045
- case M.Type.Reflection: {
1107
+ case le.Type.Reflection: {
1046
1108
  let t = n, r = {};
1047
- t.blur !== void 0 && (r.blurRad = String(q(t.blur))), t.distance !== void 0 && (r.dist = String(q(t.distance))), t.angle !== void 0 && (r.dir = String(Y(t.angle))), t.fadeAngle !== void 0 && (r.fadeDir = String(Y(t.fadeAngle))), t.startAlpha !== void 0 && (r.stA = String(D.roundAccurately(1e3 * t.startAlpha, 0))), t.startPosition !== void 0 && (r.stPos = String(D.roundAccurately(1e3 * t.startPosition, 0))), t.endAlpha !== void 0 && (r.endA = String(D.roundAccurately(1e3 * t.endAlpha, 0))), t.endPosition !== void 0 && (r.endPos = String(D.roundAccurately(1e3 * t.endPosition, 0))), t.scaleX !== void 0 && (r.sx = String(D.roundAccurately(1e3 * t.scaleX, 0))), t.scaleY !== void 0 && (r.sy = String(D.roundAccurately(1e3 * t.scaleY, 0))), t.skewX !== void 0 && (r.kx = String(Y(t.skewX))), t.skewY !== void 0 && (r.ky = String(Y(t.skewY))), t.alignment !== void 0 && (r.algn = t.alignment), t.isRotatedWithShape !== void 0 && (r.rotWithShape = t.isRotatedWithShape ? "1" : "0"), e.empty("reflection", r);
1109
+ t.blur !== void 0 && (r.blurRad = String(Y(t.blur))), t.distance !== void 0 && (r.dist = String(Y(t.distance))), t.angle !== void 0 && (r.dir = String(Z(t.angle))), t.fadeAngle !== void 0 && (r.fadeDir = String(Z(t.fadeAngle))), t.startAlpha !== void 0 && (r.stA = String(I.roundAccurately(1e3 * t.startAlpha, 0))), t.startPosition !== void 0 && (r.stPos = String(I.roundAccurately(1e3 * t.startPosition, 0))), t.endAlpha !== void 0 && (r.endA = String(I.roundAccurately(1e3 * t.endAlpha, 0))), t.endPosition !== void 0 && (r.endPos = String(I.roundAccurately(1e3 * t.endPosition, 0))), t.scaleX !== void 0 && (r.sx = String(I.roundAccurately(1e3 * t.scaleX, 0))), t.scaleY !== void 0 && (r.sy = String(I.roundAccurately(1e3 * t.scaleY, 0))), t.skewX !== void 0 && (r.kx = String(Z(t.skewX))), t.skewY !== void 0 && (r.ky = String(Z(t.skewY))), t.alignment !== void 0 && (r.algn = t.alignment), t.isRotatedWithShape !== void 0 && (r.rotWithShape = t.isRotatedWithShape ? "1" : "0"), e.empty("reflection", r);
1048
1110
  break;
1049
1111
  }
1050
1112
  }
1051
- }, $e = { type: "none" }, et = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", tt = {
1113
+ }, Tt = { type: "none" }, Et = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Dt = "imagesWritten", Ot = {
1052
1114
  mime: "image/png",
1053
1115
  ext: "png"
1054
- }, q = (e = 0) => D.roundAccurately(12700 * e, 0), J = (e = 0) => D.roundAccurately(9525 * e, 0), Y = (e) => 6e4 * e, nt = (e = 0) => D.roundAccurately(100 * e, 2), rt = class {
1116
+ }, Y = (e = 0) => I.roundAccurately(12700 * e, 0), X = (e = 0) => I.roundAccurately(9525 * e, 0), Z = (e) => 6e4 * e, kt = (e = 0) => I.roundAccurately(100 * e, 2), At = class {
1055
1117
  constructor() {
1056
1118
  this._dxfs = [], this._byKey = /* @__PURE__ */ new Map();
1057
1119
  }
@@ -1065,64 +1127,64 @@ var Je = (e, t, n, r) => {
1065
1127
  getCount() {
1066
1128
  return this._dxfs.length;
1067
1129
  }
1068
- }, it = "cfDxfs", at = [
1130
+ }, jt = "cfDxfs", Mt = [
1069
1131
  "font",
1070
1132
  "fill",
1071
- "border",
1133
+ "borders",
1072
1134
  "numberFormat",
1073
1135
  "alignment"
1074
1136
  ];
1075
- function ot(e, t, n) {
1137
+ function Nt(e, t, n) {
1076
1138
  if (t) {
1077
1139
  if (t.named) {
1078
1140
  let r = t.named, i = r.toLowerCase(), a = n.namedStyleMap;
1079
1141
  if (!a.has(i)) {
1080
1142
  a.set(i, "" + a.size);
1081
- let t = e.getNamed(r).toJSON();
1082
- ot(e, t.style ?? D.EmptyObject, n), n.namedStyles.push(t);
1143
+ let t = e.getNamedStyles().getByName(r).toJSON();
1144
+ Nt(e, t.style ?? I.EmptyObject, n), n.namedStyles.push(t);
1083
1145
  }
1084
1146
  }
1085
1147
  t.font && function(e, t, n) {
1086
1148
  if (!t) return;
1087
- let r = E.JSONStableStringify(t), i = n.fontMap;
1149
+ let r = F.JSONStableStringify(t), i = n.fontMap;
1088
1150
  if (!i.has(r)) {
1089
1151
  let e = i.size;
1090
1152
  i.set(r, "" + e), n.fonts.push(t);
1091
1153
  }
1092
1154
  }(0, t.font, n), t.fill && function(e, t, n) {
1093
1155
  if (!t) return;
1094
- let r = E.JSONStableStringify(t), i = n.fillMap;
1156
+ let r = F.JSONStableStringify(t), i = n.fillMap;
1095
1157
  if (!i.has(r) && typeof t == "object" && t.type) {
1096
1158
  let e = i.size;
1097
1159
  i.set(r, "" + e), n.fills.push(t);
1098
1160
  }
1099
- }(0, t.fill, n), t.border && function(e, t, n) {
1161
+ }(0, t.fill, n), t.borders && function(e, t, n) {
1100
1162
  if (!t) return;
1101
- let r = E.JSONStableStringify(t), i = n.borderMap;
1163
+ let r = F.JSONStableStringify(t), i = n.borderMap;
1102
1164
  if (!i.has(r)) {
1103
1165
  let e = i.size;
1104
1166
  i.set(r, "" + e), n.borders.push(t);
1105
1167
  }
1106
- }(0, t.border, n), t.numberFormat !== void 0 && function(e, t, n) {
1168
+ }(0, t.borders, n), t.numberFormat !== void 0 && function(e, t, n) {
1107
1169
  if (!t) return;
1108
- let r = R.toBuiltInID(t), i = n.numFmtMap;
1170
+ let r = pe.toBuiltInID(t), i = n.numFmtMap;
1109
1171
  if (!i.has(r)) {
1110
1172
  let e = 0;
1111
- typeof r == "number" ? e = r : (e = n.numFmtsCustom.length + pt, n.numFmtsCustom.push(r)), i.set(t, "" + e);
1173
+ typeof r == "number" ? e = r : (e = n.numFmtsCustom.length + Vt, n.numFmtsCustom.push(r)), i.set(t, "" + e);
1112
1174
  }
1113
1175
  }(0, t.numberFormat, n);
1114
1176
  }
1115
1177
  }
1116
- function st(e, t, n) {
1178
+ function Pt(e, t, n) {
1117
1179
  if (!t) return;
1118
1180
  let r = t.name.toLowerCase();
1119
- n.namedStyleMap.has(r) || (n.namedStyleMap.set(r, "" + n.namedStyleMap.size), n.namedStyles.push(t), ot(e, t.style, n));
1181
+ n.namedStyleMap.has(r) || (n.namedStyleMap.set(r, "" + n.namedStyleMap.size), n.namedStyles.push(t), Nt(e, t.style, n));
1120
1182
  }
1121
- function ct(e, t, n, r, i = !1) {
1183
+ function Ft(e, t, n, r, i = !1) {
1122
1184
  let a = r.getDefaultFontSize(), o = r.getTheme().getFontScheme().getMinorFont() ?? "Calibri", s = r.getNormal().getFont().getColor();
1123
1185
  t.start("font"), n.weight && n.weight >= 700 && t.empty("b"), n.style && n.style !== "normal" && t.empty("i"), n.strike && t.empty("strike"), n.underline && t.empty("u", { val: n.underline }), n.outline && t.empty("outline"), n.shadow && t.empty("shadow"), n.extend && t.empty("extend");
1124
1186
  let c = n.verticalAlign;
1125
- c && (c === "super" && (c = "superscript"), c === "sub" && (c = "subscript"), t.empty("vertAlign", { val: c })), i ? n.size !== void 0 && t.empty("sz", { val: String(n.size) }) : t.empty("sz", { val: String(n.size ?? a) }), G(t, r.getTheme(), n.color ?? s, "color", !i);
1187
+ c && (c === "super" && (c = "superscript"), c === "sub" && (c = "subscript"), t.empty("vertAlign", { val: c })), i ? n.size !== void 0 && t.empty("sz", { val: String(n.size) }) : t.empty("sz", { val: String(n.size ?? a) }), q(t, r.getTheme(), n.color ?? s, "color", !i);
1126
1188
  let l = !i || n.family && n.family !== o;
1127
1189
  if (l && (t.empty("name", { val: n.family ?? o }), n.fallbacks && n.fallbacks.length > 0)) {
1128
1190
  let e = n.fallbacks;
@@ -1132,57 +1194,59 @@ function ct(e, t, n, r, i = !1) {
1132
1194
  let u = n.scheme ?? (n.family === void 0 ? "minor" : void 0);
1133
1195
  l && u !== void 0 && u !== "none" && t.empty("scheme", { val: u }), t.end("font");
1134
1196
  }
1135
- function X(e, t, n, r, i, a = !1) {
1197
+ function It(e, t, n, r, i, a = !1) {
1136
1198
  if (!i || i.style === "none" || !i.style) return void (a && !i || t.empty(r));
1137
1199
  t.start(r, { style: i.style });
1138
1200
  let o = i.color;
1139
- o && G(t, n, o, "color", !a, a), t.end(r);
1201
+ o && q(t, n, o, "color", !a, a), t.end(r);
1140
1202
  }
1141
- function lt(e, t, n, r, i = !1) {
1203
+ function Lt(e, t, n, r, i = !1) {
1142
1204
  let a = {};
1143
- i ? (a.diagonalUp = "0", a.diagonalDown = "0") : (n.diagonalUp && (a.diagonalUp = "1"), n.diagonalDown && (a.diagonalDown = "1")), t.start("border", a), X(0, t, r, "left", n.left, i), X(0, t, r, "right", n.right, i), X(0, t, r, "top", n.top, i), X(0, t, r, "bottom", n.bottom, i), i ? (X(0, t, r, "vertical", n.vertical, i), X(0, t, r, "horizontal", n.horizontal, i)) : X(0, t, r, "diagonal", n.diagonalUp ?? n.diagonalDown, i), t.end("border");
1205
+ i ? (a.diagonalUp = "0", a.diagonalDown = "0") : (n.diagonalUp && (a.diagonalUp = "1"), n.diagonalDown && (a.diagonalDown = "1")), t.start("border", a), It(0, t, r, "left", n.left, i), It(0, t, r, "right", n.right, i), It(0, t, r, "top", n.top, i), It(0, t, r, "bottom", n.bottom, i), i ? (It(0, t, r, "vertical", n.vertical, i), It(0, t, r, "horizontal", n.horizontal, i)) : It(0, t, r, "diagonal", n.diagonalUp ?? n.diagonalDown, i), t.end("border");
1144
1206
  }
1145
- function ut(e, t, n, r = !1) {
1207
+ function Rt(e, t, n, r = !1) {
1146
1208
  let i = {};
1147
- n.horizontal && n.horizontal !== L.HorizontalAlignment.General && (i.horizontal = n.horizontal), n.vertical && n.vertical !== L.VerticalAlignment.Bottom && (i.vertical = n.vertical);
1209
+ n.horizontal && n.horizontal !== H.HorizontalAlignment.General && (i.horizontal = n.horizontal), n.vertical && n.vertical !== H.VerticalAlignment.Bottom && (i.vertical = n.vertical);
1148
1210
  let a = n.rotation;
1149
1211
  n.stacked && (i.textRotation = "255", a = 0), a && (a >= 270 && a < 360 ? a = 360 - a : a > 0 && a <= 90 && (a += 90), i.textRotation = String(a));
1150
1212
  let o = n.overflow;
1151
- switch (o === L.Overflow.Wrap && (i.wrapText = "1"), n.indent && (i.indent = "" + n.indent), n.relativeIndent && (i.relativeIndent = "" + n.relativeIndent), n.justifyLastLine && (i.justifyLastLine = "1"), o === L.Overflow.Shrink && (i.shrinkToFit = "1"), n.readingDirection) {
1152
- case L.ReadingDirection.Auto: break;
1153
- case L.ReadingDirection.LeftToRight:
1213
+ switch (o === H.Overflow.Wrap && (i.wrapText = "1"), n.indent && (i.indent = "" + n.indent), n.relativeIndent && (i.relativeIndent = "" + n.relativeIndent), n.justifyLastLine && (i.justifyLastLine = "1"), o === H.Overflow.Shrink && (i.shrinkToFit = "1"), n.readingDirection) {
1214
+ case H.ReadingDirection.Auto: break;
1215
+ case H.ReadingDirection.LeftToRight:
1154
1216
  i.readingOrder = "1";
1155
1217
  break;
1156
- case L.ReadingDirection.RightToLeft: i.readingOrder = "2";
1218
+ case H.ReadingDirection.RightToLeft: i.readingOrder = "2";
1157
1219
  }
1158
1220
  return Object.keys(i).length > 0 ? i : null;
1159
1221
  }
1160
- function dt(e, t, n, r, i, a) {
1161
- let o = {}, s = null, c = r.named;
1162
- c && (s = n.getNamed(c).toJSON().style);
1163
- let l = r.font ?? s?.font, u = l ? i.fontMap.get(E.JSONStableStringify(l)) ?? 0 : 0, d = r.fill ?? s?.fill, f = d ? i.fillMap.get(E.JSONStableStringify(d)) ?? 0 : 0, p = r.border ?? s?.border, m = p ? i.borderMap.get(E.JSONStableStringify(p)) ?? 0 : 0, h = r.numberFormat ?? s?.numberFormat;
1164
- if (o.numFmtId = (h === void 0 ? void 0 : i.numFmtMap.get(h)) ?? "0", o.fontId = String(u), o.fillId = String(f), o.borderId = String(m), a) {
1165
- let e = r.named ?? I.BuiltInName.Normal;
1166
- o.xfId = i.namedStyleMap.get(e.toLowerCase());
1167
- }
1168
- let g = null, _ = r.alignment ?? s?.alignment;
1169
- _ && (g = ut(0, 0, _)), r.font && (o.applyFont = "1"), r.fill && (o.applyFill = "1"), r.numberFormat && (o.applyNumberFormat = "1"), r.border && (o.applyBorder = "1"), g && (o.applyAlignment = "1"), r.quotePrefix && (o.quotePrefix = "1"), g ? (t.start("xf", o), g && t.empty("alignment", g), t.end("xf")) : t.empty("xf", o);
1222
+ function zt(e, t, n, r, i, a, o = !1) {
1223
+ let s = {}, c = null, l = r.named;
1224
+ l && (c = n.getNamedStyles().getByName(l).toJSON().style);
1225
+ let u = r.font ?? c?.font, d = u ? i.fontMap.get(F.JSONStableStringify(u)) ?? 0 : 0, f = r.fill ?? c?.fill, p = f ? i.fillMap.get(F.JSONStableStringify(f)) ?? 0 : 0, m = r.borders ?? c?.borders, h = m ? i.borderMap.get(F.JSONStableStringify(m)) ?? 0 : 0, g = r.numberFormat ?? c?.numberFormat;
1226
+ if (s.numFmtId = (g === void 0 ? void 0 : i.numFmtMap.get(g)) ?? "0", s.fontId = String(d), s.fillId = String(p), s.borderId = String(h), a) {
1227
+ let e = r.named ?? V.BuiltInName.Normal;
1228
+ s.xfId = i.namedStyleMap.get(e.toLowerCase());
1229
+ }
1230
+ let _ = null, v = r.alignment ?? c?.alignment;
1231
+ v && (_ = Rt(0, 0, v)), r.font && (s.applyFont = "1"), r.fill && (s.applyFill = "1"), r.numberFormat && (s.applyNumberFormat = "1"), r.borders && (s.applyBorder = "1"), _ && (s.applyAlignment = "1");
1232
+ let y = null, b = r.protection?.alwaysUnlocked ?? c?.protection?.alwaysUnlocked ?? !1;
1233
+ (b || o) && (y = {}, b && (y.locked = "0"), o && (y.hidden = "1"), s.applyProtection = "1"), r.quotePrefix && (s.quotePrefix = "1"), _ || y ? (t.start("xf", s), _ && t.empty("alignment", _), y && t.empty("protection", y), t.end("xf")) : t.empty("xf", s);
1170
1234
  }
1171
- function ft(e, t, n, r, i, a = "dxf", o = pt) {
1172
- if (t.start(a), n.font && ct(0, t, n.font, r, !0), n.numberFormat !== void 0 && n.numberFormat !== null) {
1173
- let e = R.toBuiltInID(n.numberFormat), r = typeof e == "number", i = r ? R.builtInFormat(e) : String(e);
1235
+ function Bt(e, t, n, r, i, a = "dxf", o = Vt) {
1236
+ if (t.start(a), n.font && Ft(0, t, n.font, r, !0), n.numberFormat !== void 0 && n.numberFormat !== null) {
1237
+ let e = pe.toBuiltInID(n.numberFormat), r = typeof e == "number", i = r ? pe.builtInFormat(e) : String(e);
1174
1238
  i && t.empty("numFmt", {
1175
1239
  numFmtId: String(r ? e : o++),
1176
1240
  formatCode: i
1177
1241
  });
1178
1242
  }
1179
- if (n.fill && K(0, t, n.fill, r, !0, !0), n.alignment) {
1180
- let e = ut(0, 0, n.alignment, !0);
1243
+ if (n.fill && J(0, t, n.fill, r, !0, !0), n.alignment) {
1244
+ let e = Rt(0, 0, n.alignment, !0);
1181
1245
  e && t.empty("alignment", e);
1182
1246
  }
1183
- return n.border && lt(0, t, n.border, i, !0), t.end(a), o;
1247
+ return n.borders && Lt(0, t, n.borders, i, !0), t.end(a), o;
1184
1248
  }
1185
- var pt = 164, mt = Object.freeze([
1249
+ var Vt = 164, Ht = Object.freeze([
1186
1250
  "wholeTable",
1187
1251
  "headerRow",
1188
1252
  "totalRow",
@@ -1196,7 +1260,7 @@ var pt = 164, mt = Object.freeze([
1196
1260
  "lastHeaderCell",
1197
1261
  "firstTotalCell",
1198
1262
  "lastTotalCell"
1199
- ]), ht = A.BuiltInOperatorNames, gt = (e, t, n, r, i, a) => {
1263
+ ]), Ut = R.BuiltInOperatorNames, Wt = (e, t, n, r, i, a) => {
1200
1264
  let o = r.sorts, s = o ? o.length : 0;
1201
1265
  if (s === 0) return;
1202
1266
  let c = {};
@@ -1215,7 +1279,7 @@ var pt = 164, mt = Object.freeze([
1215
1279
  }).toString(), r.sortOn && (c.sortBy = r.sortOn), r.dxfId !== void 0 && (c.dxfId = r.dxfId), r.iconSet !== void 0 && (c.iconSet = r.iconSet), r.customList !== void 0 && (c.customList = r.customList), t.empty("sortCondition", c);
1216
1280
  }
1217
1281
  t.end("sortState");
1218
- }, _t = (e, t, n, r, i = !1) => {
1282
+ }, Gt = (e, t, n, r, i = !1) => {
1219
1283
  let a = n.getRange();
1220
1284
  n.isShowTotals() && (a = a.getResizeBy(-1, 0));
1221
1285
  let o = a.getCoords(), s = r.sort, c = r.filter, l = c ? c.conditions : void 0, u = l ? l.length : 0, d = r.hiddenButtons, f = {};
@@ -1235,58 +1299,58 @@ var pt = 164, mt = Object.freeze([
1235
1299
  r.columns ? c = r.columns.length : i && (c = a.getColumnCount()), t.start("autoFilter", f);
1236
1300
  for (let n = 0; n < c; n++) {
1237
1301
  let r = !0 === d || !0 === p?.[n], i = m[n];
1238
- (i || r) && yt(e, t, n, i, r);
1302
+ (i || r) && qt(e, t, n, i, r);
1239
1303
  }
1240
- s && i && gt(0, t, n, s, a, o), t.end("autoFilter");
1304
+ s && i && Wt(0, t, n, s, a, o), t.end("autoFilter");
1241
1305
  } else t.empty("autoFilter", f);
1242
- s && !i && gt(0, t, n, s, a, o);
1243
- }, vt = (e, t, n) => {
1244
- let r = v(n, (t) => e.warn(t, n));
1306
+ s && !i && Wt(0, t, n, s, a, o);
1307
+ }, Kt = (e, t, n) => {
1308
+ let r = ee(n, (t) => e.warn(t, n));
1245
1309
  if (!r) return;
1246
1310
  let i = { operator: r.operator };
1247
1311
  r.val !== void 0 && (i.val = r.val), t.empty("customFilter", i);
1248
- }, yt = (e, t, n, r, i) => {
1312
+ }, qt = (e, t, n, r, i) => {
1249
1313
  let a = {};
1250
1314
  a.colId = "" + n, i && (a.hiddenButton = "1"), r ? (t.start("filterColumn", a), ((e, t, n) => {
1251
1315
  let r = n.operator;
1252
- if (r !== A.BuiltInOperatorNames.Expression) if (r !== A.BuiltInOperatorNames.Unique) {
1253
- if (r === A.BuiltInOperatorNames.Color) {
1316
+ if (r !== R.BuiltInOperatorNames.Expression) if (r !== R.BuiltInOperatorNames.Unique) {
1317
+ if (r === R.BuiltInOperatorNames.Color) {
1254
1318
  let e = n.param, r = {};
1255
1319
  e.cellColor !== void 0 && (r.cellColor = e.cellColor ? "1" : "0"), e.styleId !== void 0 && (r.dxfId = e.styleId), t.empty("colorFilter", r);
1256
1320
  }
1257
- if (bt(r)) if (r === "between") {
1321
+ if (Jt(r)) if (r === "between") {
1258
1322
  let r = n.param;
1259
- t.start("customFilters", { and: "1" }), vt(e, t, {
1260
- operator: ht.GreaterThanEqualTo,
1323
+ t.start("customFilters", { and: "1" }), Kt(e, t, {
1324
+ operator: Ut.GreaterThanEqualTo,
1261
1325
  param: r.from
1262
- }), vt(e, t, {
1263
- operator: ht.LessThanEqualTo,
1326
+ }), Kt(e, t, {
1327
+ operator: Ut.LessThanEqualTo,
1264
1328
  param: r.to
1265
1329
  }), t.end("customFilters");
1266
- } else if (r === A.BuiltInOperatorNames.Not) {
1330
+ } else if (r === R.BuiltInOperatorNames.Not) {
1267
1331
  let r = n.param;
1268
- p(r?.operator) ? (t.start("customFilters"), vt(e, t, n), t.end("customFilters")) : e.warn("Not rule with non-comparison criteria not supported in OOXML", r);
1269
- } else if (r === A.BuiltInOperatorNames.And || r === A.BuiltInOperatorNames.Or) {
1332
+ C(r?.operator) ? (t.start("customFilters"), Kt(e, t, n), t.end("customFilters")) : e.warn("Not rule with non-comparison criteria not supported in OOXML", r);
1333
+ } else if (r === R.BuiltInOperatorNames.And || r === R.BuiltInOperatorNames.Or) {
1270
1334
  let i = n.param, a = i.length;
1271
1335
  if (a > 0) {
1272
1336
  let n = {};
1273
- r === A.BuiltInOperatorNames.And && a > 1 && (n.and = "1"), t.start("customFilters", n);
1337
+ r === R.BuiltInOperatorNames.And && a > 1 && (n.and = "1"), t.start("customFilters", n);
1274
1338
  for (let n = 0; n < a; n++) {
1275
- let r = i[n], a = r.operator === ht.Not && p(r.param?.operator);
1276
- p(r.operator) || a ? vt(e, t, r) : e.warn("Only Comparison criteria supported in Union conditions for Table AutoFilters", r);
1339
+ let r = i[n], a = r.operator === Ut.Not && C(r.param?.operator);
1340
+ C(r.operator) || a ? Kt(e, t, r) : e.warn("Only Comparison criteria supported in Union conditions for Table AutoFilters", r);
1277
1341
  }
1278
1342
  t.end("customFilters");
1279
1343
  }
1280
- } else p(r) && (t.start("customFilters"), vt(e, t, n), t.end("customFilters"));
1281
- if (r === A.BuiltInOperatorNames.TimePeriod) {
1344
+ } else C(r) && (t.start("customFilters"), Kt(e, t, n), t.end("customFilters"));
1345
+ if (r === R.BuiltInOperatorNames.TimePeriod) {
1282
1346
  let e = n.param, r = {};
1283
1347
  e.type && (r.type = e.type), e.anchorDate !== void 0 && (r.val = "" + e.anchorDate), e.maxVal !== void 0 && (r.maxVal = "" + e.maxVal), t.empty("dynamicFilter", r);
1284
1348
  }
1285
- if (r === A.BuiltInOperatorNames.Average) {
1349
+ if (r === R.BuiltInOperatorNames.Average) {
1286
1350
  let e = n.param, r = {}, i = e.type;
1287
- i && (i === A.AverageType.Above ? r.type = "aboveAverage" : i === A.AverageType.Below && (r.type = "belowAverage")), e.stdDevs !== void 0 && (r.val = "" + e.stdDevs), t.empty("dynamicFilter", r);
1351
+ i && (i === R.AverageType.Above ? r.type = "aboveAverage" : i === R.AverageType.Below && (r.type = "belowAverage")), e.stdDevs !== void 0 && (r.val = "" + e.stdDevs), t.empty("dynamicFilter", r);
1288
1352
  }
1289
- if (r === A.BuiltInOperatorNames.InSet) {
1353
+ if (r === R.BuiltInOperatorNames.InSet) {
1290
1354
  let e = n.param;
1291
1355
  if (e.dateGroups) {
1292
1356
  let n = e.dateGroups, r = n.length;
@@ -1307,153 +1371,162 @@ var pt = 164, mt = Object.freeze([
1307
1371
  t.end("filters");
1308
1372
  }
1309
1373
  }
1310
- if (r === A.BuiltInOperatorNames.Icon) {
1374
+ if (r === R.BuiltInOperatorNames.Icon) {
1311
1375
  let e = n.param, r = {};
1312
1376
  e.iconSet !== void 0 && (r.iconSet = e.iconSet), e.iconId !== void 0 && (r.iconId = "" + e.iconId), t.empty("iconFilter", r);
1313
1377
  }
1314
- if (r === A.BuiltInOperatorNames.TopN) {
1378
+ if (r === R.BuiltInOperatorNames.TopN) {
1315
1379
  let e = n.param, r = {};
1316
1380
  e.percent && (r.percent = "1"), e.top !== void 0 && (r.top = e.top ? "1" : "0"), e.limit !== void 0 && (r.val = "" + e.limit), e.filterVal !== void 0 && (r.filterVal = "" + e.filterVal), t.empty("top10", r);
1317
1381
  }
1318
1382
  } else e.warn("Unique conditions not supported in Table AutoFilters", n);
1319
1383
  else e.warn("Expression conditions not supported in Table AutoFilters", n);
1320
1384
  })(e, t, r), t.end("filterColumn")) : t.empty("filterColumn", a);
1321
- }, bt = (e) => e === A.BuiltInOperatorNames.GreaterThan || e === A.BuiltInOperatorNames.GreaterThanEqualTo || e === A.BuiltInOperatorNames.LessThan || e === A.BuiltInOperatorNames.LessThanEqualTo || e === A.BuiltInOperatorNames.EqualTo || e === A.BuiltInOperatorNames.And || e === A.BuiltInOperatorNames.Or || e === A.BuiltInOperatorNames.Not || e === "between", xt = "16.0000", St = 1048575, Ct = 16383, wt = {
1385
+ }, Jt = (e) => e === R.BuiltInOperatorNames.GreaterThan || e === R.BuiltInOperatorNames.GreaterThanEqualTo || e === R.BuiltInOperatorNames.LessThan || e === R.BuiltInOperatorNames.LessThanEqualTo || e === R.BuiltInOperatorNames.EqualTo || e === R.BuiltInOperatorNames.And || e === R.BuiltInOperatorNames.Or || e === R.BuiltInOperatorNames.Not || e === "between", Yt = {
1322
1386
  names: /* @__PURE__ */ new Set(),
1323
1387
  perFormula: [],
1324
1388
  affects: () => !1
1325
- }, Tt = 1048576, Et = (e, t, n) => {
1389
+ }, Xt = 1048576, Zt = (e, t, n) => {
1326
1390
  if (!n) return [];
1327
1391
  let r = 0;
1328
1392
  for (let i = 0; i < n.length; i++) {
1329
1393
  let a = n[i][0], o = t.getRange(a).getCoords();
1330
- if (r += (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1), r > Tt) return e.warn(`Direct styles cover more than ${Tt} cells; not writing the styles from '${a}' on. A range that size belongs in a column or row style.`), n.slice(0, i);
1394
+ if (r += (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1), r > Xt) return e.warn(`Direct styles cover more than ${Xt} cells; not writing the styles from '${a}' on. A range that size belongs in a column or row style.`), n.slice(0, i);
1331
1395
  }
1332
1396
  return n;
1333
1397
  };
1334
- function Dt(e, t) {
1398
+ function Qt(e, t) {
1335
1399
  let n = t.type;
1336
- n === j.ColorStopType.AutoMin ? n = j.ColorStopType.Min : n === j.ColorStopType.AutoMax && (n = j.ColorStopType.Max), e.empty("cfvo", {
1400
+ n === z.ColorStopType.AutoMin ? n = z.ColorStopType.Min : n === z.ColorStopType.AutoMax && (n = z.ColorStopType.Max), e.empty("cfvo", {
1337
1401
  type: n,
1338
1402
  val: t.value,
1339
1403
  gte: t.exclusive ? "0" : void 0
1340
1404
  });
1341
1405
  }
1342
- function Ot(e, t) {
1406
+ function $t(e, t) {
1343
1407
  let n = {
1344
1408
  type: t.type,
1345
1409
  gte: t.exclusive ? "0" : void 0
1346
1410
  };
1347
1411
  t.value === void 0 ? e.empty("x14:cfvo", n) : (e.start("x14:cfvo", n), e.start("xm:f"), e.text(t.value), e.end("xm:f"), e.end("x14:cfvo"));
1348
1412
  }
1349
- var kt = /* @__PURE__ */ new Set([
1350
- I.IconSet.Arrows3,
1351
- I.IconSet.ArrowsGray3,
1352
- I.IconSet.Flags3,
1353
- I.IconSet.Signs3,
1354
- I.IconSet.Symbols3,
1355
- I.IconSet.Symbols3_2,
1356
- I.IconSet.TrafficLights3,
1357
- I.IconSet.TrafficLights3_2,
1358
- I.IconSet.Arrows4,
1359
- I.IconSet.ArrowsGray4,
1360
- I.IconSet.Rating4,
1361
- I.IconSet.RedToBlack4,
1362
- I.IconSet.TrafficLights4,
1363
- I.IconSet.Arrows5,
1364
- I.IconSet.ArrowsGray5,
1365
- I.IconSet.Quarters5,
1366
- I.IconSet.Rating5
1413
+ var en = /* @__PURE__ */ new Set([
1414
+ V.IconSet.Arrows3,
1415
+ V.IconSet.ArrowsGray3,
1416
+ V.IconSet.Flags3,
1417
+ V.IconSet.Signs3,
1418
+ V.IconSet.Symbols3,
1419
+ V.IconSet.Symbols3_2,
1420
+ V.IconSet.TrafficLights3,
1421
+ V.IconSet.TrafficLights3_2,
1422
+ V.IconSet.Arrows4,
1423
+ V.IconSet.ArrowsGray4,
1424
+ V.IconSet.Rating4,
1425
+ V.IconSet.RedToBlack4,
1426
+ V.IconSet.TrafficLights4,
1427
+ V.IconSet.Arrows5,
1428
+ V.IconSet.ArrowsGray5,
1429
+ V.IconSet.Quarters5,
1430
+ V.IconSet.Rating5
1367
1431
  ]);
1368
- function At(e) {
1369
- return (e.icon?.length ?? 0) > 0 || e.iconSet !== void 0 && !kt.has(e.iconSet);
1432
+ function tn(e) {
1433
+ return (e.icon?.length ?? 0) > 0 || e.iconSet !== void 0 && !en.has(e.iconSet);
1370
1434
  }
1371
- function jt(e, t, n, o, s, c, l, u, d) {
1372
- let f = o.scale;
1373
- o.ext && e.warn("Conditional format extension payload is not written to xlsx; it will be lost.");
1374
- let p = {
1375
- type: s.type,
1376
- dxfId: o.style && Object.keys(o.style).length > 0 ? u.add(o.style) : void 0,
1377
- priority: l,
1378
- stopIfTrue: Z(o.stopIfTrue),
1379
- aboveAverage: Z(s.aboveAverage),
1380
- equalAverage: Z(s.equalAverage),
1381
- stdDev: s.stdDev,
1382
- bottom: Z(s.bottom),
1383
- percent: Z(s.percent),
1384
- rank: s.rank,
1385
- operator: s.operator,
1386
- text: s.text,
1387
- timePeriod: s.timePeriod
1388
- }, m;
1389
- f?.type === j.ScaleType.DataBar && function(e) {
1435
+ function nn(e, t, n, r, i, a, o, s, l) {
1436
+ let u = r.scale;
1437
+ r.ext && e.warn("Conditional format extension payload is not written to xlsx; it will be lost.");
1438
+ let d = {
1439
+ type: i.type,
1440
+ dxfId: r.style && Object.keys(r.style).length > 0 ? s.add(r.style) : void 0,
1441
+ priority: o,
1442
+ stopIfTrue: Q(r.stopIfTrue),
1443
+ aboveAverage: Q(i.aboveAverage),
1444
+ equalAverage: Q(i.equalAverage),
1445
+ stdDev: i.stdDev,
1446
+ bottom: Q(i.bottom),
1447
+ percent: Q(i.percent),
1448
+ rank: i.rank,
1449
+ operator: i.operator,
1450
+ text: i.text,
1451
+ timePeriod: i.timePeriod
1452
+ }, f;
1453
+ u?.type === z.ScaleType.DataBar && function(e) {
1390
1454
  if (e.gradient || e.borderColor || e.negativeFillColor || e.negativeBorderColor || e.axisColor || e.axisPosition || e.direction) return !0;
1391
1455
  let t = e.stops, n = t ? t.length : 0;
1392
1456
  for (let e = 0; e < n; e++) {
1393
1457
  let n = t[e].type;
1394
- if (n === j.ColorStopType.AutoMin || n === j.ColorStopType.AutoMax) return !0;
1458
+ if (n === z.ColorStopType.AutoMin || n === z.ColorStopType.AutoMax) return !0;
1395
1459
  }
1396
1460
  return !1;
1397
- }(f) && (m = a(D.uuidV4), d.push({
1398
- guid: m,
1399
- sqref: c,
1400
- priority: l,
1401
- scale: f
1461
+ }(u) && (f = x(I.uuidV4), l.push({
1462
+ guid: f,
1463
+ sqref: a,
1464
+ priority: o,
1465
+ scale: u
1402
1466
  }));
1403
- let h = s.formulas, g = h ? h.length : 0;
1404
- if (g !== 0 || f) {
1405
- t.start("cfRule", p);
1406
- for (let e = 0; e < g; e++) t.start("formula"), t.text(h[e]), t.end("formula");
1407
- if (f?.type === j.ScaleType.ColorScale) {
1408
- let e = f.stops ?? [];
1467
+ let p = i.formulas, m = p ? p.length : 0;
1468
+ if (m !== 0 || u) {
1469
+ t.start("cfRule", d);
1470
+ for (let e = 0; e < m; e++) t.start("formula"), t.text(p[e]), t.end("formula");
1471
+ if (u?.type === z.ScaleType.ColorScale) {
1472
+ let e = u.stops ?? [];
1409
1473
  t.start("colorScale");
1410
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1411
- for (let r = 0; r < e.length; r++) G(t, n, e[r].color, "color");
1474
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1475
+ for (let r = 0; r < e.length; r++) q(t, n, e[r].color, "color");
1412
1476
  t.end("colorScale");
1413
- } else if (f?.type === j.ScaleType.DataBar) {
1414
- let e = f.stops ?? [];
1477
+ } else if (u?.type === z.ScaleType.DataBar) {
1478
+ let e = u.stops ?? [];
1415
1479
  t.start("dataBar", {
1416
- minLength: f.minLength,
1417
- maxLength: f.maxLength,
1418
- showValue: Z(f.showValue)
1480
+ minLength: u.minLength,
1481
+ maxLength: u.maxLength,
1482
+ showValue: Q(u.showValue)
1419
1483
  });
1420
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1421
- f.color && G(t, n, f.color, "color"), t.end("dataBar");
1422
- } else if (f?.type === j.ScaleType.IconSet) {
1423
- let e = f.stops ?? [];
1484
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1485
+ u.color && q(t, n, u.color, "color"), t.end("dataBar");
1486
+ } else if (u?.type === z.ScaleType.IconSet) {
1487
+ let e = u.stops ?? [];
1424
1488
  t.start("iconSet", {
1425
- iconSet: f.iconSet,
1426
- reverse: Z(f.reverse),
1427
- showValue: Z(f.showValue)
1489
+ iconSet: u.iconSet,
1490
+ reverse: Q(u.reverse),
1491
+ showValue: Q(u.showValue)
1428
1492
  });
1429
- for (let n = 0; n < e.length; n++) Dt(t, e[n]);
1493
+ for (let n = 0; n < e.length; n++) Qt(t, e[n]);
1430
1494
  t.end("iconSet");
1431
1495
  }
1432
- m && (t.start("extLst"), t.start("ext", {
1433
- uri: i,
1434
- "xmlns:x14": r
1435
- }), t.start("x14:id"), t.text(m), t.end("x14:id"), t.end("ext"), t.end("extLst")), t.end("cfRule");
1436
- } else t.empty("cfRule", p);
1496
+ f && (t.start("extLst"), t.start("ext", {
1497
+ uri: c,
1498
+ "xmlns:x14": T
1499
+ }), t.start("x14:id"), t.text(f), t.end("x14:id"), t.end("ext"), t.end("extLst")), t.end("cfRule");
1500
+ } else t.empty("cfRule", d);
1437
1501
  }
1438
- function Mt(e) {
1439
- return e.split(" ")[0].split(":")[0];
1502
+ function rn(e) {
1503
+ let t = 2 ** 53 - 1, n = 2 ** 53 - 1, r = e.split(" ");
1504
+ for (let e = 0; e < r.length; e++) {
1505
+ if (!r[e]) continue;
1506
+ let i = P.fastStringToRange(r[e]);
1507
+ i.rowStart < t && (t = i.rowStart), i.colStart < n && (n = i.colStart);
1508
+ }
1509
+ return P.cellToString({
1510
+ rowIndex: t,
1511
+ colIndex: n
1512
+ });
1440
1513
  }
1441
- function Nt(e) {
1514
+ function an(e) {
1442
1515
  if (typeof e == "string") return e.split(",").join(" ");
1443
1516
  if (Array.isArray(e)) {
1444
1517
  let t = [];
1445
1518
  for (let n = 0; n < e.length; n++) {
1446
- let r = T.rangeToString(e[n]);
1519
+ let r = P.rangeToString(e[n]);
1447
1520
  r && t.push(r);
1448
1521
  }
1449
1522
  return t.length > 0 ? t.join(" ") : null;
1450
1523
  }
1451
- return T.rangeToString(e);
1524
+ return P.rangeToString(e);
1452
1525
  }
1453
- function Z(e) {
1526
+ function Q(e) {
1454
1527
  if (e !== void 0) return e ? "1" : "0";
1455
1528
  }
1456
- function Pt(e) {
1529
+ function on(e) {
1457
1530
  if (typeof e != "string") return !1;
1458
1531
  let t = !1;
1459
1532
  for (let n = 0; n < e.length; n++) {
@@ -1463,18 +1536,112 @@ function Pt(e) {
1463
1536
  }
1464
1537
  return !1;
1465
1538
  }
1466
- function Ft(e) {
1539
+ function sn(e) {
1467
1540
  let t = e.formulas, n = t ? t.length : 0;
1468
- for (let e = 0; e < n; e++) if (Pt(t[e])) return !0;
1541
+ for (let e = 0; e < n; e++) if (on(t[e])) return !0;
1469
1542
  return !1;
1470
1543
  }
1471
- var It = {
1544
+ function cn(e) {
1545
+ let t = 2 ** 53 - 1, n = 2 ** 53 - 1, r = e.split(" ");
1546
+ for (let e = 0; e < r.length; e++) {
1547
+ if (!r[e]) continue;
1548
+ let i = P.fastStringToRange(r[e]);
1549
+ i.rowStart < t && (t = i.rowStart), i.colStart < n && (n = i.colStart);
1550
+ }
1551
+ return t === 2 ** 53 - 1 ? null : {
1552
+ rowIndex: t,
1553
+ colIndex: n
1554
+ };
1555
+ }
1556
+ function ln(e, t, n) {
1557
+ if (typeof e != "string" || !e || !t || !n) return e;
1558
+ try {
1559
+ let r = n.parse(e, t);
1560
+ return r && ce.image(n.spell(r, !0), { at: t }) || e;
1561
+ } catch {
1562
+ return e;
1563
+ }
1564
+ }
1565
+ function un(e, t, n) {
1566
+ let r = e?.stops;
1567
+ if (!r || !n) return e;
1568
+ let i;
1569
+ for (let e = 0; e < r.length; e++) {
1570
+ let a = r[e]?.value;
1571
+ if (typeof a != "string") continue;
1572
+ let o = ln(a, t, n);
1573
+ o !== a && (i ||= [...r], i[e] = {
1574
+ ...r[e],
1575
+ value: o
1576
+ });
1577
+ }
1578
+ return i ? {
1579
+ ...e,
1580
+ stops: i
1581
+ } : e;
1582
+ }
1583
+ function dn(e, t, n, r) {
1584
+ if (!r?.xml) return;
1585
+ let i = e.addPart("legacyDrawing", r);
1586
+ t.empty(n, { "r:id": i.relId });
1587
+ }
1588
+ var fn = (e, t) => {
1589
+ if (!t) return e;
1590
+ let n = e?.xml ?? null, r = _(n ?? ""), i = [], a = t.comments;
1591
+ for (let e = 0; e < a.length; e++) {
1592
+ let { comment: t, row: n, col: o } = a[e], s = t.toJSON()?.box, c = s?.xml ? te(s.xml).notes[0] : void 0;
1593
+ if (c) {
1594
+ let e = A(c.xml);
1595
+ e !== null && (r = Math.max(r, e)), i.push(O(c, n, o));
1596
+ } else i.push(b(n, o, ++r));
1597
+ }
1598
+ let o = w(n, i);
1599
+ return o ? o === n ? e : e ? {
1600
+ ...e,
1601
+ xml: o
1602
+ } : { xml: o } : e;
1603
+ }, pn = (e) => e.content?.type !== "control", mn = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp", hn = (e, t) => {
1604
+ if (!e?.xml) return e;
1605
+ let n = t.movables;
1606
+ if (!n) return e;
1607
+ let r = /* @__PURE__ */ new Map(), i = n.length;
1608
+ for (let e = 0; e < i; e++) {
1609
+ let t = n[e];
1610
+ if (pn(t)) continue;
1611
+ let i = t.content?.json?.shapeId;
1612
+ typeof i == "number" && r.set(i, t);
1613
+ }
1614
+ if (r.size === 0) return e;
1615
+ let a = e.xml.replace(/<v:shape\b[\s\S]*?<\/v:shape>/g, (e) => {
1616
+ let t = /\bo:spid="_x0000_s(\d+)"/.exec(e) ?? /\bid="_x0000_s(\d+)"/.exec(e), n = t ? r.get(parseInt(t[1], 10)) : void 0;
1617
+ if (!n) return e;
1618
+ let i = n.anchor, a = [
1619
+ i.tl.c,
1620
+ i.tl.r,
1621
+ i.br.c,
1622
+ i.br.r
1623
+ ];
1624
+ return e.replace(/(<x:Anchor>)([\s\d,-]*)(<\/x:Anchor>)/, (e, t, n, r) => {
1625
+ let i = n.split(",").map((e) => e.trim());
1626
+ if (i.length !== 8) return e;
1627
+ let o = i.slice();
1628
+ for (let e = 0; e < 4; e++) o[2 * e] = String(a[e] ?? 0);
1629
+ return o.join(",") === i.join(",") ? e : `${t}${o.join(", ")}${r}`;
1630
+ });
1631
+ });
1632
+ return a === e.xml ? e : {
1633
+ ...e,
1634
+ xml: a
1635
+ };
1636
+ }, gn = (e, t, n) => {
1637
+ e.start(t), e.start("xdr:col"), e.text(n.c ?? 0), e.end("xdr:col"), e.start("xdr:colOff"), e.text(X(n.x)), e.end("xdr:colOff"), e.start("xdr:row"), e.text(n.r ?? 0), e.end("xdr:row"), e.start("xdr:rowOff"), e.text(X(n.y)), e.end("xdr:rowOff"), e.end(t);
1638
+ }, _n = {
1472
1639
  r: void 0,
1473
1640
  s: void 0,
1474
1641
  t: void 0,
1475
1642
  cm: void 0,
1476
1643
  vm: void 0
1477
- }, Lt = {
1644
+ }, vn = {
1478
1645
  r: void 0,
1479
1646
  s: void 0,
1480
1647
  customFormat: void 0,
@@ -1484,29 +1651,29 @@ var It = {
1484
1651
  "x14ac:dyDescent": "0.25",
1485
1652
  outlineLevel: void 0,
1486
1653
  collapsed: void 0
1487
- }, Rt = {
1654
+ }, yn = {
1488
1655
  t: void 0,
1489
1656
  aca: void 0,
1490
1657
  ref: void 0,
1491
1658
  ca: void 0,
1492
1659
  si: void 0
1493
- }, zt = {
1660
+ }, bn = {
1494
1661
  t: "shared",
1495
1662
  aca: void 0,
1496
1663
  ref: void 0,
1497
1664
  ca: void 0,
1498
1665
  si: void 0
1499
- }, Bt = {
1666
+ }, xn = {
1500
1667
  t: "array",
1501
1668
  aca: void 0,
1502
1669
  ref: void 0,
1503
1670
  ca: void 0,
1504
1671
  si: void 0
1505
1672
  };
1506
- function Vt(e, t, n, r) {
1673
+ function Sn(e, t, n, r) {
1507
1674
  n && (t.start(r), t.empty("latin", { typeface: n }), t.empty("ea", { typeface: "" }), t.empty("cs", { typeface: "" }), t.end(r));
1508
1675
  }
1509
- var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1676
+ var Cn = (e) => e.toISOString().split(".")[0] + "Z", wn = (e, t, n) => {
1510
1677
  switch (t) {
1511
1678
  case "creator":
1512
1679
  e.start("dc:creator"), e.text(n), e.end("dc:creator");
@@ -1519,10 +1686,10 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1519
1686
  break;
1520
1687
  case "modified": e.start("dcterms:modified", { "xsi:type": "dcterms:W3CDTF" }), e.text(n), e.end("dcterms:modified");
1521
1688
  }
1522
- }, Q = (e, t, n, r) => {
1689
+ }, $ = (e, t, n, r) => {
1523
1690
  t.start(n), t.text(r), t.end(n);
1524
- }, Wt = (e, t, n) => {
1525
- let r = n.getSheets().getItems({ visibility: P.Visibility.Hidden }).map((e) => e.getName()), i = n.getNames().getItems({ type: "formula" }).filter((e) => !!e.getRanges?.()).map((e) => e.getName());
1691
+ }, Tn = (e, t, n) => {
1692
+ let r = n.getSheets().getItems({ visibility: ue.Visibility.Hidden }).map((e) => e.getName()), i = n.getNames().getItems({ type: "formula" }).filter((e) => !!e.getRanges?.()).map((e) => e.getName());
1526
1693
  t.start("HeadingPairs"), t.start("vt:vector", {
1527
1694
  size: i.length > 0 ? "4" : "2",
1528
1695
  baseType: "variant"
@@ -1533,7 +1700,7 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1533
1700
  for (let e of r) t.start("vt:lpstr"), t.text(e), t.end("vt:lpstr");
1534
1701
  for (let e of i) t.start("vt:lpstr"), t.text(e), t.end("vt:lpstr");
1535
1702
  t.end("vt:vector"), t.end("TitlesOfParts");
1536
- }, Gt = {
1703
+ }, En = {
1537
1704
  minSupportedVersion: "120000",
1538
1705
  copy: "1",
1539
1706
  pasteAll: "1",
@@ -1545,17 +1712,17 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1545
1712
  clearComments: "1",
1546
1713
  assign: "1",
1547
1714
  coerce: "1"
1548
- }, Kt = (e, t, n = D.EmptyArray) => {
1715
+ }, Dn = (e, t, n = I.EmptyArray) => {
1549
1716
  if (!t) return { ...n };
1550
1717
  let { text: r, runs: i, color: a, size: o, kern: s, weight: c, style: l, b: u, i: d, spc: f, baseline: p, ...m } = t, h = {
1551
1718
  ...n,
1552
1719
  ...m
1553
1720
  };
1554
- return o !== void 0 && (h.sz = "" + nt(o)), u !== void 0 && (h.b = u ? "1" : "0"), c !== void 0 && (h.b = c > 500 ? "1" : "0"), d !== void 0 && (h.i = d ? "1" : "0"), l !== void 0 && (h.i = l === "italic" ? "1" : "0"), s !== void 0 && (h.kern = "" + nt(s)), f !== void 0 && (h.spc = "" + nt(f)), p !== void 0 && (h.baseline = "" + nt(p)), h;
1555
- }, qt = (e, t, n) => {
1721
+ return o !== void 0 && (h.sz = "" + kt(o)), u !== void 0 && (h.b = u ? "1" : "0"), c !== void 0 && (h.b = c > 500 ? "1" : "0"), d !== void 0 && (h.i = d ? "1" : "0"), l !== void 0 && (h.i = l === "italic" ? "1" : "0"), s !== void 0 && (h.kern = "" + kt(s)), f !== void 0 && (h.spc = "" + kt(f)), p !== void 0 && (h.baseline = "" + kt(p)), h;
1722
+ }, On = (e, t, n) => {
1556
1723
  if (!n) return;
1557
1724
  let r = e.getXMLWriter();
1558
- r.start("txBody"), r.pushDefaultNamespace("a"), Yt(e, t, {
1725
+ r.start("txBody"), r.pushDefaultNamespace("a"), An(e, t, {
1559
1726
  vertOverflow: "clip",
1560
1727
  horzOverflow: "clip",
1561
1728
  rtlCol: "0",
@@ -1564,28 +1731,28 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1564
1731
  if (!n) return;
1565
1732
  let r = e.getXMLWriter();
1566
1733
  r.pushDefaultNamespace("a"), typeof n == "string" && (n = { runs: [{ text: n }] }), r.start("p"), r.empty("pPr", { algn: "ctr" });
1567
- let i = Kt(0, n, {
1568
- ...Xt,
1734
+ let i = Dn(0, n, {
1735
+ ...jn,
1569
1736
  size: t.getDefaultFontSize()
1570
1737
  }), a = n?.runs, o = a ? a.length : 0;
1571
1738
  if (o > 0) for (let e = 0; e < o; e++) {
1572
1739
  let n = a[e];
1573
1740
  r.start("r", {});
1574
- let i = Kt(0, n, Xt), o = n.color;
1575
- o ? (r.start("rPr", i), K(0, r, o, t), r.end("rPr")) : r.empty("rPr", i), r.start("t"), r.text(n?.text ?? ""), r.end("t"), r.end("r");
1741
+ let i = Dn(0, n, jn), o = n.color;
1742
+ o ? (r.start("rPr", i), J(0, r, o, t), r.end("rPr")) : r.empty("rPr", i), r.start("t"), r.text(n?.text ?? ""), r.end("t"), r.end("r");
1576
1743
  }
1577
1744
  else r.empty("endParaRPr", i);
1578
1745
  r.end("p"), r.popDefaultNamespace();
1579
1746
  })(e, t, n), r.popDefaultNamespace(), r.end("txBody");
1580
- }, Jt = (e, t, n) => {
1747
+ }, kn = (e, t, n) => {
1581
1748
  if (!n) return;
1582
- let r = e.getXMLWriter(), i = Kt(0, n);
1749
+ let r = e.getXMLWriter(), i = Dn(0, n);
1583
1750
  r.empty("defRPr", i);
1584
- }, Yt = (e, t, n) => {
1751
+ }, An = (e, t, n) => {
1585
1752
  if (!n) return;
1586
1753
  let r = e.getXMLWriter(), { spAutoFit: i, ...a } = n;
1587
1754
  i ? (r.start("bodyPr", a), r.empty("spAutoFit"), r.end("bodyPr")) : r.empty("bodyPr", a);
1588
- }, Xt = Object.freeze({ lang: "en-US" }), Zt = (e, t) => {
1755
+ }, jn = Object.freeze({ lang: "en-US" }), Mn = (e, t) => {
1589
1756
  if (t.length !== 0) {
1590
1757
  e.start("a:extLst");
1591
1758
  for (let n of t) {
@@ -1594,22 +1761,22 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1594
1761
  }
1595
1762
  e.end("a:extLst");
1596
1763
  }
1597
- }, Qt = async (e, t, n, r, i) => {
1764
+ }, Nn = async (e, t, n, r, i) => {
1598
1765
  let a = e.getSharedStates(), o = r.getContent().getResource(), s = await o.getExternalURI(), c;
1599
- if (s) c = e.addExternal(et, s);
1766
+ if (s) c = e.addExternal(Et, s);
1600
1767
  else if (c = n.get(o), !c) {
1601
- let t = a.get("imagesWritten");
1602
- t || (t = /* @__PURE__ */ new Map(), a.set("imagesWritten", t));
1768
+ let t = a.get(Dt);
1769
+ t || (t = /* @__PURE__ */ new Map(), a.set(Dt, t));
1603
1770
  let r = t.get(o);
1604
1771
  if (!r) {
1605
1772
  let e = await o.toBuffer();
1606
1773
  r = {
1607
1774
  bytes: new Uint8Array(e),
1608
- type: await o.getType() ?? tt,
1775
+ type: await o.getType() ?? Ot,
1609
1776
  index: t.size + 1
1610
1777
  }, t.set(o, r);
1611
1778
  }
1612
- c = e.addBinary(r.bytes, r.type.mime, et, `../media/image${r.index}.${r.type.ext}`, !0), n.set(o, c);
1779
+ c = e.addBinary(r.bytes, r.type.mime, Et, `../media/image${r.index}.${r.type.ext}`, !0), n.set(o, c);
1613
1780
  }
1614
1781
  let l = { "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" };
1615
1782
  s ? l["r:link"] = c.relId : l["r:embed"] = c.relId;
@@ -1623,30 +1790,26 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1623
1790
  }
1624
1791
  ]);
1625
1792
  let d = e.getXMLWriter();
1626
- d.start("pic"), d.start("nvPicPr"), cn(e, d, r, i, t), un(e, d, r, i), d.end("nvPicPr"), d.start("blipFill"), d.start("a:blip", l), Zt(d, u), d.end("a:blip"), d.start("a:stretch"), d.empty("a:fillRect"), d.end("a:stretch"), d.end("blipFill"), on(e, t, n, r, i), d.end("pic");
1627
- }, $t = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", en = async (e, t, n, r, i, a) => {
1628
- let o = i.content?.json, s = o?.xml, c = o?.chartRelId, l = o?.chartTargetPath;
1629
- if (!s || !c || !l) return $(e, t, n, r, i);
1630
- let u = e.getSharedStates(), d, f = u.get("claimedChartTargets");
1631
- if (f || (f = /* @__PURE__ */ new Set(), u.set("claimedChartTargets", f)), f.has(l)) {
1632
- let a = e.forkPreservedPart(l, "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", $t, "../charts/chart{n}.xml");
1633
- if (!a?.relId) return $(e, t, n, r, i);
1634
- d = a.relId;
1635
- } else f.add(l), d = e.addPreservedRelationship($t, l, c);
1636
- let p = d === c ? s : s.replace(`r:id="${c}"`, `r:id="${d}"`);
1637
- a !== void 0 && typeof o?.sourceId == "number" && (p = p.replace(`cNvPr id="${o.sourceId}"`, `cNvPr id="${a}"`)), e.getXMLWriter().raw(p);
1638
- }, tn = async (e, t, n, r, i) => $(e, t, n, r, i), nn = async (e, t, n, r, i) => $(e, t, n, r, i), rn = async (e, t, n, r, i) => $(e, t, n, r, i), an = async (e, t, n, r, i, a) => {
1793
+ d.start("pic"), d.start("nvPicPr"), Hn(e, d, r, i, t), Wn(e, d, r, i), d.end("nvPicPr"), d.start("blipFill"), d.start("a:blip", l), Mn(d, u), d.end("a:blip"), d.start("a:stretch"), d.empty("a:fillRect"), d.end("a:stretch"), d.end("blipFill"), Bn(e, t, n, r, i), d.end("pic");
1794
+ }, Pn = async (e, t, n, r, i, a) => {
1795
+ let o = i.content?.json, s = o?.xml, c = o?.part;
1796
+ if (!s || !c) return zn(e, t, n, r, i);
1797
+ let l = await Ze(c, e, "../charts/chart{n}.xml");
1798
+ if (!l?.relId) return zn(e, t, n, r, i);
1799
+ let u = l.relId === c.id ? s : s.replace(`r:id="${c.id}"`, `r:id="${l.relId}"`);
1800
+ a !== void 0 && typeof i.content?.json?.sourceId == "number" && (u = u.replace(`cNvPr id="${i.content.json.sourceId}"`, `cNvPr id="${a}"`)), e.getXMLWriter().raw(u);
1801
+ }, Fn = async (e, t, n, r, i) => zn(e, t, n, r, i), In = async (e, t, n, r, i) => zn(e, t, n, r, i), Ln = async (e, t, n, r, i) => zn(e, t, n, r, i), Rn = async (e, t, n, r, i, a) => {
1639
1802
  let o = i.content?.json, s = o?.xml;
1640
- if (!s) return $(e, t, n, r, i);
1803
+ if (!s) return zn(e, t, n, r, i);
1641
1804
  let c = a !== void 0 && typeof o?.sourceId == "number" ? s.replace(`cNvPr id="${o.sourceId}"`, `cNvPr id="${a}"`) : s;
1642
1805
  e.getXMLWriter().raw(c);
1643
- }, $ = async (e, t, n, r, i) => {
1806
+ }, zn = async (e, t, n, r, i) => {
1644
1807
  (async (e, t, n, r, i) => {
1645
1808
  let a = e.getXMLWriter(), o = {}, s = i.content?.json, c = s?.type ?? "sp", l = t.getStyles();
1646
- c === "cxnSp" ? (o.macro = "", a.start("cxnSp", o), a.start("nvCxnSpPr"), cn(e, a, r, i, t), ln(e, a, r, i, t), a.start("cNvCxnSpPr"), a.empty("a:stCnx", {
1809
+ c === "cxnSp" ? (o.macro = "", a.start("cxnSp", o), a.start("nvCxnSpPr"), Hn(e, a, r, i, t), Un(e, a, r, i, t), a.start("cNvCxnSpPr"), a.empty("a:stCnx", {
1647
1810
  id: "0",
1648
1811
  idx: "0"
1649
- }), a.end("cNvCxnSpPr"), a.end("nvCxnSpPr"), on(e, t, n, r, i), sn(e, t, n, r, i), qt(e, l, s?.text), a.end("cxnSp")) : c === "grpSp" || (o.macro = "", o.textlink = "", a.start("sp", o), a.start("nvSpPr"), cn(e, a, r, i, t), ln(e, a, r, i, t), a.end("nvSpPr"), on(e, t, n, r, i), sn(e, t, n, r, i), qt(e, l, s?.text), a.end("sp"));
1812
+ }), a.end("cNvCxnSpPr"), a.end("nvCxnSpPr"), Bn(e, t, n, r, i), Vn(e, t, n, r, i), On(e, l, s?.text), a.end("cxnSp")) : c === "grpSp" || (o.macro = "", o.textlink = "", a.start("sp", o), a.start("nvSpPr"), Hn(e, a, r, i, t), Un(e, a, r, i, t), a.end("nvSpPr"), Bn(e, t, n, r, i), Vn(e, t, n, r, i), On(e, l, s?.text), a.end("sp"));
1650
1813
  })(e, t, n, r, {
1651
1814
  ...i,
1652
1815
  content: {
@@ -1664,13 +1827,13 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1664
1827
  }
1665
1828
  }
1666
1829
  });
1667
- }, on = (e, t, n, r, i) => {
1830
+ }, Bn = (e, t, n, r, i) => {
1668
1831
  let a = e.getXMLWriter(), o = i.content?.json, s = o?.geometry ?? "rect", c = t.getStyles();
1669
- a.start("spPr"), a.pushDefaultNamespace("a"), dn(a, r, i), a.start("prstGeom", { prst: s }), a.empty("avLst"), a.end("prstGeom"), Xe(e, c, o), a.popDefaultNamespace(), a.end("spPr");
1670
- }, sn = (e, t, n, r, i) => {
1832
+ a.start("spPr"), a.pushDefaultNamespace("a"), Gn(a, r, i), a.start("prstGeom", { prst: s }), a.empty("avLst"), a.end("prstGeom"), St(e, c, o), a.popDefaultNamespace(), a.end("spPr");
1833
+ }, Vn = (e, t, n, r, i) => {
1671
1834
  let a = e.getXMLWriter();
1672
1835
  a.start("style"), a.pushDefaultNamespace("a"), a.start("lnRef", { idx: "1" }), a.start("schemeClr", { val: "accent1" }), a.empty("shade", { val: "15000" }), a.end("schemeClr"), a.end("lnRef"), a.start("fillRef", { idx: "1" }), a.empty("schemeClr", { val: "accent1" }), a.end("fillRef"), a.start("effectRef", { idx: "0" }), a.empty("schemeClr", { val: "accent1" }), a.end("effectRef"), a.start("fontRef", { idx: "minor" }), a.empty("schemeClr", { val: "lt1" }), a.end("fontRef"), a.popDefaultNamespace(), a.end("style");
1673
- }, cn = (e, t, n, r, i) => {
1836
+ }, Hn = (e, t, n, r, i) => {
1674
1837
  let a = e.getSharedStates(), o = a.get("uniqueIdCounter");
1675
1838
  o || (o = /* @__PURE__ */ new Map(), a.set("uniqueIdCounter", o));
1676
1839
  let s = o.get(i) ?? 1;
@@ -1686,41 +1849,90 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1686
1849
  "a16:creationId",
1687
1850
  {
1688
1851
  "xmlns:a16": "http://schemas.microsoft.com/office/drawing/2014/main",
1689
- id: `{${D.uuidV4().toUpperCase()}}`
1852
+ id: `{${I.uuidV4().toUpperCase()}}`
1690
1853
  }
1691
- ]), t.start("cNvPr", c), Zt(t, l), t.end("cNvPr");
1692
- }, ln = (e, t, n, r, i) => {
1854
+ ]), t.start("cNvPr", c), Mn(t, l), t.end("cNvPr");
1855
+ }, Un = (e, t, n, r, i) => {
1693
1856
  t.empty("cNvSpPr");
1694
- }, un = (e, t, n, r) => {
1857
+ }, Wn = (e, t, n, r) => {
1695
1858
  let i = {};
1696
1859
  if (r.lockAspect && (i.noChangeAspect = "1"), r.locks) for (let e of Object.keys(r.locks)) !0 === r.locks[e] && (i[e] = "1");
1697
1860
  t.start("cNvPicPr", {}), t.empty("a:picLocks", i), t.end("cNvPicPr");
1698
- }, dn = (e, t, n) => {
1861
+ }, Gn = (e, t, n) => {
1699
1862
  let r = t.getBounds(), i = {}, a = n.rotation;
1700
- a !== void 0 && a !== 0 && (i.rot = "" + Y(a)), e.start("xfrm", i), e.start("off", {
1701
- x: J(r.x),
1702
- y: J(r.y)
1863
+ a !== void 0 && a !== 0 && (i.rot = "" + Z(a)), e.start("xfrm", i), e.start("off", {
1864
+ x: X(r.x),
1865
+ y: X(r.y)
1703
1866
  }), e.end("off"), e.start("ext", {
1704
- cx: J(r.width),
1705
- cy: J(r.height)
1867
+ cx: X(r.width),
1868
+ cy: X(r.height)
1706
1869
  }), e.end("ext"), e.end("xfrm");
1707
- }, fn = (e, t, n) => {
1708
- e.start(t), e.start("col"), e.text(n.c ?? 0), e.end("col"), e.start("colOff"), e.text(J(n.x)), e.end("colOff"), e.start("row"), e.text(n.r ?? 0), e.end("row"), e.start("rowOff"), e.text(J(n.y)), e.end("rowOff"), e.end(t);
1709
- }, pn = 0, mn = (e, t, n, r) => {
1870
+ }, Kn = (e, t, n) => {
1871
+ e.start(t), e.start("col"), e.text(n.c ?? 0), e.end("col"), e.start("colOff"), e.text(X(n.x)), e.end("colOff"), e.start("row"), e.text(n.r ?? 0), e.end("row"), e.start("rowOff"), e.text(X(n.y)), e.end("rowOff"), e.end(t);
1872
+ }, qn = async (e, t, n) => {
1873
+ let r = await n.getExternalURI();
1874
+ if (r) return void e.addExternal(Et, r);
1875
+ let i = e.getSharedStates(), a = i.get(Dt);
1876
+ a || (a = /* @__PURE__ */ new Map(), i.set(Dt, a));
1877
+ let o = a.get(n);
1878
+ if (!o) {
1879
+ let e = await n.toBuffer();
1880
+ o = {
1881
+ bytes: new Uint8Array(e),
1882
+ type: await n.getType() ?? Ot,
1883
+ index: a.size + 1
1884
+ }, a.set(n, o);
1885
+ }
1886
+ let s = e.addBinary(o.bytes, o.type.mime, Et, `../media/image${o.index}.${o.type.ext}`, !0, t);
1887
+ s.relId !== t && e.log(`Legacy drawing image '${t}' was written as '${s.relId}'; the markup will not find it.`);
1888
+ };
1889
+ function Jn(e, t, r, i, a, o, s, c) {
1890
+ let l = {
1891
+ ref: t,
1892
+ dT: (a ?? /* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "Z"),
1893
+ personId: i ? Yn(i) : void 0,
1894
+ id: Yn(r),
1895
+ parentId: s ? Yn(s) : void 0,
1896
+ done: c ? "1" : void 0
1897
+ };
1898
+ e.start("threadedComment", l), e.start("text", ie.test(o) || /[\n\r]/.test(o) ? n : void 0), e.text(o), e.end("text"), e.end("threadedComment");
1899
+ }
1900
+ function Yn(e) {
1901
+ return `{${e.replace(/^\{|\}$/g, "").toUpperCase()}}`;
1902
+ }
1903
+ var Xn = 0, Zn = (e, t, n, r) => {
1710
1904
  let i = r.columns, a = i ? i.length : 0;
1711
1905
  if (a !== 0) {
1712
1906
  t.start("tableColumns", { count: a });
1713
- for (let e = 0; e < a; e++) {
1714
- let n = i[e];
1715
- typeof n == "string" && (n = { name: n });
1716
- let r = {};
1717
- r.id = e + 1, r.name = n.name ?? `Column${e + 1}`;
1718
- let a = null, o = n.totalsRowFormula;
1719
- o && (typeof o == "number" && (o = _n.get(o)), o && !gn.has(o.toLowerCase()) && (a = o, o = "custom"), o && (r.totalsRowFunction = o)), n.totalsRowLabel && (r.totalsRowLabel = n.totalsRowLabel), a ? (t.start("tableColumn", r), t.start("totalsRowFormula"), t.text(a), t.end("totalsRowFormula"), t.end("tableColumn")) : t.empty("tableColumn", r);
1907
+ for (let o = 0; o < a; o++) {
1908
+ let a = i[o];
1909
+ typeof a == "string" && (a = { name: a });
1910
+ let s = {};
1911
+ s.id = o + 1, s.name = a.name ?? `Column${o + 1}`;
1912
+ let c = null, l = a.totalsRowFormula;
1913
+ if (typeof l == "number") {
1914
+ let e = er.get(l);
1915
+ e ? s.totalsRowFunction = e : c = `SUBTOTAL(${l},${r.name?.trim()}[${s.name}])`;
1916
+ } else l && (c = Qn(e, n, o, l.startsWith("=") ? l.substring(1) : l));
1917
+ c && (s.totalsRowFunction = "custom"), a.totalsRowLabel && (s.totalsRowLabel = a.totalsRowLabel);
1918
+ let u = a.calculatedColumnFormula ? Qn(e, n, o, a.calculatedColumnFormula) : null;
1919
+ (c || u) && (t.start("tableColumn", s), u && (t.start("calculatedColumnFormula"), t.text(u), t.end("calculatedColumnFormula"))), c && (t.start("totalsRowFormula"), t.text(c), t.end("totalsRowFormula")), c || u ? t.end("tableColumn") : t.empty("tableColumn", s);
1720
1920
  }
1721
1921
  t.end("tableColumns");
1722
1922
  }
1723
- }, hn = (e, t, n, r) => {
1923
+ }, Qn = (e, t, n, r) => {
1924
+ let i = e.getSharedStates().get(o);
1925
+ if (!i) return r;
1926
+ try {
1927
+ let e = t.getDataRange().getCoords(), a = {
1928
+ rowIndex: e.rowStart,
1929
+ colIndex: e.colStart + n
1930
+ }, o = i.parse(r, a);
1931
+ return o && ce.image(i.spell(o, !1, t.getName()), { at: a }) || r;
1932
+ } catch {
1933
+ return r;
1934
+ }
1935
+ }, $n = (e, t, n, r) => {
1724
1936
  let i = {
1725
1937
  name: n.getStyle().getName(),
1726
1938
  showFirstColumn: n.isShowHighlightFirstColumn() ? "1" : "0",
@@ -1729,33 +1941,56 @@ var Ht = (e) => e.toISOString().split(".")[0] + "Z", Ut = (e, t, n) => {
1729
1941
  showColumnStripes: n.isShowBandedColumns() ? "1" : "0"
1730
1942
  };
1731
1943
  t.empty("tableStyleInfo", i);
1732
- }, gn = /* @__PURE__ */ new Map([
1733
- ["average", 101],
1734
- ["countnums", 102],
1735
- ["count", 103],
1736
- ["max", 104],
1737
- ["min", 105],
1738
- ["product", 106],
1739
- ["stddev", 107],
1740
- ["stddevp", 108],
1741
- ["sum", 109],
1742
- ["var", 110]
1743
- ]), _n = /* @__PURE__ */ new Map();
1744
- gn.forEach((e, t) => {
1745
- _n.set(e, t);
1746
- });
1747
- var vn = (e, t, n, r) => {
1944
+ }, er = /* @__PURE__ */ new Map([
1945
+ [101, "average"],
1946
+ [102, "countNums"],
1947
+ [103, "count"],
1948
+ [104, "max"],
1949
+ [105, "min"],
1950
+ [107, "stdDev"],
1951
+ [109, "sum"],
1952
+ [110, "var"]
1953
+ ]), tr = {
1954
+ rowIndex: 0,
1955
+ colIndex: 0
1956
+ };
1957
+ function nr(e, t, n, r) {
1958
+ if (r == null) return;
1959
+ tr.rowIndex = t, tr.colIndex = n;
1960
+ let i = P.cellToString(tr), a, o;
1961
+ switch (typeof r) {
1962
+ case "number":
1963
+ o = "" + r;
1964
+ break;
1965
+ case "boolean":
1966
+ a = "b", o = r ? "1" : "0";
1967
+ break;
1968
+ case "string":
1969
+ a = "str", o = r;
1970
+ break;
1971
+ default: {
1972
+ let e = r;
1973
+ if (e.t !== "e") return;
1974
+ a = "e", o = se.getBuiltInByCode(e.v)?.getLabel() ?? se.BuiltIn.Value.getLabel();
1975
+ }
1976
+ }
1977
+ e.start("cell", a ? {
1978
+ r: i,
1979
+ t: a
1980
+ } : { r: i }), e.start("v"), e.text(o), e.end("v"), e.end("cell");
1981
+ }
1982
+ var rr = (e, t, n, r) => {
1748
1983
  t.start("mc:AlternateContent", { "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006" }), t.start("mc:Choice", {
1749
1984
  Requires: "c14",
1750
1985
  "xmlns:c14": "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"
1751
1986
  }), t.empty("c14:style", { val: "102" }), t.end("mc:Choice"), t.start("mc:Fallback"), t.empty("c:style", { val: "2" }), t.end("mc:Fallback"), t.end("mc:AlternateContent");
1752
- }, yn = (e, t, n, r, i) => {
1987
+ }, ir = (e, t, n, r, i) => {
1753
1988
  t.start("chart"), ((e, t, n, r, i) => {
1754
- t.start("title"), t.empty("overlay", { val: "0" }), Xe(e, n, i, "spPr", !0), t.end("title"), t.empty("autoTitleDeleted", { val: "0" });
1989
+ t.start("title"), t.empty("overlay", { val: "0" }), St(e, n, i, "spPr", !0), t.end("title"), t.empty("autoTitleDeleted", { val: "0" });
1755
1990
  })(e, t, n, 0, i), ((e, t, n, r, i) => {
1756
- t.start("plotArea"), t.empty("layout"), Xe(e, n, i, "spPr", !0), t.end("plotArea");
1991
+ t.start("plotArea"), t.empty("layout"), St(e, n, i, "spPr", !0), t.end("plotArea");
1757
1992
  })(e, t, n, 0, i), t.empty("plotVisOnly", { val: "1" }), t.empty("dispBlanksAs", { val: "gap" }), t.empty("showDLblsOverMax", { val: "0" }), t.end("chart");
1758
- }, bn = (e, t, n, r) => {
1993
+ }, ar = (e, t, n, r) => {
1759
1994
  t.start("printSettings"), t.empty("headerFooter"), t.empty("pageMargins", {
1760
1995
  b: "0.75",
1761
1996
  l: "0.7",
@@ -1764,16 +1999,16 @@ var vn = (e, t, n, r) => {
1764
1999
  header: "0.3",
1765
2000
  footer: "0.3"
1766
2001
  }), t.empty("pageSetup"), t.end("printSettings");
1767
- }, xn = (e, t, n, r, i, a = "0") => {
2002
+ }, or = (e, t, n, r, i, a = "0") => {
1768
2003
  let o = i?.color, s = { idx: i?.idx ?? a };
1769
- o === void 0 ? t.empty(r, s) : (t.start(r, s), o === "auto" ? t.empty("styleClr", { val: "auto" }) : (t.pushDefaultNamespace("a"), U(t, n.getTheme(), o), t.popDefaultNamespace()), t.end(r));
1770
- }, Sn = (e, t, n, r) => {
2004
+ o === void 0 ? t.empty(r, s) : (t.start(r, s), o === "auto" ? t.empty("styleClr", { val: "auto" }) : (t.pushDefaultNamespace("a"), G(t, n.getTheme(), o), t.popDefaultNamespace()), t.end(r));
2005
+ }, sr = (e, t, n, r) => {
1771
2006
  let i = n.length;
1772
2007
  for (let a = 0; a < i; a++) {
1773
2008
  let i = n[a];
1774
- i.empty ? t.empty(i.type, i.mods) : (t.start(i.type, i.mods), xn(0, t, r, "lnRef", i.lineRef, "0"), xn(0, t, r, "fillRef", i.fillRef, "0"), xn(0, t, r, "effectRef", i.effectRef, "0"), xn(0, t, r, "fontRef", i.fontRef, "minor"), Xe(e, r, i, "spPr"), Jt(e, 0, i.defRPr), Yt(e, r, i.bodyPr), t.end(i.type));
2009
+ i.empty ? t.empty(i.type, i.mods) : (t.start(i.type, i.mods), or(0, t, r, "lnRef", i.lineRef, "0"), or(0, t, r, "fillRef", i.fillRef, "0"), or(0, t, r, "effectRef", i.effectRef, "0"), or(0, t, r, "fontRef", i.fontRef, "minor"), St(e, r, i, "spPr"), kn(e, 0, i.defRPr), An(e, r, i.bodyPr), t.end(i.type));
1775
2010
  }
1776
- }, Cn = Object.freeze([
2011
+ }, cr = Object.freeze([
1777
2012
  {
1778
2013
  type: "axisTitle",
1779
2014
  fontRef: { color: "tx1 lumMod 65 lumOff 35" },
@@ -2125,13 +2360,13 @@ var vn = (e, t, n, r) => {
2125
2360
  fill: { type: "none" },
2126
2361
  stroke: {}
2127
2362
  }
2128
- ]), wn = (e, t, n) => {
2363
+ ]), lr = (e, t, n) => {
2129
2364
  let r = n.length;
2130
2365
  for (let e = 0; e < r; e++) {
2131
2366
  let r = n[e], i = {}, a = r[0], o = r[1];
2132
2367
  a || o ? (t.start("variation", i), a && t.empty("a:lumMod", { val: a }), o && t.empty("a:lumOff", { val: o }), t.end("variation")) : t.empty("variation", i);
2133
2368
  }
2134
- }, Tn = Object.freeze([
2369
+ }, ur = Object.freeze([
2135
2370
  [0, 0],
2136
2371
  [6e4, 0],
2137
2372
  [8e4, 2e4],
@@ -2141,8 +2376,8 @@ var vn = (e, t, n, r) => {
2141
2376
  [7e4, 3e4],
2142
2377
  [7e4, 0],
2143
2378
  [5e4, 5e4]
2144
- ]), En = [
2145
- new class extends B {
2379
+ ]), dr = [
2380
+ new class extends U {
2146
2381
  constructor() {
2147
2382
  super({
2148
2383
  kind: "workbook",
@@ -2164,24 +2399,39 @@ var vn = (e, t, n, r) => {
2164
2399
  "xmlns:xr10": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision10",
2165
2400
  "xmlns:xr2": "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
2166
2401
  });
2167
- let r = /* @__PURE__ */ new Set(), i = e.getCalculation().getNamedFormulas().getItems();
2168
- for (let e = 0; e < i.length; e++) r.add(i[e].getName().toUpperCase());
2169
- let a = l(r), o = await e.toJSON({
2402
+ let r = t.getSharedStates().get(he), i = await e.toJSON({
2170
2403
  ignoreData: !0,
2171
- ignoreResources: !0,
2404
+ resources: (e, t) => (r?.set(t, e), null),
2172
2405
  includeHeaderStyles: !0,
2173
- formulaTransform: a,
2174
2406
  splitDirectBorders: !0
2175
2407
  });
2176
- (function(e, t, n) {
2177
- let r = {};
2178
- n.getRuntime().isDate1904() && (r.date1904 = "1"), t.empty("workbookPr", r);
2179
- })(0, n, e), function(e, t, n, r) {
2408
+ t.getSharedStates().set(o, l(i.names, function(e) {
2409
+ let t = [], n = e.sheets ?? [];
2410
+ for (let e = 0; e < n.length; e++) {
2411
+ let r = n[e]?.sheet?.tables;
2412
+ if (r) for (let e = 0; e < r.length; e++) {
2413
+ let n = r[e], i = Array.isArray(n) ? n[1]?.name : n?.v?.name;
2414
+ i && t.push(String(i));
2415
+ }
2416
+ }
2417
+ return t;
2418
+ }(i))), function(e, t) {
2419
+ let n = e.getSharedStates().get(nt);
2420
+ n && t.empty("fileVersion", n);
2421
+ }(t, n), function(e, t, n, r) {
2422
+ let i = {}, a = n.getCodeName();
2423
+ a && (i.codeName = a), n.getRuntime().isDate1904() && (i.date1904 = "1"), r.updateLinks && (i.updateLinks = r.updateLinks), t.empty("workbookPr", i);
2424
+ }(0, n, e, i), function(e, t, n, r) {
2180
2425
  let i = r.protection;
2181
- if (!i) return;
2426
+ if (!i || i.workbook) return;
2182
2427
  let a = {};
2183
- Pe(i.password ?? {}, a, "workbook"), Pe(i.revisionsPassword ?? {}, a, "revisions"), i.structure && (a.lockStructure = "1"), i.windows && (a.lockWindows = "1"), i.revision && (a.lockRevision = "1"), t.empty("workbookProtection", a);
2184
- }(0, n, 0, o), function(e, t, n) {
2428
+ Ue(i.password ?? {}, a, "workbook"), Ue(i.revisionsPassword ?? {}, a, "revisions");
2429
+ for (let e of y) {
2430
+ let t = u(e, i[e.key]);
2431
+ t !== null && (a[e.attribute] = t);
2432
+ }
2433
+ t.empty("workbookProtection", a);
2434
+ }(0, n, 0, i), function(e, t, n) {
2185
2435
  t.start("bookViews");
2186
2436
  let r = n.getView(), i = {};
2187
2437
  r.isShowHorizontalScrollbar() || (i.showHorizontalScroll = "0"), r.isShowVerticalScrollbar() || (i.showVerticalScroll = "0"), r.isShowTabs() || (i.showSheetTabs = "0");
@@ -2189,89 +2439,177 @@ var vn = (e, t, n, r) => {
2189
2439
  a !== 600 && (i.tabRatio = a);
2190
2440
  let o = n.getSelectedSheet().getIndex();
2191
2441
  o !== 0 && (i.activeTab = "" + o), t.empty("workbookView", i), t.end("bookViews");
2192
- }(0, n, e, o.view), n.start("sheets");
2193
- let s = t.getSharedStates();
2194
- s.set("formulaTransform", a);
2195
- let c = e.getStrings().beginPersist();
2442
+ }(0, n, e, i.view);
2443
+ let a = await (async (e, t) => {
2444
+ let n = [], r = t ? t.length : 0;
2445
+ if (r === 0) return n;
2446
+ let i = /* @__PURE__ */ new Map();
2447
+ e.getSharedStates().set("pivotCachePaths", i);
2448
+ for (let a = 0; a < r; a++) {
2449
+ let r = t[a], o = r.cacheId, s = r.part;
2450
+ if (s?.xml && !i.has(o)) try {
2451
+ let t = await Ze({
2452
+ ...s,
2453
+ type: s.type || "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
2454
+ contentType: s.contentType || "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
2455
+ }, e, "/xl/pivotCache/pivotCacheDefinition{n}.xml");
2456
+ if (!t?.relId) continue;
2457
+ i.set(o, t.path), n.push({
2458
+ cacheId: o,
2459
+ relId: t.relId
2460
+ });
2461
+ } catch (t) {
2462
+ e.log(`Unable to write the pivot cache ${o}; the pivot tables on it will be dropped.`, t);
2463
+ }
2464
+ }
2465
+ return n;
2466
+ })(t, i.pivotCaches);
2467
+ (function(e, t) {
2468
+ t.getComments().some((e) => !e.isNote()) && e.addPart("persons", t.getPeople());
2469
+ })(t, e), n.start("sheets");
2470
+ let s = t.getSharedStates(), c = e.getStrings().beginPersist();
2196
2471
  s.set("persistStrings", c);
2197
- let u = new Fe();
2198
- s.set("metaCollector", u);
2199
- let d = new Ie(u, t.warn.bind(t));
2200
- s.set("persistRichTypes", d);
2472
+ let d = new Ke();
2473
+ s.set("metaCollector", d);
2474
+ let f = new qe(d, t.log.bind(t));
2475
+ s.set("persistRichTypes", f), s.set(We, new Ge(i.styles, e.getStyles()));
2201
2476
  try {
2202
- let r = e.getSheets().getItems({ visibility: P.Visibility.VeryHidden }), i = o.sheets, a = e.getSelectedSheet(), l = r.length;
2477
+ let r = e.getSheets().getItems({ visibility: ue.Visibility.VeryHidden }), a = i.sheets, o = e.getSelectedSheet(), l = r.length, u = ((e, t) => {
2478
+ let n = Array(t), r = /* @__PURE__ */ new Set(), i = 1;
2479
+ for (let a = 0; a < t; a++) {
2480
+ let t = e?.[a]?.sheetId;
2481
+ t === void 0 || !Number.isInteger(t) || t < 1 || r.has(t) || (r.add(t), n[a] = t, t >= i && (i = t + 1));
2482
+ }
2483
+ for (let e = 0; e < t; e++) if (n[e] === void 0) {
2484
+ for (; r.has(i);) i++;
2485
+ r.add(i), n[e] = i++;
2486
+ }
2487
+ return n;
2488
+ })(a, l), d = ((e, t, n) => {
2489
+ let r = t.length, i = Array(r), a = new Set(n?.values() ?? []), o = /* @__PURE__ */ new Set();
2490
+ for (let a = 0; a < r; a++) {
2491
+ let r = e?.[a]?.sheetId;
2492
+ if (r === void 0 || t[a] !== r) continue;
2493
+ let s = n?.get(r);
2494
+ s && !o.has(s) && (o.add(s), i[a] = s);
2495
+ }
2496
+ let s = 1;
2497
+ for (let e = 0; e < r; e++) {
2498
+ if (i[e]) continue;
2499
+ let t;
2500
+ do
2501
+ t = `xl/worksheets/sheet${s++}.xml`;
2502
+ while (a.has(t) || o.has(t));
2503
+ o.add(t), i[e] = t;
2504
+ }
2505
+ return i;
2506
+ })(a, u, s.get(rt));
2203
2507
  for (let e = 0; e < l; e++) {
2204
- let o = r[e], s = "" + (o.getIndex() + 1), l = {
2205
- name: o.getName(),
2508
+ let i = r[e], s = "" + u[e], l = {
2509
+ name: i.getName(),
2206
2510
  sheetId: s
2207
- }, u = o.getVisibility();
2208
- u === "hidden" ? l.state = "hidden" : u === "veryHidden" && (l.state = "veryHidden");
2209
- let d = i[e].sheet;
2511
+ }, f = i.getVisibility();
2512
+ f === "hidden" ? l.state = "hidden" : f === "veryHidden" && (l.state = "veryHidden");
2513
+ let p = a[e].sheet;
2210
2514
  l["r:id"] = t.addPart("worksheet", {
2211
- model: o,
2212
- isSelected: a === o,
2213
- json: d,
2515
+ model: i,
2516
+ isSelected: o === i,
2517
+ json: p,
2214
2518
  persistStrings: c
2215
- }).relId, n.empty("sheet", l);
2519
+ }, "/" + d[e]).relId, n.empty("sheet", l);
2216
2520
  }
2217
2521
  await t.waitEmit();
2218
- let u = e.getTheme();
2522
+ let f = e.getTheme();
2219
2523
  t.addPart("theme", {
2220
- model: u,
2221
- json: o.theme
2524
+ model: f,
2525
+ json: i.theme
2222
2526
  }), await t.waitEmit(), t.addPart("styles", {
2223
2527
  styles: e.getStyles(),
2224
2528
  theme: e.getTheme(),
2225
- json: o.styles
2529
+ json: i.styles
2226
2530
  }), await t.waitEmit();
2227
- let d = await c.toJSONAsync();
2228
- d && d.length > 0 && (t.addPart("sharedStrings", {
2229
- model: d,
2230
- json: d
2531
+ let p = await c.toJSONAsync();
2532
+ p && p.length > 0 && (t.addPart("sharedStrings", {
2533
+ model: p,
2534
+ json: p
2231
2535
  }), await t.waitEmit());
2232
- let f = s.get("persistRichTypes");
2233
- f?.hasAny() && (t.addPart("richValue", f), t.addPart("richValueStructure", f), t.addPart("richValueTypes", null), await t.waitEmit());
2234
- let p = s.get("metaCollector");
2235
- p?.hasAny() && (t.addPart("metadata", p), await t.waitEmit()), s.delete("persistRichTypes"), s.delete("metaCollector"), s.delete("persistStrings");
2536
+ let m = s.get("persistRichTypes");
2537
+ m?.hasAny() && (t.addPart("richValue", m), t.addPart("richValueStructure", m), t.addPart("richValueTypes", null), await t.waitEmit());
2538
+ let h = s.get("metaCollector");
2539
+ h?.hasAny() && (t.addPart("metadata", h), await t.waitEmit()), s.delete("persistRichTypes"), s.delete("metaCollector"), s.delete("persistStrings");
2236
2540
  } catch (e) {
2237
2541
  throw e;
2238
2542
  } finally {
2239
2543
  c.endPersist();
2240
2544
  }
2241
- n.end("sheets"), function(e, t, n, r, i) {
2242
- let a = r.names, o = a ? a.length : 0;
2243
- if (o === 0) return;
2244
- let s = n.getCalculation().getNamedFormulas(), c = /* @__PURE__ */ new Map(), l = n.getSheets().getItems({ visibility: P.Visibility.VeryHidden });
2245
- for (let e = 0; e < l.length; e++) c.set(l[e].getName().toLowerCase(), e);
2545
+ n.end("sheets"), function(e, t, n) {
2546
+ let r = n.externalBooks, i = r ? r.length : 0;
2547
+ if (i === 0) return;
2548
+ let a = e.getSharedStates().get(it), o = /* @__PURE__ */ new Set();
2549
+ if (a) for (let e = 0; e < i; e++) !r[e] && a[e] && o.add(a[e]);
2550
+ let s = [], c = 1;
2551
+ for (let t = 0; t < i; t++) {
2552
+ let n = r[t];
2553
+ if (n) {
2554
+ let t;
2555
+ do
2556
+ t = `xl/externalLinks/externalLink${c++}.xml`;
2557
+ while (o.has(t));
2558
+ s.push(e.addPart("externalLink", n, "/" + t).relId);
2559
+ continue;
2560
+ }
2561
+ let i = a?.[t], l = i ? e.addRelationship(tt, i) : null;
2562
+ l ? s.push(l) : e.log(`External link [${t + 1}] cannot be written and is being dropped; later links will renumber.`);
2563
+ }
2564
+ if (s.length !== 0) {
2565
+ t.start("externalReferences");
2566
+ for (let e = 0; e < s.length; e++) t.empty("externalReference", { "r:id": s[e] });
2567
+ t.end("externalReferences");
2568
+ }
2569
+ }(t, n, i), function(e, t, n, r) {
2570
+ let i = e.getSharedStates().get(o), a = r.names, s = a ? a.length : 0;
2571
+ if (s === 0) return;
2572
+ let c = r.externalBooks?.length ?? 0, l = /* @__PURE__ */ new Map(), u = n.getSheets().getItems({ visibility: ue.Visibility.VeryHidden });
2573
+ for (let e = 0; e < u.length; e++) l.set(u[e].getName().toLowerCase(), e);
2246
2574
  t.start("definedNames");
2247
- for (let n = 0; n < o; n++) {
2575
+ for (let n = 0; n < s; n++) {
2248
2576
  let r = a[n], o = { name: r.name };
2249
2577
  if (r.comment && (o.comment = r.comment), r.scope) {
2250
- let t = c.get(r.scope.toLowerCase());
2251
- t === void 0 ? e.warn(`Defined name '${r.name}' is scoped to unknown sheet '${r.scope}'; writing it as global.`) : o.localSheetId = "" + t;
2578
+ let t = l.get(r.scope.toLowerCase());
2579
+ t === void 0 ? e.log(`Defined name '${r.name}' is scoped to unknown sheet '${r.scope}'; writing it as global.`) : o.localSheetId = "" + t;
2252
2580
  }
2253
2581
  r.hidden && (o.hidden = "1");
2254
- let l = r.ref, u = s.getItems({
2255
- name: r.name,
2256
- scope: r.scope ?? null
2257
- })[0];
2258
- u && (l = u.getExpression({ formulaTransform: i })), t.start("definedName", o), t.text(l), t.end("definedName");
2582
+ let s = i.writeName(r.ref);
2583
+ for (let t of at(s)) t > c && e.log(`Defined name '${r.name}' cites external book [${t}], but only ${c} ${c === 1 ? "is" : "are"} written; Excel will report the file as needing repair.`);
2584
+ t.start("definedName", o), t.text(s), t.end("definedName");
2259
2585
  }
2260
2586
  t.end("definedNames");
2261
- }(t, n, e, o, a), function(e, t, n) {
2262
- let r = n.getCalculation().toJSON(), i = {}, a = (e, t) => {
2587
+ }(t, n, e, i), function(e, t, n) {
2588
+ let r = n.getCalculation().toJSON(), i = { calcId: e.getSharedStates().get("calcId") ?? "191029" }, a = (e, t) => {
2263
2589
  let n = r[e];
2264
2590
  typeof n == "boolean" && (i[t] = n ? "1" : "0");
2265
2591
  };
2266
2592
  if (r.calcMode) {
2267
- let e = Re[r.calcMode];
2593
+ let e = ot[r.calcMode];
2268
2594
  e && e !== "auto" && (i.calcMode = e);
2269
2595
  }
2270
- a("fullCalcOnLoad", "fullCalcOnLoad"), a("calcOnSave", "calcOnSave"), a("calcCompleted", "calcCompleted"), a("fullPrecision", "fullPrecision"), a("forceFullCalc", "forceFullCalc"), a("concurrentCalc", "concurrentCalc"), r.refMode && (i.refMode = r.refMode), r.iterate && (i.iterate = "1"), r.maxIterations !== void 0 && (i.iterateCount = String(r.maxIterations)), r.maxIterateChange !== void 0 && (i.iterateDelta = String(r.maxIterateChange)), Object.keys(i).length !== 0 && t.empty("calcPr", i);
2271
- }(0, n, e), n.end("workbook"), n.close();
2596
+ a("fullCalcOnLoad", "fullCalcOnLoad"), a("calcOnSave", "calcOnSave"), a("calcCompleted", "calcCompleted"), a("fullPrecision", "fullPrecision"), a("forceFullCalc", "forceFullCalc"), a("concurrentCalc", "concurrentCalc"), r.refMode && (i.refMode = r.refMode), r.iterate && (i.iterate = "1"), r.maxIteration !== void 0 && (i.iterateCount = String(r.maxIteration)), r.maxIterateChange !== void 0 && (i.iterateDelta = String(r.maxIterateChange)), t.empty("calcPr", i);
2597
+ }(t, n, e), function(e, t) {
2598
+ if (t.length !== 0) {
2599
+ e.start("pivotCaches");
2600
+ for (let n = 0; n < t.length; n++) e.empty("pivotCache", {
2601
+ cacheId: t[n].cacheId,
2602
+ "r:id": t[n].relId
2603
+ });
2604
+ e.end("pivotCaches");
2605
+ }
2606
+ }(n, a), function(e, t) {
2607
+ let n = e.getSharedStates().get("calcFeatures") ?? "<ext uri=\"{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}\" xmlns:xcalcf=\"http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures\"><xcalcf:calcFeatures><xcalcf:feature name=\"microsoft.com:RD\"/><xcalcf:feature name=\"microsoft.com:Single\"/><xcalcf:feature name=\"microsoft.com:FV\"/><xcalcf:feature name=\"microsoft.com:CNMTM\"/><xcalcf:feature name=\"microsoft.com:LET_WF\"/><xcalcf:feature name=\"microsoft.com:LAMBDA_WF\"/><xcalcf:feature name=\"microsoft.com:ARRAYTEXT_WF\"/></xcalcf:calcFeatures></ext>";
2608
+ t.start("extLst"), t.raw(n), t.end("extLst");
2609
+ }(t, n), n.end("workbook"), n.close();
2272
2610
  }
2273
2611
  }(),
2274
- new class extends B {
2612
+ new class extends U {
2275
2613
  constructor() {
2276
2614
  super({
2277
2615
  kind: "worksheet",
@@ -2280,8 +2618,8 @@ var vn = (e, t, n, r) => {
2280
2618
  path: () => "/xl/worksheets/sheet{n}.xml"
2281
2619
  });
2282
2620
  }
2283
- async emit(n, i) {
2284
- let s = i.getXMLWriter(), c = n.model, l = n.json;
2621
+ async emit(i, a) {
2622
+ let s = a.getXMLWriter(), c = i.model, d = i.json;
2285
2623
  s.decl(), s.start("worksheet", {
2286
2624
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
2287
2625
  "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
@@ -2289,10 +2627,17 @@ var vn = (e, t, n, r) => {
2289
2627
  "mc:Ignorable": "x14ac",
2290
2628
  "xmlns:x14ac": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
2291
2629
  }), function(e, t, n) {
2292
- let r = n.getTabColor();
2293
- r && (t.start("sheetPr"), r && G(t, n.getStyles().getTheme(), r, "tabColor", !1), t.end("sheetPr"));
2630
+ let r = n.getTabColor(), i = n.getCodeName(), a = {};
2631
+ i && (a.codeName = i), n.isConditionalFormatCalculationEnabled() || (a.enableFormatConditionsCalculation = "0");
2632
+ let o = n.getOutlineSettings(), s = {};
2633
+ o.summaryBelow || (s.summaryBelow = "0"), o.summaryRight || (s.summaryRight = "0"), o.showOutlineSymbols || (s.showOutlineSymbols = "0"), o.applyStyles && (s.applyStyles = "1");
2634
+ let c = Object.keys(s).length > 0, l = !!r || c;
2635
+ if (!(!l && Object.keys(a).length === 0)) {
2636
+ if (!l) return void t.empty("sheetPr", a);
2637
+ t.start("sheetPr", a), r && q(t, n.getStyles().getTheme(), r, "tabColor", !1), c && t.empty("outlinePr", s), t.end("sheetPr");
2638
+ }
2294
2639
  }(0, s, c), function(e, t, n, r) {
2295
- let i = n.getUsedRange({ features: [] }), a = i ? i.getCoords() : null, o = St, s = Ct, c = r.directStyles, l = c ? c.length : 0;
2640
+ let i = n.getUsedRange({ features: [] }), a = i ? i.getCoords() : null, o = k, s = M, c = r.directStyles, l = c ? c.length : 0;
2296
2641
  for (let e = 0; e < l; e++) {
2297
2642
  let t = n.getRange(c[e][0]).getCoords();
2298
2643
  if (t.colEnd === s) {
@@ -2311,12 +2656,12 @@ var vn = (e, t, n, r) => {
2311
2656
  rowEnd: e
2312
2657
  };
2313
2658
  }
2314
- a = O.unionRanges(a, t);
2659
+ a = oe.unionRanges(a, t);
2315
2660
  }
2316
2661
  let u = r.merges, d = u ? u.length : 0;
2317
2662
  for (let e = 0; e < d; e++) {
2318
2663
  let t = n.getRange(u[e]).getCoords();
2319
- t.colEnd === s && (t = { ...a }, t.colStart = a?.colStart ?? 0, t.colEnd = t.colStart), t.rowEnd === o && (t = { ...t }, t.rowStart = a?.rowStart ?? 0, t.rowEnd = t.rowStart), a = O.unionRanges(a, t);
2664
+ t.colEnd === s && (t = { ...a }, t.colStart = a?.colStart ?? 0, t.colEnd = t.colStart), t.rowEnd === o && (t = { ...t }, t.rowStart = a?.rowStart ?? 0, t.rowEnd = t.rowStart), a = oe.unionRanges(a, t);
2320
2665
  }
2321
2666
  let f = "A1";
2322
2667
  a && (i = n.getRange(a), f = a.colStart === a.colEnd && a.rowStart === a.rowEnd ? i.getAddress() : `${i.getIntersect({
@@ -2330,8 +2675,8 @@ var vn = (e, t, n, r) => {
2330
2675
  colEnd: a.colEnd,
2331
2676
  rowEnd: a.rowEnd
2332
2677
  }).getAddress()}`), t.empty("dimension", { ref: f });
2333
- }(0, s, c, l), function(e, t, n, r, i) {
2334
- let a = n.getView(), o = a.getTopLeft(), s = n.getRowHeaders().getIndex(o.top), c = n.getColumnHeaders().getIndex(o.left), l = T.cellToString({
2678
+ }(0, s, c, d), function(e, t, n, r, i) {
2679
+ let a = n.getView(), o = a.getTopLeft(), s = n.getRowHeaders().getIndex(o.top), c = n.getColumnHeaders().getIndex(o.left), l = P.cellToString({
2335
2680
  colIndex: c,
2336
2681
  rowIndex: s
2337
2682
  });
@@ -2351,20 +2696,20 @@ var vn = (e, t, n, r) => {
2351
2696
  u.colorId = "" + s;
2352
2697
  }
2353
2698
  u.workbookViewId = "0";
2354
- let p = n.getSelection().getCoords(), m = T.cellToString(p.cell), h = {}, g = a.getFreezePanes(), _ = g.coords ?? {}, v = _.colIndex ?? 0, y = _.rowIndex ?? 0;
2699
+ let p = n.getSelection().getCoords(), m = P.cellToString(p.cell), h = {}, g = a.getFreezePanes(), _ = g.coords ?? {}, v = _.colIndex ?? 0, y = _.rowIndex ?? 0;
2355
2700
  if (v > 0 || y > 0) {
2356
- let e = g.topLeft ?? {}, r = e.top ?? 0, i = e.left ?? 0, a = n.getRowHeaders().getIndex(r), s = n.getColumnHeaders().getIndex(i), c = v - s, l = y - a, d = Math.max(v, n.getColumnHeaders().getIndex(o.left + n.getColumnHeaders().getOffset(v) - i)), f = Math.max(y, n.getRowHeaders().getIndex(o.top + n.getRowHeaders().getOffset(y) - r)), p = T.cellToString({
2701
+ let e = g.topLeft ?? {}, r = e.top ?? 0, i = e.left ?? 0, a = n.getRowHeaders().getIndex(r), s = n.getColumnHeaders().getIndex(i), c = v - s, l = y - a, d = Math.max(v, n.getColumnHeaders().getIndex(o.left + n.getColumnHeaders().getOffset(v) - i)), f = Math.max(y, n.getRowHeaders().getIndex(o.top + n.getRowHeaders().getOffset(y) - r)), p = P.cellToString({
2357
2702
  colIndex: s,
2358
2703
  rowIndex: a
2359
2704
  });
2360
2705
  p === "A1" ? delete u.topLeftCell : u.topLeftCell = p, t.start("sheetView", u);
2361
2706
  let m = {};
2362
- if (c > 0 && (m.xSplit = c), l > 0 && (m.ySplit = l), m.topLeftCell = T.cellToString({
2707
+ if (c > 0 && (m.xSplit = c), l > 0 && (m.ySplit = l), m.topLeftCell = P.cellToString({
2363
2708
  colIndex: d,
2364
2709
  rowIndex: f
2365
2710
  }), m.state = "frozen", v === 0) {
2366
2711
  m.activePane = "bottomLeft", t.empty("pane", m);
2367
- let e = T.cellToString({
2712
+ let e = P.cellToString({
2368
2713
  colIndex: d,
2369
2714
  rowIndex: a
2370
2715
  });
@@ -2374,7 +2719,7 @@ var vn = (e, t, n, r) => {
2374
2719
  }), h.pane = "bottomLeft";
2375
2720
  } else if (y === 0) {
2376
2721
  m.activePane = "topRight", t.empty("pane", m);
2377
- let e = T.cellToString({
2722
+ let e = P.cellToString({
2378
2723
  colIndex: s,
2379
2724
  rowIndex: f
2380
2725
  });
@@ -2387,7 +2732,7 @@ var vn = (e, t, n, r) => {
2387
2732
  activeCell: p,
2388
2733
  sqref: p
2389
2734
  });
2390
- let e = T.cellToString({
2735
+ let e = P.cellToString({
2391
2736
  colIndex: d,
2392
2737
  rowIndex: a
2393
2738
  });
@@ -2396,7 +2741,7 @@ var vn = (e, t, n, r) => {
2396
2741
  activeCell: e,
2397
2742
  sqref: e
2398
2743
  });
2399
- let n = T.cellToString({
2744
+ let n = P.cellToString({
2400
2745
  colIndex: s,
2401
2746
  rowIndex: f
2402
2747
  });
@@ -2413,87 +2758,109 @@ var vn = (e, t, n, r) => {
2413
2758
  let e = "";
2414
2759
  for (let t = 0; t < x; t++) {
2415
2760
  let n = b[t];
2416
- t > 0 && (e += " "), e += T.rangeToString(n);
2761
+ t > 0 && (e += " "), e += P.rangeToString(n);
2417
2762
  }
2418
2763
  h.sqref = e, (p.rangeIndex ?? 0) > 0 && (h.activeCellId = "" + p.rangeIndex);
2419
2764
  } else m === "A1" ? h = null : h.sqref = m;
2420
2765
  h && t.empty("selection", h), t.end("sheetView"), t.end("sheetViews");
2421
- }(0, s, c, 0, n.isSelected), function(e, t, n, r) {
2766
+ }(0, s, c, 0, i.isSelected), function(e, t, n, r) {
2422
2767
  let i = r.defaultColSize, a = r.defaultRowSize, o = {};
2423
2768
  i !== void 0 && (o.defaultColWidth = i), o.defaultRowHeight = a ?? .75 * n.getRowHeaders().getDefaultSize(), a !== void 0 && (o.customHeight = "1"), o["x14ac:dyDescent"] = "0.25", t.empty("sheetFormatPr", o);
2424
- }(0, s, c, l), function(e, t, n, r) {
2425
- let i = r.cols ? T.refsToRuns(r.cols, !0) : null, a = i ? i.length : 0;
2769
+ }(0, s, c, d);
2770
+ let f = !1 === d.protection?.showFormulas ? a.getSharedStates().get("hiddenFormulaXfs") ?? null : null;
2771
+ (function(e, t, n, r, i) {
2772
+ let a = r.cols ? P.refsToRuns(r.cols, !0) : null, o = a ? a.length : 0;
2426
2773
  n.getEntireRange().getColumnEnd();
2427
- let o = n.getColumnHeaders().getDefaultSizeNative();
2428
- if (a > 0) {
2774
+ let s = n.getColumnHeaders().getDefaultSizeNative(), c = i ? i.getHiddenXf(0) : 0, l = 1, u = (e) => {
2775
+ c !== 0 && e >= l && t.empty("col", {
2776
+ min: l,
2777
+ max: e,
2778
+ width: s,
2779
+ style: c
2780
+ });
2781
+ };
2782
+ if (o > 0 || c !== 0) {
2429
2783
  t.start("cols");
2430
- for (let e = 0; e < a; e++) {
2431
- let n = i[e], r = n.min + 1, a = 16384;
2432
- if (r > a) continue;
2433
- let s = {
2784
+ for (let e = 0; e < o; e++) {
2785
+ let n = a[e], r = n.min + 1, o = M + 1;
2786
+ if (r > o) continue;
2787
+ let c = Math.min(n.max + 1, o);
2788
+ u(r - 1), l = c + 1;
2789
+ let d = {
2434
2790
  min: r,
2435
- max: Math.min(n.max + 1, a)
2436
- }, c = n.value, l = c.sz;
2437
- l === void 0 ? s.width = o : l !== 0 && (s.width = Math.round(256 * l) / 256), c.s && (s.style = c.s), c.h !== void 0 && (s.hidden = 1), c.csz && (s.customWidth = 1), c.l !== void 0 && (s.outlineLevel = c.l), c.cl !== void 0 && (s.collapsed = 1), t.empty("col", s);
2791
+ max: c
2792
+ }, f = n.value, p = f.sz;
2793
+ p === void 0 ? d.width = s : p !== 0 && (d.width = Math.round(256 * p) / 256);
2794
+ let m = i ? i.getHiddenXf(f.s ?? 0) : f.s;
2795
+ m && (d.style = m), f.h !== void 0 && (d.hidden = 1), f.csz && (d.customWidth = 1), f.l !== void 0 && (d.outlineLevel = f.l), f.cl !== void 0 && (d.collapsed = 1), t.empty("col", d);
2438
2796
  }
2439
- t.end("cols");
2797
+ u(M + 1), t.end("cols");
2440
2798
  }
2441
- }(0, s, c, l), function(n, r, i, a, o) {
2442
- let s = n.getSharedStates(), c = s.get("persistStrings"), l = s.get("metaCollector"), u = s.get("persistRichTypes"), d = s.get("formulaTransform"), p = 0, m = 0, _ = i.getUsedRange(), v = 0, y = a.rows ? T.refsToRuns(a.rows, !1) : null, x = y ? y.length : 0, S = y?.[x - 1]?.max ?? -1, w = a.cols ? T.refsToRuns(a.cols, !0) : null, E = w ? w.length : 0, te = w?.[E - 1]?.max ?? -1;
2443
- if (_ || x > 0) {
2444
- let s = .75, _ = a.defaultRowSize ?? i.getRowHeaders().getDefaultSize() * s, x = i.getStyles().getNormal().getBestFit().height * s, E = (e, t) => {
2445
- let n = Lt;
2799
+ })(0, s, c, d, f), function(e, i, a, o, s, c) {
2800
+ let u = e.getSharedStates(), d = u.get("persistStrings"), f = u.get("metaCollector"), p = u.get("persistRichTypes"), m = 0, h = 0, g = a.getUsedRange(), _ = 0, v = o.rows ? P.refsToRuns(o.rows, !1) : null, y = v ? v.length : 0, b = v?.[y - 1]?.max ?? -1, x = o.cols ? P.refsToRuns(o.cols, !0) : null, S = x ? x.length : 0, C = x?.[S - 1]?.max ?? -1;
2801
+ if (g || y > 0) {
2802
+ let u = .75, g = o.defaultRowSize ?? a.getRowHeaders().getDefaultSize() * u, y = a.getStyles().getNormal().getBestFit().height * u, S = (e, t) => {
2803
+ let n = vn;
2446
2804
  if (n.r = "" + (e + 1), n.s = void 0, n.customFormat = void 0, n.hidden = void 0, n.ht = void 0, n.customHeight = void 0, n.outlineLevel = void 0, n.collapsed = void 0, !t) return n;
2447
2805
  let r = t.value;
2448
- r.s !== void 0 && (n.s = "" + r.s, n.customFormat = "1"), r.h && (n.hidden = "1");
2449
- let i = r.csz ?? !1, a = r.sz ?? _;
2450
- return (a !== x || i) && (n.ht = "" + a), i && (n.customHeight = "1"), r.l !== void 0 && (n.outlineLevel = "" + r.l), r.cl !== void 0 && (n.collapsed = "" + r.cl), n;
2451
- }, D = 0, O = y?.[D] ?? null, k = O?.min ?? 2 ** 53 - 1, A = O?.max ?? 2 ** 53 - 1, j = O?.value?.s, M = -1, N = 0, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s, re = (e, t = !1) => {
2452
- if (M !== e) {
2453
- for (M !== -1 && (r.end("row"), N !== 0 && (N = 0, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s)); M + 1 <= e;) {
2454
- M++, O && M > A && (O = y[++D] ?? null, O ? (k = O.min, A = O.max, j = O.value?.s) : (k = 2 ** 53 - 1, A = 2 ** 53 - 1, j = void 0)), M < k && M < e && (M = O ? Math.min(k, e) : e);
2455
- let n = M < e || t && M === e, i = E(M, O && M >= k && M <= A ? O : null);
2456
- n ? r.empty("row", i) : r.start("row", i);
2806
+ r.s !== void 0 && (n.s = "" + (c ? c.getHiddenXf(r.s) : r.s), n.customFormat = "1"), r.h && (n.hidden = "1");
2807
+ let i = r.csz ?? !1, a = r.sz ?? g;
2808
+ return (a !== y || i) && (n.ht = "" + a), i && (n.customHeight = "1"), r.l !== void 0 && (n.outlineLevel = "" + r.l), r.cl !== void 0 && (n.collapsed = "" + r.cl), n;
2809
+ }, w = 0, T = v?.[w] ?? null, D = T?.min ?? 2 ** 53 - 1, O = T?.max ?? 2 ** 53 - 1, ee = T?.value?.s, k = -1, A = 0, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s, re = (e, t = !1) => {
2810
+ if (k !== e) {
2811
+ for (k !== -1 && (i.end("row"), A !== 0 && (A = 0, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s)); k + 1 <= e;) {
2812
+ k++, T && k > O && (T = v[++w] ?? null, T ? (D = T.min, O = T.max, ee = T.value?.s) : (D = 2 ** 53 - 1, O = 2 ** 53 - 1, ee = void 0)), k < D && k < e && (k = T ? Math.min(D, e) : e);
2813
+ let n = k < e || t && k === e, r = S(k, T && k >= D && k <= O ? T : null);
2814
+ n ? i.empty("row", r) : i.start("row", r);
2457
2815
  }
2458
- if (e < M) {
2459
- let t = E(e, null);
2460
- r.start("row", t);
2816
+ if (e < k) {
2817
+ let t = S(e, null);
2818
+ i.start("row", t);
2461
2819
  }
2462
2820
  }
2463
2821
  };
2464
- r.setValidationDisabled(!0), r.start("sheetData");
2465
- let R = [];
2466
- R.push(Et(n, i, a.directStyles));
2467
- let B = a.formulas, ie = B ? B.length : 0;
2468
- if (ie > 0) {
2822
+ i.setValidationDisabled(!0), i.start("sheetData");
2823
+ let N = [];
2824
+ N.push(Zt(e, a, o.directStyles));
2825
+ let F = o.formulas, ae = F ? F.length : 0;
2826
+ if (ae > 0) {
2469
2827
  let n = /* @__PURE__ */ new Map();
2470
- if (o.names.size > 0 && a.formulaArray) for (let e of a.formulaArray) try {
2471
- let t = i.getRange(e[0]).getCoords();
2828
+ if (s.names.size > 0 && o.formulaArray) for (let e of o.formulaArray) try {
2829
+ let t = a.getRange(e[0]).getCoords();
2472
2830
  n.set(`${t.rowStart},${t.colStart}`, t);
2473
2831
  } catch {}
2474
2832
  let r = [];
2475
- if (a.formulaArray) for (let e of a.formulaArray) try {
2476
- r.push(i.getRange(e[0]).getCoords());
2833
+ if (o.formulaArray) for (let e of o.formulaArray) try {
2834
+ r.push(a.getRange(e[0]).getCoords());
2477
2835
  } catch {}
2478
- let s = (e) => {
2836
+ let i = (e) => {
2479
2837
  for (let t = 0; t < r.length; t++) {
2480
2838
  let n = r[t];
2481
2839
  if (n.rowStart <= e.rowEnd && n.rowEnd >= e.rowStart && n.colStart <= e.colEnd && n.colEnd >= e.colStart) return !0;
2482
2840
  }
2483
2841
  return !1;
2484
- }, c = C(() => i.getCalculation()), l = (e) => {
2485
- if (!e) return;
2486
- let t;
2487
- return e.getExpression({ formulaTransform: (e, n) => {
2488
- n === void 0 && (t = e);
2489
- } }), t;
2490
- }, u = [];
2491
- for (let r = 0; r < ie; r++) {
2492
- let a = B[r];
2842
+ }, c = e.getSharedStates().get("xlsxFormulaDialect") ?? l(a.getCalculation().getNamedFormulas().toJSON(), a.getTables().getItems().map((e) => e.getName())), u = a.getEntireRange().getCoords(), d = [];
2843
+ for (let e of a.getTables().getItems()) d.push([e.getRange().getCoords(), e.getName()]);
2844
+ let f = (e, t) => {
2845
+ for (let n = 0; n < d.length; n++) {
2846
+ let r = d[n][0];
2847
+ if (e >= r.rowStart && e <= r.rowEnd && t >= r.colStart && t <= r.colEnd) return d[n][1];
2848
+ }
2849
+ return null;
2850
+ }, p = /* @__PURE__ */ new Set();
2851
+ for (let e = 0; e < r.length; e++) p.add(`${r[e].rowStart},${r[e].colStart}`);
2852
+ let m = [];
2853
+ for (let r = 0; r < ae; r++) {
2854
+ let o = F[r];
2493
2855
  try {
2494
- let p = a[0], m = i.getRange(p), h = m.getCoords(), _ = a[1], y = null, b = l(m.getCell().getFormula()), x = !!b && t(b, c), S = e(b);
2495
- if (o.affects(r)) {
2496
- y = null, x = !1;
2856
+ let e = o[0], l = a.getRange(e), d = l.getCoords(), h = o[1], g = null, v = {
2857
+ rowIndex: d.rowStart,
2858
+ colIndex: d.colStart
2859
+ }, y = c.parse(h, v), b = y ? c.annotate(y) : void 0, x = y ? c.spell(y, p.has(`${d.rowStart},${d.colStart}`), f(d.rowStart, d.colStart)) : null, S = x ? ce.imager(x, { entireCoords: u }) : null;
2860
+ S && (h = S(v));
2861
+ let C = !0 === b?.cm, w = !0 === b?.ca;
2862
+ if (s.affects(r)) {
2863
+ g = null, C = !1;
2497
2864
  let e = (e, t, n) => {
2498
2865
  let r = {
2499
2866
  rowStart: e,
@@ -2501,91 +2868,77 @@ var vn = (e, t, n, r) => {
2501
2868
  rowEnd: e,
2502
2869
  colEnd: t
2503
2870
  };
2504
- u.push([r, {
2871
+ m.push([r, {
2505
2872
  coords: r,
2506
2873
  formula: n,
2507
2874
  sharedId: null,
2508
- ref: T.rangeToString(r),
2875
+ ref: P.rangeToString(r),
2509
2876
  isDynamicRange: !1,
2510
2877
  isWrapped: !0
2511
2878
  }]);
2512
- }, t = n.get(`${h.rowStart},${h.colStart}`), r = t !== void 0 && (t.rowEnd > t.rowStart || t.colEnd > t.colStart), a = !1;
2513
- if (r) {
2514
- let n = g(_, m.getCell().getValue());
2515
- if (n !== null) for (let r = t.rowStart; r <= t.rowEnd; r++) for (let o = t.colStart; o <= t.colEnd; o++) {
2516
- if (r === t.rowStart && o === t.colStart) {
2517
- e(r, o, n), a = !0;
2879
+ }, r = n.get(`${d.rowStart},${d.colStart}`), i = r !== void 0 && (r.rowEnd > r.rowStart || r.colEnd > r.colStart), o = !1;
2880
+ if (i) {
2881
+ let n = t(h, l.getCell().getValue());
2882
+ if (n !== null) for (let t = r.rowStart; t <= r.rowEnd; t++) for (let i = r.colStart; i <= r.colEnd; i++) {
2883
+ if (t === r.rowStart && i === r.colStart) {
2884
+ e(t, i, n), o = !0;
2518
2885
  continue;
2519
2886
  }
2520
- let s = f(i.getRange(T.rangeToString({
2521
- rowStart: r,
2522
- colStart: o,
2523
- rowEnd: r,
2524
- colEnd: o
2887
+ let s = E(a.getRange(P.rangeToString({
2888
+ rowStart: t,
2889
+ colStart: i,
2890
+ rowEnd: t,
2891
+ colEnd: i
2525
2892
  })).getCell().getValue());
2526
- s !== null && e(r, o, s);
2893
+ s !== null && e(t, i, s);
2527
2894
  }
2528
- } else {
2529
- let t = m.getCells();
2530
- for (let n = 0; n < t.length; n++) {
2531
- let r = t[n];
2532
- for (let t = 0; t < r.length; t++) {
2533
- let i = r[t], o = g(i.getFormula()?.getExpression() ?? _, i.getValue());
2534
- o !== null && (e(h.rowStart + n, h.colStart + t, o), a = !0);
2535
- }
2536
- }
2537
- }
2538
- if (a) continue;
2895
+ } else l.forEach((n, r) => {
2896
+ let i = r.getCoords(), a = t(S?.(i) ?? h, r.getCell().getValue());
2897
+ a !== null && (e(i.rowIndex, i.colIndex, a), o = !0);
2898
+ }, { includeEmpty: !0 });
2899
+ if (o) continue;
2539
2900
  }
2540
- let ee = _.indexOf("!") !== -1 || _.indexOf("[") !== -1, C;
2541
- if (x || m.isSingleCell() || ee || s(h) || (y = "" + v++), y === null && !m.isSingleCell()) {
2542
- C = [];
2543
- let e = m.getCells();
2544
- for (let t = 0; t < e.length; t++) {
2545
- let n = e[t], r = Array(n.length);
2546
- for (let e = 0; e < n.length; e++) t === 0 && e === 0 || (r[e] = n[e].getFormula()?.getExpression({ formulaTransform: d }) ?? void 0);
2547
- C.push(r);
2548
- }
2549
- }
2550
- let w = [h, {
2551
- coords: h,
2552
- formula: _,
2553
- sharedId: y,
2554
- ref: p,
2555
- isDynamicRange: x,
2556
- isExcelVolatile: S,
2557
- memberTexts: C
2901
+ let T = h.indexOf("!") !== -1 || h.indexOf("[") !== -1;
2902
+ C || l.isSingleCell() || T || i(d) || (g = "" + _++);
2903
+ let D = g !== null || l.isSingleCell() ? null : S, O = [d, {
2904
+ coords: d,
2905
+ formula: h,
2906
+ sharedId: g,
2907
+ ref: e,
2908
+ isDynamicRange: C,
2909
+ isExcelVolatile: w,
2910
+ memberImage: D
2558
2911
  }];
2559
- u.push(w);
2560
- } catch (e) {
2561
- console.warn(`Failed to parse formula: ${a[1]}`, e);
2912
+ m.push(O);
2913
+ } catch (t) {
2914
+ e.log(`Could not write the formula '${o[1]}' over '${o[0]}'; those cells are written as values only. ${t}`);
2562
2915
  continue;
2563
2916
  }
2564
2917
  }
2565
- R.push(u);
2566
- } else R.push([]);
2567
- let ae = a.volatile, oe = ae ? ae.length : 0;
2918
+ N.push(m);
2919
+ } else N.push([]);
2920
+ let I = o.volatile, oe = I ? I.length : 0;
2568
2921
  if (oe > 0) {
2569
2922
  let e = Array(oe);
2570
2923
  for (let t = 0; t < oe; t++) {
2571
- let n = ae[t];
2924
+ let n = I[t];
2572
2925
  try {
2573
- e[t] = [i.getRange(n).getCoords(), !0];
2926
+ e[t] = [a.getRange(n).getCoords(), !0];
2574
2927
  } catch (e) {
2575
2928
  console.warn(`Failed to parse volatile: ${n}`, e);
2576
2929
  continue;
2577
2930
  }
2578
2931
  }
2579
- R.push(e);
2580
- } else R.push([]);
2581
- let se = a.formulaArray, V = se ? se.length : 0;
2582
- if (V > 0) {
2583
- let e = Array(V);
2584
- for (let t = 0; t < V; t++) {
2585
- let n = se[t];
2932
+ N.push(e);
2933
+ } else N.push([]);
2934
+ let L = o.formulaArray, R = L ? L.length : 0;
2935
+ if (R > 0) {
2936
+ let e = Array(R);
2937
+ for (let t = 0; t < R; t++) {
2938
+ let n = L[t];
2586
2939
  try {
2587
2940
  let r = n[0];
2588
- e[t] = [i.getRange(r).getCoords(), {
2941
+ e[t] = [a.getRange(r).getCoords(), {
2589
2942
  ref: r,
2590
2943
  kind: n[1] ?? "dynamic"
2591
2944
  }];
@@ -2594,89 +2947,95 @@ var vn = (e, t, n, r) => {
2594
2947
  continue;
2595
2948
  }
2596
2949
  }
2597
- R.push(e);
2598
- } else R.push([]);
2599
- i.getEntireRange().forEach((e, t) => {
2600
- let i = t.getCoords(), a = i.rowIndex, o = i.colIndex;
2601
- M !== a && re(a);
2602
- let s = t.getInjectedReference(0);
2603
- if (s === void 0 && j !== void 0 && a >= k && a <= A && (s = j), s === void 0) {
2604
- for (; o <= te && o > I;) N++, P = w?.[N] ?? null, F = P?.min ?? 2 ** 53 - 1, I = P?.max ?? 2 ** 53 - 1, L = P?.value?.s;
2605
- L !== void 0 && o >= F && o <= I && (s = L);
2950
+ N.push(e);
2951
+ } else N.push([]);
2952
+ a.getEntireRange().forEach((t, a) => {
2953
+ let o = a.getCoords(), s = o.rowIndex, l = o.colIndex;
2954
+ k !== s && re(s);
2955
+ let u = a.getInjectedReference(0);
2956
+ if (u === void 0 && ee !== void 0 && s >= D && s <= O && (u = ee), u === void 0) {
2957
+ for (; l <= C && l > M;) A++, j = x?.[A] ?? null, te = j?.min ?? 2 ** 53 - 1, M = j?.max ?? 2 ** 53 - 1, ne = j?.value?.s;
2958
+ ne !== void 0 && l >= te && l <= M && (u = ne);
2606
2959
  }
2607
- let d = t.getType(), f = null;
2608
- ie > 0 && (f = t.getInjectedReference(1) ?? null);
2609
- let g = !1;
2610
- oe > 0 && (g = t.getInjectedReference(2) ?? !1);
2611
- let _ = null;
2612
- V > 0 && (_ = t.getInjectedReference(3) ?? null);
2613
- let v = _?.kind === "dynamicSpillError", y = _?.kind === "static", x = It;
2614
- x.r = t.getAddress(), x.s = void 0, x.t = void 0, x.cm = void 0, x.vm = void 0, s !== void 0 && s !== 0 && (x.s = "" + s);
2615
- let S = null, C = null;
2616
- switch (d) {
2617
- case z.Boolean:
2618
- S = e ? "1" : "0", C = "b";
2960
+ let g = a.getType(), _ = null;
2961
+ ae > 0 && (_ = a.getInjectedReference(1) ?? null);
2962
+ let v = !1;
2963
+ oe > 0 && (v = a.getInjectedReference(2) ?? !1);
2964
+ let y = null;
2965
+ R > 0 && (y = a.getInjectedReference(3) ?? null);
2966
+ let b = y?.kind === "error", S = y?.kind === "fixed", w = _n;
2967
+ w.r = a.getAddress(), w.s = void 0, w.t = void 0, w.cm = void 0, w.vm = void 0, c && (u = c.getHiddenXf(u ?? 0)), u !== void 0 && u !== 0 && (w.s = "" + u);
2968
+ let T = null, E = null;
2969
+ switch (g) {
2970
+ case me.Boolean:
2971
+ T = t ? "1" : "0", E = "b";
2619
2972
  break;
2620
- case z.Error:
2621
- let t = e.getCode();
2622
- if (C = "e", t > 7) S = ne.BuiltIn.Value.getLabel(), x.vm = "" + u.add(e);
2623
- else if (t < 1) {
2624
- let t;
2625
- C = "s", f ? (t = "=" + f.formula, f = null) : t = "" + e.getLabel(), S = "" + c.add(t), p++;
2626
- } else S = "" + e.getLabel();
2973
+ case me.Error:
2974
+ let e = t.getCode();
2975
+ if (E = "e", e > 7) T = se.BuiltIn.Value.getLabel(), w.vm = "" + p.add(t);
2976
+ else if (e < 1) {
2977
+ let e;
2978
+ E = "s", _ ? (e = "=" + _.formula, _ = null) : e = "" + t.getLabel(), T = "" + d.add(e), m++;
2979
+ } else T = "" + t.getLabel();
2627
2980
  break;
2628
- case z.Number:
2629
- S = "" + e, C = null;
2981
+ case me.Number:
2982
+ T = "" + t, E = null;
2630
2983
  break;
2631
- case z.String:
2632
- S = e, f ? (C = "str", S = e) : (C = "s", S = "" + c.add(S), p++);
2984
+ case me.String:
2985
+ T = t, _ ? (E = "str", T = t) : (E = "s", T = "" + d.add(T), m++);
2633
2986
  break;
2634
- case z.RichData: C = "e", S = ne.BuiltIn.Value.getLabel(), x.vm = "" + u.add(e);
2987
+ case me.RichData: E = "e", T = se.BuiltIn.Value.getLabel(), w.vm = "" + p.add(t);
2635
2988
  }
2636
- C && (x.t = C);
2637
- let T = !f?.isWrapped && (_ !== null || (f?.isDynamicRange ?? !1));
2638
- if (f !== null || S !== null) {
2639
- if (T && f !== null && !y && (x.cm = "" + l.registerArrayCell(v)), r.start("c", x), f) {
2640
- let e = f.memberTexts?.[a - f.coords.rowStart]?.[o - f.coords.colStart] ?? f.formula, t, n = null, i = f.sharedId;
2641
- if (i) {
2642
- t = zt;
2643
- let e = f.coords;
2644
- e.colStart === o && e.rowStart === a ? (t.ref = f.ref, t.si = i, n = f.formula) : (t.ref = void 0, t.si = i);
2645
- } else T ? (t = Bt, t.aca = v ? "1" : void 0, t.ref = v ? x.r : _?.ref ?? x.r, n = e) : (t = Rt, n = e);
2646
- t.ca = g || v || f.isExcelVolatile ? "1" : void 0, n ? (r.start("f", t), r.text(n), r.end("f")) : r.empty("f", t);
2989
+ E && (w.t = E);
2990
+ let N = !_?.isWrapped && (y !== null || (_?.isDynamicRange ?? !1));
2991
+ if (_ !== null || T !== null) {
2992
+ if (N && _ !== null && !S && (w.cm = "" + f.registerArrayCell(b)), i.start("c", w), _) {
2993
+ let e = s === _.coords.rowStart && l === _.coords.colStart, t = _.formula;
2994
+ _.memberImage && !e && (t = _.memberImage({
2995
+ rowIndex: s,
2996
+ colIndex: l
2997
+ }));
2998
+ let n, r = null, a = _.sharedId;
2999
+ if (a) {
3000
+ n = bn;
3001
+ let e = _.coords;
3002
+ e.colStart === l && e.rowStart === s ? (n.ref = _.ref, n.si = a, r = _.formula) : (n.ref = void 0, n.si = a);
3003
+ } else N ? (n = xn, n.aca = b ? "1" : void 0, n.ref = b ? w.r : y?.ref ?? w.r, r = t) : (n = yn, r = t);
3004
+ n.ca = v || b || _.isExcelVolatile ? "1" : void 0, r ? (i.start("f", n), i.text(r), i.end("f")) : i.empty("f", n);
2647
3005
  }
2648
- S !== null && (C === "str" && S ? (r.start("v", ee.test(S) ? b : void 0), r.text(h(S))) : (r.start("v"), S && r.text(S)), r.end("v")), r.end("c");
2649
- } else m++ < Tt ? r.empty("c", x) : m === 1048577 && n.warn(`Reached ${Tt} style-only cells at '${x.r}'; not writing the rest.`);
3006
+ T !== null && (E === "str" && T ? (i.start("v", ie.test(T) ? n : void 0), i.text(r(T))) : (i.start("v"), T && i.text(T)), i.end("v")), i.end("c");
3007
+ } else h++ < Xt ? i.empty("c", w) : h === 1048577 && e.warn(`Reached ${Xt} style-only cells at '${w.r}'; not writing the rest.`);
2650
3008
  }, {
2651
- injectReferences: R,
3009
+ injectReferences: N,
2652
3010
  features: []
2653
- }), M !== -1 && M >= S ? r.end("row") : re(S, !0), r.end("sheetData"), r.setValidationDisabled(!1);
2654
- } else r.empty("sheetData");
2655
- if (p > 0) {
2656
- let e = s.get("stringsCount") ?? 0;
2657
- s.set("stringsCount", e + p);
3011
+ }), k !== -1 && k >= b ? i.end("row") : re(b, !0), i.end("sheetData"), i.setValidationDisabled(!1);
3012
+ } else i.empty("sheetData");
3013
+ if (m > 0) {
3014
+ let e = u.get("stringsCount") ?? 0;
3015
+ u.set("stringsCount", e + m);
2658
3016
  }
2659
- }(i, s, c, l, await (async (e, t) => {
3017
+ }(a, s, c, d, await (async (e, t) => {
2660
3018
  let n = t ? t.length : 0;
2661
- if (n === 0) return wt;
3019
+ if (n === 0) return Yt;
2662
3020
  let r = /* @__PURE__ */ new Set(), i = Array(n);
2663
- for (let a = 0; a < n; a++) {
2664
- i[a] = null;
3021
+ for (let e = 0; e < n; e++) {
3022
+ i[e] = null;
2665
3023
  try {
2666
- let n = e.getRange(t[a][0]).getCell().getFormula()?.getTokens();
3024
+ let n = ce.parse(t[e][1]);
2667
3025
  if (!n) continue;
2668
- let o = null;
2669
- for (let e = 0; e < n.length; e++) {
2670
- let t = n[e], i = null;
2671
- t.type === "function" ? i = String(t.value) : t.type === "named" && n[e + 1]?.type === "paren" && n[e + 1].value === "(" && (i = String(t.value?.name ?? "")), i && (i = i.toUpperCase(), r.add(i), (o ??= /* @__PURE__ */ new Set()).add(i));
2672
- }
2673
- i[a] = o;
3026
+ let a = null, o = (e) => {
3027
+ let t = null;
3028
+ e.type === "function" ? t = String(e.value) : e.type === "call" && e.inputs?.[0]?.type === "named" && (t = String(e.inputs[0].value?.name ?? "")), t && (t = t.toUpperCase(), r.add(t), (a ??= /* @__PURE__ */ new Set()).add(t));
3029
+ let n = e.inputs;
3030
+ if (n) for (let e = 0; e < n.length; e++) n[e] && o(n[e]);
3031
+ };
3032
+ o(n), i[e] = a;
2674
3033
  } catch {}
2675
3034
  }
2676
3035
  let a = e.getWorkbook();
2677
- if (!a) return wt;
2678
- let o = await _(a, r);
2679
- return o.size === 0 ? wt : {
3036
+ if (!a) return Yt;
3037
+ let o = await D(a, r);
3038
+ return o.size === 0 ? Yt : {
2680
3039
  names: o,
2681
3040
  perFormula: i,
2682
3041
  affects: (e) => {
@@ -2686,136 +3045,141 @@ var vn = (e, t, n, r) => {
2686
3045
  return !1;
2687
3046
  }
2688
3047
  };
2689
- })(c, l.formulas)), function(e, t, n, r) {
3048
+ })(c, d.formulas), f), function(e, t, n, r) {
2690
3049
  let i = r.protection;
2691
3050
  if (!i) return;
2692
3051
  let a = {};
2693
- Pe(i.password ?? {}, a), a.sheet = "1";
2694
- let o = (e, t, n) => {
2695
- let r = i[e];
2696
- r !== void 0 && r !== t && (a[n ?? e] = r ? "1" : "0");
2697
- };
2698
- o("objects", "0"), o("scenarios", "0"), o("formatCells", "0"), o("formatColumns", "0"), o("formatRows", "0"), o("insertColumns", "0"), o("insertRows", "0"), o("insertHyperlinks", "0"), o("deleteColumns", "0"), o("deleteRows", "0"), o("selectLockedCells", "1"), o("sort", "0"), o("autoTable", "0", "autoFilter"), o("pivotTables", "0"), o("selectUnlockedCells", "1"), t.empty("sheetProtection", a);
2699
- }(0, s, 0, l), function(e, t, n, r) {
3052
+ i.sheet || Ue(i.password ?? {}, a);
3053
+ for (let e of N) {
3054
+ let t = u(e, i[e.key]);
3055
+ t !== null && (a[e.attribute] = t);
3056
+ }
3057
+ t.empty("sheetProtection", a);
3058
+ }(0, s, 0, d), function(e, t, n, r) {
2700
3059
  let i = r.protectedRanges, a = i ? i.length : 0;
2701
3060
  if (a === 0) return;
2702
3061
  let o = [];
2703
3062
  for (let t = 0; t < a; t++) {
2704
3063
  let n = i[t], r, a;
2705
3064
  Array.isArray(n) ? (r = n[0], a = n[1]) : (r = n.r, a = n.v);
2706
- let s = Nt(r);
3065
+ let s = an(r);
2707
3066
  if (!s || !a) {
2708
- e.warn("Skipping protectedRange with no range.");
3067
+ e.log("Skipping protectedRange with no range.");
2709
3068
  continue;
2710
3069
  }
2711
3070
  if (!a.name) {
2712
- e.warn("Skipping protectedRange with no name.");
3071
+ e.log("Skipping protectedRange with no name.");
2713
3072
  continue;
2714
3073
  }
2715
3074
  let c = {};
2716
- Pe(a.password ?? {}, c), c.sqref = s, c.name = a.name, a.securityDescriptor && (c.securityDescriptor = a.securityDescriptor), o.push(c);
3075
+ Ue(a.password ?? {}, c), c.sqref = s, c.name = a.name, a.securityDescriptor && (c.securityDescriptor = a.securityDescriptor), o.push(c);
2717
3076
  }
2718
3077
  if (o.length !== 0) {
2719
3078
  t.start("protectedRanges");
2720
3079
  for (let e = 0; e < o.length; e++) t.empty("protectedRange", o[e]);
2721
3080
  t.end("protectedRanges");
2722
3081
  }
2723
- }(i, s, 0, l);
2724
- let u = l.autoTable;
2725
- if (u) {
2726
- let e, t = u;
2727
- e = Array.isArray(t) ? t[1] : t.v, _t(i, s, c.getAutoTable(), e, !0);
3082
+ }(a, s, 0, d);
3083
+ let p = d.autoTable;
3084
+ if (p) {
3085
+ let e, t = p;
3086
+ e = Array.isArray(t) ? t[1] : t.v, Gt(a, s, c.getAutoTable(), e, !0);
2728
3087
  }
2729
3088
  (function(e, t, n, r) {
2730
3089
  let i = r.merges ? r.merges.length : 0;
2731
3090
  if (i > 0) {
2732
3091
  t.start("mergeCells", { count: i });
2733
3092
  for (let e = 0; e < i; e++) {
2734
- let n = r.merges[e], i = typeof n == "string" ? n : T.rangeToString(n);
3093
+ let n = r.merges[e], i = typeof n == "string" ? n : P.rangeToString(n);
2735
3094
  t.empty("mergeCell", { ref: i });
2736
3095
  }
2737
3096
  t.end("mergeCells");
2738
3097
  }
2739
- })(0, s, 0, l);
2740
- let p = function(e, t, n, r) {
2741
- let i = [], o = r.conditionals, s = o ? o.length : 0;
3098
+ })(0, s, 0, d);
3099
+ let m = function(e, t, n, r) {
3100
+ let i = [], a = r.conditionals, s = a ? a.length : 0;
2742
3101
  if (s === 0) return i;
2743
- let c = e.getSharedStates(), l = c.get(it);
2744
- l || (l = new rt(), c.set(it, l));
2745
- let u = n.getStyles().getTheme(), d = null, f = 0;
3102
+ let c = e.getSharedStates(), l = c.get(jt);
3103
+ l || (l = new At(), c.set(jt, l));
3104
+ let u = n.getStyles().getTheme(), d = c.get(o), f = null, p = 0;
2746
3105
  for (let n = 0; n < s; n++) {
2747
- let r = o[n], s, c;
2748
- Array.isArray(r) ? (s = r[0], c = r[1]) : (s = r.r, c = r.v);
2749
- let p = Nt(s);
2750
- if (!p || !c) {
2751
- e.warn("Skipping conditionalFormatting with no range.");
3106
+ let r = a[n], o, s;
3107
+ Array.isArray(r) ? (o = r[0], s = r[1]) : (o = r.r, s = r.v);
3108
+ let c = an(o);
3109
+ if (!c || !s) {
3110
+ e.log("Skipping conditionalFormatting with no range.");
2752
3111
  continue;
2753
3112
  }
2754
- let m = c.scale, h = m ? { type: m.type } : S(c.condition, Mt(p), (t) => e.warn(t));
2755
- h ? m?.type === j.ScaleType.IconSet && At(m) ? (f++, i.push({
2756
- guid: a(D.uuidV4),
2757
- sqref: p,
2758
- priority: f,
2759
- scale: m
2760
- })) : m || !Ft(h) ? (p !== d && (d !== null && t.end("conditionalFormatting"), t.start("conditionalFormatting", {
2761
- sqref: p,
2762
- pivot: c.pivot ? "1" : void 0
2763
- }), d = p), f++, jt(e, t, u, c, h, p, f, l, i)) : (f++, i.push({
2764
- guid: a(D.uuidV4),
2765
- sqref: p,
2766
- priority: f,
2767
- rule: h,
2768
- style: c.style,
2769
- stopIfTrue: c.stopIfTrue
2770
- })) : c.condition || e.warn("Skipping conditional format with neither a condition nor a scale.");
3113
+ let m = cn(c), h = un(s.scale, m, d);
3114
+ h !== s.scale && (s = {
3115
+ ...s,
3116
+ scale: h
3117
+ });
3118
+ let _ = h ? { type: h.type } : g(s.condition, rn(c), (t, n) => e.warn(t, void 0, n));
3119
+ _ ? (_.formulas &&= _.formulas.map((e) => ln(e, m, d)), h?.type === z.ScaleType.IconSet && tn(h) ? (p++, i.push({
3120
+ guid: x(I.uuidV4),
3121
+ sqref: c,
3122
+ priority: p,
3123
+ scale: h
3124
+ })) : h || !sn(_) ? (c !== f && (f !== null && t.end("conditionalFormatting"), t.start("conditionalFormatting", {
3125
+ sqref: c,
3126
+ pivot: s.pivot ? "1" : void 0
3127
+ }), f = c), p++, nn(e, t, u, s, _, c, p, l, i)) : (p++, i.push({
3128
+ guid: x(I.uuidV4),
3129
+ sqref: c,
3130
+ priority: p,
3131
+ rule: _,
3132
+ style: s.style,
3133
+ stopIfTrue: s.stopIfTrue
3134
+ }))) : s.condition || e.log("Skipping conditional format with neither a condition nor a scale.");
2771
3135
  }
2772
- return d !== null && t.end("conditionalFormatting"), i;
2773
- }(i, s, c, l), m = function(e, t, n, r) {
2774
- let i = [], a = r.validations, o = a ? a.length : 0;
2775
- if (o === 0) return i;
2776
- let s = [];
2777
- for (let t = 0; t < o; t++) {
2778
- let n = a[t], r, o;
3136
+ return f !== null && t.end("conditionalFormatting"), i;
3137
+ }(a, s, c, d), h = function(e, t, n, r) {
3138
+ let i = [], a = e.getSharedStates().get(o), s = r.validations, c = s ? s.length : 0;
3139
+ if (c === 0) return i;
3140
+ let l = [];
3141
+ for (let t = 0; t < c; t++) {
3142
+ let n = s[t], r, o;
2779
3143
  Array.isArray(n) ? (r = n[0], o = n[1]) : (r = n.r, o = n.v);
2780
- let c = Nt(r);
3144
+ let c = an(r);
2781
3145
  if (!c || !o) {
2782
- e.warn?.("Skipping dataValidation with no range.");
3146
+ e.log("Skipping dataValidation with no range.");
2783
3147
  continue;
2784
3148
  }
2785
3149
  o.ext && e.warn("DataValidation extension payload is not written to xlsx; it will be lost.");
2786
- let { type: l, operator: u, formula1: d, formula2: f } = x(o.condition, (t) => e.warn(t)) ?? {}, p = {
2787
- type: l,
2788
- operator: u,
2789
- allowBlank: Z(o.condition?.includeBlanks ?? !1),
3150
+ let u = (t, n) => e.warn(t, void 0, n), d = S(o.condition, u), { type: f, operator: p } = d ?? {}, m = cn(c), h = ln(d?.formula1, m, a), g = ln(d?.formula2, m, a), _ = {
3151
+ type: f,
3152
+ operator: p,
3153
+ allowBlank: Q(o.condition?.includeBlanks ?? !1),
2790
3154
  showDropDown: o.hideDropdown ? "1" : void 0,
2791
- showInputMessage: Z(o.showPromptMessage),
2792
- showErrorMessage: Z(o.showAlertMessage),
2793
- errorStyle: o.alertStyle ?? "information",
2794
- errorTitle: o.alertTitle,
2795
- error: o.alert,
2796
- promptTitle: o.promptTitle,
2797
- prompt: o.prompt,
3155
+ showInputMessage: Q(o.showPromptMessage),
3156
+ showErrorMessage: Q(o.showAlertMessage),
3157
+ errorStyle: o.alertStyle ?? "stop",
3158
+ errorTitle: re(o.alertTitle, "errorTitle", u),
3159
+ error: re(o.alert, "error", u),
3160
+ promptTitle: re(o.promptTitle, "promptTitle", u),
3161
+ prompt: re(o.prompt, "prompt", u),
2798
3162
  imeMode: o.imeMode
2799
3163
  };
2800
- Pt(d) || Pt(f) ? i.push({
2801
- attrs: p,
2802
- formula1: d,
2803
- formula2: f,
3164
+ on(h) || on(g) ? i.push({
3165
+ attrs: _,
3166
+ formula1: h,
3167
+ formula2: g,
2804
3168
  sqref: c
2805
- }) : (p.sqref = c, s.push({
2806
- attrs: p,
2807
- formula1: d,
2808
- formula2: f
3169
+ }) : (_.sqref = c, l.push({
3170
+ attrs: _,
3171
+ formula1: h,
3172
+ formula2: g
2809
3173
  }));
2810
3174
  }
2811
- if (s.length === 0) return i;
2812
- t.start("dataValidations", { count: s.length });
2813
- for (let e = 0; e < s.length; e++) {
2814
- let { attrs: n, formula1: r, formula2: i } = s[e];
3175
+ if (l.length === 0) return i;
3176
+ t.start("dataValidations", { count: l.length });
3177
+ for (let e = 0; e < l.length; e++) {
3178
+ let { attrs: n, formula1: r, formula2: i } = l[e];
2815
3179
  r !== void 0 || i !== void 0 ? (t.start("dataValidation", n), r !== void 0 && (t.start("formula1"), t.text(r), t.end("formula1")), i !== void 0 && (t.start("formula2"), t.text(i), t.end("formula2")), t.end("dataValidation")) : t.empty("dataValidation", n);
2816
3180
  }
2817
3181
  return t.end("dataValidations"), i;
2818
- }(i, s, 0, l);
3182
+ }(a, s, 0, d);
2819
3183
  (function(e, t, n, r) {
2820
3184
  let i = r.hyperlinks, a = i ? i.length : 0;
2821
3185
  if (a !== 0) {
@@ -2828,7 +3192,7 @@ var vn = (e, t, n, r) => {
2828
3192
  }
2829
3193
  t.end("hyperlinks");
2830
3194
  }
2831
- })(i, s, 0, l), function(e, t, n, r) {
3195
+ })(a, s, 0, d), function(e, t, n, r) {
2832
3196
  let i = r.pageMargins;
2833
3197
  t.empty("pageMargins", {
2834
3198
  left: i?.left ?? .7,
@@ -2838,8 +3202,8 @@ var vn = (e, t, n, r) => {
2838
3202
  header: i?.header ?? .3,
2839
3203
  footer: i?.footer ?? .3
2840
3204
  });
2841
- }(0, s, 0, l), function(e, t, n, r) {
2842
- let i = r.movables;
3205
+ }(0, s, 0, d), function(e, t, n, r) {
3206
+ let i = r.movables?.filter(pn);
2843
3207
  if ((i ? i.length : 0) === 0 || !i.some((e) => {
2844
3208
  let t = e.content?.type;
2845
3209
  if (t === "picture" || t === "chart") return !0;
@@ -2849,14 +3213,93 @@ var vn = (e, t, n, r) => {
2849
3213
  }
2850
3214
  return !1;
2851
3215
  })) return;
2852
- let a = n.getMovables().getItems(), o = e.addPart("drawing", {
3216
+ let a = n.getMovables().getItems().filter((e, t) => pn(r.movables[t])), o = e.addPart("drawing", {
2853
3217
  sheet: n,
2854
3218
  movables: a,
2855
3219
  jsonMovables: i,
2856
3220
  resources: n.getResources()
2857
3221
  });
2858
3222
  t.empty("drawing", { "r:id": o.relId });
2859
- }(i, s, c, l), function(e, t, n, r) {
3223
+ }(a, s, c, d);
3224
+ let _ = function(e) {
3225
+ let t = e.getComments().toArray();
3226
+ if (t.length === 0) return null;
3227
+ let n = [];
3228
+ for (let e = 0; e < t.length; e++) {
3229
+ let r = t[e], i = yt(r);
3230
+ i && n.push({
3231
+ comment: r,
3232
+ ...i
3233
+ });
3234
+ }
3235
+ return n.length === 0 ? null : (n.sort((e, t) => e.row - t.row || e.col - t.col), {
3236
+ sheet: e,
3237
+ comments: n
3238
+ });
3239
+ }(c);
3240
+ dn(a, s, "legacyDrawing", fn(hn(d.legacyDrawing ?? null, d), _)), dn(a, s, "legacyDrawingHF", d.legacyDrawingHF ?? null), await async function(e, t, n) {
3241
+ let r = n.getPicture();
3242
+ if (!r) return;
3243
+ let i = r.getResource(), a = await i.getExternalURI(), o;
3244
+ if (a) o = e.addExternal(Et, a);
3245
+ else {
3246
+ let t = e.getSharedStates(), n = t.get(Dt);
3247
+ n || (n = /* @__PURE__ */ new Map(), t.set(Dt, n));
3248
+ let r = n.get(i);
3249
+ if (!r) {
3250
+ let e = await i.toBuffer();
3251
+ r = {
3252
+ bytes: new Uint8Array(e),
3253
+ type: await i.getType() ?? Ot,
3254
+ index: n.size + 1
3255
+ }, n.set(i, r);
3256
+ }
3257
+ o = e.addBinary(r.bytes, r.type.mime, Et, `../media/image${r.index}.${r.type.ext}`, !0);
3258
+ }
3259
+ t.empty("picture", { "r:id": o.relId });
3260
+ }(a, s, c), await async function(e, t, n) {
3261
+ let r = n.movables;
3262
+ if (!r || r.every(pn)) return;
3263
+ let i = [], a = r.length;
3264
+ for (let t = 0; t < a; t++) {
3265
+ let n = r[t];
3266
+ if (pn(n)) continue;
3267
+ let a = n.content?.json ?? {}, o = a.part, s;
3268
+ if (o) try {
3269
+ s = (await Ze(o.type ? o : {
3270
+ ...o,
3271
+ type: mn
3272
+ }, e, "../ctrlProps/ctrlProp{n}.xml"))?.relId ?? void 0;
3273
+ } catch (t) {
3274
+ e.log(`Unable to write the properties of the control '${n.name}'`, t);
3275
+ }
3276
+ s ? i.push({
3277
+ jsonMovable: n,
3278
+ jsonControl: a,
3279
+ relId: s
3280
+ }) : e.log(`The control '${n.name}' has no properties to write and was dropped.`);
3281
+ }
3282
+ if (i.length === 0) return;
3283
+ t.start("mc:AlternateContent", {
3284
+ "xmlns:x14": T,
3285
+ "xmlns:xdr": "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
3286
+ }), t.start("mc:Choice", { Requires: "x14" }), t.start("controls");
3287
+ let o = i.length;
3288
+ for (let e = 0; e < o; e++) {
3289
+ let { jsonMovable: n, jsonControl: r, relId: a } = i[e];
3290
+ t.start("mc:AlternateContent"), t.start("mc:Choice", { Requires: "x14" }), t.start("control", {
3291
+ shapeId: r.shapeId,
3292
+ "r:id": a,
3293
+ name: n.name ?? void 0
3294
+ });
3295
+ let o = n.anchorType ?? "twoCell";
3296
+ t.start("controlPr", r.props), t.start("anchor", {
3297
+ moveWithCells: o === "absolute" ? void 0 : "1",
3298
+ sizeWithCells: o === "twoCell" ? "1" : void 0
3299
+ }), gn(t, "from", n.anchor.tl), gn(t, "to", n.anchor.br), t.end("anchor"), r.xml && t.raw(r.xml), t.end("controlPr"), t.end("control"), t.end("mc:Choice"), t.end("mc:AlternateContent");
3300
+ }
3301
+ t.end("controls"), t.end("mc:Choice"), t.end("mc:AlternateContent");
3302
+ }(a, s, d), function(e, t, n, r) {
2860
3303
  let i = r.tables, a = i ? i.length : 0;
2861
3304
  if (a === 0) return;
2862
3305
  let o = n.getTables().getItems();
@@ -2872,97 +3315,105 @@ var vn = (e, t, n, r) => {
2872
3315
  l["r:id"] = c.relId, t.empty("tablePart", l);
2873
3316
  }
2874
3317
  t.end("tableParts");
2875
- }(i, s, c, l), function(e, t, n, i, a) {
3318
+ }(a, s, c, d), function(t, n, r, i, a) {
2876
3319
  if (i.length === 0 && a.length === 0) return;
2877
- let s = n.getStyles(), c = s.getTheme();
2878
- if (t.start("extLst"), i.length > 0) {
2879
- t.start("ext", {
2880
- uri: o,
2881
- "xmlns:x14": r
2882
- }), t.start("x14:conditionalFormattings");
3320
+ let o = r.getStyles(), s = o.getTheme();
3321
+ if (n.start("extLst"), i.length > 0) {
3322
+ n.start("ext", {
3323
+ uri: e,
3324
+ "xmlns:x14": T
3325
+ }), n.start("x14:conditionalFormattings");
2883
3326
  for (let e = 0; e < i.length; e++) {
2884
- let { guid: n, sqref: r, priority: a, scale: o, rule: l, style: u, stopIfTrue: f } = i[e];
2885
- if (t.start("x14:conditionalFormatting", { "xmlns:xm": d }), o) if (o.type === j.ScaleType.DataBar) {
2886
- t.start("x14:cfRule", {
3327
+ let { guid: t, sqref: r, priority: a, scale: c, rule: l, style: u, stopIfTrue: d } = i[e];
3328
+ if (n.start("x14:conditionalFormatting", { "xmlns:xm": v }), c) if (c.type === z.ScaleType.DataBar) {
3329
+ n.start("x14:cfRule", {
2887
3330
  type: "dataBar",
2888
- id: n
2889
- }), t.start("x14:dataBar", {
2890
- minLength: o.minLength,
2891
- maxLength: o.maxLength,
2892
- gradient: o.gradient ? void 0 : "0",
2893
- border: o.borderColor ? "1" : void 0,
2894
- direction: o.direction,
2895
- negativeBarColorSameAsPositive: o.negativeFillColor ? "0" : "1",
2896
- negativeBarBorderColorSameAsPositive: o.negativeBorderColor ? "0" : void 0,
2897
- axisPosition: o.axisPosition
3331
+ id: t
3332
+ }), n.start("x14:dataBar", {
3333
+ minLength: c.minLength,
3334
+ maxLength: c.maxLength,
3335
+ gradient: c.gradient ? void 0 : "0",
3336
+ border: c.borderColor ? "1" : void 0,
3337
+ direction: c.direction,
3338
+ negativeBarColorSameAsPositive: c.negativeFillColor ? "0" : "1",
3339
+ negativeBarBorderColorSameAsPositive: c.negativeBorderColor ? "0" : void 0,
3340
+ axisPosition: c.axisPosition
2898
3341
  });
2899
- let e = o.stops ?? [];
2900
- if (e.length === 0) Ot(t, { type: j.ColorStopType.AutoMin }), Ot(t, { type: j.ColorStopType.AutoMax });
2901
- else for (let n = 0; n < e.length; n++) Ot(t, e[n]);
2902
- o.borderColor && G(t, c, o.borderColor, "x14:borderColor"), o.negativeFillColor && G(t, c, o.negativeFillColor, "x14:negativeFillColor"), o.negativeBorderColor && G(t, c, o.negativeBorderColor, "x14:negativeBorderColor"), o.axisColor && G(t, c, o.axisColor, "x14:axisColor"), t.end("x14:dataBar"), t.end("x14:cfRule");
3342
+ let e = c.stops ?? [];
3343
+ if (e.length === 0) $t(n, { type: z.ColorStopType.AutoMin }), $t(n, { type: z.ColorStopType.AutoMax });
3344
+ else for (let t = 0; t < e.length; t++) $t(n, e[t]);
3345
+ c.borderColor && q(n, s, c.borderColor, "x14:borderColor"), c.negativeFillColor && q(n, s, c.negativeFillColor, "x14:negativeFillColor"), c.negativeBorderColor && q(n, s, c.negativeBorderColor, "x14:negativeBorderColor"), c.axisColor && q(n, s, c.axisColor, "x14:axisColor"), n.end("x14:dataBar"), n.end("x14:cfRule");
2903
3346
  } else {
2904
- t.start("x14:cfRule", {
3347
+ n.start("x14:cfRule", {
2905
3348
  type: "iconSet",
2906
3349
  priority: a,
2907
- id: n
2908
- }), t.start("x14:iconSet", {
2909
- iconSet: o.iconSet,
2910
- reverse: Z(o.reverse),
2911
- showValue: Z(o.showValue),
2912
- custom: (o.icon?.length ?? 0) > 0 ? "1" : void 0
3350
+ id: t
3351
+ }), n.start("x14:iconSet", {
3352
+ iconSet: c.iconSet,
3353
+ reverse: Q(c.reverse),
3354
+ showValue: Q(c.showValue),
3355
+ custom: (c.icon?.length ?? 0) > 0 ? "1" : void 0
2913
3356
  });
2914
- let e = o.stops ?? [];
2915
- for (let n = 0; n < e.length; n++) Ot(t, e[n]);
2916
- let r = o.icon ?? [];
2917
- for (let e = 0; e < r.length; e++) t.empty("x14:cfIcon", {
3357
+ let e = c.stops ?? [];
3358
+ for (let t = 0; t < e.length; t++) $t(n, e[t]);
3359
+ let r = c.icon ?? [];
3360
+ for (let e = 0; e < r.length; e++) n.empty("x14:cfIcon", {
2918
3361
  iconSet: r[e].set,
2919
3362
  iconId: r[e].id
2920
3363
  });
2921
- t.end("x14:iconSet"), t.end("x14:cfRule");
3364
+ n.end("x14:iconSet"), n.end("x14:cfRule");
2922
3365
  }
2923
3366
  else {
2924
- t.start("x14:cfRule", {
3367
+ n.start("x14:cfRule", {
2925
3368
  type: l.type,
2926
3369
  priority: a,
2927
- stopIfTrue: Z(f),
2928
- aboveAverage: Z(l.aboveAverage),
2929
- equalAverage: Z(l.equalAverage),
3370
+ stopIfTrue: Q(d),
3371
+ aboveAverage: Q(l.aboveAverage),
3372
+ equalAverage: Q(l.equalAverage),
2930
3373
  stdDev: l.stdDev,
2931
- bottom: Z(l.bottom),
2932
- percent: Z(l.percent),
3374
+ bottom: Q(l.bottom),
3375
+ percent: Q(l.percent),
2933
3376
  rank: l.rank,
2934
3377
  operator: l.operator,
2935
3378
  text: l.text,
2936
3379
  timePeriod: l.timePeriod,
2937
- id: n
3380
+ id: t
2938
3381
  });
2939
3382
  let e = l.formulas ?? [];
2940
- for (let n = 0; n < e.length; n++) t.start("xm:f"), t.text(e[n]), t.end("xm:f");
2941
- u && Object.keys(u).length > 0 && ft(0, t, u, s, c, "x14:dxf"), t.end("x14:cfRule");
3383
+ for (let t = 0; t < e.length; t++) n.start("xm:f"), n.text(e[t]), n.end("xm:f");
3384
+ u && Object.keys(u).length > 0 && Bt(0, n, u, o, s, "x14:dxf"), n.end("x14:cfRule");
2942
3385
  }
2943
- t.start("xm:sqref"), t.text(r), t.end("xm:sqref"), t.end("x14:conditionalFormatting");
3386
+ n.start("xm:sqref"), n.text(r), n.end("xm:sqref"), n.end("x14:conditionalFormatting");
2944
3387
  }
2945
- t.end("x14:conditionalFormattings"), t.end("ext");
3388
+ n.end("x14:conditionalFormattings"), n.end("ext");
2946
3389
  }
2947
3390
  if (a.length > 0) {
2948
- t.start("ext", {
2949
- uri: w,
2950
- "xmlns:x14": r
2951
- }), t.start("x14:dataValidations", {
2952
- "xmlns:xm": d,
3391
+ n.start("ext", {
3392
+ uri: ne,
3393
+ "xmlns:x14": T
3394
+ }), n.start("x14:dataValidations", {
3395
+ "xmlns:xm": v,
2953
3396
  count: a.length
2954
3397
  });
2955
3398
  for (let e = 0; e < a.length; e++) {
2956
- let { attrs: n, formula1: r, formula2: i, sqref: o } = a[e];
2957
- t.start("x14:dataValidation", n), r !== void 0 && (t.start("x14:formula1"), t.start("xm:f"), t.text(r), t.end("xm:f"), t.end("x14:formula1")), i !== void 0 && (t.start("x14:formula2"), t.start("xm:f"), t.text(i), t.end("xm:f"), t.end("x14:formula2")), t.start("xm:sqref"), t.text(o), t.end("xm:sqref"), t.end("x14:dataValidation");
3399
+ let { attrs: t, formula1: r, formula2: i, sqref: o } = a[e];
3400
+ n.start("x14:dataValidation", t), r !== void 0 && (n.start("x14:formula1"), n.start("xm:f"), n.text(r), n.end("xm:f"), n.end("x14:formula1")), i !== void 0 && (n.start("x14:formula2"), n.start("xm:f"), n.text(i), n.end("xm:f"), n.end("x14:formula2")), n.start("xm:sqref"), n.text(o), n.end("xm:sqref"), n.end("x14:dataValidation");
2958
3401
  }
2959
- t.end("x14:dataValidations"), t.end("ext");
3402
+ n.end("x14:dataValidations"), n.end("ext");
3403
+ }
3404
+ n.end("extLst");
3405
+ }(0, s, c, m, h), function(e, t) {
3406
+ let n = t.pivotTables, r = n ? n.length : 0;
3407
+ for (let t = 0; t < r; t++) {
3408
+ let r = n[t], i = r.part;
3409
+ i?.xml && (et(e, r.cacheId) ? e.addPart("pivotTable", r) : e.log(`The pivot table '${i.name ?? ""}' has no cache with id ${r.cacheId} and was dropped.`));
2960
3410
  }
2961
- t.end("extLst");
2962
- }(0, s, c, p, m), s.end("worksheet"), s.close();
3411
+ }(a, d), function(e, t) {
3412
+ t && (e.addPart("comments", t), t.comments.some((e) => !e.comment.isNote()) && e.addPart("threadedComments", t));
3413
+ }(a, _), s.end("worksheet"), s.close();
2963
3414
  }
2964
3415
  }(),
2965
- new class extends B {
3416
+ new class extends U {
2966
3417
  constructor() {
2967
3418
  super({
2968
3419
  kind: "sharedStrings",
@@ -2972,22 +3423,22 @@ var vn = (e, t, n, r) => {
2972
3423
  });
2973
3424
  }
2974
3425
  async emit(e, t) {
2975
- let n = t.getXMLWriter(), r = e.json, i = r ? r.length : 0, a = t.getSharedStates().get("stringsCount") ?? 0;
2976
- n.decl(), n.start("sst", {
3426
+ let i = t.getXMLWriter(), a = e.json, o = a ? a.length : 0, s = t.getSharedStates().get("stringsCount") ?? 0;
3427
+ i.decl(), i.start("sst", {
2977
3428
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
2978
- count: a,
2979
- uniqueCount: i
3429
+ count: s,
3430
+ uniqueCount: o
2980
3431
  });
2981
- for (let e = 0; e < i; e++) {
2982
- let t = r[e];
2983
- n.start("si");
2984
- let i = ee.test(t) ? b : void 0;
2985
- n.start("t", i), n.text(h(t)), n.end("t"), n.end("si");
3432
+ for (let e = 0; e < o; e++) {
3433
+ let t = a[e];
3434
+ i.start("si");
3435
+ let o = ie.test(t) ? n : void 0;
3436
+ i.start("t", o), i.text(r(t)), i.end("t"), i.end("si");
2986
3437
  }
2987
- n.end("sst"), n.close();
3438
+ i.end("sst"), i.close();
2988
3439
  }
2989
3440
  }(),
2990
- new class extends B {
3441
+ new class extends U {
2991
3442
  constructor() {
2992
3443
  super({
2993
3444
  kind: "theme",
@@ -3005,22 +3456,22 @@ var vn = (e, t, n, r) => {
3005
3456
  let i = n?.getColorScheme();
3006
3457
  if (i) {
3007
3458
  t.start(r, { name: i.getName() || "Office" });
3008
- for (let e of Ve) t.start(e), U(t, n, i["get" + e.charAt(0).toUpperCase() + e.slice(1)]()), t.end(e);
3459
+ for (let e of lt) t.start(e), G(t, n, i["get" + e.charAt(0).toUpperCase() + e.slice(1)]()), t.end(e);
3009
3460
  t.end(r);
3010
3461
  }
3011
3462
  }(0, n, r, "clrScheme"), function(e, t, n, r) {
3012
- n && (t.start(r, { name: n.getName() || "Office" }), Vt(e, t, n.getMajorFont() || "Calibri Light", "majorFont"), Vt(e, t, n.getMinorFont() || "Calibri", "minorFont"), t.end(r));
3463
+ n && (t.start(r, { name: n.getName() || "Office" }), Sn(e, t, n.getMajorFont() || "Calibri Light", "majorFont"), Sn(e, t, n.getMinorFont() || "Calibri", "minorFont"), t.end(r));
3013
3464
  }(t, n, r.getFontScheme(), "fontScheme"), function(e, t, n, r, i) {
3014
3465
  if (i?.fillStyleLst && i?.lnStyleLst && i?.effectStyleLst && i?.bgFillStyleLst) return void function(e, t, n, r, i) {
3015
3466
  let a = { getTheme: () => r };
3016
3467
  t.start(n, { name: "Office" }), t.start("fillStyleLst");
3017
- for (let e of i.fillStyleLst) K(0, t, e, a);
3468
+ for (let e of i.fillStyleLst) J(0, t, e, a);
3018
3469
  t.end("fillStyleLst"), t.start("lnStyleLst");
3019
- for (let e of i.lnStyleLst) Je(0, t, e, a);
3470
+ for (let e of i.lnStyleLst) bt(0, t, e, a);
3020
3471
  t.end("lnStyleLst"), t.start("effectStyleLst");
3021
- for (let n of i.effectStyleLst) t.start("effectStyle"), n.length > 0 ? Ze(e, t, r, n) : t.empty("effectLst"), t.end("effectStyle");
3472
+ for (let n of i.effectStyleLst) t.start("effectStyle"), n.length > 0 ? Ct(e, t, r, n) : t.empty("effectLst"), t.end("effectStyle");
3022
3473
  t.end("effectStyleLst"), t.start("bgFillStyleLst");
3023
- for (let e of i.bgFillStyleLst) K(0, t, e, a);
3474
+ for (let e of i.bgFillStyleLst) J(0, t, e, a);
3024
3475
  t.end("bgFillStyleLst"), t.end(n);
3025
3476
  }(e, t, n, r, i);
3026
3477
  if (i?.formatSchemeXml) return void t.raw(i.formatSchemeXml);
@@ -3071,7 +3522,7 @@ var vn = (e, t, n, r) => {
3071
3522
  }(t, n, "fmtScheme", r, i), n.end("themeElements"), n.start("objectDefaults"), n.end("objectDefaults"), n.start("extraClrSchemeLst"), n.end("extraClrSchemeLst"), n.end("theme"), n.close();
3072
3523
  }
3073
3524
  }(),
3074
- new class extends B {
3525
+ new class extends U {
3075
3526
  constructor() {
3076
3527
  super({
3077
3528
  kind: "styles",
@@ -3097,11 +3548,11 @@ var vn = (e, t, n, r) => {
3097
3548
  for (let t = 0; t < r; t++) {
3098
3549
  let r = t === 0 ? {
3099
3550
  ...n[t],
3100
- named: I.BuiltInName.Normal
3551
+ named: V.BuiltInName.Normal
3101
3552
  } : n[t], a = e.resolve(r), o = {};
3102
- r.named !== void 0 && (o.named = r.named), r.quotePrefix !== void 0 && (o.quotePrefix = r.quotePrefix);
3103
- for (let e = 0; e < at.length; e++) {
3104
- let t = at[e];
3553
+ r.named !== void 0 && (o.named = r.named), r.quotePrefix !== void 0 && (o.quotePrefix = r.quotePrefix), r.protection !== void 0 && (o.protection = r.protection);
3554
+ for (let e = 0; e < Mt.length; e++) {
3555
+ let t = Mt[e];
3105
3556
  if (r[t] === void 0 && t !== "alignment") continue;
3106
3557
  let n = a?.[t] ?? r[t];
3107
3558
  n !== void 0 && (o[t] = n);
@@ -3123,16 +3574,16 @@ var vn = (e, t, n, r) => {
3123
3574
  namedStyles: []
3124
3575
  };
3125
3576
  (function(e, t) {
3126
- let n = (e.getNamed(I.BuiltInName.Normal).toJSON().style ?? {}).font ?? {};
3127
- t.fontMap.set(E.JSONStableStringify(n), "0"), t.fonts.push(n);
3577
+ let n = (e.getNamedStyles().getByName(V.BuiltInName.Normal).toJSON().style ?? {}).font ?? {};
3578
+ t.fontMap.set(F.JSONStableStringify(n), "0"), t.fonts.push(n);
3128
3579
  })(e, r), function(e) {
3129
3580
  let t = { type: "none" };
3130
- e.fillMap.set(E.JSONStableStringify(t), "0"), e.fills.push(t);
3581
+ e.fillMap.set(F.JSONStableStringify(t), "0"), e.fills.push(t);
3131
3582
  let n = {
3132
3583
  type: "pattern",
3133
3584
  patternType: "gray125"
3134
3585
  };
3135
- e.fillMap.set(E.JSONStableStringify(n), "1"), e.fills.push(n);
3586
+ e.fillMap.set(F.JSONStableStringify(n), "1"), e.fills.push(n);
3136
3587
  }(r), function(e) {
3137
3588
  let t = {
3138
3589
  bottom: { style: "none" },
@@ -3140,27 +3591,27 @@ var vn = (e, t, n, r) => {
3140
3591
  right: { style: "none" },
3141
3592
  top: { style: "none" }
3142
3593
  };
3143
- e.borderMap.set(E.JSONStableStringify(t), "0"), e.borders.push(t);
3594
+ e.borderMap.set(F.JSONStableStringify(t), "0"), e.borders.push(t);
3144
3595
  }(r), function(e, t) {
3145
- st(e, e.getNamed(I.BuiltInName.Normal).toJSON(), t);
3596
+ Pt(e, e.getNamedStyles().getByName(V.BuiltInName.Normal).toJSON(), t);
3146
3597
  }(e, r);
3147
- let i = t?.named ?? D.EmptyArray;
3148
- for (let t of i) st(e, t, r);
3149
- for (let t of n) ot(e, t, r);
3598
+ let i = t?.named ?? I.EmptyArray;
3599
+ for (let t of i) Pt(e, t, r);
3600
+ for (let t of n) Nt(e, t, r);
3150
3601
  return r;
3151
- }(i, r, a), s = t.getSharedStates().get(it), c = function(e, t = 0) {
3602
+ }(i, r, a), s = t.getSharedStates().get(jt), c = function(e, t = 0) {
3152
3603
  let n = e?.tables;
3153
3604
  if (!n) return null;
3154
3605
  let r = n.styles;
3155
3606
  if (!r) return null;
3156
- let i = [], a = /* @__PURE__ */ new Map(), o = Object.keys(r), s = [...mt].reverse();
3607
+ let i = [], a = /* @__PURE__ */ new Map(), o = Object.keys(r), s = [...Ht].reverse();
3157
3608
  for (let e of o) {
3158
3609
  let n = r[e];
3159
3610
  for (let r of s) {
3160
3611
  let o = n[r];
3161
3612
  if (!o) continue;
3162
3613
  let s = {};
3163
- if (o.font && (s.font = o.font), o.fill && (s.fill = o.fill), o.border && (s.border = o.border), o.numberFormat !== void 0 && (s.numberFormat = o.numberFormat), Object.keys(s).length === 0) continue;
3614
+ if (o.font && (s.font = o.font), o.fill && (s.fill = o.fill), o.borders && (s.borders = o.borders), o.numberFormat !== void 0 && (s.numberFormat = o.numberFormat), Object.keys(s).length === 0) continue;
3164
3615
  let c = t + i.length;
3165
3616
  i.push(s);
3166
3617
  let l = `${e}:${r}`;
@@ -3179,7 +3630,7 @@ var vn = (e, t, n, r) => {
3179
3630
  for (let e = 0; e < i; e++) {
3180
3631
  let n = r[e];
3181
3632
  t.empty("numFmt", {
3182
- numFmtId: String(e + pt),
3633
+ numFmtId: String(e + Vt),
3183
3634
  formatCode: n
3184
3635
  });
3185
3636
  }
@@ -3191,30 +3642,31 @@ var vn = (e, t, n, r) => {
3191
3642
  count: String(a),
3192
3643
  "x14ac:knownFonts": "1"
3193
3644
  });
3194
- for (let r of i) ct(e, t, r, n);
3645
+ for (let r of i) Ft(e, t, r, n);
3195
3646
  t.end("fonts");
3196
3647
  }(t, n, i, o), function(e, t, n, r) {
3197
3648
  let i = r.fills, a = i.length;
3198
3649
  t.start("fills", { count: String(a) });
3199
- for (let e of i) K(0, t, e, n, !0);
3650
+ for (let e of i) J(0, t, e, n, !0);
3200
3651
  t.end("fills");
3201
3652
  }(0, n, i, o), function(e, t, n, r) {
3202
3653
  let i = r.borders, a = i.length;
3203
3654
  t.start("borders", { count: String(a) });
3204
3655
  let o = n.getTheme();
3205
- for (let n of i) lt(e, t, n, o, !1);
3656
+ for (let n of i) Lt(e, t, n, o, !1);
3206
3657
  t.end("borders");
3207
3658
  }(t, n, i, o), function(e, t, n, r, i) {
3208
3659
  let a = i.namedStyles, o = a.length;
3209
3660
  t.start("cellStyleXfs", { count: String(o) });
3210
- for (let r of a) dt(e, t, n, r.style ?? D.EmptyObject, i, !1);
3661
+ for (let r of a) zt(e, t, n, r.style ?? I.EmptyObject, i, !1);
3211
3662
  t.end("cellStyleXfs");
3212
- }(t, n, i, 0, o), function(e, t, n, r, i) {
3213
- let a = r.length;
3214
- t.start("cellXfs", { count: String(a) });
3215
- for (let o = 0; o < a; o++) dt(e, t, n, r[o], i, !0);
3663
+ }(t, n, i, 0, o), function(e, t, n, r, i, a) {
3664
+ let o = r.length, s = a?.getSources() ?? [];
3665
+ t.start("cellXfs", { count: String(o + s.length) });
3666
+ for (let a = 0; a < o; a++) zt(e, t, n, r[a], i, !0);
3667
+ for (let a = 0; a < s.length; a++) zt(e, t, n, r[s[a]], i, !0, !0);
3216
3668
  t.end("cellXfs");
3217
- }(t, n, i, a, o), function(e, t, n, r, i) {
3669
+ }(t, n, i, a, o, t.getSharedStates().get(We)), function(e, t, n, r, i) {
3218
3670
  let a = i.namedStyles, o = a.length;
3219
3671
  t.start("cellStyles", { count: String(o) });
3220
3672
  let s = i.namedStyleMap;
@@ -3225,7 +3677,7 @@ var vn = (e, t, n, r) => {
3225
3677
  };
3226
3678
  r.hidden && (c.hidden = "1"), r.iLevel && (c.iLevel = String(r.iLevel));
3227
3679
  let l = null;
3228
- l = o === I.BuiltInName.Normal.toLowerCase() ? 0 : n.getNamed(i).getBuiltInID(), l !== null && (c.builtinId = String(l), c.customBuiltin = "1"), t.empty("cellStyle", c);
3680
+ l = o === V.BuiltInName.Normal.toLowerCase() ? 0 : n.getNamedStyles().getByName(i).getBuiltInID(), l !== null && (c.builtinId = String(l), c.customBuiltin = "1"), t.empty("cellStyle", c);
3229
3681
  }
3230
3682
  t.end("cellStyles");
3231
3683
  }(0, n, i, 0, o), function(e, t, n, r, i) {
@@ -3233,8 +3685,8 @@ var vn = (e, t, n, r) => {
3233
3685
  if (a.length === 0) return void t.empty("dxfs", { count: "0" });
3234
3686
  let o = n.getTheme();
3235
3687
  t.start("dxfs", { count: String(a.length) });
3236
- let s = pt;
3237
- for (let r of a) s = ft(e, t, r, n, o, "dxf", s);
3688
+ let s = Vt;
3689
+ for (let r of a) s = Bt(e, t, r, n, o, "dxf", s);
3238
3690
  t.end("dxfs");
3239
3691
  }(t, n, i, c, s), function(e, t, n, r, i) {
3240
3692
  let a = r?.tables, o = a?.styles ?? null, s = o ? Object.keys(o) : null, c = s ? s.length : 0, l = {
@@ -3246,7 +3698,7 @@ var vn = (e, t, n, r) => {
3246
3698
  t.start("tableStyles", l);
3247
3699
  for (let e of s) {
3248
3700
  let n = o[e], r = [];
3249
- for (let e of mt) {
3701
+ for (let e of Ht) {
3250
3702
  let t = n[e];
3251
3703
  t && r.push([e, t]);
3252
3704
  }
@@ -3269,7 +3721,7 @@ var vn = (e, t, n, r) => {
3269
3721
  if (t.start("colors"), i) {
3270
3722
  t.start("indexedColors");
3271
3723
  for (let e of r.indexedColors) {
3272
- let n = qe(e, !0);
3724
+ let n = ht(e, !0);
3273
3725
  t.empty("rgbColor", { rgb: n });
3274
3726
  }
3275
3727
  t.end("indexedColors");
@@ -3277,7 +3729,7 @@ var vn = (e, t, n, r) => {
3277
3729
  if (a) {
3278
3730
  t.start("mruColors");
3279
3731
  for (let e of r.mruColors) {
3280
- let n = qe(e);
3732
+ let n = ht(e);
3281
3733
  t.empty("color", { rgb: n });
3282
3734
  }
3283
3735
  t.end("mruColors");
@@ -3295,7 +3747,7 @@ var vn = (e, t, n, r) => {
3295
3747
  }(0, n), n.end("styleSheet"), n.close();
3296
3748
  }
3297
3749
  }(),
3298
- new class extends B {
3750
+ new class extends U {
3299
3751
  constructor() {
3300
3752
  super({
3301
3753
  kind: "propsCore",
@@ -3316,14 +3768,14 @@ var vn = (e, t, n, r) => {
3316
3768
  let r = /* @__PURE__ */ new Date(), i = [
3317
3769
  ["creator", "SheetXL"],
3318
3770
  ["lastModifiedBy", "SheetXL"],
3319
- ["created", Ht(r)],
3320
- ["modified", Ht(r)]
3771
+ ["created", Cn(r)],
3772
+ ["modified", Cn(r)]
3321
3773
  ];
3322
- for (let e of i) Ut(n, e[0], e[1]);
3774
+ for (let e of i) wn(n, e[0], e[1]);
3323
3775
  n.end("cp:coreProperties"), n.close();
3324
3776
  }
3325
3777
  }(),
3326
- new class extends B {
3778
+ new class extends U {
3327
3779
  constructor() {
3328
3780
  super({
3329
3781
  kind: "propsApp",
@@ -3333,21 +3785,14 @@ var vn = (e, t, n, r) => {
3333
3785
  });
3334
3786
  }
3335
3787
  async emit(e, t) {
3336
- let n = t.getXMLWriter(), r = e.model, i = await re.getDetails(), a = function(e) {
3337
- if (!e || typeof e != "string") return xt;
3338
- if (e === "local" || e === "dev" || e === "development") return "00.0000";
3339
- let t = e.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
3340
- if (!t) return xt;
3341
- let n = parseInt(t[1], 10), r = parseInt(t[2] || "0", 10);
3342
- return n > 99 || r > 9999 ? xt : `${n.toString()}.${r.toString().padStart(4, "0")}`;
3343
- }(i.getBuildVersion()), o = i.getLicensee() || "";
3788
+ let n = t.getXMLWriter(), r = e.model, i = await fe.getDetails(), a = j(i.getBuildVersion()), o = i.getLicensee() || "";
3344
3789
  n.setValidationDisabled(!0), n.decl(), n.start("Properties", {
3345
3790
  xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
3346
3791
  "xmlns:vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
3347
- }), Q(t, n, "Application", "SheetXL"), Q(t, n, "DocSecurity", "0"), Q(t, n, "ScaleCrop", "false"), Wt(t, n, r), Q(t, n, "Company", o), Q(t, n, "LinksUpToDate", "false"), Q(t, n, "SharedDoc", "false"), Q(t, n, "HyperlinksChanged", "false"), Q(t, n, "AppVersion", a), n.end("Properties"), n.close();
3792
+ }), $(t, n, "Application", "SheetXL"), $(t, n, "DocSecurity", "0"), $(t, n, "ScaleCrop", "false"), Tn(t, n, r), $(t, n, "Company", o), $(t, n, "LinksUpToDate", "false"), $(t, n, "SharedDoc", "false"), $(t, n, "HyperlinksChanged", "false"), $(t, n, "AppVersion", a), n.end("Properties"), n.close();
3348
3793
  }
3349
3794
  }(),
3350
- new class extends B {
3795
+ new class extends U {
3351
3796
  constructor() {
3352
3797
  super({
3353
3798
  kind: "metadata",
@@ -3362,11 +3807,11 @@ var vn = (e, t, n, r) => {
3362
3807
  let d = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
3363
3808
  if (r && (d["xmlns:xda"] = "http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"), i && (d["xmlns:xlrd"] = "http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"), n.decl(), n.start("metadata", d), n.start("metadataTypes", { count: u }), r && n.empty("metadataType", {
3364
3809
  name: "XLDAPR",
3365
- ...Gt,
3810
+ ...En,
3366
3811
  cellMeta: "1"
3367
3812
  }), i && n.empty("metadataType", {
3368
3813
  name: "XLRICHVALUE",
3369
- ...Gt
3814
+ ...En
3370
3815
  }), n.end("metadataTypes"), r) {
3371
3816
  n.start("futureMetadata", {
3372
3817
  name: "XLDAPR",
@@ -3405,7 +3850,7 @@ var vn = (e, t, n, r) => {
3405
3850
  n.end("metadata"), n.close();
3406
3851
  }
3407
3852
  }(),
3408
- new class extends B {
3853
+ new class extends U {
3409
3854
  constructor() {
3410
3855
  super({
3411
3856
  kind: "richValue",
@@ -3430,7 +3875,7 @@ var vn = (e, t, n, r) => {
3430
3875
  n.end("rvData"), n.close();
3431
3876
  }
3432
3877
  }(),
3433
- new class extends B {
3878
+ new class extends U {
3434
3879
  constructor() {
3435
3880
  super({
3436
3881
  kind: "richValueStructure",
@@ -3456,7 +3901,7 @@ var vn = (e, t, n, r) => {
3456
3901
  n.end("rvStructures"), n.close();
3457
3902
  }
3458
3903
  }(),
3459
- new class extends B {
3904
+ new class extends U {
3460
3905
  constructor() {
3461
3906
  super({
3462
3907
  kind: "richValueTypes",
@@ -3497,7 +3942,7 @@ var vn = (e, t, n, r) => {
3497
3942
  n.end("keyFlags"), n.end("global"), n.end("rvTypesInfo"), n.close();
3498
3943
  }
3499
3944
  }(),
3500
- new class extends B {
3945
+ new class extends U {
3501
3946
  constructor() {
3502
3947
  super({
3503
3948
  kind: "drawing",
@@ -3532,33 +3977,208 @@ var vn = (e, t, n, r) => {
3532
3977
  }
3533
3978
  for (let e = 0; e < s; e++) {
3534
3979
  let s = o[e], c = a[e], u = s.content?.type;
3535
- switch (n.start("twoCellAnchor", { editAs: s.anchorType || "twoCell" }), fn(n, "from", s.anchor.tl), fn(n, "to", s.anchor.br), u) {
3980
+ switch (n.start("twoCellAnchor", { editAs: s.anchorType || "twoCell" }), Kn(n, "from", s.anchor.tl), Kn(n, "to", s.anchor.br), u) {
3536
3981
  case "picture":
3537
- await Qt(t, i, r, c, s);
3982
+ await Nn(t, i, r, c, s);
3538
3983
  break;
3539
3984
  case "chart":
3540
- await en(t, i, r, c, s, l.get(s));
3985
+ await Pn(t, i, r, c, s, l.get(s));
3541
3986
  break;
3542
3987
  case "shape":
3543
- await an(t, i, r, c, s, l.get(s));
3988
+ await Rn(t, i, r, c, s, l.get(s));
3544
3989
  break;
3545
3990
  case "smartArt":
3546
- await tn(t, i, r, c, s);
3991
+ await Fn(t, i, r, c, s);
3547
3992
  break;
3548
3993
  case "slicer":
3549
- await nn(t, i, r, c, s);
3994
+ await In(t, i, r, c, s);
3550
3995
  break;
3551
3996
  case "graphicFrame":
3552
- await rn(t, i, r, c, s);
3997
+ await Ln(t, i, r, c, s);
3553
3998
  break;
3554
- default: await $(t, i, r, c, s);
3999
+ default: await zn(t, i, r, c, s);
3555
4000
  }
3556
4001
  n.empty("clientData"), n.end("twoCellAnchor");
3557
4002
  }
3558
4003
  n.end("wsDr"), n.close();
3559
4004
  }
3560
4005
  }(),
3561
- new class extends B {
4006
+ new class extends U {
4007
+ constructor() {
4008
+ super({
4009
+ kind: "legacyDrawing",
4010
+ contentType: "application/vnd.openxmlformats-officedocument.vmlDrawing",
4011
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
4012
+ path: "../drawings/vmlDrawing{n}.vml"
4013
+ });
4014
+ }
4015
+ async emit(e, t) {
4016
+ let n = e.images, r = n ? n.length : 0;
4017
+ if (r > 0) {
4018
+ let e = t.getSharedStates().get(he);
4019
+ for (let i = 0; i < r; i++) {
4020
+ let r = n[i], a = e?.get(r.resId);
4021
+ if (a) try {
4022
+ await qn(t, r.id, a);
4023
+ } catch (e) {
4024
+ t.log(`Unable to write legacy drawing image '${r.id}'`, e);
4025
+ }
4026
+ else t.log(`Legacy drawing image '${r.id}' has no resource ${r.resId} and was not written.`);
4027
+ }
4028
+ }
4029
+ let i = t.getXMLWriter();
4030
+ i.setValidationDisabled(!0), i.raw(e.xml), i.close();
4031
+ }
4032
+ }(),
4033
+ new class extends U {
4034
+ constructor() {
4035
+ super({
4036
+ kind: "embeddedPart",
4037
+ contentType: Ye,
4038
+ relTypeUri: ""
4039
+ });
4040
+ }
4041
+ getContentType(e) {
4042
+ return e?.contentType || Ye;
4043
+ }
4044
+ getRelTypeUri(e) {
4045
+ return e?.type ?? "";
4046
+ }
4047
+ getPath(e) {
4048
+ return `./${Qe(e.name)}`;
4049
+ }
4050
+ async emit(e, t) {
4051
+ await Xe(e, t);
4052
+ let n = t.getXMLWriter();
4053
+ n.setValidationDisabled(!0), n.raw(e.xml ?? ""), n.close();
4054
+ }
4055
+ }(),
4056
+ new class extends U {
4057
+ constructor() {
4058
+ super({
4059
+ kind: "pivotTable",
4060
+ contentType: $e,
4061
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
4062
+ path: "../pivotTables/pivotTable{n}.xml"
4063
+ });
4064
+ }
4065
+ getContentType(e) {
4066
+ return e?.part?.contentType || $e;
4067
+ }
4068
+ async emit(e, t) {
4069
+ let n = e.part;
4070
+ await Xe(n, t);
4071
+ let r = et(t, e.cacheId);
4072
+ if (!r || !t.addRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition", r)) throw Error(`Pivot table '${n.name ?? ""}' has no cache with id ${e.cacheId}.`);
4073
+ let i = t.getXMLWriter();
4074
+ i.setValidationDisabled(!0), i.raw(n.xml ?? ""), i.close();
4075
+ }
4076
+ }(),
4077
+ new class extends U {
4078
+ constructor() {
4079
+ super({
4080
+ kind: "comments",
4081
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
4082
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
4083
+ path: "../comments{n}.xml"
4084
+ });
4085
+ }
4086
+ async emit(e, t) {
4087
+ let n = t.getXMLWriter();
4088
+ n.decl(), n.start("comments", {
4089
+ xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
4090
+ "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
4091
+ "mc:Ignorable": "xr",
4092
+ "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
4093
+ });
4094
+ let r = [], i = /* @__PURE__ */ new Map(), a = (e) => {
4095
+ let t = i.get(e);
4096
+ return t === void 0 && (t = r.length, r.push(e), i.set(e, t)), t;
4097
+ }, o = e.comments, s = [];
4098
+ for (let e = 0; e < o.length; e++) {
4099
+ let { comment: t, ref: n } = o[e];
4100
+ t.isNote() ? s.push({
4101
+ ref: n,
4102
+ authorId: a(t.getAuthor()?.getDisplayName() ?? ""),
4103
+ content: t.getRichContent() ?? t.getContent()
4104
+ }) : s.push({
4105
+ ref: n,
4106
+ authorId: a(`tc={${t.getId().toUpperCase()}}`),
4107
+ content: gt(t)
4108
+ });
4109
+ }
4110
+ n.start("authors");
4111
+ for (let e = 0; e < r.length; e++) n.start("author"), n.text(r[e]), n.end("author");
4112
+ n.end("authors"), n.start("commentList");
4113
+ for (let e = 0; e < s.length; e++) {
4114
+ let t = s[e];
4115
+ n.start("comment", {
4116
+ ref: t.ref,
4117
+ authorId: t.authorId,
4118
+ shapeId: 0
4119
+ }), n.start("text"), _t(n, t.content), n.end("text"), n.end("comment");
4120
+ }
4121
+ n.end("commentList"), n.end("comments"), n.close();
4122
+ }
4123
+ }(),
4124
+ new class extends U {
4125
+ constructor() {
4126
+ super({
4127
+ kind: "threadedComments",
4128
+ contentType: "application/vnd.ms-excel.threadedcomments+xml",
4129
+ relTypeUri: "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",
4130
+ path: "../threadedComments/threadedComment{n}.xml"
4131
+ });
4132
+ }
4133
+ async emit(e, t) {
4134
+ let n = t.getXMLWriter();
4135
+ n.decl(), n.start("ThreadedComments", {
4136
+ xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
4137
+ "xmlns:x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
4138
+ });
4139
+ let r = e.comments;
4140
+ for (let e = 0; e < r.length; e++) {
4141
+ let { comment: t, ref: i } = r[e];
4142
+ if (t.isNote()) continue;
4143
+ Jn(n, i, t.getId(), t.getAuthor()?.getId(), t.getCreationDate(), t.getContent(), null, t.isResolved());
4144
+ let a = t.getReplies();
4145
+ for (let e = 0; e < a.length; e++) {
4146
+ let r = a[e];
4147
+ Jn(n, i, r.getId(), r.getAuthor()?.getId(), r.getCreationDate(), r.getContent(), t.getId(), !1);
4148
+ }
4149
+ }
4150
+ n.end("ThreadedComments"), n.close();
4151
+ }
4152
+ }(),
4153
+ new class extends U {
4154
+ constructor() {
4155
+ super({
4156
+ kind: "persons",
4157
+ contentType: "application/vnd.ms-excel.person+xml",
4158
+ relTypeUri: "http://schemas.microsoft.com/office/2017/10/relationships/person",
4159
+ path: "persons/person.xml"
4160
+ });
4161
+ }
4162
+ async emit(e, t) {
4163
+ let n = t.getXMLWriter();
4164
+ n.decl(), n.start("personList", {
4165
+ xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
4166
+ "xmlns:x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
4167
+ });
4168
+ let r = e.toArray();
4169
+ for (let e = 0; e < r.length; e++) {
4170
+ let t = r[e];
4171
+ n.empty("person", {
4172
+ displayName: t.getDisplayName(),
4173
+ id: Yn(t.getId()),
4174
+ userId: t.getUserId() ?? t.getDisplayName(),
4175
+ providerId: t.getProviderId() ?? "None"
4176
+ });
4177
+ }
4178
+ n.end("personList"), n.close();
4179
+ }
4180
+ }(),
4181
+ new class extends U {
3562
4182
  constructor() {
3563
4183
  super({
3564
4184
  kind: "table",
@@ -3577,10 +4197,79 @@ var vn = (e, t, n, r) => {
3577
4197
  "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
3578
4198
  "xmlns:xr3": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"
3579
4199
  }, i = e.json, a = e.model;
3580
- a.isShowHeaders(), r.id = ++pn, r.name = i.name?.trim(), r.displayName = i.description ?? i.name, r.ref = e.ref, i.headerRowCount !== 1 && (r.headerRowCount = i.headerRowCount), i.totalsRowCount !== 0 && (r.totalsRowCount = i.totalsRowCount), a.isShowTotals() || (r.totalsRowShown = "0"), n.start("table", r), a.isShowHeaders() && _t(t, n, a, i), mn(t, n, a, i), hn(t, n, a, i), n.end("table"), n.close();
4200
+ a.isShowHeaders(), r.id = ++Xn, r.name = i.name?.trim(), r.displayName = i.description ?? i.name, r.ref = e.ref, i.headerRowCount !== 1 && (r.headerRowCount = i.headerRowCount), i.totalsRowCount !== 0 && (r.totalsRowCount = i.totalsRowCount), i.totalsRowShown || a.isShowTotals() || (r.totalsRowShown = "0"), n.start("table", r), a.isShowHeaders() && Gt(t, n, a, i), Zn(t, n, a, i), $n(t, n, a, i), n.end("table"), n.close();
3581
4201
  }
3582
4202
  }(),
3583
- new class extends B {
4203
+ new class extends U {
4204
+ constructor() {
4205
+ super({
4206
+ kind: "externalLink",
4207
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml",
4208
+ relTypeUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",
4209
+ path: "../externalLinks/externalLink{n}.xml"
4210
+ });
4211
+ }
4212
+ async emit(e, t) {
4213
+ let n = t.getXMLWriter(), r = e.sources ?? [], i = r.findIndex((e) => e.role === "book");
4214
+ i < 0 && r.length > 0 && (i = 0);
4215
+ let a = null, o = null;
4216
+ for (let e = 0; e < r.length; e++) {
4217
+ let n = r[e], s = t.addExternal(n.type || "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", n.target).relId;
4218
+ e === i ? a = s : n.role === "absoluteUrl" && (o = s);
4219
+ }
4220
+ a || t.log("External book has no path relationship; Excel cannot locate its source.", e.sheetNames), n.decl();
4221
+ let s = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
4222
+ (e.mceIgnorable || o) && (s["xmlns:mc"] = "http://schemas.openxmlformats.org/markup-compatibility/2006", s["mc:Ignorable"] = "x14 xxl21", s["xmlns:x14"] = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main", s["xmlns:xxl21"] = "http://schemas.microsoft.com/office/spreadsheetml/2021/extlinks2021"), n.start("externalLink", s);
4223
+ let c = { "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" };
4224
+ a && (c["r:id"] = a), n.start("externalBook", c), o && (n.start("xxl21:alternateUrls"), n.empty("xxl21:absoluteUrl", { "r:id": o }), n.end("xxl21:alternateUrls")), function(e, t) {
4225
+ let n = t.sheetNames, r = n ? n.length : 0;
4226
+ if (r !== 0) {
4227
+ e.start("sheetNames");
4228
+ for (let t = 0; t < r; t++) e.empty("sheetName", { val: n[t] });
4229
+ e.end("sheetNames");
4230
+ }
4231
+ }(n, e), function(e, t) {
4232
+ let n = t.definedNames, r = n ? n.length : 0;
4233
+ if (r !== 0) {
4234
+ e.start("definedNames");
4235
+ for (let t = 0; t < r; t++) {
4236
+ let r = n[t], i = {
4237
+ name: r.name,
4238
+ refersTo: r.refersTo
4239
+ };
4240
+ r.sheetIndex !== void 0 && (i.sheetId = "" + r.sheetIndex), e.empty("definedName", i);
4241
+ }
4242
+ e.end("definedNames");
4243
+ }
4244
+ }(n, e), function(e, t) {
4245
+ let n = t.sheetDataSet, r = n ? n.length : 0;
4246
+ if (r !== 0) {
4247
+ e.start("sheetDataSet");
4248
+ for (let t = 0; t < r; t++) {
4249
+ let r = n[t], i = { sheetId: "" + r.sheetIndex };
4250
+ r.refreshError && (i.refreshError = "1");
4251
+ let a = r.data, o = a ? a.length : 0;
4252
+ if (o !== 0) {
4253
+ e.start("sheetData", i);
4254
+ for (let t = 0; t < o; t++) {
4255
+ let [n, r] = a[t];
4256
+ e.start("row", { r: "" + (n + 1) });
4257
+ let i = r.length;
4258
+ for (let t = 0; t < i; t++) {
4259
+ let [i, a] = r[t], o = a.length;
4260
+ for (let t = 0; t < o; t++) nr(e, n, i + t, a.at(t));
4261
+ }
4262
+ e.end("row");
4263
+ }
4264
+ e.end("sheetData");
4265
+ } else e.empty("sheetData", i);
4266
+ }
4267
+ e.end("sheetDataSet");
4268
+ }
4269
+ }(n, e), n.end("externalBook"), n.end("externalLink"), n.close();
4270
+ }
4271
+ }(),
4272
+ new class extends U {
3584
4273
  constructor() {
3585
4274
  super({
3586
4275
  kind: "chart",
@@ -3596,10 +4285,10 @@ var vn = (e, t, n, r) => {
3596
4285
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3597
4286
  "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
3598
4287
  "xmlns:c16r2": "http://schemas.microsoft.com/office/drawing/2015/06/chart"
3599
- }), n.empty("date1904", { val: "0" }), n.empty("lang", { val: "en-US" }), n.empty("roundedCorners", { val: "0" }), vn(t, n, e.model, e.json), yn(t, n, e.styles, e.model, e.json), bn(t, n, e.model, e.json), n.end("chartSpace"), n.popDefaultNamespace(), n.close(), t.addPart("chartStyle", { styles: e.styles }), t.addPart("chartColors", { styles: e.styles });
4288
+ }), n.empty("date1904", { val: "0" }), n.empty("lang", { val: "en-US" }), n.empty("roundedCorners", { val: "0" }), rr(t, n, e.model, e.json), ir(t, n, e.styles, e.model, e.json), ar(t, n, e.model, e.json), n.end("chartSpace"), n.popDefaultNamespace(), n.close(), t.addPart("chartStyle", { styles: e.styles }), t.addPart("chartColors", { styles: e.styles });
3600
4289
  }
3601
4290
  }(),
3602
- new class extends B {
4291
+ new class extends U {
3603
4292
  constructor() {
3604
4293
  super({
3605
4294
  kind: "chartStyle",
@@ -3614,10 +4303,10 @@ var vn = (e, t, n, r) => {
3614
4303
  "xmlns:cs": "http://schemas.microsoft.com/office/drawing/2012/chartStyle",
3615
4304
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3616
4305
  id: "297"
3617
- }), Sn(t, n, Cn, e.styles), n.end("chartStyle"), n.close();
4306
+ }), sr(t, n, cr, e.styles), n.end("chartStyle"), n.close();
3618
4307
  }
3619
4308
  }(),
3620
- new class extends B {
4309
+ new class extends U {
3621
4310
  constructor() {
3622
4311
  super({
3623
4312
  kind: "chartColors",
@@ -3633,23 +4322,107 @@ var vn = (e, t, n, r) => {
3633
4322
  "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
3634
4323
  meth: "cycle",
3635
4324
  id: "10"
3636
- }), n.empty("a:schemeClr", { val: "accent1" }), n.empty("a:schemeClr", { val: "accent2" }), n.empty("a:schemeClr", { val: "accent3" }), n.empty("a:schemeClr", { val: "accent4" }), n.empty("a:schemeClr", { val: "accent5" }), n.empty("a:schemeClr", { val: "accent6" }), wn(t, n, Tn), n.end("cs:colorStyle"), n.close();
4325
+ }), n.empty("a:schemeClr", { val: "accent1" }), n.empty("a:schemeClr", { val: "accent2" }), n.empty("a:schemeClr", { val: "accent3" }), n.empty("a:schemeClr", { val: "accent4" }), n.empty("a:schemeClr", { val: "accent5" }), n.empty("a:schemeClr", { val: "accent6" }), lr(t, n, ur), n.end("cs:colorStyle"), n.close();
3637
4326
  }
3638
4327
  }()
3639
- ], Dn = async (e, t) => {
3640
- let n = new Ne();
3641
- for (let e of En) n.register(e);
3642
- let r = On, i = ie.createUint8Array({
4328
+ ], fr = (e) => {
4329
+ let t = e.getPart("xl/_rels/workbook.xml.rels");
4330
+ if (!t) return null;
4331
+ let n = /* @__PURE__ */ new Map();
4332
+ for (let e of f(t.data)) {
4333
+ if (!e.id) continue;
4334
+ let t = e.external ? e.target : we(e.target.startsWith("/") ? e.target : "xl/" + e.target);
4335
+ n.set(e.id, {
4336
+ type: e.type,
4337
+ target: t,
4338
+ external: e.external
4339
+ });
4340
+ }
4341
+ return n;
4342
+ }, pr = (e) => {
4343
+ let t = e.getPart("xl/workbook.xml");
4344
+ return t ? new TextDecoder("utf-8").decode(t.data) : null;
4345
+ }, mr = (e) => {
4346
+ let t = hr.get(e);
4347
+ if (t !== void 0) return t;
4348
+ let n = e.getPart("xl/workbook.xml"), r = n ? new TextDecoder("utf-8").decode(n.data) : null;
4349
+ return hr.set(e, r), r;
4350
+ }, hr = /* @__PURE__ */ new WeakMap(), gr = async (e, t) => {
4351
+ let n = new He();
4352
+ for (let e of dr) n.register(e);
4353
+ let r = _r, i = ge.createUint8Array({
3643
4354
  lastModDate: new Date(1899, 11, 29, 19, 0, 0),
3644
4355
  level: r
3645
- }), a = e.getOrigin(), o = t?.format === "Excel" ? m(a) : null, s = /* @__PURE__ */ new Map(), c = new je(i, n, {
4356
+ }), a = t?.format === "Excel" || t?.format === "ExcelMacro" ? s(e) : null, o = /* @__PURE__ */ new Map(), c = a ? ((e) => {
4357
+ let t = e.getPart("xl/workbook.xml");
4358
+ if (!t) return null;
4359
+ let n = new TextDecoder("utf-8").decode(t.data.subarray(0, 4096)).match(/<fileVersion\b([^>]*)\/?>/);
4360
+ if (!n) return null;
4361
+ let r = {};
4362
+ for (let e of n[1].matchAll(/([\w:]+)="([^"]*)"/g)) r[e[1]] = e[2];
4363
+ return Object.keys(r).length > 0 ? r : null;
4364
+ })(a) : null;
4365
+ c && (t?.macroEnabled || delete c.codeName, o.set(nt, c));
4366
+ let l = a ? ((e) => {
4367
+ let t = mr(e)?.match(/<calcPr\b[^>]*?\bcalcId="([^"]*)"/);
4368
+ return t ? t[1] : null;
4369
+ })(a) : null;
4370
+ l !== null && o.set("calcId", l);
4371
+ let u = a ? ((e) => {
4372
+ let t = mr(e)?.match(/<ext\b[^>]*>\s*<xcalcf:calcFeatures\b[\s\S]*?<\/xcalcf:calcFeatures>\s*<\/ext>/);
4373
+ return t ? t[0] : null;
4374
+ })(a) : null;
4375
+ u !== null && o.set("calcFeatures", u);
4376
+ let d = a ? ((e) => {
4377
+ let t = pr(e);
4378
+ if (!t) return null;
4379
+ let n = /<externalReferences\b[^>]*>([\s\S]*?)<\/externalReferences>/.exec(t);
4380
+ if (!n) return null;
4381
+ let r = [...n[1].matchAll(/<externalReference\b[^>]*\sr:id="([^"]*)"/g)].map((e) => e[1]);
4382
+ if (r.length === 0) return null;
4383
+ let i = fr(e);
4384
+ return i ? r.map((e) => {
4385
+ let t = i.get(e);
4386
+ return t && !t.external ? t.target : null;
4387
+ }) : null;
4388
+ })(a) : null;
4389
+ d && o.set(it, d);
4390
+ let f = a ? ((e) => {
4391
+ let t = pr(e), n = t ? fr(e) : null;
4392
+ if (!t || !n) return null;
4393
+ let r = /* @__PURE__ */ new Map();
4394
+ for (let e of t.matchAll(/<sheet\b([^>]*)\/?>/g)) {
4395
+ let t = /\bsheetId="(\d+)"/.exec(e[1])?.[1], i = /\br:id="([^"]*)"/.exec(e[1])?.[1];
4396
+ if (!t || !i) continue;
4397
+ let a = n.get(i);
4398
+ a && !a.external && a.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" && r.set(parseInt(t, 10), a.target);
4399
+ }
4400
+ return r.size > 0 ? r : null;
4401
+ })(a) : null;
4402
+ f && o.set(rt, f), o.set(he, /* @__PURE__ */ new Map());
4403
+ let p = [], m = new Be(i, n, {
3646
4404
  strictDuplicateChildren: !0,
3647
4405
  onPartEmitted: t?.onPartEmitted,
3648
- mapState: s,
3649
- sourcePackage: o
4406
+ onWarning: (e, t, n) => {
4407
+ p.push([
4408
+ e,
4409
+ t,
4410
+ n
4411
+ ]);
4412
+ },
4413
+ mapState: o,
4414
+ sourcePackage: a,
4415
+ macroEnabled: t?.macroEnabled ?? !1
3650
4416
  });
3651
- c.addPart("workbook", e, "/xl/workbook.xml"), await c.waitEmit(), c.addPart("propsCore", {}), c.addPart("propsApp", { model: e });
3652
- let l = await c.build();
3653
- return l.byteOffset === 0 && l.byteLength === l.buffer.byteLength ? l.buffer : l.slice().buffer;
3654
- }, On = 1;
3655
- export { Dn as writeXLSX };
4417
+ m.addPart("workbook", e, "/xl/workbook.xml"), await m.waitEmit(), m.addPart("propsCore", {}), m.addPart("propsApp", { model: e });
4418
+ let h = await m.build(), g = t?.progress?.onWarning;
4419
+ if (p.length && g) {
4420
+ let e = /* @__PURE__ */ new Set();
4421
+ for (let [n, r, i] of p) {
4422
+ let a = i ?? n;
4423
+ e.has(a) || (e.add(a), g.call(t.progress, n, r));
4424
+ }
4425
+ }
4426
+ return h.byteOffset === 0 && h.byteLength === h.buffer.byteLength ? h.buffer : h.slice().buffer;
4427
+ }, _r = 1;
4428
+ export { gr as writeXLSX };