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

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