@sheetxl/io-xlsx 0.8.0-beta.15 → 0.8.0-beta.16

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 (57) hide show
  1. package/LICENSE.md +8 -7
  2. package/browser/esm/BQaNticMfvf7-y0L.mjs +2474 -0
  3. package/browser/esm/{BFHIFwfouCmmizKM.mjs → BalqIL4s8nR3NbK8.mjs} +2528 -1702
  4. package/browser/esm/{DPgI3veM7LuSesNu.mjs → BiueQ3eVPDOEdEeL.mjs} +1321 -1087
  5. package/browser/esm/{DsepJB2krbe8n-h0.mjs → BtLo1V0gnJ3ktOw9.mjs} +2 -2
  6. package/browser/esm/{VJT_B2rC29Twv3oJ.mjs → C3H8HKjSun-wLDrE.mjs} +5 -5
  7. package/browser/esm/{CbQ6xSA_Ryc9x49z.mjs → CCGqD5BzdZMq2pTI.mjs} +2 -2
  8. package/browser/esm/{B0as56gGm8o91eha.mjs → DT-3sV5qGuHTFmnB.mjs} +3295 -2163
  9. package/browser/esm/{CirSa4nJDHuHyGFb.mjs → W3dYk6brWDUtMZca.mjs} +3 -3
  10. package/browser/esm/{B5T6ZjCOm6tpqIxy.mjs → X5YJn8ZwrgDKMwwO.mjs} +3 -3
  11. package/browser/esm/{CVAAfrHVJ6jjaD4l.mjs → ekV6d7YNDF6FkKLw.mjs} +423 -318
  12. package/browser/esm/{cD_3iBL0XZP3GHGG.mjs → idgOmd_zpVTKLyek.mjs} +3 -3
  13. package/browser/esm/index.mjs +3 -3
  14. package/node/esm/{B_bFXQdvg63_jXXv.mjs → BO8o53Yo-gLFNELS.mjs} +3 -3
  15. package/node/esm/{CcMI8GfS94qlNCB0.mjs → BT0HKieizRDqDegH.mjs} +440 -330
  16. package/node/esm/BmIrpH_719z1aqvw.mjs +2562 -0
  17. package/node/esm/CJYMs5EGkLOZKyF0.mjs +4676 -0
  18. package/node/esm/{CQ3fUb7A8HUgTAIh.mjs → CZsPzV1CsMPKiICx.mjs} +2 -2
  19. package/node/esm/CdFqKswnjeM_u8-g.mjs +7242 -0
  20. package/node/esm/CnYiZh1EVKY4BNVs.mjs +6851 -0
  21. package/node/esm/{Cz6FfReTe9Ps5moN.mjs → OO5K_WYvAj-UV14K.mjs} +3 -3
  22. package/node/esm/index.mjs +5 -5
  23. package/package.json +4 -4
  24. package/types/src/AutoFilterRules.d.ts +26 -4
  25. package/types/src/OOXMLExtensions.d.ts +12 -1
  26. package/types/src/pivot/PivotArea.d.ts +20 -0
  27. package/types/src/pivot/PivotCacheRead.d.ts +30 -0
  28. package/types/src/pivot/PivotCacheWrite.d.ts +23 -0
  29. package/types/src/pivot/PivotFilters.d.ts +29 -0
  30. package/types/src/pivot/PivotFormats.d.ts +60 -0
  31. package/types/src/pivot/PivotTableRead.d.ts +44 -0
  32. package/types/src/pivot/PivotTableWrite.d.ts +13 -0
  33. package/types/src/pivot/_PivotCacheXml.d.ts +48 -0
  34. package/types/src/pivot/_PivotTableXml.d.ts +23 -0
  35. package/types/src/reader/PivotButtons.d.ts +14 -0
  36. package/types/src/reader/PivotCellFormats.d.ts +22 -0
  37. package/types/src/reader/SlicerJoin.d.ts +6 -4
  38. package/types/src/reader/_SlicerRecord.d.ts +22 -0
  39. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +5 -0
  40. package/types/src/reader/domVisitors/SlicerCacheDefinitionVisitor.d.ts +6 -2
  41. package/types/src/reader/domVisitors/SlicersVisitor.d.ts +2 -0
  42. package/types/src/reader/domVisitors/TimelinesVisitor.d.ts +13 -0
  43. package/types/src/reader/domVisitors/index.d.ts +2 -0
  44. package/types/src/writer/EvaluationSheet.d.ts +5 -0
  45. package/types/src/writer/builder/Types.d.ts +13 -0
  46. package/types/src/writer/emitters/PivotTableEmitter.d.ts +30 -1
  47. package/types/src/writer/emitters/SlicerEmitter.d.ts +81 -18
  48. package/types/src/writer/emitters/StylesEmitter.d.ts +32 -1
  49. package/types/src/writer/emitters/WorkbookEmitter.d.ts +19 -2
  50. package/types/src/writer/utils/DateSystem.d.ts +6 -0
  51. package/types/src/writer/utils/XfVariants.d.ts +61 -0
  52. package/browser/esm/CE5CJXtA1SK_ve3k.mjs +0 -2265
  53. package/node/esm/B0IbtakI6lvldj5N.mjs +0 -5693
  54. package/node/esm/C87CEL-9kIrXknM_.mjs +0 -2346
  55. package/node/esm/CPb9rk-UywrH-U7Y.mjs +0 -4437
  56. package/node/esm/Dw3qQRUIJShJWc_D.mjs +0 -6367
  57. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +0 -28
@@ -0,0 +1,4676 @@
1
+ /**
2
+ * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.16
3
+ *
4
+ * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
+ * License: SheetXL EULA — https://www.sheetxl.com/eula
6
+ */
7
+ import { $n as t, An as e, Ar as o, At as s, Bn as r, C as n, Dn as i, Dt as a, E as l, Fn as c, Gn as h, Hn as u, Jn as d, Kn as p, Lt as f, Mn as g, Mt as m, On as b, Or as v, Q as y, Qn as w, Qt as T, Rt as S, T as C, Tn as A, Tr as k, Tt as E, Un as I, Wn as P, Xt as O, Yn as D, Yt as N, Zn as _, Zt as $, _ as M, _t as R, an as L, ar as V, br as j, cn as B, cr as F, ct as H, dr as W, dt as z, er as X, et as q, f as U, fr as K, ft as G, gt as J, hr as Z, ht as Q, ir as Y, it as tt, jn as et, jt as ot, lr as st, lt as rt, n as nt, nt as it, o as at, on as lt, ot as ct, p as ht, pn as ut, pr as dt, qn as pt, rt as ft, st as gt, t as mt, tr as bt, vr as vt, vt as xt, wn as yt, yt as wt, zt as Tt } from "./CnYiZh1EVKY4BNVs.mjs";
8
+ import { BufferUtils as St, CommonUtils as Ct, ExpectedError as At, OverlappingRange as kt, RangeAxis as Et } from "@sheetxl/utils";
9
+ import { AddressUtils as It, BufferUtils as Pt, CommonUtils as Ot, CoordUtils as Dt, FormulaError as Nt, FormulaText as _t, FunctionDeclarations as $t, ICellStyle as Mt, ICondition as Rt, IConditionalFormat as Lt, ICustomProperty as Vt, IFont as jt, IRange as Bt, ITextFrame as Ft, NumberFormat as Ht, OutOfBoundsError as Wt, PersonCollection as zt, ResourceCollection as Xt, RichDataRegistry as qt, Scalar as Ut, Sort as Kt, Theme as Gt, Tuple as Jt, Workbook as Zt, pivotCellFormatsOf as Qt } from "@sheetxl/sdk";
10
+ import { BlobReader as Yt, Uint8ArrayReader as te, Uint8ArrayWriter as ee, ZipReader as oe } from "@zip.js/zip.js";
11
+ var se = {
12
+ ascending: "ascending",
13
+ descending: "descending",
14
+ natural: "dataSource"
15
+ };
16
+ function re(t, e) {
17
+ const o = t.sheets ?? [], s = /* @__PURE__ */ new Map();
18
+ for (let t = 0; t < o.length; t++) {
19
+ const e = o[t], r = k(e)?.tables ?? [];
20
+ for (let t = 0; t < r.length; t++) {
21
+ const e = r[t], o = Array.isArray(e) ? e[1] : e?.v;
22
+ if (!o?.id) continue;
23
+ const n = (o.columns ?? []).map((t) => "string" == typeof t ? { name: t } : t);
24
+ s.set(String(o.id), {
25
+ name: o.name ?? "",
26
+ columns: n
27
+ });
28
+ }
29
+ }
30
+ const r = /* @__PURE__ */ new Map();
31
+ for (let t = 0; t < o.length; t++) {
32
+ const e = o[t];
33
+ void 0 !== e?.sheetId && e.name && r.set(String(e.sheetId), e.name);
34
+ }
35
+ const n = function(t) {
36
+ const e = /* @__PURE__ */ new Map(), o = t.pivotCaches ?? [];
37
+ for (let t = 0; t < o.length; t++) {
38
+ const s = o[t].part?.xml, r = s ? /<(?:\w+:)?pivotCacheDefinition\b[^>]*?\spivotCacheId="(\d+)"[^>]*\/?>\s*<\/(?:\w+:)?ext>/.exec(s)?.[1] : void 0;
39
+ void 0 !== r && e.set(r, o[t].cacheId);
40
+ }
41
+ return e;
42
+ }(t), i = /* @__PURE__ */ new Map();
43
+ for (let t = 0; t < o.length; t++) {
44
+ const e = k(o[t])?.pivotTables ?? [];
45
+ for (let s = 0; s < e.length; s++) i.set(`${o[t].name}\0${e[s].name}`, e[s]);
46
+ }
47
+ const a = new Set((t.pivotCaches ?? []).flatMap((t) => t.fields ? [t.cacheId] : [])), l = /* @__PURE__ */ new Set();
48
+ for (let t = 0; t < o.length; t++) {
49
+ const c = o[t], h = k(c);
50
+ if (!h) continue;
51
+ const u = h.slicers, d = h.movables;
52
+ if (u && d) for (let t = d.length - 1; t >= 0; t--) {
53
+ const o = d[t].content;
54
+ if ("slicer" !== o?.type || o.json?.source) continue;
55
+ const c = o.name ?? "", h = u[c];
56
+ if (!h) continue;
57
+ if (!h.tableId) {
58
+ if (void 0 === h.pivotBody) continue;
59
+ o.json = ae(h, o.json), o.json.pivot = ie(h, r, n, i, a), l.add(c), h.cachePath && e.markAbsorbed(h.cachePath);
60
+ continue;
61
+ }
62
+ const p = s.get(String(h.tableId)), f = p ? ne(p.columns, h.columnId) : null;
63
+ p && f ? (o.json = ae(h, o.json, _t.structuredReference(p.name, f.name)), l.add(c), h.cachePath && e.markAbsorbed(h.cachePath)) : (e.warn("A slicer names no table; it was not imported.", "xlsx.slicer.cacheDefinition"), d.splice(t, 1));
64
+ }
65
+ delete h.slicers;
66
+ }
67
+ e.slicerParts.forEach((t, o) => {
68
+ const s = Object.keys(t);
69
+ s.length > 0 && s.every((t) => l.has(t)) && e.markAbsorbed(o);
70
+ });
71
+ }
72
+ function ne(t, e) {
73
+ if (!e) return null;
74
+ for (let o = 0; o < t.length; o++) if (void 0 !== t[o].id && String(t[o].id) === e) return t[o];
75
+ const o = Number(e);
76
+ return Number.isInteger(o) && o >= 1 && o <= t.length ? t[o - 1] : null;
77
+ }
78
+ function ie(t, e, o, s, r) {
79
+ const n = [], i = t.pivotTables ?? [];
80
+ for (let t = 0; t < i.length; t++) {
81
+ const o = e.get(i[t].tabId);
82
+ o && n.push({
83
+ sheet: o,
84
+ name: i[t].name
85
+ });
86
+ }
87
+ const a = {
88
+ sourceName: t.sourceName ?? "",
89
+ tables: n,
90
+ body: t.pivotBody ?? ""
91
+ };
92
+ let l = void 0 !== t.pivotCacheId ? o.get(t.pivotCacheId) : void 0;
93
+ if (t.tabular) {
94
+ const e = n.length > 0 ? s.get(`${n[0].sheet}\0${n[0].name}`) : void 0;
95
+ l ??= e?.cacheId, e?.fields && void 0 !== l && r.has(l) ? a.tabular = !1 === t.showMissing ? { hideMissing: !0 } : {} : a.body = (t.pivotData ?? "") + a.body;
96
+ }
97
+ return void 0 !== l && (a.cacheId = l), t.timelineAttributes && (a.timeline = {
98
+ attributes: t.timelineAttributes,
99
+ body: t.timelineBody ?? ""
100
+ }), a;
101
+ }
102
+ function ae(t, e, o) {
103
+ const s = { ...e };
104
+ if (void 0 !== o && (s.source = o), void 0 !== t.caption && t.caption !== t.sourceName && (s.caption = t.caption), !1 === t.showCaption && (s.hiddenCaption = !0), void 0 !== t.columnCount && t.columnCount > 1 && (s.columnCount = t.columnCount), void 0 !== t.rowHeight) {
105
+ const e = Math.round(t.rowHeight / 9525);
106
+ e > 0 && 27 !== e && (s.rowHeight = e);
107
+ }
108
+ t.style && "SlicerStyleLight1" !== t.style && (s.style = t.style);
109
+ const r = t.sortOrder ? se[t.sortOrder] : void 0;
110
+ return r && "ascending" !== r && (s.sortOrder = r), t.crossFilter && "showItemsWithDataAtTop" !== t.crossFilter && (s.crossFilter = t.crossFilter), t.lockedPosition && (s.lockedPosition = !0), !1 === t.customListSort && (s.disabledCustomListSort = !0), t.cacheName && (s.cacheName = t.cacheName), t.startItem && (s.startItem = t.startItem), void 0 !== t.level && (s.level = t.level), t.uid && (s.uid = t.uid), s;
111
+ }
112
+ var le = "xl/richData/rdrichvaluestructure.xml", ce = "xl/richData/rdrichvalue.xml", he = "xl/richData/rdarray.xml", ue = "xl/richData/rdsupportingpropertybagstructure.xml", de = "xl/richData/rdsupportingpropertybag.xml", pe = "xl/richData/rdRichValueTypes.xml", fe = "xl/richData/richStyles.xml", ge = (t, e) => {
113
+ const o = [], s = t?.childNodes, r = s?.length ?? 0;
114
+ for (let t = 0; t < r; t++) {
115
+ const r = s.item(t);
116
+ 1 !== r.nodeType || e && r.localName !== e || o.push(r);
117
+ }
118
+ return o;
119
+ }, me = (t) => ge(t, "k").map((t) => [t.getAttribute("n") ?? "", t.getAttribute("t") || null]), be = (t) => ge(t, "v").map((t) => ({
120
+ t: t.getAttribute("t") || null,
121
+ text: t.textContent ?? ""
122
+ })), ve = (t) => {
123
+ const e = /* @__PURE__ */ new Map();
124
+ for (const o of ge(t, "key")) {
125
+ const t = /* @__PURE__ */ new Map();
126
+ for (const e of ge(o, "flag")) t.set(e.getAttribute("name") ?? "", e.getAttribute("value") ?? "");
127
+ e.set(o.getAttribute("name") ?? "", t);
128
+ }
129
+ return e;
130
+ }, xe = /* @__PURE__ */ new Uint8Array(0), ye = class t {
131
+ constructor(t, e, o) {
132
+ this.buffers = /* @__PURE__ */ new Map(), this.zip = t, this.entries = e, this.rawBuffer = o;
133
+ }
134
+ static normalize(t) {
135
+ return t.startsWith("/") ? t.slice(1) : t;
136
+ }
137
+ static async create(e) {
138
+ const o = e instanceof Blob ? xe : e instanceof Uint8Array ? e : new Uint8Array(e), s = e instanceof Blob ? new Yt(e) : new te(o), r = new oe(s), n = /* @__PURE__ */ new Map();
139
+ for (const t of await r.getEntries()) t.directory || n.set(t.filename, t);
140
+ return new t(r, n, o);
141
+ }
142
+ getNames() {
143
+ return [...this.entries.keys()];
144
+ }
145
+ has(e) {
146
+ return this.entries.has(t.normalize(e));
147
+ }
148
+ uncompressedSize(e) {
149
+ return this.entries.get(t.normalize(e))?.uncompressedSize ?? 0;
150
+ }
151
+ async getBuffer(e) {
152
+ const o = t.normalize(e), s = this.buffers.get(o);
153
+ if (s) return s;
154
+ const r = this.entries.get(o);
155
+ if (!r) return null;
156
+ const n = await r.getData(new ee());
157
+ return this.buffers.set(o, n), n;
158
+ }
159
+ async prefetch(t) {
160
+ const e = [];
161
+ for (const [o, s] of this.entries) !this.buffers.has(o) && t(o, s) && e.push(s.getData(new ee()).then((t) => {
162
+ this.buffers.set(o, t);
163
+ }));
164
+ await Promise.all(e);
165
+ }
166
+ getEntry(e) {
167
+ return this.buffers.get(t.normalize(e)) ?? null;
168
+ }
169
+ async getTextStream(e, o) {
170
+ const s = this.entries.get(t.normalize(e));
171
+ if (!s) return null;
172
+ const r = new TransformStream();
173
+ s.getData(r.writable).catch(() => {});
174
+ const n = r.readable.getReader(), i = new TextDecoder("utf-8");
175
+ return new ReadableStream({ async pull(t) {
176
+ const { value: e, done: s } = await n.read();
177
+ if (s) {
178
+ const e = i.decode();
179
+ e && t.enqueue(e), t.close();
180
+ return;
181
+ }
182
+ o?.(e.byteLength);
183
+ const r = i.decode(e, { stream: !0 });
184
+ r && t.enqueue(r);
185
+ } }).getReader();
186
+ }
187
+ getRawEntry(e) {
188
+ const o = this.entries.get(t.normalize(e));
189
+ if (!o || o.encrypted || void 0 === o.crc32) return null;
190
+ const s = o.offset;
191
+ if (s + 30 > this.rawBuffer.byteLength) return null;
192
+ const r = new DataView(this.rawBuffer.buffer, this.rawBuffer.byteOffset + s, 30);
193
+ if (67324752 !== r.getUint32(0, !0)) return null;
194
+ const n = s + 30 + r.getUint16(26, !0) + r.getUint16(28, !0), i = n + o.compressedSize;
195
+ return i > this.rawBuffer.byteLength ? null : {
196
+ data: this.rawBuffer.subarray(n, i),
197
+ compressionMethod: o.compressionMethod,
198
+ signature: o.crc32
199
+ };
200
+ }
201
+ async close() {
202
+ await this.zip.close();
203
+ }
204
+ }, we = class {
205
+ constructor(t) {
206
+ this._sink = t, this._samples = [], this._t0 = Te(), this._tPrev = this._t0, this._heapPrev = Se();
207
+ }
208
+ mark(t) {
209
+ const e = Te(), o = Se(), s = {
210
+ label: t,
211
+ tMs: e - this._t0,
212
+ dtMs: e - this._tPrev,
213
+ heapBytes: o,
214
+ dHeapBytes: void 0 !== o && void 0 !== this._heapPrev ? o - this._heapPrev : void 0,
215
+ rssBytes: Ce()
216
+ };
217
+ this._tPrev = e, this._heapPrev = o, this._samples.push(s), this._sink?.(s);
218
+ }
219
+ samples() {
220
+ return this._samples;
221
+ }
222
+ toTable() {
223
+ return this._samples.map((t) => ({
224
+ phase: t.label,
225
+ tMs: Math.round(t.tMs),
226
+ dtMs: Math.round(t.dtMs),
227
+ heapMB: void 0 !== t.heapBytes ? Ae(t.heapBytes / 1048576) : "—",
228
+ dHeapMB: void 0 !== t.dHeapBytes ? Ae(t.dHeapBytes / 1048576) : "—",
229
+ rssMB: void 0 !== t.rssBytes ? Ae(t.rssBytes / 1048576) : "—"
230
+ }));
231
+ }
232
+ }, Te = "object" == typeof performance && "function" == typeof performance.now ? () => performance.now() : () => Date.now();
233
+ function Se() {
234
+ const t = "object" == typeof performance ? performance.memory : void 0;
235
+ if (t && "number" == typeof t.usedJSHeapSize) return t.usedJSHeapSize;
236
+ const e = globalThis.process;
237
+ return "object" == typeof e && "function" == typeof e.memoryUsage ? e.memoryUsage().heapUsed : void 0;
238
+ }
239
+ function Ce() {
240
+ const t = globalThis.process;
241
+ if ("object" == typeof t && "function" == typeof t.memoryUsage) return t.memoryUsage().rss;
242
+ }
243
+ function Ae(t) {
244
+ return Math.round(10 * t) / 10;
245
+ }
246
+ var ke = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Ee = `-${ke}.0-9·̀-ͯ‿-⁀`, Ie = (new RegExp(`^[${ke}]$`, "u"), new RegExp(`^[${Ee}]$`, "u"), new RegExp(`^[${ke}][${Ee}]*$`, "u")), Pe = (new RegExp(`^[${Ee}]+$`, "u"), [
247
+ 32,
248
+ 10,
249
+ 13,
250
+ 9
251
+ ]);
252
+ function Oe(t) {
253
+ return t >= 65 && t <= 90 || t >= 97 && t <= 122 || 58 === t || 95 === t || 8204 === t || 8205 === t || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
254
+ }
255
+ var De = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", Ne = `-${De}.0-9·̀-ͯ‿-⁀`;
256
+ new RegExp(`^[${De}]$`, "u"), new RegExp(`^[${Ne}]$`, "u"), new RegExp(`^[${De}][${Ne}]*$`, "u"), new RegExp(`^[${Ne}]+$`, "u");
257
+ var _e = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", $e = `-${_e}.0-9·̀-ͯ‿-⁀`, Me = (new RegExp(`^[${_e}]$`, "u"), new RegExp(`^[${$e}]$`, "u"), new RegExp(`^[${_e}][${$e}]*$`, "u"));
258
+ function Re(t) {
259
+ return t >= 65 && t <= 90 || 95 === t || t >= 97 && t <= 122 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 767 || t >= 880 && t <= 893 || t >= 895 && t <= 8191 || t >= 8204 && t <= 8205 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
260
+ }
261
+ var Le = function(t) {
262
+ return 32 === t || 10 === t || 13 === t || 9 === t;
263
+ }, Ve = function(t) {
264
+ return t >= 32 && t <= 55295 || 10 === t || 13 === t || 9 === t || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
265
+ }, je = Oe, Be = function(t) {
266
+ return Oe(t) || t >= 48 && t <= 57 || 45 === t || 46 === t || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
267
+ }, Fe = Pe, He = Ie, We = function(t) {
268
+ return t >= 1 && t <= 55295 || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
269
+ }, ze = Re, Xe = function(t) {
270
+ return Re(t) || 45 === t || 46 === t || t >= 48 && t <= 57 || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
271
+ }, qe = Me, Ue = "http://www.w3.org/XML/1998/namespace", Ke = "http://www.w3.org/2000/xmlns/", Ge = {
272
+ __proto__: null,
273
+ xml: Ue,
274
+ xmlns: Ke
275
+ }, Je = {
276
+ __proto__: null,
277
+ amp: "&",
278
+ gt: ">",
279
+ lt: "<",
280
+ quot: "\"",
281
+ apos: "'"
282
+ }, Ze = -1, Qe = -2, Ye = 13, to = 33, eo = 10, oo = 60, so = 61, ro = 62, no = 63, io = 93, ao = (t) => 34 === t || 39 === t, lo = [34, 39], co = [
283
+ ...lo,
284
+ 91,
285
+ ro
286
+ ], ho = [
287
+ ...lo,
288
+ oo,
289
+ io
290
+ ], uo = [
291
+ so,
292
+ no,
293
+ ...Fe
294
+ ], po = [
295
+ ...Fe,
296
+ ro,
297
+ 38,
298
+ oo
299
+ ];
300
+ function fo(t, e, o) {
301
+ switch (e) {
302
+ case "xml":
303
+ o !== Ue && t.fail(`xml prefix must be bound to ${Ue}.`);
304
+ break;
305
+ case "xmlns": o !== Ke && t.fail(`xmlns prefix must be bound to ${Ke}.`);
306
+ }
307
+ switch (o) {
308
+ case Ke:
309
+ t.fail("" === e ? `the default namespace may not be set to ${o}.` : `may not assign a prefix (even "xmlns") to the URI ${Ke}.`);
310
+ break;
311
+ case Ue: switch (e) {
312
+ case "xml": break;
313
+ case "":
314
+ t.fail(`the default namespace may not be set to ${o}.`);
315
+ break;
316
+ default: t.fail("may not assign the xml namespace to another prefix.");
317
+ }
318
+ }
319
+ }
320
+ var go, mo = (t) => qe.test(t), bo = (t) => He.test(t), vo = {
321
+ xmldecl: "xmlDeclHandler",
322
+ text: "textHandler",
323
+ processinginstruction: "piHandler",
324
+ doctype: "doctypeHandler",
325
+ comment: "commentHandler",
326
+ opentagstart: "openTagStartHandler",
327
+ attribute: "attributeHandler",
328
+ opentag: "openTagHandler",
329
+ closetag: "closeTagHandler",
330
+ cdata: "cdataHandler",
331
+ error: "errorHandler",
332
+ end: "endHandler",
333
+ ready: "readyHandler"
334
+ }, xo = class {
335
+ get closed() {
336
+ return this._closed;
337
+ }
338
+ constructor(t) {
339
+ this.i = 0, this.prevI = 0, this.opt = t ?? {}, this.fragmentOpt = !!this.opt.fragment;
340
+ const e = this.xmlnsOpt = !!this.opt.xmlns;
341
+ if (this.trackPosition = !1 !== this.opt.position, this.fileName = this.opt.fileName, e) {
342
+ this.nameStartCheck = ze, this.nameCheck = Xe, this.isName = mo, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = {
343
+ __proto__: null,
344
+ ...Ge
345
+ };
346
+ const t = this.opt.additionalNamespaces;
347
+ null != t && (function(t, e) {
348
+ for (const o of Object.keys(e)) fo(t, o, e[o]);
349
+ }(this, t), Object.assign(this.ns, t));
350
+ } else this.nameStartCheck = je, this.nameCheck = Be, this.isName = bo, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
351
+ this.stateTable = [
352
+ this.sBegin,
353
+ this.sBeginWhitespace,
354
+ this.sDoctype,
355
+ this.sDoctypeQuote,
356
+ this.sDTD,
357
+ this.sDTDQuoted,
358
+ this.sDTDOpenWaka,
359
+ this.sDTDOpenWakaBang,
360
+ this.sDTDComment,
361
+ this.sDTDCommentEnding,
362
+ this.sDTDCommentEnded,
363
+ this.sDTDPI,
364
+ this.sDTDPIEnding,
365
+ this.sText,
366
+ this.sEntity,
367
+ this.sOpenWaka,
368
+ this.sOpenWakaBang,
369
+ this.sComment,
370
+ this.sCommentEnding,
371
+ this.sCommentEnded,
372
+ this.sCData,
373
+ this.sCDataEnding,
374
+ this.sCDataEnding2,
375
+ this.sPIFirstChar,
376
+ this.sPIRest,
377
+ this.sPIBody,
378
+ this.sPIEnding,
379
+ this.sXMLDeclNameStart,
380
+ this.sXMLDeclName,
381
+ this.sXMLDeclEq,
382
+ this.sXMLDeclValueStart,
383
+ this.sXMLDeclValue,
384
+ this.sXMLDeclSeparator,
385
+ this.sXMLDeclEnding,
386
+ this.sOpenTag,
387
+ this.sOpenTagSlash,
388
+ this.sAttrib,
389
+ this.sAttribName,
390
+ this.sAttribNameSawWhite,
391
+ this.sAttribValue,
392
+ this.sAttribValueQuoted,
393
+ this.sAttribValueClosed,
394
+ this.sAttribValueUnquoted,
395
+ this.sCloseTag,
396
+ this.sCloseTagSawWhite
397
+ ], this._init();
398
+ }
399
+ _init() {
400
+ this.openWakaBang = "", this.text = "", this.name = "", this.piTarget = "", this.entity = "", this.q = null, this.tags = [], this.tag = null, this.topNS = null, this.chunk = "", this.chunkPosition = 0, this.i = 0, this.prevI = 0, this.carriedFromPrevious = void 0, this.forbiddenState = 0, this.attribList = [];
401
+ const { fragmentOpt: t } = this;
402
+ this.state = t ? Ye : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = t, this.xmlDeclPossible = !t, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
403
+ let { defaultXMLVersion: e } = this.opt;
404
+ if (void 0 === e) {
405
+ if (!0 === this.opt.forceXMLVersion) throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
406
+ e = "1.0";
407
+ }
408
+ this.setXMLVersion(e), this.positionAtNewLine = 0, this.doctype = !1, this._closed = !1, this.xmlDecl = {
409
+ version: void 0,
410
+ encoding: void 0,
411
+ standalone: void 0
412
+ }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(Je), this.readyHandler?.();
413
+ }
414
+ get position() {
415
+ return this.chunkPosition + this.i;
416
+ }
417
+ get columnIndex() {
418
+ return this.position - this.positionAtNewLine;
419
+ }
420
+ on(t, e) {
421
+ this[vo[t]] = e;
422
+ }
423
+ off(t) {
424
+ this[vo[t]] = void 0;
425
+ }
426
+ makeError(t) {
427
+ let e = this.fileName ?? "";
428
+ return this.trackPosition && (e.length > 0 && (e += ":"), e += `${this.line}:${this.column}`), e.length > 0 && (e += ": "), new Error(e + t);
429
+ }
430
+ fail(t) {
431
+ const e = this.makeError(t), o = this.errorHandler;
432
+ if (void 0 === o) throw e;
433
+ return o(e), this;
434
+ }
435
+ write(t) {
436
+ if (this.closed) return this.fail("cannot write after close.");
437
+ let e = !1;
438
+ null === t ? (e = !0, t = "") : "object" == typeof t && (t = t.toString()), void 0 !== this.carriedFromPrevious && (t = `${this.carriedFromPrevious}${t}`, this.carriedFromPrevious = void 0);
439
+ let o = t.length;
440
+ const s = t.charCodeAt(o - 1);
441
+ !e && (13 === s || s >= 55296 && s <= 56319) && (this.carriedFromPrevious = t[o - 1], o--, t = t.slice(0, o));
442
+ const { stateTable: r } = this;
443
+ for (this.chunk = t, this.i = 0; this.i < o;) r[this.state].call(this);
444
+ return this.chunkPosition += o, e ? this.end() : this;
445
+ }
446
+ close() {
447
+ return this.write(null);
448
+ }
449
+ getCode10() {
450
+ const t = this.chunk, e = this.i;
451
+ if (this.prevI = e, this.i++, e >= t.length) return Ze;
452
+ const o = t.charCodeAt(e);
453
+ if (this.column++, o < 55296) {
454
+ if (o >= 32 || 9 === o) return o;
455
+ switch (o) {
456
+ case eo: return this.line++, this.column = 0, this.positionAtNewLine = this.position, eo;
457
+ case 13: return t.charCodeAt(e + 1) === eo && (this.i = e + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, Qe;
458
+ default: return this.fail("disallowed character."), o;
459
+ }
460
+ }
461
+ if (o > 56319) return o >= 57344 && o <= 65533 || this.fail("disallowed character."), o;
462
+ const s = 65536 + 1024 * (o - 55296) + (t.charCodeAt(e + 1) - 56320);
463
+ return this.i = e + 2, s > 1114111 && this.fail("disallowed character."), s;
464
+ }
465
+ getCode11() {
466
+ const { chunk: t, i: e } = this;
467
+ if (this.prevI = e, this.i = e + 1, e >= t.length) return Ze;
468
+ const o = t.charCodeAt(e);
469
+ if (this.column++, o < 55296) {
470
+ if (o > 31 && o < 127 || o > 159 && 8232 !== o || 9 === o) return o;
471
+ switch (o) {
472
+ case eo: return this.line++, this.column = 0, this.positionAtNewLine = this.position, eo;
473
+ case 13: {
474
+ const o = t.charCodeAt(e + 1);
475
+ o !== eo && 133 !== o || (this.i = e + 2);
476
+ }
477
+ case 133:
478
+ case 8232: return this.line++, this.column = 0, this.positionAtNewLine = this.position, Qe;
479
+ default: return this.fail("disallowed character."), o;
480
+ }
481
+ }
482
+ if (o > 56319) return o >= 57344 && o <= 65533 || this.fail("disallowed character."), o;
483
+ const s = 65536 + 1024 * (o - 55296) + (t.charCodeAt(e + 1) - 56320);
484
+ return this.i = e + 2, s > 1114111 && this.fail("disallowed character."), s;
485
+ }
486
+ getCodeNorm() {
487
+ const t = this.getCode();
488
+ return t === Qe ? eo : t;
489
+ }
490
+ unGet() {
491
+ this.i = this.prevI, this.column--;
492
+ }
493
+ captureTo(t) {
494
+ let { i: e } = this;
495
+ const { chunk: o } = this;
496
+ for (;;) {
497
+ const s = this.getCode(), r = s === Qe, n = r ? eo : s;
498
+ if (n === Ze || t.includes(n)) return this.text += o.slice(e, this.prevI), n;
499
+ r && (this.text += `${o.slice(e, this.prevI)}\n`, e = this.i);
500
+ }
501
+ }
502
+ captureToChar(t) {
503
+ let { i: e } = this;
504
+ const { chunk: o } = this;
505
+ for (;;) {
506
+ let s = this.getCode();
507
+ switch (s) {
508
+ case Qe:
509
+ this.text += `${o.slice(e, this.prevI)}\n`, e = this.i, s = eo;
510
+ break;
511
+ case Ze: return this.text += o.slice(e), !1;
512
+ }
513
+ if (s === t) return this.text += o.slice(e, this.prevI), !0;
514
+ }
515
+ }
516
+ captureNameChars() {
517
+ const { chunk: t, i: e } = this;
518
+ for (;;) {
519
+ const o = this.getCode();
520
+ if (o === Ze) return this.name += t.slice(e), Ze;
521
+ if (!Be(o)) return this.name += t.slice(e, this.prevI), o === Qe ? eo : o;
522
+ }
523
+ }
524
+ skipSpaces() {
525
+ for (;;) {
526
+ const t = this.getCodeNorm();
527
+ if (t === Ze || !Le(t)) return t;
528
+ }
529
+ }
530
+ setXMLVersion(t) {
531
+ this.currentXMLVersion = t, "1.0" === t ? (this.isChar = Ve, this.getCode = this.getCode10) : (this.isChar = We, this.getCode = this.getCode11);
532
+ }
533
+ sBegin() {
534
+ 65279 === this.chunk.charCodeAt(0) && (this.i++, this.column++), this.state = 1;
535
+ }
536
+ sBeginWhitespace() {
537
+ const t = this.i, e = this.skipSpaces();
538
+ switch (this.prevI !== t && (this.xmlDeclPossible = !1), e) {
539
+ case oo:
540
+ if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
541
+ break;
542
+ case Ze: break;
543
+ default: this.unGet(), this.state = Ye, this.xmlDeclPossible = !1;
544
+ }
545
+ }
546
+ sDoctype() {
547
+ const t = this.captureTo(co);
548
+ switch (t) {
549
+ case ro:
550
+ this.doctypeHandler?.(this.text), this.text = "", this.state = Ye, this.doctype = !0;
551
+ break;
552
+ case Ze: break;
553
+ default: this.text += String.fromCodePoint(t), 91 === t ? this.state = 4 : ao(t) && (this.state = 3, this.q = t);
554
+ }
555
+ }
556
+ sDoctypeQuote() {
557
+ const t = this.q;
558
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.q = null, this.state = 2);
559
+ }
560
+ sDTD() {
561
+ const t = this.captureTo(ho);
562
+ t !== Ze && (this.text += String.fromCodePoint(t), t === io ? this.state = 2 : t === oo ? this.state = 6 : ao(t) && (this.state = 5, this.q = t));
563
+ }
564
+ sDTDQuoted() {
565
+ const t = this.q;
566
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.state = 4, this.q = null);
567
+ }
568
+ sDTDOpenWaka() {
569
+ const t = this.getCodeNorm();
570
+ switch (this.text += String.fromCodePoint(t), t) {
571
+ case 33:
572
+ this.state = 7, this.openWakaBang = "";
573
+ break;
574
+ case no:
575
+ this.state = 11;
576
+ break;
577
+ default: this.state = 4;
578
+ }
579
+ }
580
+ sDTDOpenWakaBang() {
581
+ const t = String.fromCodePoint(this.getCodeNorm()), e = this.openWakaBang += t;
582
+ this.text += t, "-" !== e && (this.state = "--" === e ? 8 : 4, this.openWakaBang = "");
583
+ }
584
+ sDTDComment() {
585
+ this.captureToChar(45) && (this.text += "-", this.state = 9);
586
+ }
587
+ sDTDCommentEnding() {
588
+ const t = this.getCodeNorm();
589
+ this.text += String.fromCodePoint(t), this.state = 45 === t ? 10 : 8;
590
+ }
591
+ sDTDCommentEnded() {
592
+ const t = this.getCodeNorm();
593
+ this.text += String.fromCodePoint(t), t === ro ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
594
+ }
595
+ sDTDPI() {
596
+ this.captureToChar(no) && (this.text += "?", this.state = 12);
597
+ }
598
+ sDTDPIEnding() {
599
+ const t = this.getCodeNorm();
600
+ this.text += String.fromCodePoint(t), t === ro && (this.state = 4);
601
+ }
602
+ sText() {
603
+ 0 !== this.tags.length ? this.handleTextInRoot() : this.handleTextOutsideRoot();
604
+ }
605
+ sEntity() {
606
+ let { i: t } = this;
607
+ const { chunk: e } = this;
608
+ t: for (;;) switch (this.getCode()) {
609
+ case Qe:
610
+ this.entity += `${e.slice(t, this.prevI)}\n`, t = this.i;
611
+ break;
612
+ case 59: {
613
+ const { entityReturnState: o } = this, s = this.entity + e.slice(t, this.prevI);
614
+ let r;
615
+ this.state = o, "" === s ? (this.fail("empty entity name."), r = "&;") : (r = this.parseEntity(s), this.entity = ""), o === Ye && void 0 === this.textHandler || (this.text += r);
616
+ break t;
617
+ }
618
+ case Ze:
619
+ this.entity += e.slice(t);
620
+ break t;
621
+ }
622
+ }
623
+ sOpenWaka() {
624
+ const t = this.getCode();
625
+ if (je(t)) this.state = 34, this.unGet(), this.xmlDeclPossible = !1;
626
+ else switch (t) {
627
+ case 47:
628
+ this.state = 43, this.xmlDeclPossible = !1;
629
+ break;
630
+ case 33:
631
+ this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = !1;
632
+ break;
633
+ case no:
634
+ this.state = 23;
635
+ break;
636
+ default: this.fail("disallowed character in tag name"), this.state = Ye, this.xmlDeclPossible = !1;
637
+ }
638
+ }
639
+ sOpenWakaBang() {
640
+ switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
641
+ case "[CDATA[":
642
+ this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0), this.state = 20, this.openWakaBang = "";
643
+ break;
644
+ case "--":
645
+ this.state = 17, this.openWakaBang = "";
646
+ break;
647
+ case "DOCTYPE":
648
+ this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
649
+ break;
650
+ default: this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
651
+ }
652
+ }
653
+ sComment() {
654
+ this.captureToChar(45) && (this.state = 18);
655
+ }
656
+ sCommentEnding() {
657
+ const t = this.getCodeNorm();
658
+ 45 === t ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(t)}`, this.state = 17);
659
+ }
660
+ sCommentEnded() {
661
+ const t = this.getCodeNorm();
662
+ t !== ro ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t)}`, this.state = 17) : this.state = Ye;
663
+ }
664
+ sCData() {
665
+ this.captureToChar(io) && (this.state = 21);
666
+ }
667
+ sCDataEnding() {
668
+ const t = this.getCodeNorm();
669
+ t === io ? this.state = 22 : (this.text += `]${String.fromCodePoint(t)}`, this.state = 20);
670
+ }
671
+ sCDataEnding2() {
672
+ const t = this.getCodeNorm();
673
+ switch (t) {
674
+ case ro:
675
+ this.cdataHandler?.(this.text), this.text = "", this.state = Ye;
676
+ break;
677
+ case io:
678
+ this.text += "]";
679
+ break;
680
+ default: this.text += `]]${String.fromCodePoint(t)}`, this.state = 20;
681
+ }
682
+ }
683
+ sPIFirstChar() {
684
+ const t = this.getCodeNorm();
685
+ this.nameStartCheck(t) ? (this.piTarget += String.fromCodePoint(t), this.state = 24) : t === no || Le(t) ? (this.fail("processing instruction without a target."), this.state = t === no ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t), this.state = 24);
686
+ }
687
+ sPIRest() {
688
+ const { chunk: t, i: e } = this;
689
+ for (;;) {
690
+ const o = this.getCodeNorm();
691
+ if (o === Ze) return void (this.piTarget += t.slice(e));
692
+ if (!this.nameCheck(o)) {
693
+ this.piTarget += t.slice(e, this.prevI);
694
+ const s = o === no;
695
+ s || Le(o) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = s ? to : 27) : this.state = s ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(o));
696
+ break;
697
+ }
698
+ }
699
+ }
700
+ sPIBody() {
701
+ if (0 === this.text.length) {
702
+ const t = this.getCodeNorm();
703
+ t === no ? this.state = 26 : Le(t) || (this.text = String.fromCodePoint(t));
704
+ } else this.captureToChar(no) && (this.state = 26);
705
+ }
706
+ sPIEnding() {
707
+ const t = this.getCodeNorm();
708
+ if (t === ro) {
709
+ const { piTarget: t } = this;
710
+ "xml" === t.toLowerCase() && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({
711
+ target: t,
712
+ body: this.text
713
+ }), this.piTarget = this.text = "", this.state = Ye;
714
+ } else t === no ? this.text += "?" : (this.text += `?${String.fromCodePoint(t)}`, this.state = 25);
715
+ this.xmlDeclPossible = !1;
716
+ }
717
+ sXMLDeclNameStart() {
718
+ const t = this.skipSpaces();
719
+ t !== no ? t !== Ze && (this.state = 28, this.name = String.fromCodePoint(t)) : this.state = to;
720
+ }
721
+ sXMLDeclName() {
722
+ const t = this.captureTo(uo);
723
+ if (t === no) return this.state = to, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
724
+ if (Le(t) || t === so) {
725
+ if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
726
+ case 0:
727
+ this.fail("did not expect any more name/value pairs.");
728
+ break;
729
+ case 1:
730
+ this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
731
+ break;
732
+ default: this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
733
+ }
734
+ this.state = t === so ? 30 : 29;
735
+ }
736
+ }
737
+ sXMLDeclEq() {
738
+ const t = this.getCodeNorm();
739
+ if (t === no) return this.state = to, void this.fail("XML declaration is incomplete.");
740
+ Le(t) || (t !== so && this.fail("value required."), this.state = 30);
741
+ }
742
+ sXMLDeclValueStart() {
743
+ const t = this.getCodeNorm();
744
+ if (t === no) return this.state = to, void this.fail("XML declaration is incomplete.");
745
+ Le(t) || (ao(t) ? this.q = t : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
746
+ }
747
+ sXMLDeclValue() {
748
+ const t = this.captureTo([this.q, no]);
749
+ if (t === no) return this.state = to, this.text = "", void this.fail("XML declaration is incomplete.");
750
+ if (t === Ze) return;
751
+ const e = this.text;
752
+ switch (this.text = "", this.name) {
753
+ case "version": {
754
+ this.xmlDeclExpects = ["encoding", "standalone"];
755
+ const t = e;
756
+ this.xmlDecl.version = t, /^1\.[0-9]+$/.test(t) ? this.opt.forceXMLVersion || this.setXMLVersion(t) : this.fail("version number must match /^1\\.[0-9]+$/.");
757
+ break;
758
+ }
759
+ case "encoding":
760
+ /^[A-Za-z][A-Za-z0-9._-]*$/.test(e) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = e;
761
+ break;
762
+ case "standalone": "yes" !== e && "no" !== e && this.fail("standalone value must match \"yes\" or \"no\"."), this.xmlDeclExpects = [], this.xmlDecl.standalone = e;
763
+ }
764
+ this.name = "", this.state = 32;
765
+ }
766
+ sXMLDeclSeparator() {
767
+ const t = this.getCodeNorm();
768
+ t !== no ? (Le(t) || (this.fail("whitespace required."), this.unGet()), this.state = 27) : this.state = to;
769
+ }
770
+ sXMLDeclEnding() {
771
+ this.getCodeNorm() === ro ? ("xml" !== this.piTarget ? this.fail("processing instructions are not allowed before root.") : "version" !== this.name && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version."), this.xmlDeclHandler?.(this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = Ye) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = !1;
772
+ }
773
+ sOpenTag() {
774
+ const t = this.captureNameChars();
775
+ if (t === Ze) return;
776
+ const e = this.tag = {
777
+ name: this.name,
778
+ attributes: Object.create(null)
779
+ };
780
+ switch (this.name = "", this.xmlnsOpt && (this.topNS = e.ns = Object.create(null)), this.openTagStartHandler?.(e), this.sawRoot = !0, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), t) {
781
+ case ro:
782
+ this.openTag();
783
+ break;
784
+ case 47:
785
+ this.state = 35;
786
+ break;
787
+ default: Le(t) || this.fail("disallowed character in tag name."), this.state = 36;
788
+ }
789
+ }
790
+ sOpenTagSlash() {
791
+ this.getCode() === ro ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
792
+ }
793
+ sAttrib() {
794
+ const t = this.skipSpaces();
795
+ t !== Ze && (je(t) ? (this.unGet(), this.state = 37) : t === ro ? this.openTag() : 47 === t ? this.state = 35 : this.fail("disallowed character in attribute name."));
796
+ }
797
+ sAttribName() {
798
+ const t = this.captureNameChars();
799
+ t === so ? this.state = 39 : Le(t) ? this.state = 38 : t === ro ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t !== Ze && this.fail("disallowed character in attribute name.");
800
+ }
801
+ sAttribNameSawWhite() {
802
+ const t = this.skipSpaces();
803
+ switch (t) {
804
+ case Ze: return;
805
+ case so:
806
+ this.state = 39;
807
+ break;
808
+ default: this.fail("attribute without value."), this.text = "", this.name = "", t === ro ? this.openTag() : je(t) ? (this.unGet(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
809
+ }
810
+ }
811
+ sAttribValue() {
812
+ const t = this.getCodeNorm();
813
+ ao(t) ? (this.q = t, this.state = 40) : Le(t) || (this.fail("unquoted attribute value."), this.state = 42, this.unGet());
814
+ }
815
+ sAttribValueQuoted() {
816
+ const { q: t, chunk: e } = this;
817
+ let { i: o } = this;
818
+ for (;;) switch (this.getCode()) {
819
+ case t:
820
+ this.pushAttrib(this.name, this.text + e.slice(o, this.prevI)), this.name = this.text = "", this.q = null, this.state = 41;
821
+ return;
822
+ case 38:
823
+ this.text += e.slice(o, this.prevI), this.state = 14, this.entityReturnState = 40;
824
+ return;
825
+ case eo:
826
+ case Qe:
827
+ case 9:
828
+ this.text += `${e.slice(o, this.prevI)} `, o = this.i;
829
+ break;
830
+ case oo:
831
+ this.text += e.slice(o, this.prevI), this.fail("disallowed character.");
832
+ return;
833
+ case Ze:
834
+ this.text += e.slice(o);
835
+ return;
836
+ }
837
+ }
838
+ sAttribValueClosed() {
839
+ const t = this.getCodeNorm();
840
+ Le(t) ? this.state = 36 : t === ro ? this.openTag() : 47 === t ? this.state = 35 : je(t) ? (this.fail("no whitespace between attributes."), this.unGet(), this.state = 37) : this.fail("disallowed character in attribute name.");
841
+ }
842
+ sAttribValueUnquoted() {
843
+ const t = this.captureTo(po);
844
+ switch (t) {
845
+ case 38:
846
+ this.state = 14, this.entityReturnState = 42;
847
+ break;
848
+ case oo:
849
+ this.fail("disallowed character.");
850
+ break;
851
+ case Ze: break;
852
+ default: this.text.includes("]]>") && this.fail("the string \"]]>\" is disallowed in char data."), this.pushAttrib(this.name, this.text), this.name = this.text = "", t === ro ? this.openTag() : this.state = 36;
853
+ }
854
+ }
855
+ sCloseTag() {
856
+ const t = this.captureNameChars();
857
+ t === ro ? this.closeTag() : Le(t) ? this.state = 44 : t !== Ze && this.fail("disallowed character in closing tag.");
858
+ }
859
+ sCloseTagSawWhite() {
860
+ switch (this.skipSpaces()) {
861
+ case ro:
862
+ this.closeTag();
863
+ break;
864
+ case Ze: break;
865
+ default: this.fail("disallowed character in closing tag.");
866
+ }
867
+ }
868
+ handleTextInRoot() {
869
+ let { i: t, forbiddenState: e } = this;
870
+ const { chunk: o, textHandler: s } = this;
871
+ t: for (;;) switch (this.getCode()) {
872
+ case oo:
873
+ if (this.state = 15, void 0 !== s) {
874
+ const { text: e } = this, r = o.slice(t, this.prevI);
875
+ 0 !== e.length ? (s(e + r), this.text = "") : 0 !== r.length && s(r);
876
+ }
877
+ e = 0;
878
+ break t;
879
+ case 38:
880
+ this.state = 14, this.entityReturnState = Ye, void 0 !== s && (this.text += o.slice(t, this.prevI)), e = 0;
881
+ break t;
882
+ case io:
883
+ switch (e) {
884
+ case 0:
885
+ e = 1;
886
+ break;
887
+ case 1:
888
+ e = 2;
889
+ break;
890
+ case 2: break;
891
+ default: throw new Error("impossible state");
892
+ }
893
+ break;
894
+ case ro:
895
+ 2 === e && this.fail("the string \"]]>\" is disallowed in char data."), e = 0;
896
+ break;
897
+ case Qe:
898
+ void 0 !== s && (this.text += `${o.slice(t, this.prevI)}\n`), t = this.i, e = 0;
899
+ break;
900
+ case Ze:
901
+ void 0 !== s && (this.text += o.slice(t));
902
+ break t;
903
+ default: e = 0;
904
+ }
905
+ this.forbiddenState = e;
906
+ }
907
+ handleTextOutsideRoot() {
908
+ let { i: t } = this;
909
+ const { chunk: e, textHandler: o } = this;
910
+ let s = !1;
911
+ t: for (;;) {
912
+ const r = this.getCode();
913
+ switch (r) {
914
+ case oo:
915
+ if (this.state = 15, void 0 !== o) {
916
+ const { text: s } = this, r = e.slice(t, this.prevI);
917
+ 0 !== s.length ? (o(s + r), this.text = "") : 0 !== r.length && o(r);
918
+ }
919
+ break t;
920
+ case 38:
921
+ this.state = 14, this.entityReturnState = Ye, void 0 !== o && (this.text += e.slice(t, this.prevI)), s = !0;
922
+ break t;
923
+ case Qe:
924
+ void 0 !== o && (this.text += `${e.slice(t, this.prevI)}\n`), t = this.i;
925
+ break;
926
+ case Ze:
927
+ void 0 !== o && (this.text += e.slice(t));
928
+ break t;
929
+ default: Le(r) || (s = !0);
930
+ }
931
+ }
932
+ s && (this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0));
933
+ }
934
+ pushAttribNS(t, e) {
935
+ const { prefix: o, local: s } = this.qName(t), r = {
936
+ name: t,
937
+ prefix: o,
938
+ local: s,
939
+ value: e
940
+ };
941
+ if (this.attribList.push(r), this.attributeHandler?.(r), "xmlns" === o) {
942
+ const t = e.trim();
943
+ "1.0" === this.currentXMLVersion && "" === t && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[s] = t, fo(this, s, t);
944
+ } else if ("xmlns" === t) {
945
+ const t = e.trim();
946
+ this.topNS[""] = t, fo(this, "", t);
947
+ }
948
+ }
949
+ pushAttribPlain(t, e) {
950
+ const o = {
951
+ name: t,
952
+ value: e
953
+ };
954
+ this.attribList.push(o), this.attributeHandler?.(o);
955
+ }
956
+ end() {
957
+ this.sawRoot || this.fail("document must contain a root element.");
958
+ const { tags: t } = this;
959
+ for (; t.length > 0;) {
960
+ const e = t.pop();
961
+ this.fail(`unclosed tag: ${e.name}`);
962
+ }
963
+ 0 !== this.state && this.state !== Ye && this.fail("unexpected end.");
964
+ const { text: e } = this;
965
+ return 0 !== e.length && (this.textHandler?.(e), this.text = ""), this._closed = !0, this.endHandler?.(), this._init(), this;
966
+ }
967
+ resolve(t) {
968
+ let e = this.topNS[t];
969
+ if (void 0 !== e) return e;
970
+ const { tags: o } = this;
971
+ for (let s = o.length - 1; s >= 0; s--) if (e = o[s].ns[t], void 0 !== e) return e;
972
+ return e = this.ns[t], void 0 !== e ? e : this.opt.resolvePrefix?.(t);
973
+ }
974
+ qName(t) {
975
+ const e = t.indexOf(":");
976
+ if (-1 === e) return {
977
+ prefix: "",
978
+ local: t
979
+ };
980
+ const o = t.slice(e + 1), s = t.slice(0, e);
981
+ return ("" === s || "" === o || o.includes(":")) && this.fail(`malformed name: ${t}.`), {
982
+ prefix: s,
983
+ local: o
984
+ };
985
+ }
986
+ processAttribsNS() {
987
+ const { attribList: t } = this, e = this.tag;
988
+ {
989
+ const { prefix: t, local: o } = this.qName(e.name);
990
+ e.prefix = t, e.local = o;
991
+ const s = e.uri = this.resolve(t) ?? "";
992
+ "" !== t && ("xmlns" === t && this.fail("tags may not have \"xmlns\" as prefix."), "" === s && (this.fail(`unbound namespace prefix: ${JSON.stringify(t)}.`), e.uri = t));
993
+ }
994
+ if (0 === t.length) return;
995
+ const { attributes: o } = e, s = /* @__PURE__ */ new Set();
996
+ for (const e of t) {
997
+ const { name: t, prefix: r, local: n } = e;
998
+ let i, a;
999
+ "" === r ? (i = "xmlns" === t ? Ke : "", a = t) : (i = this.resolve(r), void 0 === i && (this.fail(`unbound namespace prefix: ${JSON.stringify(r)}.`), i = r), a = `{${i}}${n}`), s.has(a) && this.fail(`duplicate attribute: ${a}.`), s.add(a), e.uri = i, o[t] = e;
1000
+ }
1001
+ this.attribList = [];
1002
+ }
1003
+ processAttribsPlain() {
1004
+ const { attribList: t } = this, e = this.tag.attributes;
1005
+ for (const { name: o, value: s } of t) void 0 !== e[o] && this.fail(`duplicate attribute: ${o}.`), e[o] = s;
1006
+ this.attribList = [];
1007
+ }
1008
+ openTag() {
1009
+ this.processAttribs();
1010
+ const { tags: t } = this, e = this.tag;
1011
+ e.isSelfClosing = !1, this.openTagHandler?.(e), t.push(e), this.state = Ye, this.name = "";
1012
+ }
1013
+ openSelfClosingTag() {
1014
+ this.processAttribs();
1015
+ const { tags: t } = this, e = this.tag;
1016
+ e.isSelfClosing = !0, this.openTagHandler?.(e), this.closeTagHandler?.(e), null === (this.tag = t[t.length - 1] ?? null) && (this.closedRoot = !0), this.state = Ye, this.name = "";
1017
+ }
1018
+ closeTag() {
1019
+ const { tags: t, name: e } = this;
1020
+ if (this.state = Ye, this.name = "", "" === e) return this.fail("weird empty close tag."), void (this.text += "</>");
1021
+ const o = this.closeTagHandler;
1022
+ let s = t.length;
1023
+ for (; s-- > 0;) {
1024
+ const s = this.tag = t.pop();
1025
+ if (this.topNS = s.ns, o?.(s), s.name === e) break;
1026
+ this.fail(`unexpected close tag: ${e}.`);
1027
+ }
1028
+ 0 === s ? this.closedRoot = !0 : s < 0 && (this.fail(`unmatched closing tag: ${e}.`), this.text += `</${e}>`);
1029
+ }
1030
+ parseEntity(t) {
1031
+ if ("#" !== t[0]) {
1032
+ const e = this.ENTITIES[t];
1033
+ return void 0 !== e ? e : (this.fail(this.isName(t) ? "undefined entity." : "disallowed character in entity name."), `&${t};`);
1034
+ }
1035
+ let e = NaN;
1036
+ return "x" === t[1] && /^#x[0-9a-f]+$/i.test(t) ? e = parseInt(t.slice(2), 16) : /^#[0-9]+$/.test(t) && (e = parseInt(t.slice(1), 10)), this.isChar(e) ? String.fromCodePoint(e) : (this.fail("malformed character entity."), `&${t};`);
1037
+ }
1038
+ }, yo = /&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, wo = {
1039
+ amp: "&",
1040
+ lt: "<",
1041
+ gt: ">",
1042
+ quot: "\"",
1043
+ apos: "'"
1044
+ }, To = (t, e) => {
1045
+ const o = wo[e];
1046
+ if (void 0 !== o) return o;
1047
+ const s = 120 === e.charCodeAt(1) ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
1048
+ return s > 0 && s <= 1114111 ? String.fromCodePoint(s) : t;
1049
+ }, So = (t) => {
1050
+ let e = t;
1051
+ return -1 !== e.indexOf("\r") && (e = e.replace(/\r\n?/g, "\n")), -1 !== e.indexOf("&") && (e = e.replace(yo, To)), e;
1052
+ }, Co = (t) => {
1053
+ let e = t;
1054
+ const o = e.length;
1055
+ for (let t = 0; t < o; t++) {
1056
+ const o = e.charCodeAt(t);
1057
+ if (9 === o || 10 === o || 13 === o) {
1058
+ e = e.replace(/\r\n|[\t\n\r]/g, " ");
1059
+ break;
1060
+ }
1061
+ }
1062
+ return -1 !== e.indexOf("&") && (e = e.replace(yo, To)), e;
1063
+ }, Ao = (t) => 32 === t || 9 === t || 10 === t || 13 === t, ko = class t {
1064
+ constructor() {
1065
+ this._openTagHandler = void 0, this._closeTagHandler = void 0, this._textHandler = void 0, this._cdataHandler = void 0, this._errorHandler = void 0, this._endHandler = void 0, this._scanners = null, this._carry = "", this._text = "", this._tags = [], this._sawRoot = !1, this._closed = !1;
1066
+ }
1067
+ static {
1068
+ this.NEED_MORE = -1;
1069
+ }
1070
+ static {
1071
+ this.NOT_HANDLED = -2;
1072
+ }
1073
+ static decodeText(t) {
1074
+ return So(t);
1075
+ }
1076
+ on(t, e) {
1077
+ switch (t) {
1078
+ case "opentag":
1079
+ this._openTagHandler = e;
1080
+ break;
1081
+ case "closetag":
1082
+ this._closeTagHandler = e;
1083
+ break;
1084
+ case "text":
1085
+ this._textHandler = e;
1086
+ break;
1087
+ case "cdata":
1088
+ this._cdataHandler = e;
1089
+ break;
1090
+ case "error":
1091
+ this._errorHandler = e;
1092
+ break;
1093
+ case "end": this._endHandler = e;
1094
+ }
1095
+ }
1096
+ setElementScanners(t) {
1097
+ if (!t || 0 === t.length) return void (this._scanners = null);
1098
+ const e = new Array(128);
1099
+ for (const o of t) {
1100
+ const t = o.name.charCodeAt(0);
1101
+ if (!(t < 128) || void 0 !== e[t]) throw new Error(`Element scanner '${o.name}' needs an ASCII first character no other scanner uses.`);
1102
+ e[t] = o;
1103
+ }
1104
+ this._scanners = e;
1105
+ }
1106
+ fail(t) {
1107
+ const e = new Error(t), o = this._errorHandler;
1108
+ if (void 0 === o) throw e;
1109
+ o(e);
1110
+ }
1111
+ write(t) {
1112
+ if (this._closed) return this.fail("cannot write after close."), this;
1113
+ let e = t;
1114
+ 0 !== this._carry.length && (e = this._carry + t, this._carry = "");
1115
+ const o = e.length;
1116
+ let s = 0;
1117
+ for (; s < o;) {
1118
+ const t = e.indexOf("<", s);
1119
+ if (-1 === t) return this._text += e.slice(s), this;
1120
+ t > s && (this._text += e.slice(s, t));
1121
+ const r = this._markup(e, t, o);
1122
+ if (-1 === r) return this._carry = e.slice(t), this;
1123
+ s = r;
1124
+ }
1125
+ return this;
1126
+ }
1127
+ close() {
1128
+ 0 !== this._carry.length && (this.fail("unexpected end."), this._carry = ""), this._sawRoot || this.fail("document must contain a root element.");
1129
+ const t = this._tags;
1130
+ for (; t.length > 0;) {
1131
+ const e = t.pop();
1132
+ this.fail(`unclosed tag: ${e.name}`);
1133
+ }
1134
+ return this._flushText(), this._closed = !0, this._endHandler?.(), this;
1135
+ }
1136
+ _flushText() {
1137
+ const t = this._text;
1138
+ if (0 === t.length) return;
1139
+ this._text = "";
1140
+ const e = this._textHandler;
1141
+ void 0 !== e && 0 !== this._tags.length && e(So(t));
1142
+ }
1143
+ _markup(e, o, s) {
1144
+ if (o + 1 >= s) return -1;
1145
+ const r = e.charCodeAt(o + 1);
1146
+ if (47 === r) {
1147
+ const t = e.indexOf(">", o + 2);
1148
+ return -1 === t ? -1 : (this._flushText(), this._closeTag(e.slice(o + 2, t).trimEnd()), t + 1);
1149
+ }
1150
+ if (63 === r) {
1151
+ const t = e.indexOf("?>", o + 2);
1152
+ return -1 === t ? -1 : t + 2;
1153
+ }
1154
+ if (33 === r) {
1155
+ if (o + 4 > s) return -1;
1156
+ if (45 === e.charCodeAt(o + 2) && 45 === e.charCodeAt(o + 3)) {
1157
+ const t = e.indexOf("-->", o + 4);
1158
+ return -1 === t ? -1 : t + 3;
1159
+ }
1160
+ if (o + 9 > s) return -1;
1161
+ if (e.startsWith("[CDATA[", o + 2)) {
1162
+ const t = e.indexOf("]]>", o + 9);
1163
+ return -1 === t ? -1 : (this._flushText(), this._cdataHandler?.(e.slice(o + 9, t)), t + 3);
1164
+ }
1165
+ const t = e.indexOf("[", o + 2), r = e.indexOf(">", o + 2);
1166
+ if (-1 === r) return -1;
1167
+ if (-1 !== t && t < r) {
1168
+ const o = e.indexOf("]>", t);
1169
+ return -1 === o ? -1 : o + 2;
1170
+ }
1171
+ return r + 1;
1172
+ }
1173
+ const n = this._scanners;
1174
+ if (null !== n) {
1175
+ const i = r < 128 ? n[r] : void 0;
1176
+ if (void 0 !== i && e.startsWith(i.name, o + 1)) {
1177
+ const r = o + 1 + i.name.length;
1178
+ if (r >= s) return -1;
1179
+ const n = e.charCodeAt(r);
1180
+ if (62 === n || 47 === n || Ao(n)) {
1181
+ this._flushText();
1182
+ const r = i.scan(e, o, s);
1183
+ if (r !== t.NOT_HANDLED) {
1184
+ if (r !== t.NEED_MORE) {
1185
+ this._sawRoot = !0;
1186
+ const t = i.openTag;
1187
+ void 0 !== t && this._tags.push(t);
1188
+ }
1189
+ return r;
1190
+ }
1191
+ }
1192
+ }
1193
+ }
1194
+ return this._openTag(e, o, s);
1195
+ }
1196
+ _openTag(t, e, o) {
1197
+ let s = e + 1, r = 0;
1198
+ for (; s < o && (r = t.charCodeAt(s), 62 !== r && 47 !== r && !Ao(r));) s++;
1199
+ if (s >= o) return -1;
1200
+ const n = t.slice(e + 1, s), i = {};
1201
+ let a = !1;
1202
+ for (;;) {
1203
+ for (; s < o && Ao(r = t.charCodeAt(s));) s++;
1204
+ if (s >= o) return -1;
1205
+ if (62 === r) {
1206
+ s++;
1207
+ break;
1208
+ }
1209
+ if (47 === r) {
1210
+ if (s + 1 >= o) return -1;
1211
+ if (62 !== t.charCodeAt(s + 1)) {
1212
+ this.fail("forward-slash in opening tag not followed by >."), s++;
1213
+ continue;
1214
+ }
1215
+ a = !0, s += 2;
1216
+ break;
1217
+ }
1218
+ const e = s;
1219
+ for (; s < o && (r = t.charCodeAt(s), 61 !== r && 62 !== r && 47 !== r && !Ao(r));) s++;
1220
+ if (s >= o) return -1;
1221
+ const n = t.slice(e, s);
1222
+ for (; s < o && Ao(r = t.charCodeAt(s));) s++;
1223
+ if (s >= o) return -1;
1224
+ if (61 !== r) {
1225
+ this.fail("attribute without value.");
1226
+ continue;
1227
+ }
1228
+ for (s++; s < o && Ao(r = t.charCodeAt(s));) s++;
1229
+ if (s >= o) return -1;
1230
+ if (34 !== r && 39 !== r) {
1231
+ this.fail("unquoted attribute value.");
1232
+ continue;
1233
+ }
1234
+ const l = t.indexOf(34 === r ? "\"" : "'", s + 1);
1235
+ if (-1 === l) return -1;
1236
+ "__proto__" !== n && (i[n] = Co(t.slice(s + 1, l))), s = l + 1;
1237
+ }
1238
+ this._flushText(), this._sawRoot = !0;
1239
+ const l = {
1240
+ name: n,
1241
+ attributes: i,
1242
+ isSelfClosing: a
1243
+ };
1244
+ return this._openTagHandler?.(l), a ? this._closeTagHandler?.(l) : this._tags.push(l), s;
1245
+ }
1246
+ _closeTag(t) {
1247
+ if ("" === t) return void this.fail("weird empty close tag.");
1248
+ const e = this._tags, o = this._closeTagHandler;
1249
+ let s = e.length;
1250
+ for (; s-- > 0;) {
1251
+ const s = e.pop();
1252
+ if (o?.(s), s.name === t) return;
1253
+ this.fail(`unexpected close tag: ${t}.`);
1254
+ }
1255
+ this.fail(`unmatched closing tag: ${t}.`);
1256
+ }
1257
+ };
1258
+ (function(t) {
1259
+ t.Events = {
1260
+ XmlDecl: "xmldecl",
1261
+ Text: "text",
1262
+ ProcessingInstruction: "processinginstruction",
1263
+ Doctype: "doctype",
1264
+ Comment: "comment",
1265
+ OpenTagStart: "opentagstart",
1266
+ Attribute: "attribute",
1267
+ OpenTag: "opentag",
1268
+ CloseTag: "closetag",
1269
+ CDdata: "cdata",
1270
+ Error: "error",
1271
+ End: "end",
1272
+ Ready: "ready"
1273
+ };
1274
+ t.parseStream = async (t, e, o) => {
1275
+ if (o?.lean) return (async (t, e) => {
1276
+ const o = new ko();
1277
+ let s;
1278
+ e.elementScanners && o.setElementScanners(e.elementScanners), e.onOpenTag && o.on("opentag", e.onOpenTag), e.onCloseTag && o.on("closetag", e.onCloseTag), e.onText && o.on("text", e.onText), e.onError && o.on("error", e.onError);
1279
+ const r = e.onEnd;
1280
+ for (r && o.on("end", () => {
1281
+ s = r();
1282
+ });;) {
1283
+ const { value: e, done: s } = await t.read();
1284
+ if (s) break;
1285
+ o.write(e);
1286
+ }
1287
+ return o.close(), s;
1288
+ })(t, e);
1289
+ const s = new xo({
1290
+ position: !1,
1291
+ ...o
1292
+ });
1293
+ let r;
1294
+ e.onOpenTagStart && s.on(go.Events.OpenTagStart, e.onOpenTagStart), e.onOpenTag && s.on(go.Events.OpenTag, e.onOpenTag), e.onCloseTag && s.on(go.Events.CloseTag, e.onCloseTag), e.onAttribute && s.on(go.Events.Attribute, e.onAttribute), e.onText && s.on(go.Events.Text, e.onText), e.onError && s.on(go.Events.Error, e.onError);
1295
+ const n = e.onEnd;
1296
+ if (n) {
1297
+ const t = () => {
1298
+ r = n();
1299
+ };
1300
+ s.on(go.Events.End, t);
1301
+ }
1302
+ for (;;) {
1303
+ const { value: e, done: o } = await t.read();
1304
+ if (o) break;
1305
+ s.write(e);
1306
+ }
1307
+ return s.close(), r;
1308
+ };
1309
+ })(go || (go = {}));
1310
+ var Eo = (t) => !0 === t || "1" === t || "on" === t || "true" === t || !1 !== t && "0" !== t && "off" !== t && "false" !== t && null, Io = (t) => {
1311
+ const e = parseInt(t);
1312
+ return isNaN(e) ? null : e;
1313
+ }, Po = (t) => {
1314
+ const e = parseFloat(t);
1315
+ return isNaN(e) ? null : e;
1316
+ }, Oo = null, Do = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), No = (t) => Do(t).replace(/"/g, "&quot;"), _o = class {
1317
+ constructor() {
1318
+ this._registeredVisitors = /* @__PURE__ */ new Map();
1319
+ }
1320
+ registerVisitor(t) {
1321
+ this._registeredVisitors.set(t.from, t);
1322
+ }
1323
+ createEventHandler(t, e, o) {
1324
+ const s = this._registeredVisitors, r = [], n = [];
1325
+ let i = null, a = null, l = null, c = null;
1326
+ const h = [], u = {
1327
+ key: null,
1328
+ source: t,
1329
+ parent: null
1330
+ };
1331
+ let d = null, p = !1, f = null, g = null, m = null;
1332
+ const b = (t, e) => {
1333
+ let o = l.attributes[t];
1334
+ if (e) if (Array.isArray(e)) {
1335
+ const t = e.length;
1336
+ for (let s = 0; s < t; s++) {
1337
+ if (null == o) return;
1338
+ if (o = e[s](o), null == o) return;
1339
+ }
1340
+ } else {
1341
+ if (null == o) return;
1342
+ if (o = e(o), null == o) return;
1343
+ }
1344
+ return o;
1345
+ }, v = {
1346
+ getSource: () => d?.source ?? null,
1347
+ setSource: (t) => {
1348
+ d.source = t;
1349
+ },
1350
+ setKey: (t) => {
1351
+ d.key = t;
1352
+ },
1353
+ getFrom: () => l,
1354
+ getAttribute: (t, e) => b(t, e) ?? null,
1355
+ hasAttribute: (t) => null !== v.getAttribute(t),
1356
+ getParent: () => {
1357
+ const t = h[h.length - 2];
1358
+ return t.parent ?? t.source;
1359
+ },
1360
+ getPath: () => {
1361
+ const t = [], e = n.length;
1362
+ for (let o = 0; o < e; o++) t.push(n[o].local);
1363
+ return t.join("\\");
1364
+ },
1365
+ parseAttribute: b,
1366
+ getRawXml: () => m,
1367
+ copyToObject: (t, e, o, s) => {
1368
+ const r = b(s ?? e, o);
1369
+ void 0 !== r && (t[e] = r);
1370
+ },
1371
+ copyTo: (t, e, o) => {
1372
+ const s = b(o ?? t, e);
1373
+ void 0 !== s && (d.source[t] = s);
1374
+ },
1375
+ warn: (t, e) => {
1376
+ o ? o(t, void 0, e?.onceKey) : console.warn(t);
1377
+ }
1378
+ };
1379
+ return {
1380
+ onOpenTag: (t) => {
1381
+ let e = t.name;
1382
+ const o = e.indexOf(":");
1383
+ if (-1 !== o && (e = e.slice(o + 1)), f) return f.push(((t) => {
1384
+ const e = t.attributes ?? {};
1385
+ let o = `<${t.name}`;
1386
+ for (const t in e) {
1387
+ const s = e[t];
1388
+ o += ` ${t}="${No("string" == typeof s ? s : s?.value ?? "")}"`;
1389
+ }
1390
+ return o + ">";
1391
+ })(t)), i = {
1392
+ local: e,
1393
+ tag: t,
1394
+ destination: null
1395
+ }, n.push(i), a = e, void (l = t);
1396
+ const m = (r.length > 0 ? r[r.length - 1] : s).get(e);
1397
+ if (i = {
1398
+ local: e,
1399
+ visitor: m,
1400
+ tag: t,
1401
+ destination: null
1402
+ }, p) return n.push(i), a = e, void (l = t);
1403
+ c = i?.visitor ?? null, a = e, l = t;
1404
+ let b = !!m && null === m.to;
1405
+ if (m && !b && m.scope) {
1406
+ const t = m.scope(v);
1407
+ null === t ? b = !0 : t && (r.push(t), i.pushedScope = !0);
1408
+ }
1409
+ m && (0 === n.length ? (d = u, i.destination = d, i.pushedDestination = !0, h.push(d)) : b ? (d = null, i.destination = null) : m.transparent ? i.destination = d : (d = {
1410
+ key: null,
1411
+ source: {},
1412
+ parent: null
1413
+ }, i.destination = d, i.pushedDestination = !0, h.push(d))), n.push(i), p = b;
1414
+ const x = c?.openTag?.(v);
1415
+ void 0 !== x && (d.parent = x), m?.raw && !b && (f = [], g = i);
1416
+ },
1417
+ onCloseTag: (t) => {
1418
+ let e = t.name;
1419
+ const s = e.indexOf(":");
1420
+ if (-1 !== s && (e = e.slice(s + 1)), e !== a) throw new Error(`mismatch open/close tag: '${e}'/'${a}'`);
1421
+ let b = !1;
1422
+ if (f) {
1423
+ if (n[n.length - 1] !== g) return f.push(`</${t.name}>`), n.pop(), i = n[n.length - 1] ?? null, a = i?.local ?? null, void (l = i?.tag ?? null);
1424
+ m = f.join(""), f = null, g = null, b = !0;
1425
+ }
1426
+ p || c?.closeTag?.(v), b && (m = null);
1427
+ const x = n.pop() ?? null;
1428
+ i = n[n.length - 1] ?? null, x?.pushedScope && r.pop();
1429
+ const y = x?.destination;
1430
+ if (y && x.pushedDestination) {
1431
+ h.pop(), d = h[h.length - 1] ?? u;
1432
+ const t = x.visitor;
1433
+ t && t.to && void 0 !== y.source && (Array.isArray(t.to) ? d.source.push ? d.source.push(y.source) : o?.(`Unable to parse array for ${t.from} at ${v.getPath()}`) : y.key ? d.source[y.key] = y.source : "string" == typeof t.to && (d.source[t.to] = y.source));
1434
+ } else y || (d = h[h.length - 1] ?? u);
1435
+ a = i?.local ?? null, l = i?.tag ?? null, c = i?.visitor ?? null, p = !i?.destination;
1436
+ },
1437
+ onText: (t) => {
1438
+ f ? f.push(Do(t)) : c?.text?.(t, v);
1439
+ },
1440
+ onEnd: e
1441
+ };
1442
+ }
1443
+ }, $o = `IFERROR(${m}(`, Mo = $o.toUpperCase(), Ro = ot.toUpperCase(), Lo = { kind: "none" }, Vo = { kind: "spilled" }, jo = (t, e) => {
1444
+ if (34 !== t.charCodeAt(e)) return null;
1445
+ let o = "", s = e + 1;
1446
+ for (; s < t.length;) if (34 === t.charCodeAt(s)) {
1447
+ if (34 !== t.charCodeAt(s + 1)) return {
1448
+ value: o,
1449
+ end: s + 1
1450
+ };
1451
+ o += "\"", s += 2;
1452
+ } else o += t[s], s++;
1453
+ return null;
1454
+ }, Bo = (t) => {
1455
+ const e = [];
1456
+ let o = 0;
1457
+ for (; o < t.length;) {
1458
+ const s = t.charCodeAt(o);
1459
+ if (34 === s) {
1460
+ const e = jo(t, o);
1461
+ if (null === e) break;
1462
+ o = e.end;
1463
+ continue;
1464
+ }
1465
+ if (!(s >= 65 && s <= 90 || s >= 97 && s <= 122 || 95 === s)) {
1466
+ o++;
1467
+ continue;
1468
+ }
1469
+ let r = o + 1;
1470
+ for (; r < t.length;) {
1471
+ const e = t.charCodeAt(r);
1472
+ if (!(e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 95 === e || 46 === e)) break;
1473
+ r++;
1474
+ }
1475
+ 40 === t.charCodeAt(r) && e.push(t.slice(o, r).toUpperCase().replace(/^_XLFN\./, "").replace(/^_XLWS\./, "")), o = r;
1476
+ }
1477
+ return e;
1478
+ }, Fo = class {
1479
+ constructor(t) {
1480
+ this._restored = [], this._byColumn = /* @__PURE__ */ new Map(), this._isKnown = t;
1481
+ }
1482
+ anchor(t, e, o) {
1483
+ const s = this._byColumn.get(e);
1484
+ s && t === s.rowEnd + 1 && t > s.rowStart && (s.closed = !0);
1485
+ const r = Bo(o);
1486
+ let n = !0;
1487
+ for (let t = 0; t < r.length && n; t++) n = this._isKnown(r[t]);
1488
+ const i = {
1489
+ rowStart: t,
1490
+ colStart: e,
1491
+ rowEnd: t,
1492
+ colEnd: e,
1493
+ closed: !1,
1494
+ restored: n
1495
+ };
1496
+ return this._byColumn.set(e, i), n && this._restored.push(i), n;
1497
+ }
1498
+ placeholder(t, e) {
1499
+ const o = this._byColumn.get(e);
1500
+ if (o && !o.closed && t > o.rowStart && t <= o.rowEnd + 1 && e >= o.colStart && e <= o.colEnd) return o.rowEnd = t, o.restored;
1501
+ const s = this._byColumn.get(e - 1);
1502
+ return !(!s || s.rowStart !== t || s.colEnd !== e - 1) && (s.colEnd = e, this._byColumn.set(e, s), s.restored);
1503
+ }
1504
+ getFormulaArray() {
1505
+ return this._restored.map((t) => [It.rangeToString(t), "dynamic"]);
1506
+ }
1507
+ }, Ho = /^\s*TABLE\s*\(([^()]*)\)\s*$/i, Wo = /^\s*(\$?)([A-Za-z]{1,3})(\$?)(\d{1,7})\s*$/, zo = (t) => {
1508
+ const e = Wo.exec(t);
1509
+ if (!e) return null;
1510
+ const o = It.fastStringToCol(e[2]), s = parseInt(e[4], 10) - 1;
1511
+ return o < 0 || s < 0 ? null : {
1512
+ row: s,
1513
+ col: o,
1514
+ colAbsolute: "$" === e[1],
1515
+ rowAbsolute: "$" === e[3]
1516
+ };
1517
+ }, Xo = (t) => It.cellToString({
1518
+ rowIndex: t.row,
1519
+ colIndex: t.col
1520
+ }), qo = (t, e) => {
1521
+ const o = Ho.exec(t);
1522
+ if (!o) return null;
1523
+ const s = o[1].split(",");
1524
+ if (3 !== s.length && 5 !== s.length) return null;
1525
+ const r = [];
1526
+ for (let t = 0; t < s.length; t++) {
1527
+ const e = zo(s[t]);
1528
+ if (!e) return null;
1529
+ r.push(e);
1530
+ }
1531
+ const n = e.rowStart, i = e.colStart, a = (t) => t.colAbsolute && !t.rowAbsolute && t.col === i - 1 && t.row === n, l = (t) => t.rowAbsolute && !t.colAbsolute && t.row === n - 1 && t.col === i, c = {
1532
+ rowStart: n,
1533
+ colStart: i,
1534
+ rowEnd: e.rowEnd,
1535
+ colEnd: e.colEnd
1536
+ }, h = r[0];
1537
+ if (3 === r.length) {
1538
+ const [, t, e] = r;
1539
+ return a(e) && l(h) ? {
1540
+ ref: c,
1541
+ columnInput: Xo(t)
1542
+ } : l(e) && a(h) ? {
1543
+ ref: c,
1544
+ rowInput: Xo(t)
1545
+ } : null;
1546
+ }
1547
+ if (!h.rowAbsolute || !h.colAbsolute || h.row !== n - 1 || h.col !== i - 1) return null;
1548
+ const [, u, d, p, f] = r;
1549
+ return a(d) && l(f) ? {
1550
+ ref: c,
1551
+ rowInput: Xo(p),
1552
+ columnInput: Xo(u)
1553
+ } : l(d) && a(f) ? {
1554
+ ref: c,
1555
+ rowInput: Xo(u),
1556
+ columnInput: Xo(p)
1557
+ } : null;
1558
+ }, Uo = /^(?:(\d{4})-(\d{2})-(\d{2}))?T?(?:(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?)?(?:Z|[+-]\d{2}:?\d{2})?$/, Ko = /^PT(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?$/, Go = (t, e, o) => {
1559
+ const s = Math.floor((14 - e) / 12), r = t + 4800 - s, n = e + 12 * s - 3;
1560
+ return o + Math.floor((153 * n + 2) / 5) + 365 * r + Math.floor(r / 4) - Math.floor(r / 100) + Math.floor(r / 400) - 32045;
1561
+ }, Jo = Go(1899, 12, 30), Zo = (t) => {
1562
+ const e = t.indexOf(":");
1563
+ return -1 === e ? t : t.slice(e + 1);
1564
+ }, Qo = class {
1565
+ constructor() {
1566
+ this._runs = null, this._text = "", this._font = null, this._inRun = !1, this._inRPr = !1;
1567
+ }
1568
+ reset() {
1569
+ this._runs = null, this._inRun = !1, this._inRPr = !1;
1570
+ }
1571
+ onOpenTag(t, e) {
1572
+ "r" === t ? (this._inRun = !0, this._text = "", this._font = null, this._runs ??= []) : "rPr" === t ? this._inRun && (this._inRPr = !0) : this._inRPr && function(t, e, o) {
1573
+ switch (t) {
1574
+ case "b":
1575
+ o.weight = es(e) ? 700 : 400;
1576
+ break;
1577
+ case "i":
1578
+ o.style = es(e) ? jt.Style.Italic : jt.Style.Normal;
1579
+ break;
1580
+ case "strike":
1581
+ o.strike = xt(es(e));
1582
+ break;
1583
+ case "outline":
1584
+ o.outline = es(e);
1585
+ break;
1586
+ case "shadow":
1587
+ o.shadow = es(e);
1588
+ break;
1589
+ case "condense":
1590
+ case "extend": {
1591
+ const s = R(t, es(e));
1592
+ void 0 !== s && (o.letterSpacing = s);
1593
+ break;
1594
+ }
1595
+ case "u":
1596
+ o.underline = wt(e.val);
1597
+ break;
1598
+ case "vertAlign": {
1599
+ const t = Q(e.val);
1600
+ void 0 !== t && (o.baseline = t);
1601
+ break;
1602
+ }
1603
+ case "sz": {
1604
+ const t = parseFloat(e.val ?? "");
1605
+ isNaN(t) || (o.size = t);
1606
+ break;
1607
+ }
1608
+ case "rFont": {
1609
+ const t = e.val;
1610
+ t && (o.family = t);
1611
+ break;
1612
+ }
1613
+ case "family": {
1614
+ const t = ts[e.val ?? ""];
1615
+ t && (o.fallbacks = [t]);
1616
+ break;
1617
+ }
1618
+ case "charset": {
1619
+ const t = parseInt(e.val ?? "", 10);
1620
+ isNaN(t) || (o.charset = t);
1621
+ break;
1622
+ }
1623
+ case "scheme":
1624
+ J(o, e.val);
1625
+ break;
1626
+ case "color": {
1627
+ const t = e.rgb;
1628
+ if (t && void 0 === e.theme) {
1629
+ o.color = "#" + (8 === t.length ? t.substring(2) : t).toUpperCase();
1630
+ break;
1631
+ }
1632
+ const s = pt((t) => e[t]);
1633
+ s && (o.color = s);
1634
+ break;
1635
+ }
1636
+ }
1637
+ }(t, e, this._font ??= {});
1638
+ }
1639
+ onText(t) {
1640
+ this._inRun && (this._text += t);
1641
+ }
1642
+ onCloseTag(t) {
1643
+ if ("rPr" === t) this._inRPr = !1, this._font ??= {};
1644
+ else if ("r" === t && this._inRun) {
1645
+ const t = v(this._text), e = this._font;
1646
+ this._runs.push(e ? {
1647
+ text: t,
1648
+ font: e
1649
+ } : { text: t }), this._inRun = !1;
1650
+ }
1651
+ }
1652
+ take() {
1653
+ const t = this._runs;
1654
+ if (this.reset(), !t) return null;
1655
+ for (let e = 0; e < t.length; e++) if (t[e].font) return t;
1656
+ return null;
1657
+ }
1658
+ };
1659
+ function Yo(t, e) {
1660
+ const o = {
1661
+ family: "Calibri",
1662
+ size: 11,
1663
+ ...e,
1664
+ weight: 400,
1665
+ style: jt.Style.Normal,
1666
+ underline: jt.UnderlineStyle.None,
1667
+ strike: jt.StrikeStyle.None,
1668
+ baseline: 0
1669
+ }, s = new Array(t.length);
1670
+ for (let e = 0; e < t.length; e++) {
1671
+ const r = t[e];
1672
+ if (!r.font) {
1673
+ s[e] = r;
1674
+ continue;
1675
+ }
1676
+ const n = {
1677
+ ...o,
1678
+ ...r.font
1679
+ };
1680
+ s[e] = {
1681
+ text: r.text,
1682
+ font: n
1683
+ };
1684
+ }
1685
+ return s;
1686
+ }
1687
+ var ts = {
1688
+ 1: "serif",
1689
+ 2: "sans-serif",
1690
+ 3: "monospace",
1691
+ 4: "cursive",
1692
+ 5: "fantasy"
1693
+ }, es = (t) => {
1694
+ const e = t.val;
1695
+ return void 0 === e || "1" === e || "true" === e;
1696
+ };
1697
+ var os = (t) => {
1698
+ const e = (e) => {
1699
+ if (t) return new RegExp(`<(?:[\\w.-]+:)?${e}\\b[^>]*>([^<]*)<`).exec(t)?.[1];
1700
+ }, o = (t) => {
1701
+ const e = parseInt(t ?? "", 10);
1702
+ return isNaN(e) ? 0 : e;
1703
+ };
1704
+ return {
1705
+ c: o(e("col")),
1706
+ r: o(e("row")),
1707
+ x: S(e("colOff") ?? "0") ?? 0,
1708
+ y: S(e("rowOff") ?? "0") ?? 0
1709
+ };
1710
+ }, ss = "formulaDialect", rs = "isKnownFunction", ns = "date1904", is = "richStrings", as = "defaultFont", ls = (e, o, s, r, n, i, l, c) => {
1711
+ const h = new _o(), u = (t) => {
1712
+ const e = t.getAttribute("dxfId", Io);
1713
+ if (null === e) return;
1714
+ return r?.get(e) || (i?.(`A color filter or sort names a format that does not exist (dxfId '${e}').`), {});
1715
+ };
1716
+ let d = !1;
1717
+ const p = c?.get("parseInlineDxf"), g = c?.get(ss), m = (t) => g && t ? g.readDetached(t) : t, b = new Jt.TransposedBuilder();
1718
+ let x = null, T = "topLeft";
1719
+ h.registerVisitor({
1720
+ from: "autoFilter",
1721
+ to: "autoTable",
1722
+ openTag: (t) => {
1723
+ const e = t.getAttribute("ref"), o = It.fastStringToRange(e);
1724
+ t.getSource().r = o, t.getSource().v = {};
1725
+ },
1726
+ closeTag: (t) => {
1727
+ const e = t.getSource(), o = e.v, s = o.hiddenButtons;
1728
+ if (Array.isArray(s)) {
1729
+ const t = s.length, r = e.r, n = r.colEnd - r.colStart + 1;
1730
+ 0 === t ? o.hiddenButtons = !1 : t === n && (o.hiddenButtons = !0);
1731
+ }
1732
+ }
1733
+ }), h.registerVisitor({
1734
+ from: "conditionalFormatting",
1735
+ to: {},
1736
+ openTag: (t) => {
1737
+ const e = t.getParent();
1738
+ e.conditionals || (e.conditionals = []);
1739
+ let o = t.getAttribute("sqref");
1740
+ o && (o = o.trim().split(/\s+/).join(","));
1741
+ const s = {
1742
+ r: o,
1743
+ conditionals: e.conditionals
1744
+ }, r = t.getAttribute("pivot", Eo);
1745
+ null !== r && (s.pivot = r), t.setSource(s);
1746
+ }
1747
+ }), h.registerVisitor({
1748
+ from: "cfRule",
1749
+ to: {},
1750
+ openTag: (t) => {
1751
+ const e = t.getParent();
1752
+ if (!e?.r) return;
1753
+ const o = t.getSource() ?? {};
1754
+ void 0 !== e.pivot && (o.pivot = e.pivot), e.conditionals.push({
1755
+ r: e.r,
1756
+ v: null,
1757
+ rule: o
1758
+ }), t.copyToObject(o, "type", Oo), t.copyToObject(o, "priority", Io), t.copyToObject(o, "stopIfTrue", Eo);
1759
+ const s = t.getAttribute("dxfId", Io);
1760
+ if (null !== s) {
1761
+ let e = r?.get(s);
1762
+ e || (i?.(`Unable to load conditional color. Invalid dxfI: '${s}' at '${t.getPath()}'.`), e = {}), o.style = e;
1763
+ }
1764
+ t.copyToObject(o, "aboveAverage", Eo), t.copyToObject(o, "equalAverage", Eo), t.copyToObject(o, "stdDev", Io), t.copyToObject(o, "bottom", Eo), t.copyToObject(o, "percent", Eo), t.copyToObject(o, "rank", Io), t.copyToObject(o, "operator", Oo), t.copyToObject(o, "text", Oo), t.copyToObject(o, "timePeriod", Oo);
1765
+ },
1766
+ closeTag: (t) => {
1767
+ const e = t.getParent();
1768
+ if (!e?.r) return;
1769
+ const o = e.conditionals[e.conditionals.length - 1], s = o?.rule;
1770
+ if (!s) return;
1771
+ const r = {}, n = it(s, i);
1772
+ n && (r.condition = n), s.style && (r.style = s.style), s.scale && (r.scale = s.scale), s.stopIfTrue && (r.stopIfTrue = !0), s.pivot && "number" == typeof s.priority && (r.pivotKey = s.priority), o.v = r, o.priority = s.priority, s.x14Id && (o.x14Id = s.x14Id), delete o.rule;
1773
+ }
1774
+ });
1775
+ const S = (t) => {
1776
+ const e = t.conditions ?? [], o = [];
1777
+ for (let t = 0; t < e.length; t++) {
1778
+ const s = e[t], r = {};
1779
+ s.type && (r.type = s.type), void 0 !== s.value && (r.value = s.value), s.exclusive && (r.exclusive = !0), o.push(r);
1780
+ }
1781
+ return o;
1782
+ };
1783
+ h.registerVisitor({
1784
+ from: "colorScale",
1785
+ to: {},
1786
+ openTag: (t) => {},
1787
+ closeTag: (t) => {
1788
+ const e = t.getSource(), o = e.colors ?? [], s = S(e);
1789
+ for (let t = 0; t < s.length; t++) s[t].color = o[t];
1790
+ t.getParent().scale = {
1791
+ type: Lt.ScaleType.ColorScale,
1792
+ stops: s
1793
+ };
1794
+ }
1795
+ }), h.registerVisitor({
1796
+ from: "dataBar",
1797
+ to: {},
1798
+ openTag: (t) => {
1799
+ t.copyTo("maxLength", Io), t.copyTo("minLength", Io), t.copyTo("showValue", Eo);
1800
+ },
1801
+ closeTag: (t) => {
1802
+ const e = t.getSource(), o = {
1803
+ type: Lt.ScaleType.DataBar,
1804
+ stops: S(e)
1805
+ }, s = e.colors?.[0];
1806
+ s && (o.color = s), void 0 !== e.minLength && (o.minLength = e.minLength), void 0 !== e.maxLength && (o.maxLength = e.maxLength), void 0 !== e.showValue && (o.showValue = e.showValue), t.getParent().scale = o;
1807
+ }
1808
+ }), h.registerVisitor({
1809
+ from: "iconSet",
1810
+ to: {},
1811
+ openTag: (t) => {
1812
+ t.copyTo("iconSet", Oo), t.copyTo("reverse", Eo), t.copyTo("showValue", Eo);
1813
+ },
1814
+ closeTag: (t) => {
1815
+ const e = t.getSource(), o = {
1816
+ type: Lt.ScaleType.IconSet,
1817
+ stops: S(e)
1818
+ };
1819
+ void 0 !== e.iconSet && (o.iconSet = e.iconSet), void 0 !== e.reverse && (o.reverse = e.reverse), void 0 !== e.showValue && (o.showValue = e.showValue), t.getParent().scale = o;
1820
+ }
1821
+ }), h.registerVisitor({
1822
+ from: "formula",
1823
+ to: {},
1824
+ text: (t, e) => {
1825
+ const o = e.getParent();
1826
+ let s = o.formulas;
1827
+ s || (s = [], o.formulas = s), s.push(m(t));
1828
+ }
1829
+ }), h.registerVisitor({
1830
+ from: "cfvo",
1831
+ to: {},
1832
+ openTag: (t) => {
1833
+ const e = t.getParent();
1834
+ e.conditions || (e.conditions = []);
1835
+ const o = t.getSource();
1836
+ if (e.conditions.push(o), t.copyTo("type", Oo), o.type === Lt.ColorStopType.Formula) {
1837
+ const e = t.getAttribute("val");
1838
+ null != e && (o.value = m(String(e)));
1839
+ } else t.copyTo("value", Po, "val");
1840
+ !1 === t.getAttribute("gte", Eo) && (o.exclusive = !0);
1841
+ }
1842
+ }), h.registerVisitor({
1843
+ from: "color",
1844
+ to: {},
1845
+ openTag: (t) => {
1846
+ const e = t.getParent();
1847
+ e.colors || (e.colors = []);
1848
+ const o = pt((e) => t.getAttribute(e));
1849
+ e.colors.push(o);
1850
+ }
1851
+ }), h.registerVisitor({
1852
+ from: "filterColumn",
1853
+ to: {},
1854
+ openTag: (t) => {
1855
+ const e = t.getParent().v, o = parseInt(t.getAttribute("colId")), s = t.getSource();
1856
+ s.index = o;
1857
+ let r = e.filter;
1858
+ r || (r = { conditions: [] }, e.filter = r);
1859
+ let n = r.conditions;
1860
+ if (n || (n = [], r.conditions = n), n.push(s), t.getAttribute("hiddenButton", Eo) && e) {
1861
+ let t = e.hiddenButtons;
1862
+ t || (t = [], e.hiddenButtons = t), t.push(o);
1863
+ }
1864
+ if (t.getAttribute("showButton", Eo) && e) {
1865
+ let t = e.showButtons;
1866
+ t || (t = [], e.showButtons = t), t.push(o);
1867
+ }
1868
+ return s;
1869
+ }
1870
+ }), h.registerVisitor({
1871
+ from: "colorFilter",
1872
+ openTag: (t) => {
1873
+ const e = t.getParent(), o = {};
1874
+ e.operator = Rt.BuiltInOperatorNames.Color, e.param = o, t.copyToObject(o, "cellColor", Eo);
1875
+ const s = u(t);
1876
+ s && (o.style = s);
1877
+ }
1878
+ }), h.registerVisitor({
1879
+ from: "iconFilter",
1880
+ openTag: (t) => {
1881
+ const e = t.getParent(), o = {};
1882
+ e.operator = Rt.BuiltInOperatorNames.Icon, e.param = o, t.copyToObject(o, "iconId", Io), t.copyToObject(o, "iconSet", Oo);
1883
+ }
1884
+ }), h.registerVisitor({
1885
+ from: "top10",
1886
+ openTag: (t) => {
1887
+ const e = t.getParent(), o = {};
1888
+ e.operator = Rt.BuiltInOperatorNames.TopN, e.param = o, t.copyToObject(o, "filterVal", Po), t.copyToObject(o, "percent", Eo), t.copyToObject(o, "top", Eo), t.copyToObject(o, "limit", Po, "val");
1889
+ }
1890
+ }), h.registerVisitor({
1891
+ from: "dynamicFilter",
1892
+ openTag: (t) => {
1893
+ const e = t.getParent(), o = L(t.getAttribute("type"), t.getAttribute("val"), t.getAttribute("maxVal"));
1894
+ e.operator = o.operator, e.param = o.param;
1895
+ }
1896
+ });
1897
+ const C = {
1898
+ from: "filters",
1899
+ to: {},
1900
+ openTag: (t) => {
1901
+ const e = t.getParent(), o = {};
1902
+ return e.selector = Rt.BuiltInSelectorNames.Display, e.operator = Rt.BuiltInOperatorNames.InSet, e.param = o, t.copyToObject(o, "blank", Eo), t.copyToObject(o, "calendarType", Oo), o;
1903
+ }
1904
+ };
1905
+ h.registerVisitor(C);
1906
+ const A = {
1907
+ from: "filter",
1908
+ openTag: (t) => {
1909
+ const e = t.getParent();
1910
+ let o = e.items;
1911
+ o || (o = [], e.items = o), o.push(t.getAttribute("val", Oo));
1912
+ }
1913
+ };
1914
+ h.registerVisitor(A);
1915
+ const k = {
1916
+ from: "dateGroupItem",
1917
+ to: {},
1918
+ openTag: (t) => {
1919
+ const e = t.getParent();
1920
+ let o = e.dateGroups;
1921
+ o || (o = [], e.dateGroups = o), o.push(t.getSource()), t.copyTo("group", Oo, "dateTimeGrouping"), t.copyTo("day", Io), t.copyTo("hour", Io), t.copyTo("minute", Io), t.copyTo("month", Io), t.copyTo("second", Io), t.copyTo("year", Io);
1922
+ }
1923
+ };
1924
+ h.registerVisitor(k);
1925
+ const I = /* @__PURE__ */ new Map();
1926
+ I.set("filterColumn", {
1927
+ from: "filterColumn",
1928
+ transparent: !0
1929
+ }), I.set("filters", C), I.set("filter", A), I.set("dateGroupItem", k), h.registerVisitor({
1930
+ from: "customFilters",
1931
+ openTag: (t) => {
1932
+ const e = t.getParent(), o = t.getAttribute("and"), s = "and" === o || "1" === o, r = [];
1933
+ return e.operator = s ? Rt.BuiltInOperatorNames.And : Rt.BuiltInOperatorNames.Or, e.param = r, t.setSource(e), r;
1934
+ },
1935
+ closeTag: (t) => {
1936
+ const e = t.getSource(), o = e?.param;
1937
+ if (!e || !o) return;
1938
+ const s = 1 === o.length ? o[0] : lt(e);
1939
+ s !== e && (e.operator = s.operator, e.param = s.param);
1940
+ }
1941
+ }), h.registerVisitor({
1942
+ from: "customFilter",
1943
+ openTag: (t) => {
1944
+ const e = t.getParent();
1945
+ let o;
1946
+ Array.isArray(e) ? (o = {}, e.push(o)) : o = e;
1947
+ const s = ut({
1948
+ operator: t.getAttribute("operator"),
1949
+ val: t.getAttribute("val")
1950
+ }, (e) => t.warn(e));
1951
+ s && (o.operator = s.operator, o.param = s.param);
1952
+ }
1953
+ });
1954
+ let P = {}, O = null;
1955
+ h.registerVisitor({
1956
+ from: "sortState",
1957
+ to: {},
1958
+ openTag: (t) => {
1959
+ const e = t.getParent();
1960
+ let o = e.v;
1961
+ if (!o) return;
1962
+ const s = {};
1963
+ P = {};
1964
+ const r = t.getAttribute("caseSensitive", Eo);
1965
+ null != r && (P.collatorOptions = r ? Kt.CaseSensitiveOptions : Kt.CaseInsensitiveOptions);
1966
+ const n = t.getAttribute("sortMethod");
1967
+ "stroke" !== n && "pinYin" !== n || (P.collatorOptions = {
1968
+ ...P.collatorOptions,
1969
+ collation: "stroke" === n ? "stroke" : "pinyin"
1970
+ }), t.getAttribute("columnSort", Eo) && (s.axis = Bt.Axis.Column);
1971
+ const i = t.getAttribute("ref"), l = e.r;
1972
+ O = i && l ? It.fastStringToRange(i) : null, O && (s.extent = { range: a(l, O) }), o.sort = s, t.setSource(e);
1973
+ }
1974
+ }), h.registerVisitor({
1975
+ from: "sortCondition",
1976
+ to: {},
1977
+ openTag: (t) => {
1978
+ const e = t.getParent(), o = e.v;
1979
+ if (!o) return;
1980
+ const s = o.sort;
1981
+ if (!s) return;
1982
+ let r = s.sorts;
1983
+ r || (r = [], s.sorts = r);
1984
+ const n = t.getAttribute("ref");
1985
+ let i = 0, a = null;
1986
+ if (n) {
1987
+ const t = It.fastStringToRange(n, ds), o = t.colStart, s = e.r, r = s.colStart;
1988
+ i = s ? o - r : o, s && O && (a = E(s, O, t));
1989
+ }
1990
+ s.extent && (s.extent.sorts ??= []).push(a);
1991
+ const l = { ...P }, c = B(t.getAttribute("sortBy"));
1992
+ c && (l.sortOn = c);
1993
+ const h = u(t);
1994
+ h && (l.style = h), t.copyToObject(l, "iconSet", Oo), t.copyToObject(l, "customList", Oo), l.reverse = t.getAttribute("descending", Eo) ?? !1;
1995
+ const d = {
1996
+ index: i,
1997
+ criteria: l
1998
+ };
1999
+ r.push(d);
2000
+ }
2001
+ });
2002
+ const D = (t) => {
2003
+ x = t.getSource(), T = "topLeft", t.copyTo("topLeft", Oo, "topLeftCell");
2004
+ const e = f(t.getAttribute("defaultGridColor")), o = t.getAttribute("colorId");
2005
+ null === o || e || (t.getSource().gridLineColor = "index" + parseFloat(o)), t.copyTo("showZeros", Eo), t.copyTo("showFormulas", Eo), t.copyTo("zoomScale", Io), t.copyTo("viewMode", Oo, "view");
2006
+ const s = {};
2007
+ for (const [e, o] of rt) {
2008
+ const r = t.getAttribute(o, Io);
2009
+ r && (s[e] = Math.min(400, Math.max(10, r)));
2010
+ }
2011
+ Object.keys(s).length > 0 && (t.getSource().zoomScales = s), t.copyTo("showRuler", Eo), t.copyTo("showWhitespace", Eo, "showWhiteSpace"), t.copyTo("windowProtection", Eo), t.copyTo("showRowHeaders", Eo, "showRowColHeaders"), t.copyTo("showColumnHeaders", Eo, "showRowColHeaders"), t.copyTo("showRowGridlines", Eo, "showGridLines"), t.copyTo("showColumnGridlines", Eo, "showGridLines"), t.copyTo("rightToLeft", Eo), t.copyTo("showOutlineSymbols", Eo);
2012
+ };
2013
+ h.registerVisitor({
2014
+ from: "sheetView",
2015
+ to: "view",
2016
+ openTag: (t) => {
2017
+ D(t);
2018
+ },
2019
+ closeTag: () => {
2020
+ x = null;
2021
+ }
2022
+ }), h.registerVisitor({
2023
+ from: "customSheetViews",
2024
+ to: "customSheetViews",
2025
+ openTag: (t) => {
2026
+ t.setSource([]);
2027
+ }
2028
+ }), h.registerVisitor({
2029
+ from: "customSheetView",
2030
+ to: [],
2031
+ openTag: (t) => {
2032
+ N = !0, D(t);
2033
+ },
2034
+ closeTag: () => {
2035
+ N = !1, x = null;
2036
+ }
2037
+ }), h.registerVisitor({
2038
+ from: "selection",
2039
+ to: null,
2040
+ openTag: (t) => {
2041
+ if (!x) return;
2042
+ const e = t.getAttribute("activeCell")?.replace(/\$/g, ""), o = t.getAttribute("sqref")?.replace(/\$/g, ""), s = t.getAttribute("pane") ?? "topLeft";
2043
+ if (s !== T) {
2044
+ const t = x.freezePanes;
2045
+ if (t && e) {
2046
+ const r = { activeCell: e };
2047
+ o && o !== e && (r.sqref = o), (t.paneSelections ??= {})[s] = r;
2048
+ }
2049
+ return;
2050
+ }
2051
+ const r = {};
2052
+ e && (r.cell = e);
2053
+ const n = t.getAttribute("activeCellId", Io);
2054
+ null !== n && (r.rangeIndex = n), o && o !== e && (r.ranges = o.trim().split(/\s+/)), x.selection = r;
2055
+ }
2056
+ }), h.registerVisitor({
2057
+ from: "pane",
2058
+ to: null,
2059
+ openTag: (t) => {
2060
+ if (!x) return;
2061
+ T = t.getAttribute("activePane") ?? "topLeft";
2062
+ const e = t.getAttribute("state");
2063
+ if ("frozen" === e || "frozenSplit" === e) {
2064
+ const e = {};
2065
+ x.freezePanes = e, t.copyToObject(e, "topLeft", Oo, "topLeftCell");
2066
+ const o = (x.topLeft ? It.fastStringToCell(x.topLeft) : void 0) ?? {
2067
+ colIndex: 0,
2068
+ rowIndex: 0
2069
+ }, s = {
2070
+ colIndex: 0,
2071
+ rowIndex: 0
2072
+ };
2073
+ t.copyToObject(s, "colIndex", Io, "xSplit"), t.copyToObject(s, "rowIndex", Io, "ySplit");
2074
+ const r = {
2075
+ colIndex: o.colIndex + s.colIndex,
2076
+ rowIndex: o.rowIndex + s.rowIndex
2077
+ };
2078
+ e.coords = It.cellToString(r);
2079
+ }
2080
+ }
2081
+ }), h.registerVisitor({
2082
+ from: "sheetPr",
2083
+ transparent: !0,
2084
+ openTag: (t) => {
2085
+ const o = t.getAttribute("codeName");
2086
+ o && (e.codeName = o), !1 === t.getAttribute("enableFormatConditionsCalculation", Eo) && (e.conditionalFormatCalculation = !1), !0 === t.getAttribute("transitionEvaluation", Eo) && (e.transitionFormulaEvaluation = !0), !0 === t.getAttribute("transitionEntry", Eo) && (e.transitionFormulaEntry = !0), !1 === t.getAttribute("published", Eo) && (e.excludeFromPublishing = !0);
2087
+ const s = {};
2088
+ !0 === t.getAttribute("syncHorizontal", Eo) && (s.horizontal = !0), !0 === t.getAttribute("syncVertical", Eo) && (s.vertical = !0);
2089
+ const r = t.getAttribute("syncRef");
2090
+ r && (s.anchor = r), Object.keys(s).length > 0 && (e.syncScroll = s);
2091
+ }
2092
+ }), h.registerVisitor({
2093
+ from: "tabColor",
2094
+ to: null,
2095
+ openTag: (t) => {
2096
+ const o = pt((e) => t.getAttribute(e));
2097
+ o && (e.tabColor = o);
2098
+ }
2099
+ });
2100
+ let N = !1;
2101
+ const $ = () => e.pageLayout ??= {};
2102
+ h.registerVisitor({
2103
+ from: "pageSetUpPr",
2104
+ to: null,
2105
+ openTag: (t) => {
2106
+ !0 === t.getAttribute("fitToPage", Eo) && ($().fitToPage = !0), !1 === t.getAttribute("autoPageBreaks", Eo) && ($().hideAutoPageBreaks = !0);
2107
+ }
2108
+ }), h.registerVisitor({
2109
+ from: "outlinePr",
2110
+ to: null,
2111
+ openTag: (t) => {
2112
+ const o = (e) => {
2113
+ const o = t.getAttribute(e);
2114
+ return "0" === o || "false" === o;
2115
+ }, s = {};
2116
+ o("summaryBelow") && (s.summaryRow = "up"), o("summaryRight") && (s.summaryColumn = "left"), ((e) => {
2117
+ const o = t.getAttribute(e);
2118
+ return "1" === o || "true" === o;
2119
+ })("applyStyles") && (s.automaticStyles = !0), Object.keys(s).length > 0 && (e.outline = s);
2120
+ }
2121
+ }), h.registerVisitor({
2122
+ from: "pageMargins",
2123
+ to: null,
2124
+ openTag: (t) => {
2125
+ if (N) return;
2126
+ const e = (e, o) => t.getAttribute(e, Po) ?? o, o = {
2127
+ left: e("left", .7),
2128
+ right: e("right", .7),
2129
+ top: e("top", .75),
2130
+ bottom: e("bottom", .75),
2131
+ header: e("header", .3),
2132
+ footer: e("footer", .3)
2133
+ };
2134
+ .7 === o.left && .7 === o.right && .75 === o.top && .75 === o.bottom && .3 === o.header && .3 === o.footer || ($().margins = o);
2135
+ }
2136
+ }), h.registerVisitor({
2137
+ from: "pageSetup",
2138
+ to: null,
2139
+ openTag: (t) => {
2140
+ if (N) return;
2141
+ const e = $(), s = (e) => t.getAttribute(e, Io) ?? void 0, r = (e) => t.getAttribute(e, Eo), n = t.getAttribute("orientation");
2142
+ "landscape" !== n && "portrait" !== n || (e.orientation = n);
2143
+ for (const t of [
2144
+ "paperSize",
2145
+ "scale",
2146
+ "fitToWidth",
2147
+ "fitToHeight",
2148
+ "firstPageNumber",
2149
+ "horizontalDpi",
2150
+ "verticalDpi",
2151
+ "copies"
2152
+ ]) {
2153
+ const o = s(t);
2154
+ void 0 !== o && (e[t] = o);
2155
+ }
2156
+ const i = t.getAttribute("paperHeight");
2157
+ i && (e.paperHeight = i);
2158
+ const a = t.getAttribute("paperWidth");
2159
+ a && (e.paperWidth = a), "overThenDown" === t.getAttribute("pageOrder") && (e.printOrder = "overThenDown"), !0 === r("blackAndWhite") && (e.blackAndWhite = !0), !0 === r("draft") && (e.draftMode = !0), !0 === r("useFirstPageNumber") && (e.useFirstPageNumber = !0), !1 === r("usePrinterDefaults") && (e.ignorePrinterDefaults = !0);
2160
+ const l = t.getAttribute("cellComments"), c = ct.find(([t]) => t === l)?.[1];
2161
+ c && (e.printComments = c);
2162
+ const h = t.getAttribute("errors"), u = H.find(([t]) => t === h)?.[1];
2163
+ u && (e.printErrors = u);
2164
+ const d = t.getAttribute("r:id"), p = d ? o(d, "part") : null;
2165
+ p && (e.printerSettings = p);
2166
+ }
2167
+ }), h.registerVisitor({
2168
+ from: "printOptions",
2169
+ to: null,
2170
+ openTag: (t) => {
2171
+ if (N) return;
2172
+ const e = (e) => !0 === t.getAttribute(e, Eo);
2173
+ e("horizontalCentered") && ($().centerHorizontally = !0), e("verticalCentered") && ($().centerVertically = !0), e("gridLines") && ($().printGridlines = !0), e("headings") && ($().printHeadings = !0);
2174
+ }
2175
+ }), h.registerVisitor({
2176
+ from: "headerFooter",
2177
+ to: {},
2178
+ openTag: (t) => {
2179
+ if (N) return;
2180
+ const e = {}, o = (e) => t.getAttribute(e, Eo);
2181
+ !0 === o("differentOddEven") && (e.differentOddEven = !0), !0 === o("differentFirst") && (e.differentFirst = !0), !1 === o("scaleWithDoc") && (e.ignoreSheetScale = !0), !1 === o("alignWithMargins") && (e.ignoreSheetMargins = !0), Object.keys(e).length > 0 && ($().headerFooter = e);
2182
+ }
2183
+ });
2184
+ for (const t of gt) h.registerVisitor({
2185
+ from: t,
2186
+ to: {},
2187
+ text: (e, o) => {
2188
+ if (N) return;
2189
+ const s = $(), r = s.headerFooter ??= {};
2190
+ r[t] = (r[t] ?? "") + v(e);
2191
+ }
2192
+ });
2193
+ let R = "rowBreaks";
2194
+ for (const [t, e] of [["rowBreaks", "rowBreaks"], ["colBreaks", "columnBreaks"]]) h.registerVisitor({
2195
+ from: t,
2196
+ to: {},
2197
+ openTag: () => {
2198
+ R = e;
2199
+ }
2200
+ });
2201
+ h.registerVisitor({
2202
+ from: "brk",
2203
+ to: null,
2204
+ openTag: (t) => {
2205
+ if (N) return;
2206
+ const e = t.getAttribute("id", Io);
2207
+ if (null == e) return;
2208
+ const o = { index: e }, s = t.getAttribute("min", Io);
2209
+ null != s && (o.min = s);
2210
+ const r = t.getAttribute("max", Io);
2211
+ null != r && (o.max = r), !0 !== t.getAttribute("man", Eo) && (o.automatic = !0), !0 === t.getAttribute("pt", Eo) && (o.pivot = !0);
2212
+ const n = $();
2213
+ (n[R] ??= []).push(o);
2214
+ }
2215
+ }), h.registerVisitor({
2216
+ from: "ignoredErrors",
2217
+ transparent: !0
2218
+ }), h.registerVisitor({
2219
+ from: "ignoredError",
2220
+ to: null,
2221
+ openTag: (t) => {
2222
+ const o = t.getAttribute("sqref");
2223
+ if (!o) return;
2224
+ const s = [];
2225
+ for (const e of Tt) !0 === t.getAttribute(e, Eo) && s.push(e);
2226
+ if (0 !== s.length) for (const t of o.trim().split(/\s+/)) (e.ignoredErrors ??= []).push({
2227
+ r: t,
2228
+ v: s
2229
+ });
2230
+ }
2231
+ }), h.registerVisitor({
2232
+ from: "mergeCells",
2233
+ to: "merges",
2234
+ openTag: (t) => {
2235
+ t.setSource([]);
2236
+ }
2237
+ }), h.registerVisitor({
2238
+ from: "dataValidations",
2239
+ to: "validations",
2240
+ openTag: (t) => {
2241
+ t.setSource([]);
2242
+ const o = {};
2243
+ !0 === t.getAttribute("disablePrompts", Eo) && (o.disablePrompts = !0);
2244
+ const s = t.getAttribute("xWindow", Io);
2245
+ null !== s && (o.windowX = s);
2246
+ const r = t.getAttribute("yWindow", Io);
2247
+ null !== r && (o.windowY = r), Object.keys(o).length > 0 && (e.validationSettings = {
2248
+ ...e.validationSettings,
2249
+ ...o
2250
+ });
2251
+ }
2252
+ });
2253
+ const j = {
2254
+ from: "dataValidation",
2255
+ to: [],
2256
+ openTag: (t) => {
2257
+ let e = t.getAttribute("sqref");
2258
+ e && (e = e.trim().split(/\s+/).join(","));
2259
+ const o = {}, s = {
2260
+ r: e,
2261
+ v: o,
2262
+ rule: {
2263
+ type: t.getAttribute("type") ?? void 0,
2264
+ operator: t.getAttribute("operator") ?? void 0
2265
+ }
2266
+ };
2267
+ !0 === t.getAttribute("showDropDown", Eo) && (o.hideDropdown = !0), t.copyToObject(o, "alert", Oo, "error"), t.copyToObject(o, "alertTitle", Oo, "errorTitle"), t.copyToObject(o, "showAlertMessage", Eo, "showErrorMessage"), o.alertStyle = t.getAttribute("errorStyle") ?? "stop", t.copyToObject(o, "imeMode"), t.copyToObject(o, "prompt"), t.copyToObject(o, "promptTitle"), t.copyToObject(o, "showPromptMessage", Eo, "showInputMessage"), t.setSource(s);
2268
+ },
2269
+ closeTag: (t) => {
2270
+ const e = t.getSource();
2271
+ if (!e?.rule) return;
2272
+ const o = q(e.rule, i);
2273
+ o && (t.getAttribute("allowBlank", Eo) && (o.includeBlanks = !0), e.v.condition = o), delete e.rule;
2274
+ }
2275
+ };
2276
+ h.registerVisitor(j), h.registerVisitor({
2277
+ from: "formula1",
2278
+ to: {},
2279
+ text: (t, e) => {
2280
+ const o = e.getParent().rule;
2281
+ o?.type && (o.formula1 = y(m(t), o.type));
2282
+ }
2283
+ }), h.registerVisitor({
2284
+ from: "formula2",
2285
+ to: {},
2286
+ text: (t, e) => {
2287
+ const o = e.getParent().rule;
2288
+ o?.type && (o.formula2 = y(m(t), o.type));
2289
+ }
2290
+ }), h.registerVisitor({
2291
+ from: "picture",
2292
+ to: "picture",
2293
+ openTag: (t) => {
2294
+ const e = t.getAttribute("r:id");
2295
+ if (!e) return void t.warn("A picture names no image; it was not imported.", { onceKey: "xlsx.sheet.picture.noRel" });
2296
+ const s = o(e, "resource");
2297
+ t.getSource().resId = s;
2298
+ }
2299
+ });
2300
+ const W = {
2301
+ from: "slicer",
2302
+ to: {},
2303
+ openTag: (t) => {
2304
+ const e = t.getAttribute("r:id");
2305
+ if (!e) return void t.warn("A slicer names no cache; it was not imported.", { onceKey: "xlsx.sheet.slicer.noRel" });
2306
+ const s = o(e)?.slicers, r = t.getParent();
2307
+ r.slicers || (r.slicers = {});
2308
+ const n = Object.keys(s);
2309
+ for (const t of n) r.slicers[t] = s[t];
2310
+ }
2311
+ };
2312
+ h.registerVisitor(W);
2313
+ const U = {
2314
+ from: "timelineRef",
2315
+ to: {},
2316
+ openTag: (t) => {
2317
+ const e = t.getAttribute("r:id"), s = e ? o(e)?.slicers : void 0;
2318
+ if (!s) return void t.warn("A timeline names no part; it was not imported.", { onceKey: "xlsx.sheet.timeline.noRel" });
2319
+ const r = t.getParent();
2320
+ r.slicers ??= {};
2321
+ for (const t of Object.keys(s)) r.slicers[t] = s[t];
2322
+ }
2323
+ }, J = (t, e) => ({
2324
+ from: t,
2325
+ to: {},
2326
+ openTag: (t) => {
2327
+ t.setSource("");
2328
+ },
2329
+ text: (t, e) => {
2330
+ e.setSource((e.getSource() ?? "") + t);
2331
+ },
2332
+ closeTag: (t) => {
2333
+ e(String(t.getSource() ?? ""), t);
2334
+ }
2335
+ }), Q = /* @__PURE__ */ new Map();
2336
+ Q.set("dataValidations", {
2337
+ from: "dataValidations",
2338
+ to: "validations",
2339
+ openTag: (t) => {
2340
+ const e = t.getParent();
2341
+ t.setSource(e.validations ?? []);
2342
+ },
2343
+ closeTag: (t) => {
2344
+ 0 === (t.getSource()?.length ?? 0) && t.setSource(void 0);
2345
+ }
2346
+ }), Q.set("dataValidation", {
2347
+ ...j,
2348
+ closeTag: (t) => {
2349
+ j.closeTag(t);
2350
+ const e = t.getSource();
2351
+ e && !e.r && (t.warn("x14 dataValidation with no xm:sqref was dropped."), t.setSource(void 0));
2352
+ }
2353
+ });
2354
+ const tt = (t) => ({
2355
+ from: t,
2356
+ to: {},
2357
+ openTag: (e) => {
2358
+ e.setSource({
2359
+ rule: e.getParent()?.rule,
2360
+ key: t
2361
+ });
2362
+ }
2363
+ });
2364
+ Q.set("formula1", tt("formula1")), Q.set("formula2", tt("formula2")), Q.set("f", J("f", (t, e) => {
2365
+ const o = e.getParent(), s = o?.rule;
2366
+ s && (s[o.key] = y(m(t), s.type));
2367
+ })), Q.set("sqref", J("sqref", (t, e) => {
2368
+ const o = e.getParent(), s = t.trim();
2369
+ o && s && (o.r = s.split(/\s+/).join(","));
2370
+ }));
2371
+ const et = /* @__PURE__ */ new Map(), ot = [], st = /* @__PURE__ */ new Map();
2372
+ st.set("conditionalFormattings", {
2373
+ from: "conditionalFormattings",
2374
+ transparent: !0
2375
+ }), st.set("conditionalFormatting", {
2376
+ from: "conditionalFormatting",
2377
+ to: {},
2378
+ openTag: (t) => {
2379
+ t.setSource({ rules: [] });
2380
+ },
2381
+ closeTag: (t) => {
2382
+ const e = t.getSource(), o = e?.rules ?? [];
2383
+ for (let t = 0; t < o.length; t++) {
2384
+ const s = o[t];
2385
+ s.sqref = e.sqref, s.id ? et.set(s.id, s) : ot.push(s);
2386
+ }
2387
+ }
2388
+ }), st.set("cfRule", {
2389
+ from: "cfRule",
2390
+ to: {},
2391
+ openTag: (t) => {
2392
+ t.copyTo("id", Oo), t.copyTo("type", Oo), t.copyTo("priority", Io), t.copyTo("stopIfTrue", Eo), t.copyTo("operator", Oo), t.copyTo("text", Oo), t.copyTo("timePeriod", Oo), t.copyTo("aboveAverage", Eo), t.copyTo("equalAverage", Eo), t.copyTo("stdDev", Io), t.copyTo("bottom", Eo), t.copyTo("percent", Eo), t.copyTo("rank", Io);
2393
+ },
2394
+ closeTag: (t) => {
2395
+ const e = t.getSource();
2396
+ e && t.getParent()?.rules?.push(e);
2397
+ }
2398
+ }), st.set("sqref", J("sqref", (t, e) => {
2399
+ const o = e.getParent(), s = t.trim();
2400
+ o && s && (o.sqref = s);
2401
+ })), st.set("dataBar", {
2402
+ from: "dataBar",
2403
+ to: {},
2404
+ openTag: (t) => {
2405
+ t.copyTo("minLength", Io), t.copyTo("maxLength", Io), t.copyTo("gradient", Eo), t.copyTo("border", Eo), t.copyTo("direction", Oo), t.copyTo("axisPosition", Oo), t.copyTo("negativeBarColorSameAsPositive", Eo), t.copyTo("negativeBarBorderColorSameAsPositive", Eo);
2406
+ },
2407
+ closeTag: (t) => {
2408
+ t.getParent().dataBar = t.getSource();
2409
+ }
2410
+ }), st.set("iconSet", {
2411
+ from: "iconSet",
2412
+ to: {},
2413
+ openTag: (t) => {
2414
+ t.copyTo("iconSet", Oo), t.copyTo("custom", Eo), t.copyTo("reverse", Eo), t.copyTo("showValue", Eo);
2415
+ },
2416
+ closeTag: (t) => {
2417
+ t.getParent().iconSet = t.getSource();
2418
+ }
2419
+ });
2420
+ const nt = /* @__PURE__ */ new Map();
2421
+ nt.set("f", J("f", (t, e) => {
2422
+ const o = e.getParent();
2423
+ if (!o) return;
2424
+ const s = t.trim(), r = Number(s);
2425
+ o.value = s.length > 0 && Number.isFinite(r) ? r : m(t);
2426
+ })), st.set("cfvo", {
2427
+ from: "cfvo",
2428
+ to: {},
2429
+ scope: () => nt,
2430
+ openTag: (t) => {
2431
+ const e = t.getParent();
2432
+ e.conditions || (e.conditions = []);
2433
+ const o = t.getSource();
2434
+ e.conditions.push(o), t.copyTo("type", Oo), !1 === t.getAttribute("gte", Eo) && (o.exclusive = !0);
2435
+ }
2436
+ }), st.set("f", J("f", (t, e) => {
2437
+ const o = e.getParent();
2438
+ o && (o.formulas ??= []).push(m(t));
2439
+ })), st.set("dxf", {
2440
+ from: "dxf",
2441
+ to: {},
2442
+ raw: !0,
2443
+ closeTag: (t) => {
2444
+ if (!p) return;
2445
+ const e = t.getParent();
2446
+ if (!e) return;
2447
+ const o = p(t.getRawXml() ?? "");
2448
+ o && (e.style = o);
2449
+ }
2450
+ });
2451
+ const at = (t) => ({
2452
+ from: t,
2453
+ to: {},
2454
+ openTag: (e) => {
2455
+ const o = pt((t) => e.getAttribute(t));
2456
+ o && (e.getParent()[t] = o);
2457
+ }
2458
+ });
2459
+ st.set("borderColor", at("borderColor")), st.set("negativeFillColor", at("negativeFillColor")), st.set("negativeBorderColor", at("negativeBorderColor")), st.set("axisColor", at("axisColor")), st.set("cfIcon", {
2460
+ from: "cfIcon",
2461
+ to: {},
2462
+ openTag: (t) => {
2463
+ const e = t.getAttribute("iconSet"), o = t.getAttribute("iconId", Io);
2464
+ if (null === e || null === o) return;
2465
+ const s = t.getParent();
2466
+ s.icons || (s.icons = []), s.icons.push({
2467
+ set: e,
2468
+ id: o
2469
+ });
2470
+ }
2471
+ });
2472
+ const ht = /* @__PURE__ */ new Map();
2473
+ ht.set("id", J("id", (t, e) => {
2474
+ const o = e.getParent(), s = t.trim();
2475
+ o && s && (o.x14Id = s);
2476
+ }));
2477
+ const ft = /* @__PURE__ */ new Map();
2478
+ ft.set("slicerList", {
2479
+ from: "slicerList",
2480
+ transparent: !0
2481
+ }), ft.set("slicer", W);
2482
+ const mt = /* @__PURE__ */ new Map();
2483
+ mt.set("timelineRefs", {
2484
+ from: "timelineRefs",
2485
+ transparent: !0
2486
+ }), mt.set("timelineRef", U);
2487
+ const vt = /* @__PURE__ */ new Map([
2488
+ [Z(X), Q],
2489
+ [Z(w), st],
2490
+ [Z(t), st],
2491
+ [Z(_), ht],
2492
+ [Z(Y), ft],
2493
+ [Z(V), ft],
2494
+ [Z(F), mt],
2495
+ [Z(bt), I]
2496
+ ]), xt = /* @__PURE__ */ new Set();
2497
+ h.registerVisitor({
2498
+ from: "extLst",
2499
+ transparent: !0
2500
+ }), h.registerVisitor({
2501
+ from: "ext",
2502
+ transparent: !0,
2503
+ scope: (t) => {
2504
+ const e = t.getAttribute("uri"), o = Z(e), s = vt.get(o);
2505
+ if (s) return s;
2506
+ if (!K.has(o) && !xt.has(o)) {
2507
+ xt.add(o);
2508
+ const s = dt[o];
2509
+ t.warn(s ? `Extension content '${s}' (${e}) is not read; it will be lost on resave.` : `Unknown extension content (uri ${e}) is not read; it will be lost on resave.`);
2510
+ }
2511
+ return null;
2512
+ }
2513
+ }), h.registerVisitor({
2514
+ from: "mergeCell",
2515
+ to: [],
2516
+ openTag: (t) => {
2517
+ const e = t.getAttribute("ref");
2518
+ t.setSource(e);
2519
+ }
2520
+ }), h.registerVisitor({
2521
+ from: "hyperlinks",
2522
+ to: "hyperlinks",
2523
+ openTag: (t) => {
2524
+ t.setSource([]);
2525
+ }
2526
+ }), h.registerVisitor({
2527
+ from: "hyperlink",
2528
+ to: [],
2529
+ openTag: (t) => {
2530
+ const e = t.getAttribute("r:id"), s = t.getAttribute("ref");
2531
+ if (!s) return void t.warn("A hyperlink has no ref; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.noRef" });
2532
+ t.setKey(s);
2533
+ let r = e ? o(e) : "";
2534
+ if ("string" != typeof r) return void t.warn("A hyperlink has an invalid address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2535
+ r.endsWith("\\") && (r = r.substring(0, r.length - 1));
2536
+ const n = t.getAttribute("location");
2537
+ if (n && (r += "#" + n), !r) return void t.warn("A hyperlink has no address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2538
+ let i;
2539
+ const a = t.getAttribute("tooltip"), l = t.getAttribute("display");
2540
+ a || l ? (i = { address: r }, a && (i.screenTip = a), l && (i.display = l)) : i = r, t.setSource({
2541
+ r: s,
2542
+ v: i
2543
+ });
2544
+ }
2545
+ }), h.registerVisitor({
2546
+ from: "drawing",
2547
+ to: "movables",
2548
+ openTag: (t) => {
2549
+ const e = t.getAttribute("r:id");
2550
+ if (!e) return;
2551
+ const s = o(e);
2552
+ s ? t.setSource(s.movables) : t.warn("A drawing part is missing; its shapes were not imported.", { onceKey: "xlsx.sheet.drawing.missing" });
2553
+ }
2554
+ }), h.registerVisitor({
2555
+ from: "legacyDrawing",
2556
+ to: "legacyDrawing",
2557
+ openTag: (t) => {
2558
+ t.setSource(o(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2559
+ }
2560
+ }), h.registerVisitor({
2561
+ from: "legacyDrawingHF",
2562
+ to: "legacyDrawingHF",
2563
+ openTag: (t) => {
2564
+ t.setSource(o(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2565
+ }
2566
+ });
2567
+ let yt = null, wt = !1;
2568
+ const St = /* @__PURE__ */ new Map(), Ct = {
2569
+ from: "Fallback",
2570
+ to: null
2571
+ }, At = {
2572
+ from: "Choice",
2573
+ transparent: !0
2574
+ };
2575
+ St.set("Fallback", Ct), St.set("Choice", At), St.set("control", {
2576
+ from: "control",
2577
+ transparent: !0,
2578
+ openTag: (t) => {
2579
+ const e = t.getAttribute("name"), s = t.getAttribute("r:id"), r = s ? o(s, "formControl") : null;
2580
+ if (!r) return t.warn(`The form control '${e ?? ""}' has no properties and was not read.`, { onceKey: "xlsx.sheet.control.noProperties" }), void (yt = null);
2581
+ const n = r.json, i = parseInt(t.getAttribute("shapeId") ?? "", 10);
2582
+ isNaN(i) || (n.shapeId = i);
2583
+ const a = {
2584
+ anchor: {
2585
+ tl: {
2586
+ c: 0,
2587
+ r: 0,
2588
+ x: 0,
2589
+ y: 0
2590
+ },
2591
+ br: {
2592
+ c: 0,
2593
+ r: 0,
2594
+ x: 0,
2595
+ y: 0
2596
+ }
2597
+ },
2598
+ content: {
2599
+ type: r.type,
2600
+ json: n
2601
+ }
2602
+ };
2603
+ e && (a.content.name = e), yt = {
2604
+ movable: a,
2605
+ control: n
2606
+ };
2607
+ },
2608
+ closeTag: () => {
2609
+ yt && (e.movables || (e.movables = []), e.movables.push(yt.movable), yt = null);
2610
+ }
2611
+ }), St.set("controlPr", {
2612
+ from: "controlPr",
2613
+ transparent: !0,
2614
+ raw: !0,
2615
+ openTag: (t) => {
2616
+ if (!yt) return;
2617
+ const e = t.getFrom().attributes ?? {}, o = {};
2618
+ for (const t in e) {
2619
+ const s = e[t];
2620
+ o[t] = "string" == typeof s ? s : s?.value ?? "";
2621
+ }
2622
+ M(o, yt.control);
2623
+ },
2624
+ closeTag: (t) => {
2625
+ if (!yt) return;
2626
+ const e = ((t) => {
2627
+ const e = /<(?:[\w.-]+:)?anchor\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?anchor>/.exec(t);
2628
+ if (!e) return null;
2629
+ const o = e[2], s = (t) => new RegExp(`<(?:[\\w.-]+:)?${t}\\b[^>]*>([\\s\\S]*?)<\\/(?:[\\w.-]+:)?${t}>`).exec(o)?.[1], r = e[1], n = /\bmoveWithCells="(?:1|true)"/.test(r), i = /\bsizeWithCells="(?:1|true)"/.test(r);
2630
+ return {
2631
+ anchor: {
2632
+ tl: os(s("from")),
2633
+ br: os(s("to"))
2634
+ },
2635
+ anchorType: n ? i ? "twoCell" : "oneCell" : "absolute",
2636
+ rest: (t.slice(0, e.index) + t.slice(e.index + e[0].length)).trim()
2637
+ };
2638
+ })(t.getRawXml() ?? "");
2639
+ e ? (yt.movable.anchor = e.anchor, "twoCell" !== e.anchorType && (yt.movable.anchorType = e.anchorType), e.rest && (yt.control.xml = e.rest)) : wt || (wt = !0, t.warn("A form control has no anchor; it is placed at the top left of the sheet."));
2640
+ }
2641
+ });
2642
+ const kt = {
2643
+ from: "controls",
2644
+ transparent: !0,
2645
+ scope: () => St
2646
+ };
2647
+ h.registerVisitor(kt);
2648
+ const Et = /* @__PURE__ */ new Map([
2649
+ ["Choice", At],
2650
+ ["Fallback", Ct],
2651
+ ["controls", kt]
2652
+ ]);
2653
+ h.registerVisitor({
2654
+ from: "AlternateContent",
2655
+ transparent: !0,
2656
+ scope: () => Et
2657
+ }), h.registerVisitor({
2658
+ from: "tableParts",
2659
+ to: "tables",
2660
+ openTag: (t) => {
2661
+ t.setSource([]);
2662
+ }
2663
+ }), h.registerVisitor({
2664
+ from: "tablePart",
2665
+ to: [],
2666
+ openTag: (t) => {
2667
+ const e = t.getAttribute("r:id");
2668
+ if (!e) return;
2669
+ const s = o(e);
2670
+ s ? t.setSource(s) : t.warn("A table part is missing; the table was not imported.", { onceKey: "xlsx.sheet.table.missing" });
2671
+ }
2672
+ });
2673
+ const Pt = (t, e) => {
2674
+ e.conditions?.length && (t.stops = S(e)), void 0 !== e.minLength && (t.minLength = e.minLength), void 0 !== e.maxLength && (t.maxLength = e.maxLength), (e.gradient ?? 1) && (t.gradient = !0), e.border && e.borderColor && (t.borderColor = e.borderColor), !e.negativeBarColorSameAsPositive && e.negativeFillColor && (t.negativeFillColor = e.negativeFillColor), !(e.negativeBarBorderColorSameAsPositive ?? 1) && e.negativeBorderColor && (t.negativeBorderColor = e.negativeBorderColor), e.axisColor && (t.axisColor = e.axisColor), "middle" !== e.axisPosition && "none" !== e.axisPosition || (t.axisPosition = e.axisPosition), "leftToRight" !== e.direction && "rightToLeft" !== e.direction || (t.direction = e.direction);
2675
+ }, Ot = (t, e) => {
2676
+ e.conditions?.length && (t.stops = S(e)), e.iconSet && e.iconSet !== t.iconSet && (t.iconSet = e.iconSet), e.icons?.length && (t.icon = e.icons), void 0 !== e.reverse && (t.reverse = e.reverse), void 0 !== e.showValue && (t.showValue = e.showValue);
2677
+ }, Dt = (t) => {
2678
+ if (!t.sqref) return null;
2679
+ const e = t.sqref.split(/\s+/).join(",");
2680
+ if ("iconSet" === t.type) {
2681
+ if (!t.iconSet) return null;
2682
+ const o = {
2683
+ type: Lt.ScaleType.IconSet,
2684
+ stops: []
2685
+ };
2686
+ return Ot(o, t.iconSet), {
2687
+ r: e,
2688
+ v: { scale: o },
2689
+ priority: t.priority
2690
+ };
2691
+ }
2692
+ const o = it(t, i);
2693
+ if (!o) return null;
2694
+ const s = { condition: o };
2695
+ return t.style && (s.style = t.style), t.stopIfTrue && (s.stopIfTrue = !0), {
2696
+ r: e,
2697
+ v: s,
2698
+ priority: t.priority
2699
+ };
2700
+ };
2701
+ h.registerVisitor({
2702
+ from: "worksheet",
2703
+ to: {},
2704
+ openTag: (t) => {},
2705
+ closeTag: (t) => {
2706
+ const e = t.getSource();
2707
+ let o = e?.conditionals;
2708
+ if (o) for (let t = 0; t < o.length; t++) {
2709
+ const e = o[t], s = e.x14Id;
2710
+ if (!s) continue;
2711
+ delete e.x14Id;
2712
+ const r = et.get(s);
2713
+ if (!r) continue;
2714
+ et.delete(s);
2715
+ const n = e.v?.scale;
2716
+ r.dataBar && n?.type === Lt.ScaleType.DataBar ? Pt(n, r.dataBar) : r.iconSet && n?.type === Lt.ScaleType.IconSet && Ot(n, r.iconSet);
2717
+ }
2718
+ const s = [...et.values(), ...ot], r = /* @__PURE__ */ new Set();
2719
+ let n = 0;
2720
+ for (let t = 0; t < s.length; t++) {
2721
+ const i = Dt(s[t]);
2722
+ i ? (o || (o = [], e.conditionals = o), o.push(i)) : (r.add(s[t].type ?? "unknown"), n++);
2723
+ }
2724
+ if (n > 0) {
2725
+ const t = [...r].map((t) => `'${t}'`).join(", ");
2726
+ i?.(1 === n ? `An x14-only conditional formatting rule (type ${t}) is not read and will be lost on resave.` : `${n} x14-only conditional formatting rules (types ${t}) are not read and will be lost on resave.`);
2727
+ }
2728
+ if (o) {
2729
+ o.length > 1 && o.sort((t, e) => (t.priority ?? 1 / 0) - (e.priority ?? 1 / 0));
2730
+ for (let t = 0; t < o.length; t++) delete o[t].priority;
2731
+ }
2732
+ }
2733
+ }), h.registerVisitor({
2734
+ from: "customProperties",
2735
+ to: "customProperties",
2736
+ openTag: (t) => {
2737
+ t.setSource([]);
2738
+ },
2739
+ closeTag: (t) => {
2740
+ const e = t.getSource();
2741
+ if (e.length > 0) t.getParent().customProperties = e;
2742
+ }
2743
+ }), h.registerVisitor({
2744
+ from: "customPr",
2745
+ to: {},
2746
+ openTag: (t) => {
2747
+ const e = t.getParent();
2748
+ t.copyTo("name");
2749
+ const s = t.getAttribute("r:id");
2750
+ if (!s) return void t.warn("A custom property names no part; it was not imported.", { onceKey: "xlsx.sheet.customProperty.noRel" });
2751
+ const r = o(s, "resource"), n = t.getSource();
2752
+ n.resId = r, e.push(n);
2753
+ }
2754
+ }), h.registerVisitor({
2755
+ from: "sheetProtection",
2756
+ to: "protection",
2757
+ openTag: (t) => {
2758
+ const e = t.getSource();
2759
+ for (const o of z) {
2760
+ const s = t.hasAttribute(o.attribute) ? t.getAttribute(o.attribute) : null;
2761
+ e[o.key] = G(o, s);
2762
+ }
2763
+ if (e.sheet) return;
2764
+ const o = {};
2765
+ if (t.copyToObject(o, "hash", Oo, "hashValue"), t.copyToObject(o, "algorithm", Oo, "algorithmName"), t.copyToObject(o, "salt", Oo, "saltValue"), t.copyToObject(o, "spinCount", Io), t.copyToObject(o, "legacyHash", Oo, "password"), Object.keys(o).length > 0) t.getSource().password = o;
2766
+ }
2767
+ }), h.registerVisitor({
2768
+ from: "protectedRanges",
2769
+ to: "protectedRanges",
2770
+ openTag: (t) => {
2771
+ t.setSource([]);
2772
+ }
2773
+ }), h.registerVisitor({
2774
+ from: "protectedRange",
2775
+ to: [],
2776
+ openTag: (t) => {
2777
+ let e = t.getAttribute("sqref");
2778
+ e && (e = e.trim().split(/\s+/).join(","));
2779
+ const o = {}, s = {
2780
+ r: e,
2781
+ v: o
2782
+ };
2783
+ t.copyToObject(o, "name"), t.copyToObject(o, "securityDescriptor");
2784
+ const r = {};
2785
+ t.copyToObject(r, "hash", Oo, "hashValue"), t.copyToObject(r, "algorithm", Oo, "algorithmName"), t.copyToObject(r, "salt", Oo, "saltValue"), t.copyToObject(r, "spinCount", Io), t.copyToObject(r, "legacyHash", Oo, "password"), Object.keys(r).length > 0 && (o.password = r), t.setSource(s);
2786
+ },
2787
+ closeTag: (t) => {
2788
+ const e = t.getSource();
2789
+ e?.r && e.v.name || t.setSource(void 0);
2790
+ }
2791
+ }), h.registerVisitor({
2792
+ from: "sheetFormatPr",
2793
+ to: "sheetFormatPr",
2794
+ openTag: (t) => {
2795
+ t.copyToObject(e, "defaultColSize", Po, "defaultColWidth");
2796
+ const o = t.getAttribute("customHeight");
2797
+ "1" !== o && "true" !== o || t.copyToObject(e, "defaultRowSize", Po, "defaultRowHeight");
2798
+ const s = t.getAttribute("baseColWidth", Io);
2799
+ s && 8 !== s && (e.baseColSize = s), d = !!t.getAttribute("zeroHeight", Eo);
2800
+ }
2801
+ }), h.registerVisitor({
2802
+ from: "cols",
2803
+ to: "cols",
2804
+ openTag: (t) => {
2805
+ t.setSource([]);
2806
+ }
2807
+ }), h.registerVisitor({
2808
+ from: "col",
2809
+ to: [],
2810
+ openTag: (t) => {
2811
+ const e = t.getSource(), o = t.getAttribute("min"), s = t.getAttribute("max"), r = void 0 === o ? 0 : parseInt(o) - 1, n = void 0 === s ? r : parseInt(s) - 1;
2812
+ e.r = It.runToString(r, n, !0);
2813
+ const i = {};
2814
+ e.v = i, t.copyToObject(i, "sz", Po, "width"), t.copyToObject(i, "csz", Eo, "customWidth"), t.copyToObject(i, "h", Eo, "hidden"), t.copyToObject(i, "l", Io, "outlineLevel"), t.copyToObject(i, "cl", Eo, "collapsed"), t.getAttribute("bestFit", Eo) && (i.bf = !0), t.copyToObject(i, "s", Io, "style");
2815
+ }
2816
+ }), h.registerVisitor({
2817
+ from: "oleObjects",
2818
+ to: null,
2819
+ openTag: (t) => {
2820
+ t.warn("'OLE Objects' are not supported.");
2821
+ }
2822
+ });
2823
+ let Nt = !1, _t = !1, $t = 0, Mt = "", Vt = "";
2824
+ const jt = (t) => {
2825
+ const e = t.indexOf(":");
2826
+ return -1 === e ? t : t.slice(e + 1);
2827
+ }, Ft = new Qo();
2828
+ return fs(b, e, h.createEventHandler(e, n, i), i, l, {
2829
+ onOpenTag: (t) => {
2830
+ Nt = !0;
2831
+ const e = jt(t.name);
2832
+ "t" === e || "v" === e ? 0 === $t && (_t = !0) : "rPh" === e || "phoneticPr" === e ? $t++ : 0 === $t && Ft.onOpenTag(e, t.attributes);
2833
+ },
2834
+ onText: (t) => {
2835
+ _t && (Mt += t, Ft.onText(t));
2836
+ },
2837
+ onCloseTag: (t) => {
2838
+ const e = jt(t.name);
2839
+ "t" === e || "v" === e ? _t = !1 : "rPh" === e || "phoneticPr" === e ? $t > 0 && $t-- : Ft.onCloseTag(e);
2840
+ },
2841
+ onEnd: () => {
2842
+ if (!Nt) return;
2843
+ const t = Ft.take();
2844
+ Nt = !1, _t = !1, $t = 0;
2845
+ const e = v(Mt);
2846
+ return Mt = "", Vt = e, t ? {
2847
+ t: "r",
2848
+ v: {
2849
+ type: "richText",
2850
+ data: { runs: Yo(t, c?.get(as)) }
2851
+ }
2852
+ } : s(e);
2853
+ },
2854
+ onError: (t) => {}
2855
+ }, c, s, () => d, () => Vt);
2856
+ }, cs = class {
2857
+ static {
2858
+ this.Collapsed = 1;
2859
+ }
2860
+ static {
2861
+ this.CustomFormat = 2;
2862
+ }
2863
+ static {
2864
+ this.CustomHeight = 4;
2865
+ }
2866
+ static {
2867
+ this.Hidden = 8;
2868
+ }
2869
+ static {
2870
+ this.Ht = 16;
2871
+ }
2872
+ static {
2873
+ this.OutlineLevel = 32;
2874
+ }
2875
+ static {
2876
+ this.Ph = 64;
2877
+ }
2878
+ static {
2879
+ this.R = 128;
2880
+ }
2881
+ static {
2882
+ this.S = 256;
2883
+ }
2884
+ static {
2885
+ this.Spans = 512;
2886
+ }
2887
+ }, hs = (t, e, o) => {
2888
+ if (t[0].value[0] === t[1].value[0]) return e;
2889
+ }, us = /^\s*TABLE\s*\(/i, ds = {
2890
+ colStart: 0,
2891
+ colEnd: 0,
2892
+ rowStart: 0,
2893
+ rowEnd: 0
2894
+ }, ps = (t) => "1" === t || "true" === t, fs = (t, e, o, r, n, i, a, l, c, h) => {
2895
+ let u = !1;
2896
+ const d = [], p = a?.get(is), f = a?.get(as), m = /* @__PURE__ */ new Map();
2897
+ let b = !1, v = [], x = !1, y = null, w = null, T = null, S = null, C = null, A = null;
2898
+ const k = a?.get("richData") ?? Ot.EmptyArray;
2899
+ let E = null, I = !1;
2900
+ const P = It.normalizeA1ToR1C1, O = Dt.createConflatingRanges(), D = /* @__PURE__ */ new Map(), N = [], _ = [];
2901
+ let $ = !1, M = !1, R = null;
2902
+ const L = (t) => {
2903
+ const e = (a?.get("metadata"))?.values;
2904
+ if (!e) return;
2905
+ const o = parseInt(t, 10);
2906
+ if (!Number.isFinite(o) || o < 1) return;
2907
+ const s = e[o - 1]?.get("XLRICHVALUE");
2908
+ return void 0 !== s?.richValueIndex ? k[s.richValueIndex] : void 0;
2909
+ };
2910
+ let V = !1;
2911
+ const j = Dt.createConflatingRanges();
2912
+ let B, F = !1, H = -1, W = -1, z = null, X = null;
2913
+ const q = (t) => ({
2914
+ t: "r",
2915
+ v: {
2916
+ type: "hyperlink",
2917
+ data: {
2918
+ address: B,
2919
+ friendly: t
2920
+ }
2921
+ }
2922
+ });
2923
+ let U = null;
2924
+ const K = [];
2925
+ let G = null, J = -2, Z = 0, Q = "", Y = "", et = "", ot = "", st = "", rt = "", nt = "", it = "", at = "", lt = "", ct = "", ht = "", ut = "", dt = "", pt = !0, ft = null, gt = !1, mt = !1, bt = !1, vt = null, xt = 0;
2926
+ const yt = (t) => {
2927
+ let s = t.name;
2928
+ const r = s.indexOf(":");
2929
+ if (-1 !== r && (s = s.slice(r + 1)), xt++, xt % 196608 == 0 && n?.(xt), X) {
2930
+ const e = t.attributes;
2931
+ switch (s) {
2932
+ case "v":
2933
+ b = !0;
2934
+ break;
2935
+ case "f":
2936
+ switch (x = !0, e.t ?? null) {
2937
+ case null:
2938
+ case "normal": break;
2939
+ case "shared":
2940
+ const t = e.si;
2941
+ w = e.ref, y = t;
2942
+ break;
2943
+ case "array":
2944
+ w = e.ref, R = w;
2945
+ break;
2946
+ case "dataTable": {
2947
+ const t = ((t, e, o) => {
2948
+ const s = t.r1, r = ps(t.del1);
2949
+ if (!s && !r) return null;
2950
+ const n = t.ref ?? It.cellToString({
2951
+ rowIndex: e,
2952
+ colIndex: o
2953
+ }), i = It.fastStringToRange(n);
2954
+ if (!i) return null;
2955
+ const a = { ref: {
2956
+ rowStart: i.rowStart,
2957
+ colStart: i.colStart,
2958
+ rowEnd: i.rowEnd,
2959
+ colEnd: i.colEnd
2960
+ } }, l = ps(t.dt2D);
2961
+ if (l || ps(t.dtr) ? (s && (a.rowInput = s), r && (a.rowInputDeleted = !0)) : (s && (a.columnInput = s), r && (a.columnInputDeleted = !0)), l) {
2962
+ const e = t.r2;
2963
+ e && (a.columnInput = e), ps(t.del2) && (a.columnInputDeleted = !0);
2964
+ }
2965
+ return a;
2966
+ })(e, H, W);
2967
+ t && (_.push(t), ps(e.ca) && j.append(H, W));
2968
+ return;
2969
+ }
2970
+ }
2971
+ const t = e.ca;
2972
+ void 0 !== t && (V = "1" === t);
2973
+ break;
2974
+ case "is":
2975
+ F = !0;
2976
+ return;
2977
+ }
2978
+ F && !x && i?.onOpenTag?.(t);
2979
+ return;
2980
+ }
2981
+ if (u) {
2982
+ if ("c" === s) {
2983
+ X = t, B = void 0;
2984
+ const e = t.attributes, o = e.r;
2985
+ W = void 0 !== o ? It.fastStringToCol(o) : W + 1;
2986
+ const s = e.t;
2987
+ void 0 === s ? U = null : (U = s, "str" === U && (F = !0));
2988
+ let r = e.s;
2989
+ void 0 === r && (null !== vt || bt) && (r = "0"), void 0 !== r && (r = parseInt(r), ft && ft.value === r && ft.colEnd + 1 === W ? ft.colEnd = W : (ft = {
2990
+ colStart: W,
2991
+ rowStart: H,
2992
+ colEnd: W,
2993
+ rowEnd: H,
2994
+ value: r
2995
+ }, v.push(ft))), R = null, M = !1, I = !1;
2996
+ const n = e.cm;
2997
+ $ = void 0 !== n && ((t) => {
2998
+ const e = (a?.get("metadata"))?.cells;
2999
+ if (!e) return !1;
3000
+ const o = parseInt(t, 10);
3001
+ return !(!Number.isFinite(o) || o < 1) && !0 === (e[o - 1]?.get("XLDAPR"))?.fDynamic;
3002
+ })(n);
3003
+ const i = e.vm;
3004
+ if (void 0 !== i) {
3005
+ const t = L(i);
3006
+ if (Nt.isError(t)) {
3007
+ const e = t.getCode();
3008
+ z = {
3009
+ t: "e",
3010
+ v: e
3011
+ }, $ && e === Nt.Code.Spill && (M = !0);
3012
+ }
3013
+ }
3014
+ }
3015
+ } else {
3016
+ if (mt && "row" === s) {
3017
+ u = !0;
3018
+ const e = t.attributes.r;
3019
+ if (H = void 0 !== e ? parseInt(e) - 1 : H + 1, W = -1, c?.()) {
3020
+ const t = d[d.length - 1];
3021
+ t && t.max + 1 === H ? t.max = H : d.push({
3022
+ min: H,
3023
+ max: H
3024
+ });
3025
+ }
3026
+ if (Z = 0, Y = t.attributes.customHeight, void 0 !== Y && (Z |= cs.CustomHeight), Y !== at && (pt = !0, at = Y), Q = t.attributes.ht, void 0 !== Q && (Z |= cs.Ht), Q !== it && (pt = !0, it = Q), et = t.attributes.hidden, void 0 !== et && (Z |= cs.Hidden), et !== lt && (pt = !0, lt = et), st = t.attributes.s, void 0 !== st && (Z |= cs.S), st !== ht && (pt = !0, ht = st), ot = t.attributes.customFormat, void 0 !== ot && (Z |= cs.CustomFormat), ot !== ct && (pt = !0, ct = ot), rt = t.attributes.outlineLevel, void 0 !== rt && (Z |= cs.OutlineLevel), rt !== ut && (pt = !0, ut = rt), nt = t.attributes.collapsed, void 0 !== nt && (Z |= cs.Collapsed), nt !== dt && (pt = !0, dt = nt), 0 !== Z) if (J + 1 !== H || pt) {
3027
+ const t = void 0 !== Y && ("1" === Y || "true" === Y), e = void 0 !== ot && ("1" === ot || "true" === ot);
3028
+ vt = e && void 0 !== st ? st : null, e && null === vt && (vt = "0"), G = {
3029
+ min: H,
3030
+ max: H,
3031
+ value: {
3032
+ sz: void 0 === Q ? -1 : parseFloat(Q),
3033
+ csz: t,
3034
+ h: void 0 !== et && ("1" === et || "true" === et),
3035
+ s: null === vt ? void 0 : "0" === vt ? 0 : parseInt(vt),
3036
+ l: void 0 === rt || "0" === rt ? 0 : parseInt(rt),
3037
+ cl: void 0 !== nt && ("1" === nt || "true" === nt)
3038
+ }
3039
+ }, K.push(G);
3040
+ } else G.max = H;
3041
+ J = H, pt = !1;
3042
+ return;
3043
+ }
3044
+ if ("sheetData" === s && (mt = !0), !gt && "sheetData" === s) {
3045
+ gt = !0;
3046
+ const t = e.cols, o = t ? t.length : 0;
3047
+ for (let e = 0; !bt && e < o; e++) t[e].v.s && (bt = !0);
3048
+ }
3049
+ o?.onOpenTag?.(t);
3050
+ }
3051
+ }, wt = (e) => {
3052
+ let s = e.name;
3053
+ if ("sheetData" === s && (mt = !1), !x || "c" !== s && "f" !== s || (y && (S = D.get(y) ?? null), S && (B = ((t) => {
3054
+ if (t.length < 11 || 104 != (32 | t.charCodeAt(0))) return;
3055
+ if (!/^HYPERLINK\(/i.test(t)) return;
3056
+ let e = 1, o = !1, s = 10;
3057
+ for (; s < t.length && e > 0; s++) {
3058
+ const r = t.charCodeAt(s);
3059
+ o ? 34 === r && (34 === t.charCodeAt(s + 1) ? s++ : o = !1) : 34 === r ? o = !0 : 40 === r ? e++ : 41 === r && e--;
3060
+ }
3061
+ if (0 !== e || t.slice(s).trim().length > 0) return;
3062
+ const r = /^HYPERLINK\(\s*"((?:[^"]|"")*)"\s*[,)]/i.exec(t);
3063
+ return r ? r[1].replace(/""/g, "\"") : null;
3064
+ })(S[2]), O.append(H, W, S), V && j.append(H, W)), null !== R && N.push([R, $ ? M ? "error" : "dynamic" : "fixed"]), x = !1, S = null, y = null, w = null, b = !1, V = !1, R = null, $ = !1, M = !1), X) {
3065
+ const o = s.indexOf(":");
3066
+ if (-1 !== o && (s = s.slice(o + 1)), F) if ("is" === s || "v" === s) {
3067
+ const e = i?.onEnd?.();
3068
+ null == e || I && "" === h?.() || t.pushAt(H, W, void 0 !== B && "number" == typeof e ? q(h?.() ?? "") : "number" == typeof e ? "" + e : e);
3069
+ } else "f" !== s && i?.onCloseTag?.(e);
3070
+ b && (b = !1), "c" === s && (X = null, F = !1);
3071
+ return;
3072
+ }
3073
+ if (u) return u = !1, void (ft = null);
3074
+ o?.onCloseTag?.(e);
3075
+ }, Tt = (e) => {
3076
+ const s = e.trim();
3077
+ if (b) {
3078
+ switch (z = null, U) {
3079
+ case null:
3080
+ case "n":
3081
+ z = Ut.flushSubnormal(parseFloat(s));
3082
+ break;
3083
+ case "b":
3084
+ z = "1" === s || "true" === s;
3085
+ break;
3086
+ case "s": {
3087
+ const t = parseInt(s, 10);
3088
+ let e = m.get(t);
3089
+ if (void 0 === e) {
3090
+ const o = p?.get(t);
3091
+ e = o ? Yo(o, f) : null, m.set(t, e);
3092
+ }
3093
+ z = e ? {
3094
+ t: "r",
3095
+ v: {
3096
+ type: "richText",
3097
+ data: { runs: e }
3098
+ }
3099
+ } : s;
3100
+ break;
3101
+ }
3102
+ case "d": {
3103
+ const t = ((t, e = !1) => {
3104
+ if (!t) return null;
3105
+ const o = Ko.exec(t);
3106
+ if (o) {
3107
+ const [, t, e, s] = o;
3108
+ return void 0 === t && void 0 === e && void 0 === s ? null : (3600 * parseFloat(t ?? "0") + 60 * parseFloat(e ?? "0") + parseFloat(s ?? "0")) / 86400;
3109
+ }
3110
+ const s = Uo.exec(t);
3111
+ if (!s) return null;
3112
+ const [, r, n, i, a, l, c, h] = s;
3113
+ if (void 0 === r && void 0 === a) return null;
3114
+ let u = 0;
3115
+ if (void 0 !== r) {
3116
+ const t = parseInt(r, 10), o = parseInt(n, 10), s = parseInt(i, 10);
3117
+ if (o < 1 || o > 12 || s < 1 || s > 31) return null;
3118
+ const a = Go(t, o, s) - Jo;
3119
+ if (u = a <= 60 ? a - 1 : a, e && (u -= 1462), u < 0) return null;
3120
+ }
3121
+ void 0 !== a && (u += (3600 * parseInt(a, 10) + 60 * parseInt(l, 10) + (void 0 !== c ? parseInt(c, 10) : 0) + (void 0 !== h ? parseFloat(h) : 0)) / 86400);
3122
+ return u;
3123
+ })(s, !0 === a?.get(ns));
3124
+ null !== t ? z = t : l && (r?.(`Date '${s}' in cell ${It.cellToString({
3125
+ colIndex: W,
3126
+ rowIndex: H
3127
+ })} is not a date this workbook can hold; kept as text.`, void 0, "xlsx.cell.isoDateText"), z = "" + l(s));
3128
+ break;
3129
+ }
3130
+ case "e":
3131
+ if ("#VALUE!" === s) {
3132
+ const t = X.attributes.vm;
3133
+ if (void 0 !== t) {
3134
+ const e = L(t);
3135
+ if (Nt.isError(e)) {
3136
+ z = {
3137
+ t: "e",
3138
+ v: e.getCode()
3139
+ };
3140
+ break;
3141
+ }
3142
+ if (qt.isJSON(e)) {
3143
+ z = {
3144
+ t: "r",
3145
+ v: e
3146
+ };
3147
+ break;
3148
+ }
3149
+ }
3150
+ }
3151
+ const t = Nt.getBuiltInByLabel(s);
3152
+ t ? z = {
3153
+ t: "e",
3154
+ v: t.getCode()
3155
+ } : (z = s, r?.(`Unknown formula error '${s}' in cell ${It.cellToString({
3156
+ colIndex: W,
3157
+ rowIndex: H
3158
+ })}`));
3159
+ break;
3160
+ case "str":
3161
+ case "inlineStr": F = !0;
3162
+ }
3163
+ null !== z && t.pushAt(H, W, void 0 === B || "number" != typeof z && "boolean" != typeof z ? z : q(z));
3164
+ }
3165
+ const n = null !== y;
3166
+ if (y) {
3167
+ if (C === y) S = A;
3168
+ else {
3169
+ if (S = D.get(y) ?? null, !S) {
3170
+ const t = [];
3171
+ T = P(s, H, W, t), S = [
3172
+ T,
3173
+ t,
3174
+ s
3175
+ ], D.set(y, S);
3176
+ }
3177
+ C = y, A = S;
3178
+ }
3179
+ y = null;
3180
+ }
3181
+ if (x) {
3182
+ let t = s;
3183
+ const e = n ? void 0 : a?.get(rs);
3184
+ if (e) {
3185
+ const o = ((t) => {
3186
+ if (t.length < $o.length) return Lo;
3187
+ if (t.slice(0, $o.length).toUpperCase() !== Mo) return Lo;
3188
+ const e = jo(t, $o.length);
3189
+ if (null === e) return Lo;
3190
+ if (41 !== t.charCodeAt(e.end)) return Lo;
3191
+ if (44 !== t.charCodeAt(e.end + 1)) return Lo;
3192
+ if (41 !== t.charCodeAt(t.length - 1)) return Lo;
3193
+ const o = e.value;
3194
+ return o.toUpperCase() === Ro ? Vo : 0 === o.length ? Lo : {
3195
+ kind: "formula",
3196
+ formula: o
3197
+ };
3198
+ })(s);
3199
+ "none" !== o.kind && (E ??= new Fo(e), "spilled" === o.kind ? I = E.placeholder(H, W) : E.anchor(H, W, o.formula) && (t = o.formula, V ||= ((t) => Bo(t).some((t) => g(t) || !0 === $t.get(t)?.getDeclaration().getReturnType()?.isVolatile()))(t)));
3200
+ }
3201
+ if (I) V = !1;
3202
+ else {
3203
+ const e = [];
3204
+ T = P(t, H, W, e), S = [
3205
+ T,
3206
+ e,
3207
+ t
3208
+ ];
3209
+ }
3210
+ }
3211
+ F ? i?.onText?.(e) : u || o?.onText?.(s);
3212
+ }, St = {
3213
+ r: void 0,
3214
+ t: void 0,
3215
+ s: void 0,
3216
+ cm: void 0,
3217
+ vm: void 0
3218
+ }, Ct = {
3219
+ name: "c",
3220
+ attributes: St,
3221
+ isSelfClosing: !1
3222
+ }, At = {
3223
+ t: void 0,
3224
+ si: void 0,
3225
+ ref: void 0,
3226
+ ca: void 0
3227
+ }, kt = {
3228
+ name: "f",
3229
+ attributes: At,
3230
+ isSelfClosing: !1
3231
+ }, Et = {
3232
+ name: "v",
3233
+ attributes: {},
3234
+ isSelfClosing: !1
3235
+ }, Pt = {
3236
+ r: void 0,
3237
+ s: void 0,
3238
+ ht: void 0,
3239
+ hidden: void 0,
3240
+ collapsed: void 0,
3241
+ customHeight: void 0,
3242
+ customFormat: void 0,
3243
+ outlineLevel: void 0
3244
+ }, _t = {
3245
+ name: "row",
3246
+ attributes: Pt,
3247
+ isSelfClosing: !1
3248
+ }, Mt = ko.NEED_MORE, Rt = ko.NOT_HANDLED, Lt = ko.decodeText;
3249
+ let Vt = !1;
3250
+ const jt = (t, e, o, s) => {
3251
+ for (;;) {
3252
+ let r = 0;
3253
+ for (; e < o && (32 === (r = t.charCodeAt(e)) || 9 === r || 10 === r || 13 === r);) e++;
3254
+ if (e >= o) return Mt;
3255
+ if (62 === r) return Vt = !1, e + 1;
3256
+ if (47 === r) return e + 1 >= o ? Mt : 62 !== t.charCodeAt(e + 1) ? Rt : (Vt = !0, e + 2);
3257
+ const n = e;
3258
+ for (; e < o && 61 !== (r = t.charCodeAt(e));) {
3259
+ if (62 === r || 47 === r || 32 === r || 9 === r || 10 === r || 13 === r) return Rt;
3260
+ e++;
3261
+ }
3262
+ if (e + 1 >= o) return Mt;
3263
+ const i = e - n, a = t.charCodeAt(e + 1);
3264
+ if (34 !== a && 39 !== a) return Rt;
3265
+ const l = e + 2;
3266
+ let c = l;
3267
+ for (; c < o && (r = t.charCodeAt(c)) !== a;) {
3268
+ if (38 === r || r < 32) return Rt;
3269
+ c++;
3270
+ }
3271
+ if (c >= o) return Mt;
3272
+ e = c + 1;
3273
+ const h = t.charCodeAt(n);
3274
+ if (2 === s) switch (i) {
3275
+ case 1:
3276
+ 114 === h ? Pt.r = t.slice(l, c) : 115 === h && (Pt.s = t.slice(l, c));
3277
+ break;
3278
+ case 2:
3279
+ t.startsWith("ht", n) && (Pt.ht = t.slice(l, c));
3280
+ break;
3281
+ case 6:
3282
+ t.startsWith("hidden", n) && (Pt.hidden = t.slice(l, c));
3283
+ break;
3284
+ case 9:
3285
+ t.startsWith("collapsed", n) && (Pt.collapsed = t.slice(l, c));
3286
+ break;
3287
+ case 12: t.startsWith("customHeight", n) ? Pt.customHeight = t.slice(l, c) : t.startsWith("customFormat", n) ? Pt.customFormat = t.slice(l, c) : t.startsWith("outlineLevel", n) && (Pt.outlineLevel = t.slice(l, c));
3288
+ }
3289
+ else if (0 === s) 1 === i ? 114 === h ? St.r = t.slice(l, c) : 116 === h ? St.t = t.slice(l, c) : 115 === h && (St.s = t.slice(l, c)) : 2 === i && 109 === t.charCodeAt(n + 1) && (99 === h ? St.cm = t.slice(l, c) : 118 === h && (St.vm = t.slice(l, c)));
3290
+ else if (1 === i) 116 === h && (At.t = t.slice(l, c));
3291
+ else if (2 === i) {
3292
+ const e = t.charCodeAt(n + 1);
3293
+ 115 === h && 105 === e ? At.si = t.slice(l, c) : 99 === h && 97 === e && (At.ca = t.slice(l, c));
3294
+ } else 3 === i && t.startsWith("ref", n) && (At.ref = t.slice(l, c));
3295
+ }
3296
+ }, Ft = (t, e, o) => 47 === t.charCodeAt(e + 1) && t.charCodeAt(e + 2) === o && 62 === t.charCodeAt(e + 3);
3297
+ return {
3298
+ ...o,
3299
+ onEnd: () => {
3300
+ if (c?.()) {
3301
+ let t = 0;
3302
+ const e = [], o = (t, e) => ({
3303
+ min: t,
3304
+ max: e,
3305
+ value: {
3306
+ sz: -1,
3307
+ csz: !1,
3308
+ h: !0,
3309
+ s: void 0,
3310
+ l: 0,
3311
+ cl: !1
3312
+ }
3313
+ });
3314
+ for (const s of d) s.min > t && e.push(o(t, s.min - 1)), t = Math.max(t, s.max + 1);
3315
+ t <= tt && e.push(o(t, tt)), e.length > 0 && (K.push(...e), K.sort((t, e) => t.min - e.min));
3316
+ }
3317
+ K.length > 0 && (e.rows = It.runsToRefs(K, !1));
3318
+ let r = O.done(hs);
3319
+ r = ((t, e) => {
3320
+ let o = null;
3321
+ for (let e = 0; e < t.length; e++) {
3322
+ const s = t[e];
3323
+ if (!us.test(s.value[2])) continue;
3324
+ o ??= /* @__PURE__ */ new Map();
3325
+ const r = s.value[0], n = o.get(r);
3326
+ n ? n.push(s) : o.set(r, [s]);
3327
+ }
3328
+ if (null === o) return t;
3329
+ const s = /* @__PURE__ */ new Set();
3330
+ for (const t of o.values()) {
3331
+ const o = t[0], r = {
3332
+ rowStart: o.rowStart,
3333
+ colStart: o.colStart,
3334
+ rowEnd: o.rowEnd,
3335
+ colEnd: o.colEnd
3336
+ };
3337
+ let n = 0;
3338
+ for (let e = 0; e < t.length; e++) {
3339
+ const o = t[e];
3340
+ o.rowStart < r.rowStart && (r.rowStart = o.rowStart), o.colStart < r.colStart && (r.colStart = o.colStart), o.rowEnd > r.rowEnd && (r.rowEnd = o.rowEnd), o.colEnd > r.colEnd && (r.colEnd = o.colEnd), n += (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1);
3341
+ }
3342
+ if (n !== (r.rowEnd - r.rowStart + 1) * (r.colEnd - r.colStart + 1)) continue;
3343
+ const a = qo(It.resolveRelativeToA1(o.value[1], r.rowStart, r.colStart), r);
3344
+ if (a) {
3345
+ e.push(a);
3346
+ for (let e = 0; e < t.length; e++) s.add(t[e]);
3347
+ }
3348
+ }
3349
+ return 0 === s.size ? t : t.filter((t) => !s.has(t));
3350
+ })(r, _);
3351
+ const n = r.length;
3352
+ if (n > 0 || _.length > 0) {
3353
+ const t = new Array(n);
3354
+ for (let e = 0; e < n; e++) {
3355
+ const o = r[e], s = It.rangeToString(o), n = o.value[1], i = It.resolveRelativeToA1(n, o.rowStart, o.colStart);
3356
+ t[e] = [s, i];
3357
+ }
3358
+ for (let e = 0; e < _.length; e++) {
3359
+ const o = _[e], r = o.ref;
3360
+ t.push([It.cellToString({
3361
+ rowIndex: r.rowStart,
3362
+ colIndex: r.colStart
3363
+ }), s(o)]), N.push([It.rangeToString(r), "dynamic"]);
3364
+ }
3365
+ e.formulas = t;
3366
+ }
3367
+ const i = j.done(!0), a = i.length;
3368
+ if (a > 0) {
3369
+ const t = new Array(a);
3370
+ for (let e = 0; e < a; e++) {
3371
+ const o = i[e], s = It.rangeToString(o);
3372
+ t[e] = s;
3373
+ }
3374
+ e.volatile = t;
3375
+ }
3376
+ E && N.push(...E.getFormulaArray()), N.length > 0 && (e.formulaArray = [...N]);
3377
+ const l = v.length;
3378
+ if (l > 0) {
3379
+ v.sort(Dt.createRangeComparator(Bt.Axis.Column));
3380
+ let t = v[0], o = t.colStart, s = t.colEnd, r = t.rowEnd, n = t.value;
3381
+ const i = [];
3382
+ i.push(t);
3383
+ let a = null;
3384
+ for (let e = 1; e < l; e++) a = v[e], n !== a.value || o !== a.colStart || s !== a.colEnd || r + 1 !== a.rowEnd ? (i.push(a), t = a, o = t.colStart, s = t.colEnd, r = t.rowEnd, n = t.value) : (r = a.rowEnd, t.rowEnd = r);
3385
+ const c = i.length, h = new Array(c);
3386
+ for (let t = 0; t < c; t++) {
3387
+ const e = i[t], o = It.rangeToString(e);
3388
+ h[t] = [o, e.value];
3389
+ }
3390
+ e.directStyles = h;
3391
+ }
3392
+ const h = t.build();
3393
+ h && (e.data = h.tuples), o?.onEnd?.();
3394
+ },
3395
+ onOpenTag: yt,
3396
+ onCloseTag: wt,
3397
+ onText: Tt,
3398
+ elementScanners: [{
3399
+ name: "c",
3400
+ scan: (t, e, o) => {
3401
+ if (!u || null !== X) return Rt;
3402
+ St.r = St.t = St.s = St.cm = St.vm = void 0;
3403
+ let s = jt(t, e + 2, o, 0);
3404
+ if (s < 0) return s;
3405
+ const r = St.t;
3406
+ if (void 0 === St.r || "str" === r || "inlineStr" === r) return Rt;
3407
+ let n = !1, i = -1, a = -1, l = -1, c = -1, h = s;
3408
+ if (!Vt) for (At.t = At.si = At.ref = At.ca = void 0;;) {
3409
+ const e = t.indexOf("<", s);
3410
+ if (-1 === e || e + 3 >= o) return Mt;
3411
+ for (let o = s; o < e; o++) {
3412
+ const e = t.charCodeAt(o);
3413
+ if (32 !== e && 9 !== e && 10 !== e && 13 !== e) return Rt;
3414
+ }
3415
+ const r = t.charCodeAt(e + 1), u = t.charCodeAt(e + 2);
3416
+ if (47 === r) {
3417
+ if (!Ft(t, e, 99)) return Rt;
3418
+ h = e + 4;
3419
+ break;
3420
+ }
3421
+ if (102 === r && !n && -1 === l && (32 === u || 62 === u || 47 === u)) {
3422
+ if (n = !0, s = jt(t, e + 2, o, 1), s < 0) return s;
3423
+ if ("dataTable" === At.t) return Rt;
3424
+ if (Vt) continue;
3425
+ const r = t.indexOf("<", s);
3426
+ if (-1 === r || r + 3 >= o) return Mt;
3427
+ if (!Ft(t, r, 102)) return Rt;
3428
+ i = s, a = r, s = r + 4;
3429
+ continue;
3430
+ }
3431
+ if (118 === r && 62 === u && -1 === l) {
3432
+ const r = t.indexOf("<", e + 3);
3433
+ if (-1 === r || r + 3 >= o) return Mt;
3434
+ if (!Ft(t, r, 118)) return Rt;
3435
+ l = e + 3, c = r, s = r + 4;
3436
+ continue;
3437
+ }
3438
+ return Rt;
3439
+ }
3440
+ return yt(Ct), n && (yt(kt), a > i && Tt(Lt(t.slice(i, a))), wt(kt)), -1 !== l && (yt(Et), c > l && Tt(Lt(t.slice(l, c))), wt(Et)), wt(Ct), h;
3441
+ }
3442
+ }, {
3443
+ name: "row",
3444
+ openTag: _t,
3445
+ scan: (t, e, o) => {
3446
+ if (!mt || u || null !== X) return Rt;
3447
+ Pt.r = Pt.s = Pt.ht = Pt.hidden = Pt.collapsed = Pt.customHeight = Pt.customFormat = Pt.outlineLevel = void 0;
3448
+ const s = jt(t, e + 4, o, 2);
3449
+ return s < 0 ? s : Vt || void 0 === Pt.r ? Rt : (yt(_t), s);
3450
+ }
3451
+ }]
3452
+ };
3453
+ }, gs = /* @__PURE__ */ new Map([
3454
+ ["urn:schemas-microsoft-com:vml", "v"],
3455
+ ["urn:schemas-microsoft-com:office:office", "o"],
3456
+ ["urn:schemas-microsoft-com:office:excel", "x"]
3457
+ ]), ms = [...gs].map(([t, e]) => ` xmlns:${e}="${t}"`).join(""), bs = /<(\/?)([A-Za-z_][\w.-]*(?::[\w.-]+)?)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g, vs = /(\s+)([A-Za-z_][\w.-]*(?::[\w.-]+)?)(\s*=\s*)("[^"]*"|'[^']*')/g, xs = /\sxmlns(?::([\w.-]+))?\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
3458
+ function ys(t) {
3459
+ if (!t || !((t) => {
3460
+ let e;
3461
+ for (xs.lastIndex = 0; null !== (e = xs.exec(t));) {
3462
+ const t = gs.get(e[2] ?? e[3] ?? "");
3463
+ if (t && t !== (e[1] ?? "")) return !0;
3464
+ }
3465
+ return !1;
3466
+ })(t)) return t;
3467
+ const e = [], o = (t, o, s) => {
3468
+ const r = t.indexOf(":");
3469
+ if (-1 === r && s) return null;
3470
+ const n = -1 === r ? "" : t.substring(0, r);
3471
+ if ("xmlns" === n) return null;
3472
+ const i = ((t, o) => {
3473
+ const s = o?.get(t);
3474
+ if (void 0 !== s) return s;
3475
+ for (let o = e.length - 1; o >= 0; o--) {
3476
+ const s = e[o].bindings.get(t);
3477
+ if (void 0 !== s) return s;
3478
+ }
3479
+ })(n, o), a = void 0 !== i ? gs.get(i) : void 0;
3480
+ return a ? `${a}:${-1 === r ? t : t.substring(r + 1)}` : null;
3481
+ };
3482
+ let s = !1, r = !1;
3483
+ const n = t.replace(bs, (t, n, i, a, l) => {
3484
+ if (n) {
3485
+ const s = e[e.length - 1], r = o(i, null, !1);
3486
+ return s && s.name === i && (s.nested > 0 ? s.nested-- : e.pop()), r ? `</${r}>` : t;
3487
+ }
3488
+ const c = ((t) => {
3489
+ let e, o = null;
3490
+ for (xs.lastIndex = 0; null !== (e = xs.exec(t));) (o ??= /* @__PURE__ */ new Map()).set(e[1] ?? "", e[2] ?? e[3] ?? "");
3491
+ return o;
3492
+ })(a);
3493
+ c?.forEach((t, e) => {
3494
+ const o = [...gs].find(([, t]) => t === e)?.[0];
3495
+ o && o !== t && (s = !0);
3496
+ });
3497
+ const h = o(i, c, !1);
3498
+ let u = a.replace(vs, (t, e, s, r, n) => {
3499
+ if ("xmlns" === s || s.startsWith("xmlns:")) {
3500
+ const e = n.slice(1, -1);
3501
+ return gs.has(e) ? "" : t;
3502
+ }
3503
+ const i = o(s, c, !0);
3504
+ return i ? `${e}${i}${r}${n}` : t;
3505
+ });
3506
+ if (r || (r = !0, u = u.replace(/\s+$/, "") + ms), !l) {
3507
+ const t = e[e.length - 1];
3508
+ c ? e.push({
3509
+ name: i,
3510
+ bindings: c,
3511
+ nested: 0
3512
+ }) : t && t.name === i && t.nested++;
3513
+ }
3514
+ return `<${h ?? i}${u}${l}>`;
3515
+ });
3516
+ return s ? t : n;
3517
+ }
3518
+ var ws = {
3519
+ creator: "author",
3520
+ category: "category",
3521
+ description: "comments",
3522
+ contentStatus: "contentStatus",
3523
+ created: "creationDate",
3524
+ keywords: "keywords",
3525
+ lastModifiedBy: "lastAuthor",
3526
+ modified: "lastModifiedDate",
3527
+ lastPrinted: "lastPrinted",
3528
+ revision: "revisionNumber",
3529
+ subject: "subject",
3530
+ title: "title"
3531
+ }, Ts = {
3532
+ Company: "company",
3533
+ Manager: "manager"
3534
+ }, Ss = {
3535
+ lpwstr: Vt.Type.String,
3536
+ lpstr: Vt.Type.String,
3537
+ bstr: Vt.Type.String,
3538
+ i1: Vt.Type.Number,
3539
+ i2: Vt.Type.Number,
3540
+ i4: Vt.Type.Number,
3541
+ i8: Vt.Type.Number,
3542
+ int: Vt.Type.Number,
3543
+ ui1: Vt.Type.Number,
3544
+ ui2: Vt.Type.Number,
3545
+ ui4: Vt.Type.Number,
3546
+ ui8: Vt.Type.Number,
3547
+ uint: Vt.Type.Number,
3548
+ r4: Vt.Type.Float,
3549
+ r8: Vt.Type.Float,
3550
+ decimal: Vt.Type.Float,
3551
+ bool: Vt.Type.Boolean,
3552
+ filetime: Vt.Type.Date,
3553
+ date: Vt.Type.Date
3554
+ }, Cs = (t) => {
3555
+ const e = t.kind ? Ss[t.kind] : void 0;
3556
+ if (!e) return null;
3557
+ const o = t.value.trim();
3558
+ let s;
3559
+ if (e === Vt.Type.String) s = {
3560
+ key: t.key,
3561
+ type: e,
3562
+ value: t.value
3563
+ };
3564
+ else if (e === Vt.Type.Boolean) {
3565
+ if ("true" !== o && "false" !== o && "1" !== o && "0" !== o) return null;
3566
+ s = {
3567
+ key: t.key,
3568
+ type: e,
3569
+ value: "true" === o || "1" === o
3570
+ };
3571
+ } else if (e === Vt.Type.Date) {
3572
+ const r = new Date(o);
3573
+ if (!o || isNaN(r.getTime())) return null;
3574
+ s = {
3575
+ key: t.key,
3576
+ type: e,
3577
+ value: r.toISOString()
3578
+ };
3579
+ } else {
3580
+ const r = Number(o);
3581
+ if (!o || !Number.isFinite(r)) return null;
3582
+ const n = e === Vt.Type.Number && r >= -2147483648 && r <= 2147483647;
3583
+ s = {
3584
+ key: t.key,
3585
+ type: n ? e : Vt.Type.Float,
3586
+ value: r
3587
+ };
3588
+ }
3589
+ return t.linkTarget && (s.linkTarget = t.linkTarget), s;
3590
+ }, As = "hiddenXfs", ks = (t) => (Array.isArray(t) ? t[1] : t?.v)?.s, Es = (t) => {
3591
+ if (!t || 0 === t.length) return !1;
3592
+ const e = It.refsToRuns(t, !0);
3593
+ let o = 0;
3594
+ for (const t of e) {
3595
+ if (t.min > o || void 0 === t.value?.s) return !1;
3596
+ o = Math.max(o, t.max + 1);
3597
+ }
3598
+ return o > ft;
3599
+ }, Is = (t, e) => {
3600
+ t.protection = {
3601
+ ...t.protection,
3602
+ showFormulas: e
3603
+ };
3604
+ }, Ps = "pivotButtonXfs", Os = (t, e) => {
3605
+ const o = t.styles?.direct;
3606
+ if (!o || 0 === o.length) return;
3607
+ let s = null;
3608
+ const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = (t, i, a, l) => {
3609
+ let c = "";
3610
+ l && (c = n.get(l) ?? Pt.JSONStableStringify(l), n.set(l, c));
3611
+ const h = `${t}|${i ?? ""}|${a ?? ""}|${c}`;
3612
+ let u = r.get(h);
3613
+ if (void 0 !== u) return u;
3614
+ const d = o[t], p = d ? Ns(d, i, a, l) : null, f = e?.get(t);
3615
+ return u = p === d ? t : p || void 0 !== f ? ((t, r) => {
3616
+ if (!s) {
3617
+ s = /* @__PURE__ */ new Map();
3618
+ for (let t = 0; t < o.length; t++) {
3619
+ let r = Pt.JSONStableStringify(o[t]);
3620
+ const n = e?.get(t);
3621
+ void 0 !== n && (r += `|${n}`), s.has(r) || s.set(r, t);
3622
+ }
3623
+ }
3624
+ let n = Pt.JSONStableStringify(t);
3625
+ void 0 !== r && (n += `|${r}`);
3626
+ let i = s.get(n);
3627
+ return void 0 === i && (i = o.length, o.push(t), s.set(n, i), void 0 !== r && e.set(i, r)), i;
3628
+ })(p ?? {}, f) : null, r.set(h, u), u;
3629
+ }, a = new Map((t.pivotCaches ?? []).map((t) => [t.cacheId, t.fields]));
3630
+ for (const e of t.sheets ?? []) {
3631
+ const t = k(e), o = t?.pivotTables, s = t?.directStyles;
3632
+ if (!t || !o || 0 === o.length || !s || 0 === s.length) continue;
3633
+ let r = s, n = !1;
3634
+ for (const t of o) {
3635
+ const e = Ds(t, a.get(t.cacheId));
3636
+ if (!e) continue;
3637
+ const o = [];
3638
+ for (const t of r) {
3639
+ const s = It.fastStringToRange(t[0]), r = js(s, e.coords);
3640
+ if (!r) {
3641
+ o.push(t);
3642
+ continue;
3643
+ }
3644
+ n = !0;
3645
+ for (const e of Bs(s, r)) o.push([It.rangeToString(e), t[1]]);
3646
+ const { rowIndex: a, colIndex: l } = e.origin;
3647
+ for (let s = r.rowStart; s <= r.rowEnd; s++) {
3648
+ let n = r.colStart, c = null;
3649
+ const h = (t) => {
3650
+ null !== c && o.push([It.rangeToString({
3651
+ rowStart: s,
3652
+ rowEnd: s,
3653
+ colStart: n,
3654
+ colEnd: t
3655
+ }), c]);
3656
+ };
3657
+ for (let o = r.colStart; o <= r.colEnd; o++) {
3658
+ const { numberFormat: u, labelIndent: d, user: p } = e.formats.formatAt(s - a, o - l), f = i(t[1], u, d, p);
3659
+ o !== r.colStart && f === c || (o !== r.colStart && h(o - 1), n = o, c = f);
3660
+ }
3661
+ h(r.colEnd);
3662
+ }
3663
+ }
3664
+ r = o;
3665
+ }
3666
+ n && (t.directStyles = r);
3667
+ }
3668
+ }, Ds = (t, e) => {
3669
+ const o = Qt(t, e);
3670
+ if (!o || !t.location) return null;
3671
+ const s = It.fastStringToRange(t.location), r = {
3672
+ rowIndex: s.rowStart - o.top,
3673
+ colIndex: s.colStart
3674
+ };
3675
+ return r.rowIndex < 0 || s.rowEnd !== r.rowIndex + o.rows - 1 ? null : {
3676
+ coords: {
3677
+ rowStart: r.rowIndex,
3678
+ colStart: r.colIndex,
3679
+ rowEnd: s.rowEnd,
3680
+ colEnd: r.colIndex + o.columns - 1
3681
+ },
3682
+ origin: r,
3683
+ formats: o
3684
+ };
3685
+ }, Ns = (t, e, o, s) => {
3686
+ let r = t;
3687
+ const n = s?.numberFormat ?? e ?? 0;
3688
+ if (void 0 !== t.numberFormat && _s(t.numberFormat, n)) {
3689
+ const { numberFormat: t, ...e } = r;
3690
+ r = e;
3691
+ }
3692
+ const i = r.alignment;
3693
+ if (null !== o && i?.horizontal === Ft.HorizontalAlignment.Left && (i.indent ?? 0) === o) {
3694
+ const { horizontal: t, indent: e, ...o } = i, { alignment: s, ...n } = r;
3695
+ r = Vs(o) ? n : {
3696
+ ...n,
3697
+ alignment: o
3698
+ };
3699
+ }
3700
+ if (s) {
3701
+ const { numberFormat: t, ...e } = s;
3702
+ if (r = Rs(r, e), r.alignment && Vs(r.alignment)) {
3703
+ const { alignment: t, ...e } = r;
3704
+ r = e;
3705
+ }
3706
+ }
3707
+ if (r === t) return t;
3708
+ for (const t of Object.keys(r)) if (void 0 !== r[t] && ("named" !== t || r.named !== Mt.BuiltInName.Normal)) return r;
3709
+ return null;
3710
+ }, _s = (t, e) => t === e || Ht.toBuiltInID(t) === Ht.toBuiltInID(e), $s = (t) => "object" == typeof t && null !== t && !Array.isArray(t), Ms = (t, e) => !(!$s(t) || !$s(e)) && ("solid" === t.patternType && "solid" === e.patternType ? t.foreground === e.foreground : Pt.JSONStableStringify(t) === Pt.JSONStableStringify(e)), Rs = (t, e) => {
3711
+ let o = null;
3712
+ const s = (e, s) => {
3713
+ o ??= { ...t }, void 0 === s ? delete o[e] : o[e] = s;
3714
+ };
3715
+ for (const o of Object.keys(t)) {
3716
+ const r = t[o], n = e[o];
3717
+ if (void 0 !== n && void 0 !== r) if ("fill" === o) Ms(r, n) && s(o);
3718
+ else if ($s(r) && $s(n)) {
3719
+ const t = Rs(r, n);
3720
+ t !== r && s(o, Object.keys(t).some((e) => void 0 !== t[e]) ? t : void 0);
3721
+ } else r === n && s(o);
3722
+ }
3723
+ return o ?? t;
3724
+ }, Ls = {
3725
+ vertical: Ft.VerticalAlignment.Bottom,
3726
+ relativeIndent: 0,
3727
+ overflow: Ft.Overflow.Visible,
3728
+ rotation: 0
3729
+ }, Vs = (t) => Object.keys(t).every((e) => void 0 === t[e] || Ls[e] === t[e]), js = (t, e) => {
3730
+ const o = Math.max(t.rowStart, e.rowStart), s = Math.min(t.rowEnd, e.rowEnd), r = Math.max(t.colStart, e.colStart), n = Math.min(t.colEnd, e.colEnd);
3731
+ return o <= s && r <= n ? {
3732
+ rowStart: o,
3733
+ rowEnd: s,
3734
+ colStart: r,
3735
+ colEnd: n
3736
+ } : null;
3737
+ }, Bs = (t, e) => {
3738
+ const o = [];
3739
+ return t.rowStart < e.rowStart && o.push({
3740
+ ...t,
3741
+ rowEnd: e.rowStart - 1
3742
+ }), t.rowEnd > e.rowEnd && o.push({
3743
+ ...t,
3744
+ rowStart: e.rowEnd + 1
3745
+ }), t.colStart < e.colStart && o.push({
3746
+ rowStart: e.rowStart,
3747
+ rowEnd: e.rowEnd,
3748
+ colStart: t.colStart,
3749
+ colEnd: e.colStart - 1
3750
+ }), t.colEnd > e.colEnd && o.push({
3751
+ rowStart: e.rowStart,
3752
+ rowEnd: e.rowEnd,
3753
+ colStart: e.colEnd + 1,
3754
+ colEnd: t.colEnd
3755
+ }), o;
3756
+ }, Fs = "xfComplements", Hs = (t, e) => {
3757
+ if ("string" == typeof t) return void e.push(t);
3758
+ const o = Array.isArray(t) ? t : [t];
3759
+ for (let t = 0; t < o.length; t++) {
3760
+ const s = It.rangeToString(o[t]);
3761
+ s && e.push(s);
3762
+ }
3763
+ }, Ws = (t) => {
3764
+ const e = Array.isArray(t) ? t[1] : t.v;
3765
+ if (!e || !("s" in e)) return;
3766
+ const o = e.s;
3767
+ return delete e.s, o;
3768
+ }, zs = (t, e, o, s) => {
3769
+ if (!t) return;
3770
+ const r = e ? 2 : 1, n = e ? o.rowStart : o.colStart, i = e ? o.rowEnd : o.colEnd;
3771
+ let a, l = -1;
3772
+ for (const o of t) {
3773
+ const t = It.refToRun(o, e), c = Ws(o);
3774
+ t && void 0 !== c ? c !== l || (e ? a.colEnd : a.rowEnd) + 1 !== t.min ? (a = {
3775
+ colStart: e ? t.min : n,
3776
+ rowStart: e ? n : t.min,
3777
+ colEnd: e ? t.max : i,
3778
+ rowEnd: e ? i : t.max,
3779
+ value: {
3780
+ kind: r,
3781
+ index: c
3782
+ }
3783
+ }, l = c, s.push(a)) : e ? a.colEnd = t.max : a.rowEnd = t.max : l = -1;
3784
+ }
3785
+ }, Xs = {
3786
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
3787
+ "application/vnd.ms-excel.sheet.macroEnabled.main+xml": "workbooks",
3788
+ "application/vnd.ms-excel.sheet.binary.macroEnabled.main": "workbooks",
3789
+ "application/vnd.ms-excel.addin.macroEnabled.main+xml": "workbooks",
3790
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": "workbooks",
3791
+ "application/vnd.ms-excel.template.macroEnabled.main+xml": "workbooks",
3792
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": "sheets",
3793
+ "application/vnd.ms-excel.worksheet": "sheets",
3794
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "charts",
3795
+ "application/vnd.ms-excel.chartsheet": "charts",
3796
+ "application/vnd.ms-excel.macrosheet+xml": "macros",
3797
+ "application/vnd.ms-excel.macrosheet": "macros",
3798
+ "application/vnd.ms-excel.intlmacrosheet+xml": "macros",
3799
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "dialogs",
3800
+ "application/vnd.ms-excel.dialogsheet": "dialogs",
3801
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml": "strs",
3802
+ "application/vnd.ms-excel.sharedStrings": "strs",
3803
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": "styles",
3804
+ "application/vnd.ms-excel.styles": "styles",
3805
+ "application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
3806
+ "application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
3807
+ "application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
3808
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
3809
+ "application/vnd.ms-excel.comments": "comments",
3810
+ "application/vnd.ms-excel.threadedcomments+xml": "threadedcomments",
3811
+ "application/vnd.ms-excel.person+xml": "people",
3812
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "metadata",
3813
+ "application/vnd.ms-excel.sheetMetadata": "metadata",
3814
+ "application/vnd.ms-excel.featurepropertybag+xml": "featurePropertyBag",
3815
+ "application/vnd.ms-excel.externalLink": "links",
3816
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "links",
3817
+ "application/vnd.openxmlformats-officedocument.theme+xml": "themes"
3818
+ }, qs = o({ readXLSX: () => Zs }), Us = (t) => t.startsWith("/") ? t.slice(1) : t, Ks = [
3819
+ 208,
3820
+ 207,
3821
+ 17,
3822
+ 224,
3823
+ 161,
3824
+ 177,
3825
+ 26,
3826
+ 225
3827
+ ], Gs = /^xl\/worksheets\/[^/]+\.xml$/i, Js = (t) => "string" == typeof t ? t : (t?.runs ?? []).map((t) => t.text ?? "").join(""), Zs = async (t, o) => {
3828
+ const { password: s, onVBA: a, profile: f, calcOnLoad: g = "auto", createWorkbookOptions: m = {}, ...x } = o ?? {};
3829
+ await _t.load();
3830
+ const y = !!m.origin && "string" != typeof m.origin, w = f ? new we("function" == typeof f ? f : void 0) : null, S = [], E = (t, e, o) => {
3831
+ S.push([
3832
+ t,
3833
+ e ?? "",
3834
+ o
3835
+ ]);
3836
+ }, _ = { onWarning: E }, M = o?.progress, R = M?.onProgress ? M.onProgress.bind(M) : void 0, L = t.byteLength;
3837
+ let V = 0, B = 0;
3838
+ const F = R ? (t) => {
3839
+ if (V <= 0) return;
3840
+ B += t;
3841
+ const e = Math.min(L, Math.round(B / V * L));
3842
+ R(e, L);
3843
+ } : void 0, H = import("./BT0HKieizRDqDegH.mjs");
3844
+ let z = null;
3845
+ try {
3846
+ z = new DOMParser();
3847
+ } catch (t) {}
3848
+ let X = null;
3849
+ try {
3850
+ X = new XMLSerializer();
3851
+ } catch (t) {}
3852
+ let q, K, G, J = null;
3853
+ z || (J = import("@xmldom/xmldom"));
3854
+ try {
3855
+ const [t, e] = await Promise.all([J, H]);
3856
+ q = new e.DOMTransformer(), K = z ?? new t.DOMParser(), G = X ?? new t.XMLSerializer();
3857
+ } catch (t) {
3858
+ throw new Error("Unable to load XLSX parser.", { cause: t });
3859
+ }
3860
+ const Z = (t) => G.serializeToString(t);
3861
+ if (((t) => {
3862
+ if (t.byteLength < Ks.length) return !1;
3863
+ const e = new Uint8Array(t, 0, Ks.length);
3864
+ return Ks.every((t, o) => e[o] === t);
3865
+ })(t)) throw new At("This is an Excel 97-2003 workbook (.xls), which cannot be read. Save it as '.xlsx' and try again.");
3866
+ let Q;
3867
+ try {
3868
+ Q = await ye.create(t);
3869
+ } catch (t) {
3870
+ throw new At("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.", { cause: t });
3871
+ }
3872
+ w?.mark("zip-open");
3873
+ try {
3874
+ if (!Q.has("[Content_Types].xml")) throw new At("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
3875
+ const t = (t) => {
3876
+ const e = Q.getEntry(t);
3877
+ return e ? { content: e } : void 0;
3878
+ }, o = {
3879
+ workbooks: [],
3880
+ sheets: [],
3881
+ charts: [],
3882
+ dialogs: [],
3883
+ macros: [],
3884
+ strs: [],
3885
+ comments: [],
3886
+ threadedcomments: [],
3887
+ links: [],
3888
+ coreprops: [],
3889
+ extprops: [],
3890
+ custprops: [],
3891
+ themes: [],
3892
+ styles: [],
3893
+ metadata: [],
3894
+ people: [],
3895
+ featurePropertyBag: [],
3896
+ overrides: {},
3897
+ sst: "",
3898
+ style: "",
3899
+ defaults: {}
3900
+ };
3901
+ {
3902
+ const t = ((t, e) => ({
3903
+ onOpenTag: (e) => {
3904
+ const o = ((t) => {
3905
+ const e = t.indexOf(":");
3906
+ return -1 === e ? t : t.slice(e + 1);
3907
+ })(e.name), s = e.attributes;
3908
+ if ("Override" === o) {
3909
+ const e = s.ContentType, o = s.PartName;
3910
+ if (!e || !o) return;
3911
+ t.overrides[o.startsWith("/") ? o.slice(1) : o] = e;
3912
+ const r = Xs[e], n = r ? t[r] : void 0;
3913
+ Array.isArray(n) && n.push(o);
3914
+ } else if ("Default" === o) {
3915
+ const e = s.Extension, o = s.ContentType;
3916
+ e && (t.defaults[e.toLowerCase()] = o);
3917
+ }
3918
+ },
3919
+ onEnd: () => {
3920
+ t.sst = t.strs.length > 0 ? t.strs[0] : "", t.style = t.styles.length > 0 ? t.styles[0] : "";
3921
+ },
3922
+ onError: (t) => {
3923
+ e?.(`Error parsing content types: ${t?.message ?? t}`);
3924
+ }
3925
+ }))(o, (t) => {
3926
+ S.push([t, "[Content_Types].xml"]);
3927
+ }), e = await Q.getTextStream("[Content_Types].xml");
3928
+ if (!e) throw new Error("Error parsing content types: '[Content_Types].xml'");
3929
+ try {
3930
+ await go.parseStream(e, t, { xmlns: !1 });
3931
+ } catch (t) {
3932
+ throw new Error("Error parsing content types: '[Content_Types].xml'", { cause: t });
3933
+ }
3934
+ y && await Q.getBuffer("[Content_Types].xml");
3935
+ }
3936
+ w?.mark("content-types");
3937
+ const s = o.sst, x = /* @__PURE__ */ new Set();
3938
+ for (const t of o.sheets) x.add(Us(t));
3939
+ s && x.add(Us(s));
3940
+ for (const t of x) V += Q.uncompressedSize(t);
3941
+ if (await Q.prefetch((t) => !x.has(t) && !Gs.test(t)), w?.mark("prefetch-side-parts"), 0 === o.workbooks.length) {
3942
+ const e = I("_rels/.rels", t, K, q, _), s = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
3943
+ if (e) {
3944
+ for (const t of e.values()) if (t.type === s && t.target) {
3945
+ o.workbooks.push(t.target);
3946
+ break;
3947
+ }
3948
+ }
3949
+ }
3950
+ if (0 === o.workbooks.length) throw new At("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
3951
+ const B = m?.resources ?? new Xt(), H = B.beginPersist(), z = {}, X = /* @__PURE__ */ new Set(), G = /* @__PURE__ */ new Map();
3952
+ G.set("parseInlineDxf", (t) => {
3953
+ if (!t) return;
3954
+ const e = K.parseFromString(`<dxf xmlns:x14="${st}" xmlns:xm="${W}">${t}</dxf>`, "text/xml")?.documentElement;
3955
+ if (!e) return;
3956
+ const o = q.parseDxf(e, "", _);
3957
+ return Object.keys(o).length > 0 ? o : void 0;
3958
+ });
3959
+ const J = p("metadata", o, t, K, q, _).entries().next()?.value?.[1]?.metadata;
3960
+ J && G.set("metadata", J), G.set(ss, e());
3961
+ const Y = /* @__PURE__ */ new Map(), ot = [], rt = /* @__PURE__ */ new Set(), it = (t) => {
3962
+ rt.add(Us(t));
3963
+ }, lt = (e, o = Y) => {
3964
+ const s = e.lastIndexOf("/"), r = e.substring(0, s + 1) + "_rels/" + e.substring(s + 1, e.length) + ".rels";
3965
+ let n = o.get(r);
3966
+ return n || (n = I(r, t, K, q, Nt), o.set(r, n)), n;
3967
+ }, ct = (e, o, s, r = Y) => {
3968
+ let n = lt(o, r).get(e), i = n?.target;
3969
+ if (!i) return null;
3970
+ if ("External" === n.targetMode) {
3971
+ if (!s) return n.target;
3972
+ const t = B.add({ source: { external: n.target } });
3973
+ return t.addReference(z), X.add(t), H.toResourceId(t);
3974
+ }
3975
+ const a = o.lastIndexOf("/"), l = o.substring(0, a + 1);
3976
+ i.startsWith("/") || (i = l + i), i = D(i);
3977
+ const u = q?.getVisitorParamsState().get("dxfs");
3978
+ let d = r.get(i);
3979
+ if (!d) {
3980
+ const e = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", o = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink";
3981
+ if (n.type === e) {
3982
+ const t = {};
3983
+ d = t;
3984
+ const e = async () => {
3985
+ const e = ls(t, (t, e) => "legacyDrawing" === e ? pt(t, i) : "formControl" === e ? gt(t, i) : "part" === e ? bt(t, i) : ct(t, i, "resource" === e) ?? null, Bt, u, () => {}, (t, e, o) => {
3986
+ E(t, e ? `${e} (${i})` : i, o);
3987
+ }, void 0, G), o = await Q.getTextStream(i, F);
3988
+ if (o) try {
3989
+ await go.parseStream(o, e, {
3990
+ xmlns: !1,
3991
+ lean: !0
3992
+ });
3993
+ } catch (t) {
3994
+ throw new Error(`Error parsing sheet: '${i}'`, { cause: t });
3995
+ }
3996
+ const s = lt(i, r);
3997
+ if (s) {
3998
+ dt(t, i, s, r), ht(t), U(t);
3999
+ const e = [];
4000
+ s.forEach((t, o) => {
4001
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" !== t.type) return;
4002
+ const s = bt(o, i, t.type, (t) => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" !== t);
4003
+ if (!s?.xml) return;
4004
+ const r = /<pivotTableDefinition\b[^>]*>/.exec(s.xml)?.[0] ?? "", n = parseInt(/\scacheId="(\d+)"/.exec(r)?.[1] ?? "", 10);
4005
+ if (isNaN(n)) return void S.push([`Pivot table '${s.name}' names no cache and was dropped.`, i]);
4006
+ const a = /\sname="([^"]*)"/.exec(r)?.[1], l = N(s.xml);
4007
+ if (!l) return void S.push([`Pivot table '${s.name}' states no location and was dropped.`, i]);
4008
+ const h = q?.getVisitorParamsState(), u = $(h?.get("numFmts"), h?.get("dxfs")), d = O(s.xml, u), p = d ? void 0 : T(s.xml, u);
4009
+ e.push({
4010
+ ...a ? { name: c(a) } : {},
4011
+ cacheId: n,
4012
+ location: l,
4013
+ part: s,
4014
+ ...p ? { partFormats: p } : {},
4015
+ ...d
4016
+ });
4017
+ }), e.length > 0 && (t.pivotTables = e);
4018
+ }
4019
+ };
4020
+ ot.push(e());
4021
+ } else if (n.type === o) {
4022
+ const e = h(i, t, K, q, Nt);
4023
+ if (e && 0 !== Object.keys(e).length) {
4024
+ const t = e, o = t.__bookRelId, s = t.__absoluteUrlRelId;
4025
+ delete t.__bookRelId, delete t.__absoluteUrlRelId;
4026
+ const n = [];
4027
+ lt(i, r)?.forEach((t, e) => {
4028
+ if ("External" === t.targetMode && t.type && t.target) {
4029
+ const r = {
4030
+ type: t.type,
4031
+ target: t.target
4032
+ };
4033
+ e === o ? r.role = "book" : e === s && (r.role = "absoluteUrl"), n.push(r);
4034
+ }
4035
+ }), n.sort((t, e) => ("book" === t.role ? 0 : 1) - ("book" === e.role ? 0 : 1)), t.sources = n, it(i), d = t;
4036
+ } else d = null;
4037
+ } else d = s ? P(i, t, (t, e) => {
4038
+ const o = B.add({ source: { buffer: t } });
4039
+ return o.addReference(z), X.add(o), H.toResourceId(o);
4040
+ }, Nt) : h(i, t, K, q, Nt);
4041
+ }
4042
+ return d;
4043
+ }, ut = (t, e) => {
4044
+ if (!t) return null;
4045
+ const o = lt(e, Y)?.get(t);
4046
+ if (!o?.target || "External" === o.targetMode) return null;
4047
+ let s = o.target;
4048
+ return s.startsWith("/") || (s = e.substring(0, e.lastIndexOf("/") + 1) + s), D(s);
4049
+ }, dt = (t, e, o, s) => {
4050
+ const r = [], i = /* @__PURE__ */ new Map(), a = [];
4051
+ o.forEach((t, o) => {
4052
+ if ("http://schemas.microsoft.com/office/2017/10/relationships/threadedComment" !== t.type) return;
4053
+ const n = ct(o, e, !1, s)?.comments;
4054
+ if (!n) return;
4055
+ for (let t = 0; t < n.length; t++) {
4056
+ const e = n[t];
4057
+ if (!e?.v?.id) continue;
4058
+ const { parentId: o, done: s, content: l, ...c } = e.v, h = {
4059
+ ...c,
4060
+ content: Js(l)
4061
+ };
4062
+ o ? a.push({
4063
+ parentId: o,
4064
+ json: h
4065
+ }) : (s && (h.done = !0), i.set(h.id, h), r.push({
4066
+ r: e.r,
4067
+ v: h
4068
+ }));
4069
+ }
4070
+ const l = ut(o, e);
4071
+ l && it(l);
4072
+ });
4073
+ for (let t = 0; t < a.length; t++) {
4074
+ const { parentId: e, json: o } = a[t], s = i.get(e);
4075
+ s && (s.replies ??= []).push(o);
4076
+ }
4077
+ const c = [];
4078
+ if (o.forEach((t, o) => {
4079
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" !== t.type) return;
4080
+ const r = ct(o, e, !1, s), n = r?.comments;
4081
+ if (!n) return;
4082
+ const a = r?.authors;
4083
+ for (let t = 0; t < n.length; t++) {
4084
+ const e = n[t];
4085
+ if (!e?.r) continue;
4086
+ let o = a && void 0 !== e.v.authorId ? a[e.v.authorId] : void 0;
4087
+ if (o && o.startsWith("tc=")) {
4088
+ if (i.has(d(o.substring(3)))) continue;
4089
+ o = void 0;
4090
+ }
4091
+ const s = {
4092
+ id: Ct.uuidV4().toUpperCase(),
4093
+ asNote: !0,
4094
+ content: e.v.content ?? ""
4095
+ }, r = o ? Dt({ displayName: o }) : void 0;
4096
+ r && (s.personId = r.id), c.push({
4097
+ r: e.r,
4098
+ v: s
4099
+ });
4100
+ }
4101
+ const l = ut(o, e);
4102
+ l && it(l);
4103
+ }), 0 === r.length && 0 === c.length) return;
4104
+ const h = [...r, ...c], u = t.legacyDrawing;
4105
+ if (u?.xml) {
4106
+ const { rest: e, notes: o } = l(u.xml);
4107
+ if (o.length > 0) {
4108
+ const s = /* @__PURE__ */ new Map();
4109
+ for (let t = 0; t < o.length; t++) {
4110
+ const e = o[t];
4111
+ s.set(It.cellToString({
4112
+ rowIndex: e.row,
4113
+ colIndex: e.col
4114
+ }), e);
4115
+ }
4116
+ for (let t = 0; t < h.length; t++) {
4117
+ const e = h[t], o = s.get(String(e.r).toUpperCase());
4118
+ if (!o) continue;
4119
+ if (s.delete(String(e.r).toUpperCase()), !e.v.asNote) continue;
4120
+ const r = C(o.xml), n = {};
4121
+ if (r.anchor) {
4122
+ const [t, e, s, i, a, l, c, h] = r.anchor;
4123
+ n.anchor = {
4124
+ tl: {
4125
+ c: t - o.col,
4126
+ x: e,
4127
+ r: s - o.row,
4128
+ y: i
4129
+ },
4130
+ br: {
4131
+ c: a - o.col,
4132
+ x: l,
4133
+ r: c - o.row,
4134
+ y: h
4135
+ }
4136
+ };
4137
+ } else r.bounds && (n.bounds = r.bounds);
4138
+ r.style.fill && (n.fill = r.style.fill), r.style.stroke && (n.stroke = r.style.stroke), r.xml && (n.xml = r.xml), (n.anchor || n.bounds || n.fill || n.stroke || n.xml) && (e.v.box = n), r.visible && (e.v.shown = !0), r.alt && (e.v.description = r.alt);
4139
+ }
4140
+ const r = [];
4141
+ s.forEach((t) => {
4142
+ r.push(t.xml);
4143
+ });
4144
+ const i = n(e, r);
4145
+ i ? u.xml = i : delete t.legacyDrawing;
4146
+ }
4147
+ }
4148
+ t.comments = h;
4149
+ }, pt = (e, o) => {
4150
+ const s = ut(e, o);
4151
+ if (!s) return null;
4152
+ const r = t(Us(s));
4153
+ if (!r) return null;
4154
+ const n = { xml: ys(new TextDecoder("utf-8").decode(r.content)) }, i = [];
4155
+ return lt(s, Y)?.forEach((t, e) => {
4156
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" !== t.type) return;
4157
+ const o = ct(e, s, !0);
4158
+ "number" == typeof o && i.push({
4159
+ id: e,
4160
+ resId: o
4161
+ });
4162
+ }), i.length > 0 && (n.images = i), it(s), n;
4163
+ }, gt = (e, o) => {
4164
+ const s = ut(e, o);
4165
+ if (!s) return null;
4166
+ const r = h(s, t, K, q, Nt)?.formControl ?? null;
4167
+ return r && it(s), r;
4168
+ }, bt = (e, s, r, n, i = /* @__PURE__ */ new Set()) => {
4169
+ const a = ut(e, s);
4170
+ if (!a || i.has(a)) return null;
4171
+ const l = r ?? lt(s, Y)?.get(e)?.type;
4172
+ if (!l) return null;
4173
+ const c = t(Us(a));
4174
+ if (!c) return null;
4175
+ i.add(a);
4176
+ const h = a.substring(a.lastIndexOf("/") + 1), u = o.overrides[Us(a)] ?? o.defaults[h.substring(h.lastIndexOf(".") + 1).toLowerCase()], d = {
4177
+ id: e,
4178
+ type: l,
4179
+ name: h
4180
+ };
4181
+ if (u && (d.contentType = u), ((t, e) => t ? t.endsWith("+xml") || "application/xml" === t : /\.(xml|rels|vml)$/i.test(e))(u, h)) d.xml = new TextDecoder("utf-8").decode(c.content);
4182
+ else {
4183
+ const t = ct(e, s, !0);
4184
+ if ("number" != typeof t) return null;
4185
+ d.resId = t;
4186
+ }
4187
+ const p = [];
4188
+ return lt(a, Y)?.forEach((t, e) => {
4189
+ if (!t?.type) return;
4190
+ if (n && !n(t.type)) return;
4191
+ if ("External" === t.targetMode) {
4192
+ const o = ct(e, a, !0);
4193
+ "number" == typeof o && p.push({
4194
+ id: e,
4195
+ type: t.type,
4196
+ resId: o
4197
+ });
4198
+ return;
4199
+ }
4200
+ const o = bt(e, a, t.type, n, i);
4201
+ o && p.push(o);
4202
+ }), p.length > 0 && (d.parts = p), it(a), d;
4203
+ }, xt = p("coreprops", o, t, K, q, _), wt = p("extprops", o, t, K, q, _), Tt = p("custprops", o, t, K, q, _);
4204
+ Tt.forEach((t, e) => {
4205
+ t?.custom && it(e);
4206
+ });
4207
+ const Pt = new zt(), Ot = p("people", o, t, K, q, _);
4208
+ if (Ot.size > 0) {
4209
+ const [t, e] = Ot.entries().next().value;
4210
+ Pt.fromJSON(e?.persons), it(t);
4211
+ }
4212
+ const Dt = (t) => {
4213
+ if (t) return Pt.add(t).toJSON();
4214
+ }, Nt = {
4215
+ paramMap: G,
4216
+ getRefs: lt,
4217
+ getRef: ct,
4218
+ parsedRefs: Y,
4219
+ readEmbeddedPart: (t, e) => bt(t, e),
4220
+ addPerson: Dt,
4221
+ serializeElement: Z,
4222
+ onWarning: E
4223
+ }, _t = [], Rt = /* @__PURE__ */ new Map();
4224
+ if (G.set(is, Rt), s) {
4225
+ const t = await Q.getTextStream(s, F);
4226
+ if (t) {
4227
+ const e = ((t, e) => {
4228
+ let o = !1, s = !1, r = 0, n = "";
4229
+ const i = new Qo();
4230
+ return {
4231
+ onOpenTag: (t) => {
4232
+ const e = Zo(t.name);
4233
+ "t" === e ? o && 0 === r && (s = !0) : "si" === e ? (o = !0, n = "", i.reset(), r = 0) : "rPh" === e || "phoneticPr" === e ? r++ : o && 0 === r && i.onOpenTag(e, t.attributes);
4234
+ },
4235
+ onText: (t) => {
4236
+ s && (n += t, i.onText(t));
4237
+ },
4238
+ onCloseTag: (e) => {
4239
+ const a = Zo(e.name);
4240
+ "t" === a ? s = !1 : "si" === a ? (t(v(n), i.take() ?? void 0), o = !1, n = "") : "rPh" === a || "phoneticPr" === a ? r > 0 && r-- : i.onCloseTag(a);
4241
+ },
4242
+ onError: (t) => {
4243
+ e?.(`Error parsing shared strings: ${t?.message ?? t}`);
4244
+ }
4245
+ };
4246
+ })((t, e) => {
4247
+ e && Rt.set(_t.length, e), _t.push(t);
4248
+ }, (t) => {
4249
+ E(t, s);
4250
+ });
4251
+ try {
4252
+ await go.parseStream(t, e, { xmlns: !1 });
4253
+ } catch (t) {
4254
+ throw new Error(`Error parsing shared strings: '${s}'`, { cause: t });
4255
+ }
4256
+ }
4257
+ }
4258
+ w?.mark("shared-strings");
4259
+ let Lt = _t.length;
4260
+ const Vt = /* @__PURE__ */ new Map();
4261
+ let jt = Lt;
4262
+ const Bt = (t) => {
4263
+ const e = Vt.get(t);
4264
+ if (void 0 !== e) return e;
4265
+ const o = jt;
4266
+ return Vt.set(t, jt++), _t.push(t), o;
4267
+ }, Ft = [];
4268
+ o.slicersCache = Ft;
4269
+ const Ht = Q.getNames(), Wt = Ht.length;
4270
+ for (let t = 0; t < Wt; t++) {
4271
+ const e = Ht[t];
4272
+ e && (e.startsWith("xl/slicerCache") || e.startsWith("xl/timelineCaches/") && e.endsWith(".xml")) && Ft.push(`/${e}`);
4273
+ }
4274
+ const qt = p("slicersCache", o, t, K, q, Nt), Ut = /* @__PURE__ */ new Map();
4275
+ qt.forEach((t, e) => {
4276
+ t?.cacheName && (t.cachePath = e, Ut.set(t.cacheName, t));
4277
+ }), G.set("slicerCaches", Ut);
4278
+ const Kt = [];
4279
+ o.slicers = Kt;
4280
+ for (let t = 0; t < Wt; t++) {
4281
+ const e = Ht[t];
4282
+ e && (e.startsWith("xl/slicers/") || e.startsWith("xl/timelines/")) && e.endsWith(".xml") && Kt.push(`/${e}`);
4283
+ }
4284
+ const Jt = {
4285
+ getFile: t,
4286
+ domParser: K,
4287
+ getAddress: (t, e) => {
4288
+ const o = ct(e, t, !1);
4289
+ return "string" == typeof o ? o : null;
4290
+ },
4291
+ getBytes: (e, o) => {
4292
+ const s = ut(o, e), r = s ? t(s.substring(1))?.content : void 0;
4293
+ return r ? r.slice().buffer : null;
4294
+ },
4295
+ addFetched: (t, e) => {
4296
+ const o = B.add({
4297
+ source: { buffer: t },
4298
+ fetchedFrom: e
4299
+ });
4300
+ return o.addReference(z), X.add(o), H.toResourceId(o);
4301
+ },
4302
+ markAbsorbed: it
4303
+ }, Qt = /* @__PURE__ */ new Map();
4304
+ for (const t of u.getAll()) Qt.set(t.structure, t.beginRead(Jt));
4305
+ const Yt = ((t, e) => {
4306
+ const o = (o) => {
4307
+ const s = t(o);
4308
+ return s ? e.parseFromString(new TextDecoder().decode(s.content), "text/xml").documentElement ?? null : null;
4309
+ }, s = ge(o(le), "s").map((t) => ({
4310
+ t: t.getAttribute("t") ?? "",
4311
+ keys: me(t)
4312
+ })), r = ge(o(ce), "rv").map((t) => {
4313
+ const e = ge(t, "fb")[0];
4314
+ return {
4315
+ s: parseInt(t.getAttribute("s") ?? "-1", 10),
4316
+ values: ge(t, "v").map((t) => t.textContent ?? ""),
4317
+ fb: e ? e.textContent ?? "" : null
4318
+ };
4319
+ }), n = ge(o(he), "a").map((t) => {
4320
+ const e = be(t), o = parseInt(t.getAttribute("r") ?? "", 10), s = parseInt(t.getAttribute("c") ?? "", 10), r = o > 0 ? o : e.length;
4321
+ return {
4322
+ rows: r,
4323
+ columns: s > 0 ? s : Math.max(1, Math.ceil(e.length / Math.max(1, r))),
4324
+ items: e
4325
+ };
4326
+ }), i = ge(o(ue), "s").map(me), a = o(de), l = ge(ge(a, "spbArrays")[0], "a").map(be), c = ge(ge(a, "spbData")[0], "spb").map((t) => ({
4327
+ s: parseInt(t.getAttribute("s") ?? "-1", 10),
4328
+ values: ge(t, "v").map((t) => t.textContent ?? "")
4329
+ })), h = o(pe), u = ve(ge(ge(h, "global")[0], "keyFlags")[0]), d = /* @__PURE__ */ new Map();
4330
+ for (const t of ge(ge(h, "types")[0], "type")) d.set(t.getAttribute("name") ?? "", ve(ge(t, "keyFlags")[0]));
4331
+ const p = o(fe), f = ge(ge(p, "dxfs")[0], "dxf").map((t) => ge(t, "numFmt")[0]?.getAttribute("formatCode") ?? null), g = ge(ge(p, "richProperties")[0], "rPr").map((t) => t.getAttribute("n") ?? "");
4332
+ return {
4333
+ structures: s,
4334
+ values: r,
4335
+ arrays: n,
4336
+ bagStructures: i,
4337
+ bagArrays: l,
4338
+ bags: c,
4339
+ globalKeyFlags: u,
4340
+ typeKeyFlags: d,
4341
+ richStyles: ge(ge(p, "richStyles")[0], "rSty").map((t) => {
4342
+ const e = /* @__PURE__ */ new Map();
4343
+ for (const o of ge(t, "rpv")) {
4344
+ const t = g[parseInt(o.getAttribute("i") ?? "-1", 10)];
4345
+ t && e.set(t, o.textContent ?? "");
4346
+ }
4347
+ const o = parseInt(t.getAttribute("dxfid") ?? "", 10);
4348
+ return {
4349
+ numberFormat: e.get("NumberFormat") ?? (o >= 0 ? f[o] ?? null : null),
4350
+ isTitle: "1" === e.get("IsTitleField"),
4351
+ isHero: "1" === e.get("IsHeroField")
4352
+ };
4353
+ })
4354
+ };
4355
+ })(t, K), te = r(Yt, Qt, (t) => {
4356
+ E(t, "/xl/richData/rdrichvalue.xml");
4357
+ });
4358
+ G.set("richData", Yt.values.map((t, e) => te.cellValue(e)));
4359
+ for (let t = 0; t < Wt; t++) {
4360
+ const e = Ht[t];
4361
+ e.startsWith("xl/richData/") && !e.includes("/_rels/") && it(e);
4362
+ }
4363
+ const ee = p("themes", o, t, K, q, Nt);
4364
+ let oe = null;
4365
+ if (ee && ee.entries) {
4366
+ let t = ee.entries().next();
4367
+ t?.value?.[1] && (oe = t.value[1]);
4368
+ }
4369
+ const se = new Gt(oe);
4370
+ let ne = p("styles", o, t, K, q, Nt).entries().next()?.value?.[1];
4371
+ ne && (ne = JSON.parse(St.JSONStableStringify(ne)));
4372
+ const ie = p("workbooks", o, t, K, q, Nt);
4373
+ G.set(ns, !0 === ie.entries().next().value?.[1]?.date1904), "none" !== (m.calcOnLoad ?? g) && G.set(rs, ((t, e) => {
4374
+ const o = /* @__PURE__ */ new Set();
4375
+ if (t) for (let e = 0; e < t.length; e++) o.add(String(t[e]?.name).toUpperCase());
4376
+ if (e) for (let t = 0; t < e.length; t++) try {
4377
+ const s = e[t](() => {
4378
+ throw new Error("Not evaluating.");
4379
+ }, (t, e, s, r) => {
4380
+ for (const t of Object.keys(r)) o.add(t.toUpperCase());
4381
+ }, /* @__PURE__ */ new Map());
4382
+ for (const t of s.keys()) o.add(t.toUpperCase());
4383
+ } catch {}
4384
+ return (t) => o.has(t) || $t.has(t);
4385
+ })(ie.entries().next().value?.[1]?.names, m.functions)), w?.mark("side-parts-json"), await Promise.all(ot);
4386
+ {
4387
+ const t = ie.entries().next().value?.[1], o = e(t?.names), s = t?.sheets ?? [];
4388
+ for (let t = 0; t < s.length; t++) {
4389
+ const e = s[t], r = j(e);
4390
+ if ("macro" === e?.kind && r?.part.xml) {
4391
+ r.part.xml = vt(r.part.xml, _t);
4392
+ continue;
4393
+ }
4394
+ const n = k(e);
4395
+ n && et(n, o);
4396
+ }
4397
+ const r = t?.names;
4398
+ if (r) for (let t = 0; t < r.length; t++) {
4399
+ const e = r[t]?.ref;
4400
+ "string" == typeof e && (r[t].ref = o.readDetached(e));
4401
+ }
4402
+ }
4403
+ R && V > 0 && (R(L, L), await new Promise((t) => setTimeout(t, 0))), w?.mark("sheets");
4404
+ const ae = {
4405
+ ...ie.entries().next().value?.[1],
4406
+ styles: ne,
4407
+ theme: se.toJSON()
4408
+ }, xe = ((t, e, o, s) => {
4409
+ const r = {}, n = (t, e) => {
4410
+ if (t) for (const { key: o, value: s } of t) {
4411
+ const t = e[o];
4412
+ if (t && s) if ("revisionNumber" === t) {
4413
+ const t = parseInt(s, 10);
4414
+ Number.isFinite(t) && (r.revisionNumber = t);
4415
+ } else r[t] = s;
4416
+ }
4417
+ };
4418
+ if (n(t, ws), n(e, Ts), o) {
4419
+ const t = [];
4420
+ for (const e of o) {
4421
+ const o = Cs(e);
4422
+ o ? t.push(o) : s?.(`The custom document property '${e.key}' holds a value of a kind that is not read (${e.kind ? "vt:" + e.kind : "none"}); it was dropped.`, "xlsx.docProps.custom.kind");
4423
+ }
4424
+ t.length > 0 && (r.custom = t);
4425
+ }
4426
+ return Object.keys(r).length > 0 ? r : void 0;
4427
+ })(xt.values().next().value?.properties, wt.values().next().value?.properties, Tt.values().next().value?.custom, (t, e) => {
4428
+ E(t, "docProps/custom.xml", e);
4429
+ });
4430
+ xe && (ae.properties = xe), ((t, e) => {
4431
+ if (!e || 0 === e.size) return;
4432
+ const o = t.styles;
4433
+ if (!o) return;
4434
+ const s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
4435
+ for (const o of t.sheets ?? []) {
4436
+ const t = k(o);
4437
+ if (!t) continue;
4438
+ const n = /* @__PURE__ */ new Set();
4439
+ Es(t.cols) || n.add(0);
4440
+ for (const e of t.directStyles ?? []) n.add(Array.isArray(e) ? e[1] : e.v);
4441
+ for (const e of t.rows ?? []) {
4442
+ const t = ks(e);
4443
+ void 0 !== t && n.add(t);
4444
+ }
4445
+ for (const e of t.cols ?? []) {
4446
+ const t = ks(e);
4447
+ void 0 !== t && n.add(t);
4448
+ }
4449
+ let i = !1;
4450
+ for (const t of n) if (e.has(t)) {
4451
+ i = !0;
4452
+ break;
4453
+ }
4454
+ if (i) {
4455
+ t.protection = {
4456
+ ...t.protection ?? { sheet: !0 },
4457
+ showFormulas: !1
4458
+ };
4459
+ for (const t of n) (e.has(t) ? r : s).add(t);
4460
+ }
4461
+ }
4462
+ if (0 === s.size) return;
4463
+ const n = o.direct ?? (o.direct = []);
4464
+ for (const t of s) 0 !== t && Is(n[t] ?? (n[t] = {}), !0);
4465
+ for (const t of r) 0 !== t && Is(n[t] ?? (n[t] = {}), !1);
4466
+ if (s.has(0)) {
4467
+ const t = o.named ?? (o.named = []), e = Mt.BuiltInName.Normal.toLowerCase();
4468
+ let s = t.find((t) => t.name?.toLowerCase() === e);
4469
+ s || (s = {
4470
+ name: Mt.BuiltInName.Normal,
4471
+ style: {}
4472
+ }, t.push(s)), Is(s.style, !0);
4473
+ }
4474
+ })(ae, G.get(As)), ((t, e) => {
4475
+ if (e && 0 !== e.size) for (const o of t.sheets ?? []) {
4476
+ const t = k(o), s = t?.pivotTables;
4477
+ if (!t || !s || 0 === s.length) continue;
4478
+ const r = s.map(at), n = s.map(() => []);
4479
+ for (const [o, s] of t.directStyles ?? []) {
4480
+ if (!e.has(s)) continue;
4481
+ const t = It.fastStringToRange(o);
4482
+ for (let e = 0; e < r.length; e++) {
4483
+ const o = r[e];
4484
+ if (!o) continue;
4485
+ const s = Math.max(t.rowStart, o.rowStart), i = Math.min(t.rowEnd, o.rowEnd), a = Math.max(t.colStart, o.colStart), l = Math.min(t.colEnd, o.colEnd);
4486
+ if (s > i || a > l) continue;
4487
+ const c = It.rangeToString({
4488
+ rowStart: s - o.rowStart,
4489
+ rowEnd: i - o.rowStart,
4490
+ colStart: a - o.colStart,
4491
+ colEnd: l - o.colStart
4492
+ });
4493
+ c && n[e].push(c);
4494
+ }
4495
+ }
4496
+ for (let t = 0; t < s.length; t++) n[t].length > 0 && (s[t].buttons = n[t]);
4497
+ }
4498
+ })(ae, G.get(Ps));
4499
+ const ye = G.get(Fs);
4500
+ if (Os(ae, ye), ((t) => {
4501
+ const e = {
4502
+ colStart: 0,
4503
+ rowStart: 0,
4504
+ colEnd: ft,
4505
+ rowEnd: tt
4506
+ };
4507
+ for (const o of t.sheets ?? []) {
4508
+ const t = k(o);
4509
+ if (!t) continue;
4510
+ const s = [];
4511
+ if (zs(t.cols, !0, e, s), zs(t.rows, !1, e, s), 0 === s.length) continue;
4512
+ const r = [];
4513
+ for (const [e, o] of t.directStyles ?? []) r.push({
4514
+ ...It.fastStringToRange(e),
4515
+ value: {
4516
+ kind: 0,
4517
+ index: o
4518
+ }
4519
+ });
4520
+ r.push(...s);
4521
+ const n = [], i = new kt.IteratorInstance(r, { axis: Et.Column });
4522
+ for (let t = i.next(); !t.done; t = i.next()) {
4523
+ const o = t.value.overlaps;
4524
+ let s;
4525
+ if (1 === o.length) {
4526
+ if (s = o[0].value, 0 === s.index) continue;
4527
+ } else {
4528
+ let t, e, r;
4529
+ for (let s = 0; !t && s < o.length; s++) {
4530
+ const n = o[s].value;
4531
+ 0 === n.kind ? t = n : 1 === n.kind ? e = n : r = n;
4532
+ }
4533
+ s = t ?? e ?? r;
4534
+ }
4535
+ n.push([It.rangeToString(t.value.range, e), s.index]);
4536
+ }
4537
+ n.length > 0 ? t.directStyles = n : delete t.directStyles;
4538
+ }
4539
+ })(ae), ye) ((t, e, o) => {
4540
+ if (!e || 0 === e.size || !o) return;
4541
+ const s = (t) => {
4542
+ if (void 0 === t || 0 === t) return null;
4543
+ const s = e.get(t);
4544
+ return void 0 !== s ? o.controls[s] ?? null : null;
4545
+ };
4546
+ for (const e of t.sheets ?? []) {
4547
+ const t = k(e);
4548
+ if (!t) continue;
4549
+ const o = /* @__PURE__ */ new Map();
4550
+ for (const e of t.directStyles ?? []) {
4551
+ const t = Array.isArray(e) ? e[0] : e.r, r = s(Array.isArray(e) ? e[1] : e.v);
4552
+ if (!r) continue;
4553
+ const n = JSON.stringify(r);
4554
+ let i = o.get(n);
4555
+ i || (i = {
4556
+ control: r,
4557
+ addresses: []
4558
+ }, o.set(n, i)), Hs(t, i.addresses);
4559
+ }
4560
+ if (0 === o.size) continue;
4561
+ const r = [...t.cellControls ?? []];
4562
+ for (const { control: t, addresses: e } of o.values()) r.push({
4563
+ r: e.join(","),
4564
+ v: t
4565
+ });
4566
+ t.cellControls = r;
4567
+ }
4568
+ })(ae, ye, p("featurePropertyBag", o, t, K, q, Nt).values().next().value?.featurePropertyBag);
4569
+ {
4570
+ const e = /* @__PURE__ */ new Map();
4571
+ p("slicers", o, t, K, q, Nt).forEach((t, o) => {
4572
+ t?.slicers && e.set(o, t.slicers);
4573
+ }), re(ae, {
4574
+ warn: (t, e) => {
4575
+ E(t, "xl/slicers", e);
4576
+ },
4577
+ markAbsorbed: it,
4578
+ slicerParts: e
4579
+ });
4580
+ }
4581
+ ae.calc = {
4582
+ ...ae.calc ?? {},
4583
+ legacyIntersect: !0
4584
+ }, _t.length > 0 && (ae.strings = _t);
4585
+ const we = Pt.toJSON();
4586
+ we && we.length > 0 && (ae.people = we);
4587
+ const Te = Q.getEntry("xl/vbaProject.bin");
4588
+ if (Te) try {
4589
+ const { VBAProject: t } = await import("./BO8o53Yo-gLFNELS.mjs"), e = t.extract(Te);
4590
+ if (e) {
4591
+ const o = /* @__PURE__ */ new Map();
4592
+ for (const t of ae.sheets ?? []) {
4593
+ const e = k(t), s = e?.codeName;
4594
+ s && o.set(s, e);
4595
+ }
4596
+ for (const s of e.modules) {
4597
+ const e = { language: "vba" }, { header: r, body: n } = t.splitAttributes(s.code);
4598
+ n && (e.source = n), r && (e.sourceHeader = r);
4599
+ const i = "document" === s.type ? o.get(s.name) : void 0;
4600
+ i || "document" !== s.type || (e.scope = "workbook");
4601
+ const a = i ? i.modules ??= {} : ae.modules ??= {};
4602
+ a[s.name] || (a[s.name] = e);
4603
+ }
4604
+ a?.(e);
4605
+ } else S.push(["Unable to parse VBA project.", "xl/vbaProject.bin"]);
4606
+ } catch (t) {
4607
+ S.push([`Error extracting VBA: ${t?.message ?? t}`, "xl/vbaProject.bin"]);
4608
+ }
4609
+ const Se = G.get("calcId"), Ce = void 0 === Se || !(Number(Se) >= 191029), Ae = m.calcOnLoad ?? ("auto" === g && Ce ? "full" : g), ke = {
4610
+ ...m,
4611
+ calcOnLoad: Ae,
4612
+ resources: B,
4613
+ json: ae
4614
+ };
4615
+ if (void 0 === ke.disableLoadAutoFit) {
4616
+ const t = G.get(mt);
4617
+ ke.disableLoadAutoFit = !!t?.declared && t.normalIsThemeFont && await nt(t.faces);
4618
+ }
4619
+ w?.mark("json-assembled");
4620
+ const Ee = new Zt(ke);
4621
+ if (w?.mark("workbook-constructed"), X.forEach((t) => {
4622
+ t.deleteReference(z);
4623
+ }), H.endPersist(), y) {
4624
+ i(Ee);
4625
+ const t = /* @__PURE__ */ new Map();
4626
+ let e = 0;
4627
+ for (const o of Q.getNames()) {
4628
+ const s = Q.getEntry(o);
4629
+ if (!s) continue;
4630
+ const r = Q.getRawEntry(o), n = r ? {
4631
+ data: s,
4632
+ uncompressedSize: Q.uncompressedSize(o),
4633
+ raw: {
4634
+ compressedData: r.data,
4635
+ compressionMethod: r.compressionMethod,
4636
+ signature: r.signature
4637
+ }
4638
+ } : {
4639
+ data: s,
4640
+ uncompressedSize: Q.uncompressedSize(o)
4641
+ };
4642
+ t.set(o, n), e += s.byteLength;
4643
+ }
4644
+ if (e > 67108864) S.push([`Source package too large to retain (${e} bytes, limit ${yt}); unmodeled parts will be dropped on save.`, "SourcePackage"]);
4645
+ else if (t.size > 0) {
4646
+ const e = new A(t, rt);
4647
+ b(Ee, e);
4648
+ let o = Ee.getWorksheets().getItems();
4649
+ const s = Ee.getTransactions().addListener({ onCommitEnd: (t) => {
4650
+ const o = t.getOperation()?.name;
4651
+ "insertCells" !== o && "deleteCells" !== o || e.markStructuralChange();
4652
+ } }), r = Ee.addListeners({ onSheetsChange: () => {
4653
+ const t = Ee.getWorksheets().getItems();
4654
+ (t.length !== o.length || t.some((t, e) => t !== o[e])) && e.markStructuralChange(), o = t;
4655
+ } });
4656
+ Ee.addListeners({ onClose: () => {
4657
+ s(), r(), i(Ee);
4658
+ } });
4659
+ }
4660
+ }
4661
+ if (S.length && M?.onWarning) {
4662
+ const t = /* @__PURE__ */ new Set();
4663
+ for (const e of S) {
4664
+ const [o, s, r] = e, n = r ?? o;
4665
+ t.has(n) || (t.add(n), M.onWarning(o, s));
4666
+ }
4667
+ }
4668
+ return w && !0 === f && console.table(w.toTable()), await Ee.whenFontsReady(), Ee;
4669
+ } catch (t) {
4670
+ let e = "Unable to parse XLSX.";
4671
+ throw t instanceof Wt && (e = "Unable to open XLSX. There are too many rows or columns."), new Error(e, { cause: t });
4672
+ } finally {
4673
+ await Q.close().catch(() => {});
4674
+ }
4675
+ };
4676
+ export { as as a, As as i, Fs as n, Ps as r, Zs as readXLSX, qs as t };