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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/browser/cjs/BGFXHa9DqD7qfj7K.cjs +5 -0
  2. package/browser/cjs/C8oC1tPbhgR0Dqtx.cjs +2 -0
  3. package/browser/cjs/CIQ0CyhkW02G7UhX.cjs +1 -0
  4. package/browser/cjs/{D5Y4KQhKdukOkjvA.cjs → D3EWCPfCu-qMOIGd.cjs} +1 -2
  5. package/browser/cjs/{BAtEL-5TLyoaPFDP.cjs → DULsYP_GcPGLVYSE.cjs} +10 -1
  6. package/browser/cjs/DtBN3UOzNJjYBwJ6.cjs +1 -0
  7. package/browser/cjs/index.cjs +1 -1
  8. package/browser/cjs/sNZR19Wk-XQ2xZ9E.cjs +1 -0
  9. package/browser/esm/{BkNXyG6NC-w5Xo92.mjs → 9kAH9485xCkOzN_I.mjs} +28 -13
  10. package/browser/esm/{Cok_fBIUCHDSrKw0.mjs → B8BqrWUHPa06PzmO.mjs} +446 -347
  11. package/browser/esm/{Dj7D2nVdAZ3TiUks.mjs → BdmxnPd0ptyqOCaM.mjs} +1595 -1124
  12. package/browser/esm/BzlhIt5zSG0Ts4xd.mjs +3324 -0
  13. package/browser/esm/CED9M7CASY6R5LBH.mjs +159 -0
  14. package/browser/esm/{4BWLu134ABlCQEtM.mjs → DNwAYvPHH1G27K-w.mjs} +1824 -1051
  15. package/browser/esm/{ijQzHH-bvDfUHIi1.mjs → DbSKfjIyE4a1YHoX.mjs} +1 -1
  16. package/browser/esm/{Dz1Dp8DDJvhd09RR.mjs → DtypWHI_cwfAvvyR.mjs} +1 -1
  17. package/browser/esm/PpS5wqbPAZ9D3W7c.mjs +67 -0
  18. package/browser/esm/{Ctqql4O-3xj2K8vv.mjs → aL7oQqItresvrEf2.mjs} +2 -2
  19. package/browser/esm/{CLWzJJyoSrykkVLX.mjs → h9ucGRwzGRA2N44D.mjs} +2 -2
  20. package/browser/esm/index.mjs +3 -3
  21. package/node/esm/{fOnuUjpPCAzmuIXN.mjs → A5sK8gK9ymQOyChG.mjs} +2 -2
  22. package/node/esm/CCD1vEduHhKax_d_.mjs +170 -0
  23. package/node/esm/{CF1R5ovFsRNu--Rw.mjs → CJGTDWKH_yrWAW8o.mjs} +1934 -1143
  24. package/node/esm/{CEAmv36xpTNgFwl_.mjs → CsTuNxyS02vBz0Tk.mjs} +49 -35
  25. package/node/esm/{Ctcl4jN52INWpKWC.mjs → DOXXVsfrZi_6L0V7.mjs} +607 -506
  26. package/node/esm/OkoETXoPSSH3gQxa.mjs +2959 -0
  27. package/node/esm/TERvDGVSsvCefEiX.mjs +3410 -0
  28. package/node/esm/index.mjs +40 -25
  29. package/node/esm/{CEV7nKotMpeRRnQC.mjs → mlCt7xhd97xcwrEr.mjs} +1 -1
  30. package/package.json +3 -3
  31. package/types/src/ConditionalFormatRules.d.ts +3 -3
  32. package/types/src/DataValidationRules.d.ts +18 -2
  33. package/types/src/ExcelCalcStamp.d.ts +39 -0
  34. package/types/src/ExcelCompat.d.ts +197 -42
  35. package/types/src/LegacyFormula.d.ts +28 -7
  36. package/types/src/Plugin.d.ts +16 -5
  37. package/types/src/ProtectionAttributes.d.ts +38 -0
  38. package/types/src/SourcePackage.d.ts +31 -12
  39. package/types/src/Types.d.ts +17 -0
  40. package/types/src/reader/HiddenFormulas.d.ts +16 -0
  41. package/types/src/reader/Warning.d.ts +29 -0
  42. package/types/src/reader/dom/DOMTransformer.d.ts +1 -1
  43. package/types/src/reader/dom/ExecutionContext.d.ts +16 -3
  44. package/types/src/reader/dom/Types.d.ts +19 -3
  45. package/types/src/reader/domVisitors/CommentVisitor.d.ts +18 -1
  46. package/types/src/reader/domVisitors/CommentsVisitor.d.ts +2 -2
  47. package/types/src/reader/domVisitors/ExternalLinkVisitor.d.ts +21 -3
  48. package/types/src/reader/domVisitors/SheetColorContainerVisitor.d.ts +2 -2
  49. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +6 -1
  50. package/types/src/reader/domVisitors/ThreadedCommentVisitor.d.ts +9 -1
  51. package/types/src/reader/domVisitors/ThreadedCommentsVisitor.d.ts +2 -2
  52. package/types/src/reader/domVisitors/WorkbookVisitor.d.ts +11 -1
  53. package/types/src/reader/sax/LeanSaxParser.d.ts +58 -0
  54. package/types/src/reader/sax/SaxParser.d.ts +11 -1
  55. package/types/src/reader/sax/SaxVisitor.d.ts +3 -2
  56. package/types/src/reader/saxVisitors/ContentTypesVisitor.d.ts +9 -0
  57. package/types/src/reader/saxVisitors/WorksheetVisitor.d.ts +11 -4
  58. package/types/src/utils/VmlNoteShapes.d.ts +75 -0
  59. package/types/src/vba/VBAProject.d.ts +52 -4
  60. package/types/src/writer/builder/ContentTypes.d.ts +13 -0
  61. package/types/src/writer/builder/Emitter.d.ts +6 -6
  62. package/types/src/writer/builder/OpcXmlUtils.d.ts +2 -0
  63. package/types/src/writer/builder/PackageBuilder.d.ts +70 -22
  64. package/types/src/writer/builder/PartWriter.d.ts +5 -0
  65. package/types/src/writer/builder/RelationshipSet.d.ts +3 -0
  66. package/types/src/writer/builder/Types.d.ts +107 -38
  67. package/types/src/writer/builder/_Types.d.ts +17 -0
  68. package/types/src/writer/emitters/CommentsEmitter.d.ts +52 -0
  69. package/types/src/writer/emitters/EmbeddedPartEmitter.d.ts +60 -0
  70. package/types/src/writer/emitters/ExternalLinkEmitter.d.ts +19 -0
  71. package/types/src/writer/emitters/LegacyDrawingEmitter.d.ts +18 -0
  72. package/types/src/writer/emitters/PersonsEmitter.d.ts +17 -0
  73. package/types/src/writer/emitters/PivotTableEmitter.d.ts +45 -0
  74. package/types/src/writer/emitters/ThreadedCommentsEmitter.d.ts +21 -0
  75. package/types/src/writer/emitters/WorkbookEmitter.d.ts +16 -3
  76. package/types/src/writer/utils/DrawMLUtils.d.ts +16 -1
  77. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +28 -0
  78. package/browser/cjs/Bg0e53JZa8vhmm5a.cjs +0 -1
  79. package/browser/cjs/CK5FFUvet6FnIYO_.cjs +0 -5
  80. package/browser/cjs/DV6LeTEiiFUrZoxj.cjs +0 -1
  81. package/browser/cjs/DWkuoJSgvcXJTdN1.cjs +0 -1
  82. package/browser/cjs/Db8YjGM6TG34c8aT.cjs +0 -1
  83. package/browser/esm/BzQ_lPzc8C4OTIGZ.mjs +0 -99
  84. package/browser/esm/CJknI8BYGSZr-4zS.mjs +0 -52
  85. package/browser/esm/D-m_kQLaewdwuXaF.mjs +0 -2685
  86. package/node/esm/CvnRSooxEQdlJgMn.mjs +0 -2766
  87. package/node/esm/DQd0vxzTaPt2qSL-.mjs +0 -108
  88. package/node/esm/ssSlRCbCqxvZ9IX8.mjs +0 -2481
@@ -0,0 +1,3410 @@
1
+ /**
2
+ * @license @sheetxl/io-xlsx - SheetXL - Import/Export from/to Excel - v0.8.0-beta.3
3
+ *
4
+ * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
+ * License: The license can be found at https://www.sheetxl.com/license.
6
+ */
7
+ import { a as t, d as e, f as s, h as o, l as r, m as i, n, p as a, s as c, t as l, u as h } from "./CCD1vEduHhKax_d_.mjs";
8
+ import { $ as u, D as p, F as d, G as f, H as g, I as m, J as x, K as y, M as b, N as T, O as v, Q as w, R as S, T as C, X as A, Y as O, Z as E, d as P, et as I, g as D, i as _, nt as V, p as L, q as N, s as $, v as R, x as j, y as M, z as B } from "./OkoETXoPSSH3gQxa.mjs";
9
+ import { BufferUtils as H, CommonUtils as F, ExpectedError as W } from "@sheetxl/utils";
10
+ import { AddressUtils as z, CommonUtils as X, CoordUtils as q, FormulaError as U, ICondition as G, IConditionalFormat as K, IRange as Z, OutOfBoundsError as J, ResourceCollection as Q, Theme as Y, Tuple as tt, Workbook as et } from "@sheetxl/sdk";
11
+ import { BlobReader as st, Uint8ArrayReader as ot, Uint8ArrayWriter as rt, ZipReader as it } from "@zip.js/zip.js";
12
+ var nt = /* @__PURE__ */ new Uint8Array(0), at = class t {
13
+ constructor(t, e, s) {
14
+ this.buffers = /* @__PURE__ */ new Map(), this.zip = t, this.entries = e, this.rawBuffer = s;
15
+ }
16
+ static normalize(t) {
17
+ return t.startsWith("/") ? t.slice(1) : t;
18
+ }
19
+ static async create(e) {
20
+ const s = e instanceof Blob ? nt : e instanceof Uint8Array ? e : new Uint8Array(e), o = new it(e instanceof Blob ? new st(e) : new ot(s)), r = /* @__PURE__ */ new Map();
21
+ for (const t of await o.getEntries()) t.directory || r.set(t.filename, t);
22
+ return new t(o, r, s);
23
+ }
24
+ getNames() {
25
+ return [...this.entries.keys()];
26
+ }
27
+ has(e) {
28
+ return this.entries.has(t.normalize(e));
29
+ }
30
+ uncompressedSize(e) {
31
+ return this.entries.get(t.normalize(e))?.uncompressedSize ?? 0;
32
+ }
33
+ async getBuffer(e) {
34
+ const s = t.normalize(e), o = this.buffers.get(s);
35
+ if (o) return o;
36
+ const r = this.entries.get(s);
37
+ if (!r) return null;
38
+ const i = await r.getData(new rt());
39
+ return this.buffers.set(s, i), i;
40
+ }
41
+ async prefetch(t) {
42
+ const e = [];
43
+ for (const [s, o] of this.entries) !this.buffers.has(s) && t(s, o) && e.push(o.getData(new rt()).then((t) => {
44
+ this.buffers.set(s, t);
45
+ }));
46
+ await Promise.all(e);
47
+ }
48
+ getEntry(e) {
49
+ return this.buffers.get(t.normalize(e)) ?? null;
50
+ }
51
+ async getTextStream(e, s) {
52
+ const o = this.entries.get(t.normalize(e));
53
+ if (!o) return null;
54
+ const r = new TransformStream();
55
+ o.getData(r.writable).catch(() => {});
56
+ const i = r.readable.getReader(), n = new TextDecoder("utf-8");
57
+ return new ReadableStream({ async pull(t) {
58
+ const { value: e, done: o } = await i.read();
59
+ if (o) {
60
+ const e = n.decode();
61
+ e && t.enqueue(e), t.close();
62
+ return;
63
+ }
64
+ s?.(e.byteLength);
65
+ const r = n.decode(e, { stream: !0 });
66
+ r && t.enqueue(r);
67
+ } }).getReader();
68
+ }
69
+ getRawEntry(e) {
70
+ const s = this.entries.get(t.normalize(e));
71
+ if (!s || s.encrypted) return null;
72
+ const o = s.offset;
73
+ if (o + 30 > this.rawBuffer.byteLength) return null;
74
+ const r = new DataView(this.rawBuffer.buffer, this.rawBuffer.byteOffset + o, 30);
75
+ if (67324752 !== r.getUint32(0, !0)) return null;
76
+ const i = o + 30 + r.getUint16(26, !0) + r.getUint16(28, !0), n = i + s.compressedSize;
77
+ return n > this.rawBuffer.byteLength ? null : {
78
+ data: this.rawBuffer.subarray(i, n),
79
+ compressionMethod: s.compressionMethod,
80
+ signature: s.signature
81
+ };
82
+ }
83
+ async close() {
84
+ await this.zip.close();
85
+ }
86
+ }, ct = class {
87
+ constructor(t) {
88
+ this._sink = t, this._samples = [], this._t0 = lt(), this._tPrev = this._t0, this._heapPrev = ht();
89
+ }
90
+ mark(t) {
91
+ const e = lt(), s = ht(), o = {
92
+ label: t,
93
+ tMs: e - this._t0,
94
+ dtMs: e - this._tPrev,
95
+ heapBytes: s,
96
+ dHeapBytes: void 0 !== s && void 0 !== this._heapPrev ? s - this._heapPrev : void 0,
97
+ rssBytes: ut()
98
+ };
99
+ this._tPrev = e, this._heapPrev = s, this._samples.push(o), this._sink?.(o);
100
+ }
101
+ samples() {
102
+ return this._samples;
103
+ }
104
+ toTable() {
105
+ return this._samples.map((t) => ({
106
+ phase: t.label,
107
+ tMs: Math.round(t.tMs),
108
+ dtMs: Math.round(t.dtMs),
109
+ heapMB: void 0 !== t.heapBytes ? pt(t.heapBytes / 1048576) : "—",
110
+ dHeapMB: void 0 !== t.dHeapBytes ? pt(t.dHeapBytes / 1048576) : "—",
111
+ rssMB: void 0 !== t.rssBytes ? pt(t.rssBytes / 1048576) : "—"
112
+ }));
113
+ }
114
+ }, lt = "object" == typeof performance && "function" == typeof performance.now ? () => performance.now() : () => Date.now();
115
+ function ht() {
116
+ const t = "object" == typeof performance ? performance.memory : void 0;
117
+ if (t && "number" == typeof t.usedJSHeapSize) return t.usedJSHeapSize;
118
+ const e = globalThis.process;
119
+ return "object" == typeof e && "function" == typeof e.memoryUsage ? e.memoryUsage().heapUsed : void 0;
120
+ }
121
+ function ut() {
122
+ const t = globalThis.process;
123
+ if ("object" == typeof t && "function" == typeof t.memoryUsage) return t.memoryUsage().rss;
124
+ }
125
+ function pt(t) {
126
+ return Math.round(10 * t) / 10;
127
+ }
128
+ var dt = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", ft = `-${dt}.0-9·̀-ͯ‿-⁀`, gt = (new RegExp(`^[${dt}]$`, "u"), new RegExp(`^[${ft}]$`, "u"), new RegExp(`^[${dt}][${ft}]*$`, "u")), mt = (new RegExp(`^[${ft}]+$`, "u"), [
129
+ 32,
130
+ 10,
131
+ 13,
132
+ 9
133
+ ]);
134
+ function xt(t) {
135
+ 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;
136
+ }
137
+ var yt = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", bt = `-${yt}.0-9·̀-ͯ‿-⁀`;
138
+ new RegExp(`^[${yt}]$`, "u"), new RegExp(`^[${bt}]$`, "u"), new RegExp(`^[${yt}][${bt}]*$`, "u"), new RegExp(`^[${bt}]+$`, "u");
139
+ var Tt = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", vt = `-${Tt}.0-9·̀-ͯ‿-⁀`, wt = (new RegExp(`^[${Tt}]$`, "u"), new RegExp(`^[${vt}]$`, "u"), new RegExp(`^[${Tt}][${vt}]*$`, "u"));
140
+ function St(t) {
141
+ 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;
142
+ }
143
+ var Ct = function(t) {
144
+ return 32 === t || 10 === t || 13 === t || 9 === t;
145
+ }, kt = function(t) {
146
+ return t >= 32 && t <= 55295 || 10 === t || 13 === t || 9 === t || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
147
+ }, At = xt, Ot = function(t) {
148
+ return xt(t) || t >= 48 && t <= 57 || 45 === t || 46 === t || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
149
+ }, Et = mt, Pt = gt, It = function(t) {
150
+ return t >= 1 && t <= 55295 || t >= 57344 && t <= 65533 || t >= 65536 && t <= 1114111;
151
+ }, Dt = St, _t = function(t) {
152
+ return St(t) || 45 === t || 46 === t || t >= 48 && t <= 57 || 183 === t || t >= 768 && t <= 879 || t >= 8255 && t <= 8256;
153
+ }, Vt = wt, Lt = "http://www.w3.org/XML/1998/namespace", Nt = "http://www.w3.org/2000/xmlns/", $t = {
154
+ __proto__: null,
155
+ xml: Lt,
156
+ xmlns: Nt
157
+ }, Rt = {
158
+ __proto__: null,
159
+ amp: "&",
160
+ gt: ">",
161
+ lt: "<",
162
+ quot: "\"",
163
+ apos: "'"
164
+ }, jt = -1, Mt = -2, Bt = 13, Ht = 33, Ft = 10, Wt = 60, zt = 61, Xt = 62, qt = 63, Ut = 93, Gt = (t) => 34 === t || 39 === t, Kt = [34, 39], Zt = [
165
+ ...Kt,
166
+ 91,
167
+ Xt
168
+ ], Jt = [
169
+ ...Kt,
170
+ Wt,
171
+ Ut
172
+ ], Qt = [
173
+ zt,
174
+ qt,
175
+ ...Et
176
+ ], Yt = [
177
+ ...Et,
178
+ Xt,
179
+ 38,
180
+ Wt
181
+ ];
182
+ function te(t, e, s) {
183
+ switch (e) {
184
+ case "xml":
185
+ s !== Lt && t.fail(`xml prefix must be bound to ${Lt}.`);
186
+ break;
187
+ case "xmlns": s !== Nt && t.fail(`xmlns prefix must be bound to ${Nt}.`);
188
+ }
189
+ switch (s) {
190
+ case Nt:
191
+ t.fail("" === e ? `the default namespace may not be set to ${s}.` : `may not assign a prefix (even "xmlns") to the URI ${Nt}.`);
192
+ break;
193
+ case Lt: switch (e) {
194
+ case "xml": break;
195
+ case "":
196
+ t.fail(`the default namespace may not be set to ${s}.`);
197
+ break;
198
+ default: t.fail("may not assign the xml namespace to another prefix.");
199
+ }
200
+ }
201
+ }
202
+ var ee, se = (t) => Vt.test(t), oe = (t) => Pt.test(t), re = {
203
+ xmldecl: "xmlDeclHandler",
204
+ text: "textHandler",
205
+ processinginstruction: "piHandler",
206
+ doctype: "doctypeHandler",
207
+ comment: "commentHandler",
208
+ opentagstart: "openTagStartHandler",
209
+ attribute: "attributeHandler",
210
+ opentag: "openTagHandler",
211
+ closetag: "closeTagHandler",
212
+ cdata: "cdataHandler",
213
+ error: "errorHandler",
214
+ end: "endHandler",
215
+ ready: "readyHandler"
216
+ }, ie = class {
217
+ get closed() {
218
+ return this._closed;
219
+ }
220
+ constructor(t) {
221
+ this.i = 0, this.prevI = 0, this.opt = t ?? {}, this.fragmentOpt = !!this.opt.fragment;
222
+ const e = this.xmlnsOpt = !!this.opt.xmlns;
223
+ if (this.trackPosition = !1 !== this.opt.position, this.fileName = this.opt.fileName, e) {
224
+ this.nameStartCheck = Dt, this.nameCheck = _t, this.isName = se, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = {
225
+ __proto__: null,
226
+ ...$t
227
+ };
228
+ const t = this.opt.additionalNamespaces;
229
+ null != t && (function(t, e) {
230
+ for (const s of Object.keys(e)) te(t, s, e[s]);
231
+ }(this, t), Object.assign(this.ns, t));
232
+ } else this.nameStartCheck = At, this.nameCheck = Ot, this.isName = oe, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
233
+ this.stateTable = [
234
+ this.sBegin,
235
+ this.sBeginWhitespace,
236
+ this.sDoctype,
237
+ this.sDoctypeQuote,
238
+ this.sDTD,
239
+ this.sDTDQuoted,
240
+ this.sDTDOpenWaka,
241
+ this.sDTDOpenWakaBang,
242
+ this.sDTDComment,
243
+ this.sDTDCommentEnding,
244
+ this.sDTDCommentEnded,
245
+ this.sDTDPI,
246
+ this.sDTDPIEnding,
247
+ this.sText,
248
+ this.sEntity,
249
+ this.sOpenWaka,
250
+ this.sOpenWakaBang,
251
+ this.sComment,
252
+ this.sCommentEnding,
253
+ this.sCommentEnded,
254
+ this.sCData,
255
+ this.sCDataEnding,
256
+ this.sCDataEnding2,
257
+ this.sPIFirstChar,
258
+ this.sPIRest,
259
+ this.sPIBody,
260
+ this.sPIEnding,
261
+ this.sXMLDeclNameStart,
262
+ this.sXMLDeclName,
263
+ this.sXMLDeclEq,
264
+ this.sXMLDeclValueStart,
265
+ this.sXMLDeclValue,
266
+ this.sXMLDeclSeparator,
267
+ this.sXMLDeclEnding,
268
+ this.sOpenTag,
269
+ this.sOpenTagSlash,
270
+ this.sAttrib,
271
+ this.sAttribName,
272
+ this.sAttribNameSawWhite,
273
+ this.sAttribValue,
274
+ this.sAttribValueQuoted,
275
+ this.sAttribValueClosed,
276
+ this.sAttribValueUnquoted,
277
+ this.sCloseTag,
278
+ this.sCloseTagSawWhite
279
+ ], this._init();
280
+ }
281
+ _init() {
282
+ 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 = [];
283
+ const { fragmentOpt: t } = this;
284
+ this.state = t ? Bt : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = t, this.xmlDeclPossible = !t, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
285
+ let { defaultXMLVersion: e } = this.opt;
286
+ if (void 0 === e) {
287
+ if (!0 === this.opt.forceXMLVersion) throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
288
+ e = "1.0";
289
+ }
290
+ this.setXMLVersion(e), this.positionAtNewLine = 0, this.doctype = !1, this._closed = !1, this.xmlDecl = {
291
+ version: void 0,
292
+ encoding: void 0,
293
+ standalone: void 0
294
+ }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(Rt), this.readyHandler?.();
295
+ }
296
+ get position() {
297
+ return this.chunkPosition + this.i;
298
+ }
299
+ get columnIndex() {
300
+ return this.position - this.positionAtNewLine;
301
+ }
302
+ on(t, e) {
303
+ this[re[t]] = e;
304
+ }
305
+ off(t) {
306
+ this[re[t]] = void 0;
307
+ }
308
+ makeError(t) {
309
+ let e = this.fileName ?? "";
310
+ return this.trackPosition && (e.length > 0 && (e += ":"), e += `${this.line}:${this.column}`), e.length > 0 && (e += ": "), new Error(e + t);
311
+ }
312
+ fail(t) {
313
+ const e = this.makeError(t), s = this.errorHandler;
314
+ if (void 0 === s) throw e;
315
+ return s(e), this;
316
+ }
317
+ write(t) {
318
+ if (this.closed) return this.fail("cannot write after close.");
319
+ let e = !1;
320
+ null === t ? (e = !0, t = "") : "object" == typeof t && (t = t.toString()), void 0 !== this.carriedFromPrevious && (t = `${this.carriedFromPrevious}${t}`, this.carriedFromPrevious = void 0);
321
+ let s = t.length;
322
+ const o = t.charCodeAt(s - 1);
323
+ !e && (13 === o || o >= 55296 && o <= 56319) && (this.carriedFromPrevious = t[s - 1], s--, t = t.slice(0, s));
324
+ const { stateTable: r } = this;
325
+ for (this.chunk = t, this.i = 0; this.i < s;) r[this.state].call(this);
326
+ return this.chunkPosition += s, e ? this.end() : this;
327
+ }
328
+ close() {
329
+ return this.write(null);
330
+ }
331
+ getCode10() {
332
+ const t = this.chunk, e = this.i;
333
+ if (this.prevI = e, this.i++, e >= t.length) return jt;
334
+ const s = t.charCodeAt(e);
335
+ if (this.column++, s < 55296) {
336
+ if (s >= 32 || 9 === s) return s;
337
+ switch (s) {
338
+ case Ft: return this.line++, this.column = 0, this.positionAtNewLine = this.position, Ft;
339
+ case 13: return t.charCodeAt(e + 1) === Ft && (this.i = e + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, Mt;
340
+ default: return this.fail("disallowed character."), s;
341
+ }
342
+ }
343
+ if (s > 56319) return s >= 57344 && s <= 65533 || this.fail("disallowed character."), s;
344
+ const o = 65536 + 1024 * (s - 55296) + (t.charCodeAt(e + 1) - 56320);
345
+ return this.i = e + 2, o > 1114111 && this.fail("disallowed character."), o;
346
+ }
347
+ getCode11() {
348
+ const { chunk: t, i: e } = this;
349
+ if (this.prevI = e, this.i = e + 1, e >= t.length) return jt;
350
+ const s = t.charCodeAt(e);
351
+ if (this.column++, s < 55296) {
352
+ if (s > 31 && s < 127 || s > 159 && 8232 !== s || 9 === s) return s;
353
+ switch (s) {
354
+ case Ft: return this.line++, this.column = 0, this.positionAtNewLine = this.position, Ft;
355
+ case 13: {
356
+ const s = t.charCodeAt(e + 1);
357
+ s !== Ft && 133 !== s || (this.i = e + 2);
358
+ }
359
+ case 133:
360
+ case 8232: return this.line++, this.column = 0, this.positionAtNewLine = this.position, Mt;
361
+ default: return this.fail("disallowed character."), s;
362
+ }
363
+ }
364
+ if (s > 56319) return s >= 57344 && s <= 65533 || this.fail("disallowed character."), s;
365
+ const o = 65536 + 1024 * (s - 55296) + (t.charCodeAt(e + 1) - 56320);
366
+ return this.i = e + 2, o > 1114111 && this.fail("disallowed character."), o;
367
+ }
368
+ getCodeNorm() {
369
+ const t = this.getCode();
370
+ return t === Mt ? Ft : t;
371
+ }
372
+ unGet() {
373
+ this.i = this.prevI, this.column--;
374
+ }
375
+ captureTo(t) {
376
+ let { i: e } = this;
377
+ const { chunk: s } = this;
378
+ for (;;) {
379
+ const o = this.getCode(), r = o === Mt, i = r ? Ft : o;
380
+ if (i === jt || t.includes(i)) return this.text += s.slice(e, this.prevI), i;
381
+ r && (this.text += `${s.slice(e, this.prevI)}\n`, e = this.i);
382
+ }
383
+ }
384
+ captureToChar(t) {
385
+ let { i: e } = this;
386
+ const { chunk: s } = this;
387
+ for (;;) {
388
+ let o = this.getCode();
389
+ switch (o) {
390
+ case Mt:
391
+ this.text += `${s.slice(e, this.prevI)}\n`, e = this.i, o = Ft;
392
+ break;
393
+ case jt: return this.text += s.slice(e), !1;
394
+ }
395
+ if (o === t) return this.text += s.slice(e, this.prevI), !0;
396
+ }
397
+ }
398
+ captureNameChars() {
399
+ const { chunk: t, i: e } = this;
400
+ for (;;) {
401
+ const s = this.getCode();
402
+ if (s === jt) return this.name += t.slice(e), jt;
403
+ if (!Ot(s)) return this.name += t.slice(e, this.prevI), s === Mt ? Ft : s;
404
+ }
405
+ }
406
+ skipSpaces() {
407
+ for (;;) {
408
+ const t = this.getCodeNorm();
409
+ if (t === jt || !Ct(t)) return t;
410
+ }
411
+ }
412
+ setXMLVersion(t) {
413
+ this.currentXMLVersion = t, "1.0" === t ? (this.isChar = kt, this.getCode = this.getCode10) : (this.isChar = It, this.getCode = this.getCode11);
414
+ }
415
+ sBegin() {
416
+ 65279 === this.chunk.charCodeAt(0) && (this.i++, this.column++), this.state = 1;
417
+ }
418
+ sBeginWhitespace() {
419
+ const t = this.i, e = this.skipSpaces();
420
+ switch (this.prevI !== t && (this.xmlDeclPossible = !1), e) {
421
+ case Wt:
422
+ if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
423
+ break;
424
+ case jt: break;
425
+ default: this.unGet(), this.state = Bt, this.xmlDeclPossible = !1;
426
+ }
427
+ }
428
+ sDoctype() {
429
+ const t = this.captureTo(Zt);
430
+ switch (t) {
431
+ case Xt:
432
+ this.doctypeHandler?.(this.text), this.text = "", this.state = Bt, this.doctype = !0;
433
+ break;
434
+ case jt: break;
435
+ default: this.text += String.fromCodePoint(t), 91 === t ? this.state = 4 : Gt(t) && (this.state = 3, this.q = t);
436
+ }
437
+ }
438
+ sDoctypeQuote() {
439
+ const t = this.q;
440
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.q = null, this.state = 2);
441
+ }
442
+ sDTD() {
443
+ const t = this.captureTo(Jt);
444
+ t !== jt && (this.text += String.fromCodePoint(t), t === Ut ? this.state = 2 : t === Wt ? this.state = 6 : Gt(t) && (this.state = 5, this.q = t));
445
+ }
446
+ sDTDQuoted() {
447
+ const t = this.q;
448
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.state = 4, this.q = null);
449
+ }
450
+ sDTDOpenWaka() {
451
+ const t = this.getCodeNorm();
452
+ switch (this.text += String.fromCodePoint(t), t) {
453
+ case 33:
454
+ this.state = 7, this.openWakaBang = "";
455
+ break;
456
+ case qt:
457
+ this.state = 11;
458
+ break;
459
+ default: this.state = 4;
460
+ }
461
+ }
462
+ sDTDOpenWakaBang() {
463
+ const t = String.fromCodePoint(this.getCodeNorm()), e = this.openWakaBang += t;
464
+ this.text += t, "-" !== e && (this.state = "--" === e ? 8 : 4, this.openWakaBang = "");
465
+ }
466
+ sDTDComment() {
467
+ this.captureToChar(45) && (this.text += "-", this.state = 9);
468
+ }
469
+ sDTDCommentEnding() {
470
+ const t = this.getCodeNorm();
471
+ this.text += String.fromCodePoint(t), this.state = 45 === t ? 10 : 8;
472
+ }
473
+ sDTDCommentEnded() {
474
+ const t = this.getCodeNorm();
475
+ this.text += String.fromCodePoint(t), t === Xt ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
476
+ }
477
+ sDTDPI() {
478
+ this.captureToChar(qt) && (this.text += "?", this.state = 12);
479
+ }
480
+ sDTDPIEnding() {
481
+ const t = this.getCodeNorm();
482
+ this.text += String.fromCodePoint(t), t === Xt && (this.state = 4);
483
+ }
484
+ sText() {
485
+ 0 !== this.tags.length ? this.handleTextInRoot() : this.handleTextOutsideRoot();
486
+ }
487
+ sEntity() {
488
+ let { i: t } = this;
489
+ const { chunk: e } = this;
490
+ t: for (;;) switch (this.getCode()) {
491
+ case Mt:
492
+ this.entity += `${e.slice(t, this.prevI)}\n`, t = this.i;
493
+ break;
494
+ case 59: {
495
+ const { entityReturnState: s } = this, o = this.entity + e.slice(t, this.prevI);
496
+ let r;
497
+ this.state = s, "" === o ? (this.fail("empty entity name."), r = "&;") : (r = this.parseEntity(o), this.entity = ""), s === Bt && void 0 === this.textHandler || (this.text += r);
498
+ break t;
499
+ }
500
+ case jt:
501
+ this.entity += e.slice(t);
502
+ break t;
503
+ }
504
+ }
505
+ sOpenWaka() {
506
+ const t = this.getCode();
507
+ if (At(t)) this.state = 34, this.unGet(), this.xmlDeclPossible = !1;
508
+ else switch (t) {
509
+ case 47:
510
+ this.state = 43, this.xmlDeclPossible = !1;
511
+ break;
512
+ case 33:
513
+ this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = !1;
514
+ break;
515
+ case qt:
516
+ this.state = 23;
517
+ break;
518
+ default: this.fail("disallowed character in tag name"), this.state = Bt, this.xmlDeclPossible = !1;
519
+ }
520
+ }
521
+ sOpenWakaBang() {
522
+ switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
523
+ case "[CDATA[":
524
+ 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 = "";
525
+ break;
526
+ case "--":
527
+ this.state = 17, this.openWakaBang = "";
528
+ break;
529
+ case "DOCTYPE":
530
+ this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
531
+ break;
532
+ default: this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
533
+ }
534
+ }
535
+ sComment() {
536
+ this.captureToChar(45) && (this.state = 18);
537
+ }
538
+ sCommentEnding() {
539
+ const t = this.getCodeNorm();
540
+ 45 === t ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(t)}`, this.state = 17);
541
+ }
542
+ sCommentEnded() {
543
+ const t = this.getCodeNorm();
544
+ t !== Xt ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t)}`, this.state = 17) : this.state = Bt;
545
+ }
546
+ sCData() {
547
+ this.captureToChar(Ut) && (this.state = 21);
548
+ }
549
+ sCDataEnding() {
550
+ const t = this.getCodeNorm();
551
+ t === Ut ? this.state = 22 : (this.text += `]${String.fromCodePoint(t)}`, this.state = 20);
552
+ }
553
+ sCDataEnding2() {
554
+ const t = this.getCodeNorm();
555
+ switch (t) {
556
+ case Xt:
557
+ this.cdataHandler?.(this.text), this.text = "", this.state = Bt;
558
+ break;
559
+ case Ut:
560
+ this.text += "]";
561
+ break;
562
+ default: this.text += `]]${String.fromCodePoint(t)}`, this.state = 20;
563
+ }
564
+ }
565
+ sPIFirstChar() {
566
+ const t = this.getCodeNorm();
567
+ this.nameStartCheck(t) ? (this.piTarget += String.fromCodePoint(t), this.state = 24) : t === qt || Ct(t) ? (this.fail("processing instruction without a target."), this.state = t === qt ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t), this.state = 24);
568
+ }
569
+ sPIRest() {
570
+ const { chunk: t, i: e } = this;
571
+ for (;;) {
572
+ const s = this.getCodeNorm();
573
+ if (s === jt) return void (this.piTarget += t.slice(e));
574
+ if (!this.nameCheck(s)) {
575
+ this.piTarget += t.slice(e, this.prevI);
576
+ const o = s === qt;
577
+ o || Ct(s) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = o ? Ht : 27) : this.state = o ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(s));
578
+ break;
579
+ }
580
+ }
581
+ }
582
+ sPIBody() {
583
+ if (0 === this.text.length) {
584
+ const t = this.getCodeNorm();
585
+ t === qt ? this.state = 26 : Ct(t) || (this.text = String.fromCodePoint(t));
586
+ } else this.captureToChar(qt) && (this.state = 26);
587
+ }
588
+ sPIEnding() {
589
+ const t = this.getCodeNorm();
590
+ if (t === Xt) {
591
+ const { piTarget: t } = this;
592
+ "xml" === t.toLowerCase() && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({
593
+ target: t,
594
+ body: this.text
595
+ }), this.piTarget = this.text = "", this.state = Bt;
596
+ } else t === qt ? this.text += "?" : (this.text += `?${String.fromCodePoint(t)}`, this.state = 25);
597
+ this.xmlDeclPossible = !1;
598
+ }
599
+ sXMLDeclNameStart() {
600
+ const t = this.skipSpaces();
601
+ t !== qt ? t !== jt && (this.state = 28, this.name = String.fromCodePoint(t)) : this.state = Ht;
602
+ }
603
+ sXMLDeclName() {
604
+ const t = this.captureTo(Qt);
605
+ if (t === qt) return this.state = Ht, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
606
+ if (Ct(t) || t === zt) {
607
+ if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
608
+ case 0:
609
+ this.fail("did not expect any more name/value pairs.");
610
+ break;
611
+ case 1:
612
+ this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
613
+ break;
614
+ default: this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
615
+ }
616
+ this.state = t === zt ? 30 : 29;
617
+ }
618
+ }
619
+ sXMLDeclEq() {
620
+ const t = this.getCodeNorm();
621
+ if (t === qt) return this.state = Ht, void this.fail("XML declaration is incomplete.");
622
+ Ct(t) || (t !== zt && this.fail("value required."), this.state = 30);
623
+ }
624
+ sXMLDeclValueStart() {
625
+ const t = this.getCodeNorm();
626
+ if (t === qt) return this.state = Ht, void this.fail("XML declaration is incomplete.");
627
+ Ct(t) || (Gt(t) ? this.q = t : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
628
+ }
629
+ sXMLDeclValue() {
630
+ const t = this.captureTo([this.q, qt]);
631
+ if (t === qt) return this.state = Ht, this.text = "", void this.fail("XML declaration is incomplete.");
632
+ if (t === jt) return;
633
+ const e = this.text;
634
+ switch (this.text = "", this.name) {
635
+ case "version": {
636
+ this.xmlDeclExpects = ["encoding", "standalone"];
637
+ const t = e;
638
+ this.xmlDecl.version = t, /^1\.[0-9]+$/.test(t) ? this.opt.forceXMLVersion || this.setXMLVersion(t) : this.fail("version number must match /^1\\.[0-9]+$/.");
639
+ break;
640
+ }
641
+ case "encoding":
642
+ /^[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;
643
+ break;
644
+ case "standalone": "yes" !== e && "no" !== e && this.fail("standalone value must match \"yes\" or \"no\"."), this.xmlDeclExpects = [], this.xmlDecl.standalone = e;
645
+ }
646
+ this.name = "", this.state = 32;
647
+ }
648
+ sXMLDeclSeparator() {
649
+ const t = this.getCodeNorm();
650
+ t !== qt ? (Ct(t) || (this.fail("whitespace required."), this.unGet()), this.state = 27) : this.state = Ht;
651
+ }
652
+ sXMLDeclEnding() {
653
+ this.getCodeNorm() === Xt ? ("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 = Bt) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = !1;
654
+ }
655
+ sOpenTag() {
656
+ const t = this.captureNameChars();
657
+ if (t === jt) return;
658
+ const e = this.tag = {
659
+ name: this.name,
660
+ attributes: Object.create(null)
661
+ };
662
+ 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) {
663
+ case Xt:
664
+ this.openTag();
665
+ break;
666
+ case 47:
667
+ this.state = 35;
668
+ break;
669
+ default: Ct(t) || this.fail("disallowed character in tag name."), this.state = 36;
670
+ }
671
+ }
672
+ sOpenTagSlash() {
673
+ this.getCode() === Xt ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
674
+ }
675
+ sAttrib() {
676
+ const t = this.skipSpaces();
677
+ t !== jt && (At(t) ? (this.unGet(), this.state = 37) : t === Xt ? this.openTag() : 47 === t ? this.state = 35 : this.fail("disallowed character in attribute name."));
678
+ }
679
+ sAttribName() {
680
+ const t = this.captureNameChars();
681
+ t === zt ? this.state = 39 : Ct(t) ? this.state = 38 : t === Xt ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t !== jt && this.fail("disallowed character in attribute name.");
682
+ }
683
+ sAttribNameSawWhite() {
684
+ const t = this.skipSpaces();
685
+ switch (t) {
686
+ case jt: return;
687
+ case zt:
688
+ this.state = 39;
689
+ break;
690
+ default: this.fail("attribute without value."), this.text = "", this.name = "", t === Xt ? this.openTag() : At(t) ? (this.unGet(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
691
+ }
692
+ }
693
+ sAttribValue() {
694
+ const t = this.getCodeNorm();
695
+ Gt(t) ? (this.q = t, this.state = 40) : Ct(t) || (this.fail("unquoted attribute value."), this.state = 42, this.unGet());
696
+ }
697
+ sAttribValueQuoted() {
698
+ const { q: t, chunk: e } = this;
699
+ let { i: s } = this;
700
+ for (;;) switch (this.getCode()) {
701
+ case t:
702
+ this.pushAttrib(this.name, this.text + e.slice(s, this.prevI)), this.name = this.text = "", this.q = null, this.state = 41;
703
+ return;
704
+ case 38:
705
+ this.text += e.slice(s, this.prevI), this.state = 14, this.entityReturnState = 40;
706
+ return;
707
+ case Ft:
708
+ case Mt:
709
+ case 9:
710
+ this.text += `${e.slice(s, this.prevI)} `, s = this.i;
711
+ break;
712
+ case Wt:
713
+ this.text += e.slice(s, this.prevI), this.fail("disallowed character.");
714
+ return;
715
+ case jt:
716
+ this.text += e.slice(s);
717
+ return;
718
+ }
719
+ }
720
+ sAttribValueClosed() {
721
+ const t = this.getCodeNorm();
722
+ Ct(t) ? this.state = 36 : t === Xt ? this.openTag() : 47 === t ? this.state = 35 : At(t) ? (this.fail("no whitespace between attributes."), this.unGet(), this.state = 37) : this.fail("disallowed character in attribute name.");
723
+ }
724
+ sAttribValueUnquoted() {
725
+ const t = this.captureTo(Yt);
726
+ switch (t) {
727
+ case 38:
728
+ this.state = 14, this.entityReturnState = 42;
729
+ break;
730
+ case Wt:
731
+ this.fail("disallowed character.");
732
+ break;
733
+ case jt: break;
734
+ default: this.text.includes("]]>") && this.fail("the string \"]]>\" is disallowed in char data."), this.pushAttrib(this.name, this.text), this.name = this.text = "", t === Xt ? this.openTag() : this.state = 36;
735
+ }
736
+ }
737
+ sCloseTag() {
738
+ const t = this.captureNameChars();
739
+ t === Xt ? this.closeTag() : Ct(t) ? this.state = 44 : t !== jt && this.fail("disallowed character in closing tag.");
740
+ }
741
+ sCloseTagSawWhite() {
742
+ switch (this.skipSpaces()) {
743
+ case Xt:
744
+ this.closeTag();
745
+ break;
746
+ case jt: break;
747
+ default: this.fail("disallowed character in closing tag.");
748
+ }
749
+ }
750
+ handleTextInRoot() {
751
+ let { i: t, forbiddenState: e } = this;
752
+ const { chunk: s, textHandler: o } = this;
753
+ t: for (;;) switch (this.getCode()) {
754
+ case Wt:
755
+ if (this.state = 15, void 0 !== o) {
756
+ const { text: e } = this, r = s.slice(t, this.prevI);
757
+ 0 !== e.length ? (o(e + r), this.text = "") : 0 !== r.length && o(r);
758
+ }
759
+ e = 0;
760
+ break t;
761
+ case 38:
762
+ this.state = 14, this.entityReturnState = Bt, void 0 !== o && (this.text += s.slice(t, this.prevI)), e = 0;
763
+ break t;
764
+ case Ut:
765
+ switch (e) {
766
+ case 0:
767
+ e = 1;
768
+ break;
769
+ case 1:
770
+ e = 2;
771
+ break;
772
+ case 2: break;
773
+ default: throw new Error("impossible state");
774
+ }
775
+ break;
776
+ case Xt:
777
+ 2 === e && this.fail("the string \"]]>\" is disallowed in char data."), e = 0;
778
+ break;
779
+ case Mt:
780
+ void 0 !== o && (this.text += `${s.slice(t, this.prevI)}\n`), t = this.i, e = 0;
781
+ break;
782
+ case jt:
783
+ void 0 !== o && (this.text += s.slice(t));
784
+ break t;
785
+ default: e = 0;
786
+ }
787
+ this.forbiddenState = e;
788
+ }
789
+ handleTextOutsideRoot() {
790
+ let { i: t } = this;
791
+ const { chunk: e, textHandler: s } = this;
792
+ let o = !1;
793
+ t: for (;;) {
794
+ const r = this.getCode();
795
+ switch (r) {
796
+ case Wt:
797
+ if (this.state = 15, void 0 !== s) {
798
+ const { text: o } = this, r = e.slice(t, this.prevI);
799
+ 0 !== o.length ? (s(o + r), this.text = "") : 0 !== r.length && s(r);
800
+ }
801
+ break t;
802
+ case 38:
803
+ this.state = 14, this.entityReturnState = Bt, void 0 !== s && (this.text += e.slice(t, this.prevI)), o = !0;
804
+ break t;
805
+ case Mt:
806
+ void 0 !== s && (this.text += `${e.slice(t, this.prevI)}\n`), t = this.i;
807
+ break;
808
+ case jt:
809
+ void 0 !== s && (this.text += e.slice(t));
810
+ break t;
811
+ default: Ct(r) || (o = !0);
812
+ }
813
+ }
814
+ o && (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));
815
+ }
816
+ pushAttribNS(t, e) {
817
+ const { prefix: s, local: o } = this.qName(t), r = {
818
+ name: t,
819
+ prefix: s,
820
+ local: o,
821
+ value: e
822
+ };
823
+ if (this.attribList.push(r), this.attributeHandler?.(r), "xmlns" === s) {
824
+ const t = e.trim();
825
+ "1.0" === this.currentXMLVersion && "" === t && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[o] = t, te(this, o, t);
826
+ } else if ("xmlns" === t) {
827
+ const t = e.trim();
828
+ this.topNS[""] = t, te(this, "", t);
829
+ }
830
+ }
831
+ pushAttribPlain(t, e) {
832
+ const s = {
833
+ name: t,
834
+ value: e
835
+ };
836
+ this.attribList.push(s), this.attributeHandler?.(s);
837
+ }
838
+ end() {
839
+ this.sawRoot || this.fail("document must contain a root element.");
840
+ const { tags: t } = this;
841
+ for (; t.length > 0;) {
842
+ const e = t.pop();
843
+ this.fail(`unclosed tag: ${e.name}`);
844
+ }
845
+ 0 !== this.state && this.state !== Bt && this.fail("unexpected end.");
846
+ const { text: e } = this;
847
+ return 0 !== e.length && (this.textHandler?.(e), this.text = ""), this._closed = !0, this.endHandler?.(), this._init(), this;
848
+ }
849
+ resolve(t) {
850
+ let e = this.topNS[t];
851
+ if (void 0 !== e) return e;
852
+ const { tags: s } = this;
853
+ for (let o = s.length - 1; o >= 0; o--) if (e = s[o].ns[t], void 0 !== e) return e;
854
+ return e = this.ns[t], void 0 !== e ? e : this.opt.resolvePrefix?.(t);
855
+ }
856
+ qName(t) {
857
+ const e = t.indexOf(":");
858
+ if (-1 === e) return {
859
+ prefix: "",
860
+ local: t
861
+ };
862
+ const s = t.slice(e + 1), o = t.slice(0, e);
863
+ return ("" === o || "" === s || s.includes(":")) && this.fail(`malformed name: ${t}.`), {
864
+ prefix: o,
865
+ local: s
866
+ };
867
+ }
868
+ processAttribsNS() {
869
+ const { attribList: t } = this, e = this.tag;
870
+ {
871
+ const { prefix: t, local: s } = this.qName(e.name);
872
+ e.prefix = t, e.local = s;
873
+ const o = e.uri = this.resolve(t) ?? "";
874
+ "" !== t && ("xmlns" === t && this.fail("tags may not have \"xmlns\" as prefix."), "" === o && (this.fail(`unbound namespace prefix: ${JSON.stringify(t)}.`), e.uri = t));
875
+ }
876
+ if (0 === t.length) return;
877
+ const { attributes: s } = e, o = /* @__PURE__ */ new Set();
878
+ for (const e of t) {
879
+ const { name: t, prefix: r, local: i } = e;
880
+ let n, a;
881
+ "" === r ? (n = "xmlns" === t ? Nt : "", a = t) : (n = this.resolve(r), void 0 === n && (this.fail(`unbound namespace prefix: ${JSON.stringify(r)}.`), n = r), a = `{${n}}${i}`), o.has(a) && this.fail(`duplicate attribute: ${a}.`), o.add(a), e.uri = n, s[t] = e;
882
+ }
883
+ this.attribList = [];
884
+ }
885
+ processAttribsPlain() {
886
+ const { attribList: t } = this, e = this.tag.attributes;
887
+ for (const { name: s, value: o } of t) void 0 !== e[s] && this.fail(`duplicate attribute: ${s}.`), e[s] = o;
888
+ this.attribList = [];
889
+ }
890
+ openTag() {
891
+ this.processAttribs();
892
+ const { tags: t } = this, e = this.tag;
893
+ e.isSelfClosing = !1, this.openTagHandler?.(e), t.push(e), this.state = Bt, this.name = "";
894
+ }
895
+ openSelfClosingTag() {
896
+ this.processAttribs();
897
+ const { tags: t } = this, e = this.tag;
898
+ e.isSelfClosing = !0, this.openTagHandler?.(e), this.closeTagHandler?.(e), null === (this.tag = t[t.length - 1] ?? null) && (this.closedRoot = !0), this.state = Bt, this.name = "";
899
+ }
900
+ closeTag() {
901
+ const { tags: t, name: e } = this;
902
+ if (this.state = Bt, this.name = "", "" === e) return this.fail("weird empty close tag."), void (this.text += "</>");
903
+ const s = this.closeTagHandler;
904
+ let o = t.length;
905
+ for (; o-- > 0;) {
906
+ const o = this.tag = t.pop();
907
+ if (this.topNS = o.ns, s?.(o), o.name === e) break;
908
+ this.fail(`unexpected close tag: ${e}.`);
909
+ }
910
+ 0 === o ? this.closedRoot = !0 : o < 0 && (this.fail(`unmatched closing tag: ${e}.`), this.text += `</${e}>`);
911
+ }
912
+ parseEntity(t) {
913
+ if ("#" !== t[0]) {
914
+ const e = this.ENTITIES[t];
915
+ return void 0 !== e ? e : (this.fail(this.isName(t) ? "undefined entity." : "disallowed character in entity name."), `&${t};`);
916
+ }
917
+ let e = NaN;
918
+ 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};`);
919
+ }
920
+ }, ne = /&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, ae = {
921
+ amp: "&",
922
+ lt: "<",
923
+ gt: ">",
924
+ quot: "\"",
925
+ apos: "'"
926
+ }, ce = (t, e) => {
927
+ const s = ae[e];
928
+ if (void 0 !== s) return s;
929
+ const o = 120 === e.charCodeAt(1) ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
930
+ return o > 0 && o <= 1114111 ? String.fromCodePoint(o) : t;
931
+ }, le = (t) => {
932
+ let e = t;
933
+ return -1 !== e.indexOf("\r") && (e = e.replace(/\r\n?/g, "\n")), -1 !== e.indexOf("&") && (e = e.replace(ne, ce)), e;
934
+ }, he = (t) => {
935
+ let e = t;
936
+ const s = e.length;
937
+ for (let t = 0; t < s; t++) {
938
+ const s = e.charCodeAt(t);
939
+ if (9 === s || 10 === s || 13 === s) {
940
+ e = e.replace(/\r\n|[\t\n\r]/g, " ");
941
+ break;
942
+ }
943
+ }
944
+ return -1 !== e.indexOf("&") && (e = e.replace(ne, ce)), e;
945
+ }, ue = (t) => 32 === t || 9 === t || 10 === t || 13 === t, pe = class t {
946
+ constructor() {
947
+ 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;
948
+ }
949
+ static {
950
+ this.NEED_MORE = -1;
951
+ }
952
+ static {
953
+ this.NOT_HANDLED = -2;
954
+ }
955
+ static decodeText(t) {
956
+ return le(t);
957
+ }
958
+ on(t, e) {
959
+ switch (t) {
960
+ case "opentag":
961
+ this._openTagHandler = e;
962
+ break;
963
+ case "closetag":
964
+ this._closeTagHandler = e;
965
+ break;
966
+ case "text":
967
+ this._textHandler = e;
968
+ break;
969
+ case "cdata":
970
+ this._cdataHandler = e;
971
+ break;
972
+ case "error":
973
+ this._errorHandler = e;
974
+ break;
975
+ case "end": this._endHandler = e;
976
+ }
977
+ }
978
+ setElementScanners(t) {
979
+ if (!t || 0 === t.length) return void (this._scanners = null);
980
+ const e = new Array(128);
981
+ for (const s of t) {
982
+ const t = s.name.charCodeAt(0);
983
+ if (!(t < 128) || void 0 !== e[t]) throw new Error(`Element scanner '${s.name}' needs an ASCII first character no other scanner uses.`);
984
+ e[t] = s;
985
+ }
986
+ this._scanners = e;
987
+ }
988
+ fail(t) {
989
+ const e = new Error(t), s = this._errorHandler;
990
+ if (void 0 === s) throw e;
991
+ s(e);
992
+ }
993
+ write(t) {
994
+ if (this._closed) return this.fail("cannot write after close."), this;
995
+ let e = t;
996
+ 0 !== this._carry.length && (e = this._carry + t, this._carry = "");
997
+ const s = e.length;
998
+ let o = 0;
999
+ for (; o < s;) {
1000
+ const t = e.indexOf("<", o);
1001
+ if (-1 === t) return this._text += e.slice(o), this;
1002
+ t > o && (this._text += e.slice(o, t));
1003
+ const r = this._markup(e, t, s);
1004
+ if (-1 === r) return this._carry = e.slice(t), this;
1005
+ o = r;
1006
+ }
1007
+ return this;
1008
+ }
1009
+ close() {
1010
+ 0 !== this._carry.length && (this.fail("unexpected end."), this._carry = ""), this._sawRoot || this.fail("document must contain a root element.");
1011
+ const t = this._tags;
1012
+ for (; t.length > 0;) {
1013
+ const e = t.pop();
1014
+ this.fail(`unclosed tag: ${e.name}`);
1015
+ }
1016
+ return this._flushText(), this._closed = !0, this._endHandler?.(), this;
1017
+ }
1018
+ _flushText() {
1019
+ const t = this._text;
1020
+ if (0 === t.length) return;
1021
+ this._text = "";
1022
+ const e = this._textHandler;
1023
+ void 0 !== e && 0 !== this._tags.length && e(le(t));
1024
+ }
1025
+ _markup(e, s, o) {
1026
+ if (s + 1 >= o) return -1;
1027
+ const r = e.charCodeAt(s + 1);
1028
+ if (47 === r) {
1029
+ const t = e.indexOf(">", s + 2);
1030
+ return -1 === t ? -1 : (this._flushText(), this._closeTag(e.slice(s + 2, t).trimEnd()), t + 1);
1031
+ }
1032
+ if (63 === r) {
1033
+ const t = e.indexOf("?>", s + 2);
1034
+ return -1 === t ? -1 : t + 2;
1035
+ }
1036
+ if (33 === r) {
1037
+ if (s + 4 > o) return -1;
1038
+ if (45 === e.charCodeAt(s + 2) && 45 === e.charCodeAt(s + 3)) {
1039
+ const t = e.indexOf("-->", s + 4);
1040
+ return -1 === t ? -1 : t + 3;
1041
+ }
1042
+ if (s + 9 > o) return -1;
1043
+ if (e.startsWith("[CDATA[", s + 2)) {
1044
+ const t = e.indexOf("]]>", s + 9);
1045
+ return -1 === t ? -1 : (this._flushText(), this._cdataHandler?.(e.slice(s + 9, t)), t + 3);
1046
+ }
1047
+ const t = e.indexOf("[", s + 2), r = e.indexOf(">", s + 2);
1048
+ if (-1 === r) return -1;
1049
+ if (-1 !== t && t < r) {
1050
+ const s = e.indexOf("]>", t);
1051
+ return -1 === s ? -1 : s + 2;
1052
+ }
1053
+ return r + 1;
1054
+ }
1055
+ const i = this._scanners;
1056
+ if (null !== i) {
1057
+ const n = r < 128 ? i[r] : void 0;
1058
+ if (void 0 !== n && e.startsWith(n.name, s + 1)) {
1059
+ const r = s + 1 + n.name.length;
1060
+ if (r >= o) return -1;
1061
+ const i = e.charCodeAt(r);
1062
+ if (62 === i || 47 === i || ue(i)) {
1063
+ this._flushText();
1064
+ const r = n.scan(e, s, o);
1065
+ if (r !== t.NOT_HANDLED) {
1066
+ if (r !== t.NEED_MORE) {
1067
+ this._sawRoot = !0;
1068
+ const t = n.openTag;
1069
+ void 0 !== t && this._tags.push(t);
1070
+ }
1071
+ return r;
1072
+ }
1073
+ }
1074
+ }
1075
+ }
1076
+ return this._openTag(e, s, o);
1077
+ }
1078
+ _openTag(t, e, s) {
1079
+ let o = e + 1, r = 0;
1080
+ for (; o < s && (r = t.charCodeAt(o), 62 !== r && 47 !== r && !ue(r));) o++;
1081
+ if (o >= s) return -1;
1082
+ const i = t.slice(e + 1, o), n = {};
1083
+ let a = !1;
1084
+ for (;;) {
1085
+ for (; o < s && ue(r = t.charCodeAt(o));) o++;
1086
+ if (o >= s) return -1;
1087
+ if (62 === r) {
1088
+ o++;
1089
+ break;
1090
+ }
1091
+ if (47 === r) {
1092
+ if (o + 1 >= s) return -1;
1093
+ if (62 !== t.charCodeAt(o + 1)) {
1094
+ this.fail("forward-slash in opening tag not followed by >."), o++;
1095
+ continue;
1096
+ }
1097
+ a = !0, o += 2;
1098
+ break;
1099
+ }
1100
+ const e = o;
1101
+ for (; o < s && (r = t.charCodeAt(o), 61 !== r && 62 !== r && 47 !== r && !ue(r));) o++;
1102
+ if (o >= s) return -1;
1103
+ const i = t.slice(e, o);
1104
+ for (; o < s && ue(r = t.charCodeAt(o));) o++;
1105
+ if (o >= s) return -1;
1106
+ if (61 !== r) {
1107
+ this.fail("attribute without value.");
1108
+ continue;
1109
+ }
1110
+ for (o++; o < s && ue(r = t.charCodeAt(o));) o++;
1111
+ if (o >= s) return -1;
1112
+ if (34 !== r && 39 !== r) {
1113
+ this.fail("unquoted attribute value.");
1114
+ continue;
1115
+ }
1116
+ const c = t.indexOf(34 === r ? "\"" : "'", o + 1);
1117
+ if (-1 === c) return -1;
1118
+ "__proto__" !== i && (n[i] = he(t.slice(o + 1, c))), o = c + 1;
1119
+ }
1120
+ this._flushText(), this._sawRoot = !0;
1121
+ const c = {
1122
+ name: i,
1123
+ attributes: n,
1124
+ isSelfClosing: a
1125
+ };
1126
+ return this._openTagHandler?.(c), a ? this._closeTagHandler?.(c) : this._tags.push(c), o;
1127
+ }
1128
+ _closeTag(t) {
1129
+ if ("" === t) return void this.fail("weird empty close tag.");
1130
+ const e = this._tags, s = this._closeTagHandler;
1131
+ let o = e.length;
1132
+ for (; o-- > 0;) {
1133
+ const o = e.pop();
1134
+ if (s?.(o), o.name === t) return;
1135
+ this.fail(`unexpected close tag: ${t}.`);
1136
+ }
1137
+ this.fail(`unmatched closing tag: ${t}.`);
1138
+ }
1139
+ };
1140
+ (function(t) {
1141
+ t.Events = {
1142
+ XmlDecl: "xmldecl",
1143
+ Text: "text",
1144
+ ProcessingInstruction: "processinginstruction",
1145
+ Doctype: "doctype",
1146
+ Comment: "comment",
1147
+ OpenTagStart: "opentagstart",
1148
+ Attribute: "attribute",
1149
+ OpenTag: "opentag",
1150
+ CloseTag: "closetag",
1151
+ CDdata: "cdata",
1152
+ Error: "error",
1153
+ End: "end",
1154
+ Ready: "ready"
1155
+ };
1156
+ t.parseStream = async (t, e, s) => {
1157
+ if (s?.lean) return (async (t, e) => {
1158
+ const s = new pe();
1159
+ let o;
1160
+ e.elementScanners && s.setElementScanners(e.elementScanners), e.onOpenTag && s.on("opentag", e.onOpenTag), e.onCloseTag && s.on("closetag", e.onCloseTag), e.onText && s.on("text", e.onText), e.onError && s.on("error", e.onError);
1161
+ const r = e.onEnd;
1162
+ for (r && s.on("end", () => {
1163
+ o = r();
1164
+ });;) {
1165
+ const { value: e, done: o } = await t.read();
1166
+ if (o) break;
1167
+ s.write(e);
1168
+ }
1169
+ return s.close(), o;
1170
+ })(t, e);
1171
+ const o = new ie({
1172
+ position: !1,
1173
+ ...s
1174
+ });
1175
+ let r;
1176
+ e.onOpenTagStart && o.on(ee.Events.OpenTagStart, e.onOpenTagStart), e.onOpenTag && o.on(ee.Events.OpenTag, e.onOpenTag), e.onCloseTag && o.on(ee.Events.CloseTag, e.onCloseTag), e.onAttribute && o.on(ee.Events.Attribute, e.onAttribute), e.onText && o.on(ee.Events.Text, e.onText), e.onError && o.on(ee.Events.Error, e.onError);
1177
+ const i = e.onEnd;
1178
+ if (i) {
1179
+ const t = () => {
1180
+ r = i();
1181
+ };
1182
+ o.on(ee.Events.End, t);
1183
+ }
1184
+ for (;;) {
1185
+ const { value: e, done: s } = await t.read();
1186
+ if (s) break;
1187
+ o.write(e);
1188
+ }
1189
+ return o.close(), r;
1190
+ };
1191
+ })(ee || (ee = {}));
1192
+ var de = (t) => !0 === t || "1" === t || "on" === t || "true" === t || !1 !== t && "0" !== t && "off" !== t && "false" !== t && null, fe = (t) => {
1193
+ const e = parseInt(t);
1194
+ return isNaN(e) ? null : e;
1195
+ }, ge = (t) => {
1196
+ const e = parseFloat(t);
1197
+ return isNaN(e) ? null : e;
1198
+ }, me = null, xe = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), ye = (t) => xe(t).replace(/"/g, "&quot;"), be = class {
1199
+ constructor() {
1200
+ this._registeredVisitors = /* @__PURE__ */ new Map();
1201
+ }
1202
+ registerVisitor(t) {
1203
+ this._registeredVisitors.set(t.from, t);
1204
+ }
1205
+ createEventHandler(t, e, s) {
1206
+ const o = this._registeredVisitors, r = [], i = [];
1207
+ let n = null, a = null, c = null, l = null;
1208
+ const h = [], u = {
1209
+ key: null,
1210
+ source: t,
1211
+ parent: null
1212
+ };
1213
+ let p = null, d = !1, f = null, g = null, m = null;
1214
+ const x = (t, e) => {
1215
+ let s = c.attributes[t];
1216
+ if (e) if (Array.isArray(e)) {
1217
+ const t = e.length;
1218
+ for (let o = 0; o < t; o++) {
1219
+ if (null == s) return;
1220
+ if (s = e[o](s), null == s) return;
1221
+ }
1222
+ } else {
1223
+ if (null == s) return;
1224
+ if (s = e(s), null == s) return;
1225
+ }
1226
+ return s;
1227
+ }, y = {
1228
+ getSource: () => p?.source ?? null,
1229
+ setSource: (t) => {
1230
+ p.source = t;
1231
+ },
1232
+ setKey: (t) => {
1233
+ p.key = t;
1234
+ },
1235
+ getFrom: () => c,
1236
+ getAttribute: (t, e) => x(t, e) ?? null,
1237
+ hasAttribute: (t) => null !== y.getAttribute(t),
1238
+ getParent: () => {
1239
+ const t = h[h.length - 2];
1240
+ return t.parent ?? t.source;
1241
+ },
1242
+ getPath: () => {
1243
+ const t = [], e = i.length;
1244
+ for (let s = 0; s < e; s++) t.push(i[s].local);
1245
+ return t.join("\\");
1246
+ },
1247
+ parseAttribute: x,
1248
+ getRawXml: () => m,
1249
+ copyToObject: (t, e, s, o) => {
1250
+ const r = x(o ?? e, s);
1251
+ void 0 !== r && (t[e] = r);
1252
+ },
1253
+ copyTo: (t, e, s) => {
1254
+ const o = x(s ?? t, e);
1255
+ void 0 !== o && (p.source[t] = o);
1256
+ },
1257
+ warn: (t, e) => {
1258
+ s ? s(t, void 0, e?.onceKey) : console.warn(t);
1259
+ }
1260
+ };
1261
+ return {
1262
+ onOpenTag: (t) => {
1263
+ let e = t.name;
1264
+ const s = e.indexOf(":");
1265
+ if (-1 !== s && (e = e.slice(s + 1)), f) return f.push(((t) => {
1266
+ const e = t.attributes ?? {};
1267
+ let s = `<${t.name}`;
1268
+ for (const t in e) {
1269
+ const o = e[t];
1270
+ s += ` ${t}="${ye("string" == typeof o ? o : o?.value ?? "")}"`;
1271
+ }
1272
+ return s + ">";
1273
+ })(t)), n = {
1274
+ local: e,
1275
+ tag: t,
1276
+ destination: null
1277
+ }, i.push(n), a = e, void (c = t);
1278
+ const m = (r.length > 0 ? r[r.length - 1] : o).get(e);
1279
+ if (n = {
1280
+ local: e,
1281
+ visitor: m,
1282
+ tag: t,
1283
+ destination: null
1284
+ }, d) return i.push(n), a = e, void (c = t);
1285
+ l = n?.visitor ?? null, a = e, c = t;
1286
+ let x = !!m && null === m.to;
1287
+ if (m && !x && m.scope) {
1288
+ const t = m.scope(y);
1289
+ null === t ? x = !0 : t && (r.push(t), n.pushedScope = !0);
1290
+ }
1291
+ m && (0 === i.length ? (p = u, n.destination = p, n.pushedDestination = !0, h.push(p)) : x ? (p = null, n.destination = null) : m.transparent ? n.destination = p : (p = {
1292
+ key: null,
1293
+ source: {},
1294
+ parent: null
1295
+ }, n.destination = p, n.pushedDestination = !0, h.push(p))), i.push(n), d = x;
1296
+ const b = l?.openTag?.(y);
1297
+ void 0 !== b && (p.parent = b), m?.raw && !x && (f = [], g = n);
1298
+ },
1299
+ onCloseTag: (t) => {
1300
+ let e = t.name;
1301
+ const o = e.indexOf(":");
1302
+ if (-1 !== o && (e = e.slice(o + 1)), e !== a) throw new Error(`mismatch open/close tag: '${e}'/'${a}'`);
1303
+ let x = !1;
1304
+ if (f) {
1305
+ if (i[i.length - 1] !== g) return f.push(`</${t.name}>`), i.pop(), n = i[i.length - 1] ?? null, a = n?.local ?? null, void (c = n?.tag ?? null);
1306
+ m = f.join(""), f = null, g = null, x = !0;
1307
+ }
1308
+ d || l?.closeTag?.(y), x && (m = null);
1309
+ const b = i.pop() ?? null;
1310
+ n = i[i.length - 1] ?? null, b?.pushedScope && r.pop();
1311
+ const T = b?.destination;
1312
+ if (T && b.pushedDestination) {
1313
+ h.pop(), p = h[h.length - 1] ?? u;
1314
+ const t = b.visitor;
1315
+ t && t.to && void 0 !== T.source && (Array.isArray(t.to) ? p.source.push ? p.source.push(T.source) : s?.(`Unable to parse array for ${t.from} at ${y.getPath()}`) : T.key ? p.source[T.key] = T.source : "string" == typeof t.to && (p.source[t.to] = T.source));
1316
+ } else T || (p = h[h.length - 1] ?? u);
1317
+ a = n?.local ?? null, c = n?.tag ?? null, l = n?.visitor ?? null, d = !n?.destination;
1318
+ },
1319
+ onText: (t) => {
1320
+ f ? f.push(xe(t)) : l?.text?.(t, y);
1321
+ },
1322
+ onEnd: e
1323
+ };
1324
+ }
1325
+ }, Te = `IFERROR(${v}(`, ve = Te.toUpperCase(), we = p.toUpperCase(), Se = { kind: "none" }, Ce = { kind: "spilled" }, ke = (t, e) => {
1326
+ if (34 !== t.charCodeAt(e)) return null;
1327
+ let s = "", o = e + 1;
1328
+ for (; o < t.length;) if (34 === t.charCodeAt(o)) {
1329
+ if (34 !== t.charCodeAt(o + 1)) return {
1330
+ value: s,
1331
+ end: o + 1
1332
+ };
1333
+ s += "\"", o += 2;
1334
+ } else s += t[o], o++;
1335
+ return null;
1336
+ }, Ae = (t) => {
1337
+ const e = [];
1338
+ let s = 0;
1339
+ for (; s < t.length;) {
1340
+ const o = t.charCodeAt(s);
1341
+ if (34 === o) {
1342
+ const e = ke(t, s);
1343
+ if (null === e) break;
1344
+ s = e.end;
1345
+ continue;
1346
+ }
1347
+ if (!(o >= 65 && o <= 90 || o >= 97 && o <= 122 || 95 === o)) {
1348
+ s++;
1349
+ continue;
1350
+ }
1351
+ let r = s + 1;
1352
+ for (; r < t.length;) {
1353
+ const e = t.charCodeAt(r);
1354
+ if (!(e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57 || 95 === e || 46 === e)) break;
1355
+ r++;
1356
+ }
1357
+ 40 === t.charCodeAt(r) && e.push(t.slice(s, r).toUpperCase().replace(/^_XLFN\./, "").replace(/^_XLWS\./, "")), s = r;
1358
+ }
1359
+ return e;
1360
+ }, Oe = (t) => {
1361
+ const e = (e) => {
1362
+ if (t) return new RegExp(`<(?:[\\w.-]+:)?${e}\\b[^>]*>([^<]*)<`).exec(t)?.[1];
1363
+ }, s = (t) => {
1364
+ const e = parseInt(t ?? "", 10);
1365
+ return isNaN(e) ? 0 : e;
1366
+ };
1367
+ return {
1368
+ c: s(e("col")),
1369
+ r: s(e("row")),
1370
+ x: c(e("colOff") ?? "0") ?? 0,
1371
+ y: c(e("rowOff") ?? "0") ?? 0
1372
+ };
1373
+ }, Ee = "formulaDialect", Pe = (e, s, o, r, i, n, c, l) => {
1374
+ const h = new be(), p = l?.get("parseInlineDxf"), d = l?.get(Ee), g = (t) => d && t ? d.readDetached(t) : t, m = new tt.TransposedBuilder();
1375
+ let b = null;
1376
+ h.registerVisitor({
1377
+ from: "autoFilter",
1378
+ to: "autoTable",
1379
+ openTag: (t) => {
1380
+ const e = t.getAttribute("ref"), s = z.fastStringToRange(e);
1381
+ t.getSource().r = s, t.getSource().v = {};
1382
+ },
1383
+ closeTag: (t) => {
1384
+ const e = t.getSource(), s = e.v, o = s.hiddenButtons;
1385
+ if (Array.isArray(o)) {
1386
+ const t = o.length, r = e.r, i = r.colEnd - r.colStart + 1;
1387
+ 0 === t ? s.hiddenButtons = !1 : t === i && (s.hiddenButtons = !0);
1388
+ }
1389
+ }
1390
+ }), h.registerVisitor({
1391
+ from: "conditionalFormatting",
1392
+ to: {},
1393
+ openTag: (t) => {
1394
+ const e = t.getParent();
1395
+ e.conditionals || (e.conditionals = []);
1396
+ let s = t.getAttribute("sqref");
1397
+ s && (s = s.trim().split(/\s+/).join(","));
1398
+ const o = {
1399
+ r: s,
1400
+ conditionals: e.conditionals
1401
+ }, r = t.getAttribute("pivot", de);
1402
+ null !== r && (o.pivot = r), t.setSource(o);
1403
+ }
1404
+ }), h.registerVisitor({
1405
+ from: "cfRule",
1406
+ to: {},
1407
+ openTag: (t) => {
1408
+ const e = t.getParent();
1409
+ if (!e?.r) return;
1410
+ const s = t.getSource() ?? {};
1411
+ void 0 !== e.pivot && (s.pivot = e.pivot), e.conditionals.push({
1412
+ r: e.r,
1413
+ v: null,
1414
+ rule: s
1415
+ }), t.copyToObject(s, "type", me), t.copyToObject(s, "priority", fe), t.copyToObject(s, "stopIfTrue", de);
1416
+ const o = t.getAttribute("dxfId", fe);
1417
+ if (null !== o) {
1418
+ let e = r?.get(o);
1419
+ e || (n?.(`Unable to load conditional color. Invalid dxfI: '${o}' at '${t.getPath()}'.`), e = {}), s.style = e;
1420
+ }
1421
+ t.copyToObject(s, "aboveAverage", de), t.copyToObject(s, "equalAverage", de), t.copyToObject(s, "stdDev", fe), t.copyToObject(s, "bottom", de), t.copyToObject(s, "percent", de), t.copyToObject(s, "rank", fe), t.copyToObject(s, "operator", me), t.copyToObject(s, "text", me), t.copyToObject(s, "timePeriod", me);
1422
+ },
1423
+ closeTag: (t) => {
1424
+ const e = t.getParent();
1425
+ if (!e?.r) return;
1426
+ const s = e.conditionals[e.conditionals.length - 1], o = s?.rule;
1427
+ if (!o) return;
1428
+ const r = {}, i = R(o, n);
1429
+ i && (r.condition = i), o.style && (r.style = o.style), o.scale && (r.scale = o.scale), o.stopIfTrue && (r.stopIfTrue = !0), o.pivot && (r.pivot = !0), s.v = r, s.priority = o.priority, o.x14Id && (s.x14Id = o.x14Id), delete s.rule;
1430
+ }
1431
+ });
1432
+ const T = (t) => {
1433
+ const e = t.conditions ?? [], s = [];
1434
+ for (let t = 0; t < e.length; t++) {
1435
+ const o = e[t], r = {};
1436
+ o.type && (r.type = o.type), void 0 !== o.value && (r.value = o.value), o.exclusive && (r.exclusive = !0), s.push(r);
1437
+ }
1438
+ return s;
1439
+ };
1440
+ h.registerVisitor({
1441
+ from: "colorScale",
1442
+ to: {},
1443
+ openTag: (t) => {},
1444
+ closeTag: (t) => {
1445
+ const e = t.getSource(), s = e.colors ?? [], o = T(e);
1446
+ for (let t = 0; t < o.length; t++) o[t].color = s[t];
1447
+ t.getParent().scale = {
1448
+ type: K.ScaleType.ColorScale,
1449
+ stops: o
1450
+ };
1451
+ }
1452
+ }), h.registerVisitor({
1453
+ from: "dataBar",
1454
+ to: {},
1455
+ openTag: (t) => {
1456
+ t.copyTo("maxLength", fe), t.copyTo("minLength", fe), t.copyTo("showValue", de);
1457
+ },
1458
+ closeTag: (t) => {
1459
+ const e = t.getSource(), s = {
1460
+ type: K.ScaleType.DataBar,
1461
+ stops: T(e)
1462
+ }, o = e.colors?.[0];
1463
+ o && (s.color = o), void 0 !== e.minLength && (s.minLength = e.minLength), void 0 !== e.maxLength && (s.maxLength = e.maxLength), void 0 !== e.showValue && (s.showValue = e.showValue), t.getParent().scale = s;
1464
+ }
1465
+ }), h.registerVisitor({
1466
+ from: "iconSet",
1467
+ to: {},
1468
+ openTag: (t) => {
1469
+ t.copyTo("iconSet", me), t.copyTo("reverse", de), t.copyTo("showValue", de);
1470
+ },
1471
+ closeTag: (t) => {
1472
+ const e = t.getSource(), s = {
1473
+ type: K.ScaleType.IconSet,
1474
+ stops: T(e)
1475
+ };
1476
+ void 0 !== e.iconSet && (s.iconSet = e.iconSet), void 0 !== e.reverse && (s.reverse = e.reverse), void 0 !== e.showValue && (s.showValue = e.showValue), t.getParent().scale = s;
1477
+ }
1478
+ }), h.registerVisitor({
1479
+ from: "formula",
1480
+ to: {},
1481
+ text: (t, e) => {
1482
+ const s = e.getParent();
1483
+ let o = s.formulas;
1484
+ o || (o = [], s.formulas = o), o.push(g(t));
1485
+ }
1486
+ }), h.registerVisitor({
1487
+ from: "cfvo",
1488
+ to: {},
1489
+ openTag: (t) => {
1490
+ const e = t.getParent();
1491
+ e.conditions || (e.conditions = []);
1492
+ const s = t.getSource();
1493
+ if (e.conditions.push(s), t.copyTo("type", me), s.type === K.ColorStopType.Formula) {
1494
+ const e = t.getAttribute("val");
1495
+ null != e && (s.value = g(String(e)));
1496
+ } else t.copyTo("value", ge, "val");
1497
+ !1 === t.getAttribute("gte", de) && (s.exclusive = !0);
1498
+ }
1499
+ }), h.registerVisitor({
1500
+ from: "color",
1501
+ to: {},
1502
+ openTag: (t) => {
1503
+ const e = t.getParent();
1504
+ e.colors || (e.colors = []);
1505
+ const s = a((e) => t.getAttribute(e));
1506
+ e.colors.push(s);
1507
+ }
1508
+ }), h.registerVisitor({
1509
+ from: "filterColumn",
1510
+ to: {},
1511
+ openTag: (t) => {
1512
+ const e = t.getParent().v, s = parseInt(t.getAttribute("colId")), o = t.getSource();
1513
+ o.index = s;
1514
+ let r = e.filter;
1515
+ r || (r = { conditions: [] }, e.filter = r);
1516
+ let i = r.conditions;
1517
+ if (i || (i = [], r.conditions = i), i.push(o), t.getAttribute("hiddenButton", de) && e) {
1518
+ let t = e.hiddenButtons;
1519
+ t || (t = [], e.hiddenButtons = t), t.push(s);
1520
+ }
1521
+ if (t.getAttribute("showButton", de) && e) {
1522
+ let t = e.showButtons;
1523
+ t || (t = [], e.showButtons = t), t.push(s);
1524
+ }
1525
+ return o;
1526
+ }
1527
+ }), h.registerVisitor({
1528
+ from: "colorFilter",
1529
+ openTag: (t) => {
1530
+ const e = t.getParent(), s = {};
1531
+ e.operator = G.BuiltInOperatorNames.Color, e.param = s, t.copyToObject(s, "cellColor"), t.copyToObject(s, "styleId", fe, "dxfId");
1532
+ }
1533
+ }), h.registerVisitor({
1534
+ from: "iconFilter",
1535
+ openTag: (t) => {
1536
+ const e = t.getParent(), s = {};
1537
+ e.operator = G.BuiltInOperatorNames.Icon, e.param = s, t.copyToObject(s, "iconId", fe), t.copyToObject(s, "iconSet", me);
1538
+ }
1539
+ }), h.registerVisitor({
1540
+ from: "top10",
1541
+ openTag: (t) => {
1542
+ const e = t.getParent(), s = {};
1543
+ e.operator = G.BuiltInOperatorNames.TopN, e.param = s, t.copyToObject(s, "filterVal", ge), t.copyToObject(s, "percent", de), t.copyToObject(s, "top", de), t.copyToObject(s, "limit", ge, "val");
1544
+ }
1545
+ }), h.registerVisitor({
1546
+ from: "dynamicFilter",
1547
+ openTag: (t) => {
1548
+ const e = t.getParent(), s = {};
1549
+ e.operator = G.BuiltInOperatorNames.TimePeriod, e.param = s;
1550
+ let o = t.getAttribute("type");
1551
+ Object.values(G.AverageType).includes(o) ? (e.operator = G.BuiltInOperatorNames.Average, t.copyToObject(s, "stdDevs", fe, "val")) : t.copyToObject(s, "anchorDate", fe, "val"), t.copyToObject(s, "operator", me, "type"), t.copyToObject(s, "maxVal", ge, "maxVal");
1552
+ }
1553
+ }), h.registerVisitor({
1554
+ from: "filters",
1555
+ to: {},
1556
+ openTag: (t) => {
1557
+ const e = t.getParent(), s = {};
1558
+ return e.operator = G.BuiltInOperatorNames.InSet, e.param = s, t.copyToObject(s, "blank", de), t.copyToObject(s, "calendarType", me), s;
1559
+ }
1560
+ }), h.registerVisitor({
1561
+ from: "filter",
1562
+ openTag: (t) => {
1563
+ const e = t.getParent();
1564
+ let s = e.items;
1565
+ s || (s = [], e.items = s), s.push(t.getAttribute("val", me));
1566
+ }
1567
+ }), h.registerVisitor({
1568
+ from: "dateGroupItem",
1569
+ to: {},
1570
+ openTag: (t) => {
1571
+ const e = t.getParent();
1572
+ let s = e.dateGroups;
1573
+ s || (s = [], e.dateGroups = s), s.push(t.getSource()), t.copyTo("group", me, "dateTimeGrouping"), t.copyTo("day", fe), t.copyTo("hour", fe), t.copyTo("minute", fe), t.copyTo("month", fe), t.copyTo("second", fe), t.copyTo("year", fe);
1574
+ }
1575
+ }), h.registerVisitor({
1576
+ from: "customFilters",
1577
+ openTag: (t) => {
1578
+ const e = t.getParent(), s = t.getAttribute("and"), o = "and" === s || "1" === s, r = [];
1579
+ return e.operator = o ? G.BuiltInOperatorNames.And : G.BuiltInOperatorNames.Or, e.param = r, t.setSource(e), r;
1580
+ },
1581
+ closeTag: (t) => {
1582
+ const e = t.getSource(), s = e?.param;
1583
+ if (1 !== s?.length) return;
1584
+ const o = s[0];
1585
+ e.operator = o.operator, e.param = o.param;
1586
+ }
1587
+ }), h.registerVisitor({
1588
+ from: "customFilter",
1589
+ openTag: (t) => {
1590
+ const e = t.getParent();
1591
+ let s;
1592
+ Array.isArray(e) ? (s = {}, e.push(s)) : s = e;
1593
+ const o = D({
1594
+ operator: t.getAttribute("operator"),
1595
+ val: t.getAttribute("val")
1596
+ });
1597
+ o && (s.operator = o.operator, s.param = o.param);
1598
+ }
1599
+ }), h.registerVisitor({
1600
+ from: "sortState",
1601
+ to: {},
1602
+ openTag: (t) => {
1603
+ const e = t.getParent();
1604
+ let s = e.v;
1605
+ s && (s.sort = {}, t.setSource(e));
1606
+ }
1607
+ }), h.registerVisitor({
1608
+ from: "sortCondition",
1609
+ to: {},
1610
+ openTag: (t) => {
1611
+ const e = t.getParent(), s = e.v;
1612
+ if (!s) return;
1613
+ const o = s.sort;
1614
+ if (!o) return;
1615
+ let r = o.sorts;
1616
+ r || (r = [], o.sorts = r);
1617
+ const i = t.getAttribute("ref");
1618
+ let n = 0;
1619
+ if (i) {
1620
+ const t = z.fastStringToRange(i, _e).colStart, s = e.r, o = s.colStart;
1621
+ n = s ? t - o : t;
1622
+ }
1623
+ const a = {};
1624
+ t.copyToObject(a, "sortOn", me, "sortBy"), t.copyToObject(a, "dxfId", me, "sortBy"), t.copyToObject(a, "iconSet", me), t.copyToObject(a, "customList", me), a.reverse = t.getAttribute("descending", de) ?? !1;
1625
+ const c = {
1626
+ index: n,
1627
+ criteria: a
1628
+ };
1629
+ r.push(c);
1630
+ }
1631
+ });
1632
+ const v = (e) => {
1633
+ b = e.getSource(), e.copyTo("topLeft", me, "topLeftCell");
1634
+ const s = t(e.getAttribute("defaultGridColor")), o = e.getAttribute("colorId");
1635
+ null === o || s || (e.getSource().gridLineColor = "index" + parseFloat(o)), e.copyTo("showZeros", de), e.copyTo("showFormulas", de), e.copyTo("zoomScale", fe), e.copyTo("showRowHeaders", de, "showRowColHeaders"), e.copyTo("showColumnHeaders", de, "showRowColHeaders"), e.copyTo("showRowGridlines", de, "showGridLines"), e.copyTo("showColumnGridlines", de, "showGridLines"), e.copyTo("rightToLeft", de);
1636
+ };
1637
+ h.registerVisitor({
1638
+ from: "sheetView",
1639
+ to: "view",
1640
+ openTag: (t) => {
1641
+ v(t);
1642
+ },
1643
+ closeTag: () => {
1644
+ b = null;
1645
+ }
1646
+ }), h.registerVisitor({
1647
+ from: "customSheetViews",
1648
+ to: "customSheetViews",
1649
+ openTag: (t) => {
1650
+ t.setSource([]);
1651
+ }
1652
+ }), h.registerVisitor({
1653
+ from: "customSheetView",
1654
+ to: [],
1655
+ openTag: (t) => {
1656
+ v(t);
1657
+ },
1658
+ closeTag: () => {
1659
+ b = null;
1660
+ }
1661
+ }), h.registerVisitor({
1662
+ from: "selection",
1663
+ to: "selection",
1664
+ openTag: (t) => {
1665
+ if (!b) return;
1666
+ t.copyTo("cell", me, "activeCell"), t.copyTo("rangeIndex", fe, "activeCellId");
1667
+ const e = t.getAttribute("activeCell"), s = t.getAttribute("sqref");
1668
+ if (s && s !== e) t.getSource().ranges = s.trim().split(/\s+/);
1669
+ }
1670
+ }), h.registerVisitor({
1671
+ from: "pane",
1672
+ to: null,
1673
+ openTag: (t) => {
1674
+ if (!b) return;
1675
+ if ("frozen" === t.getAttribute("state")) {
1676
+ const e = {};
1677
+ b.freezePanes = e, t.copyToObject(e, "topLeft", me, "topLeftCell");
1678
+ const s = (b.topLeft ? z.fastStringToCell(b.topLeft) : void 0) ?? {
1679
+ colIndex: 0,
1680
+ rowIndex: 0
1681
+ }, o = {
1682
+ colIndex: 0,
1683
+ rowIndex: 0
1684
+ };
1685
+ t.copyToObject(o, "colIndex", fe, "xSplit"), t.copyToObject(o, "rowIndex", fe, "ySplit");
1686
+ const r = {
1687
+ colIndex: s.colIndex + o.colIndex,
1688
+ rowIndex: s.rowIndex + o.rowIndex
1689
+ };
1690
+ e.coords = z.cellToString(r);
1691
+ }
1692
+ }
1693
+ }), h.registerVisitor({
1694
+ from: "sheetPr",
1695
+ transparent: !0,
1696
+ openTag: (t) => {
1697
+ const s = t.getAttribute("codeName");
1698
+ s && (e.codeName = s), !1 === t.getAttribute("enableFormatConditionsCalculation", de) && (e.conditionalFormatCalculation = !1);
1699
+ }
1700
+ }), h.registerVisitor({
1701
+ from: "tabColor",
1702
+ to: null,
1703
+ openTag: (t) => {
1704
+ const s = a((e) => t.getAttribute(e));
1705
+ s && (e.tabColor = s);
1706
+ }
1707
+ }), h.registerVisitor({
1708
+ from: "pageSetUpPr",
1709
+ to: "pageSetUpPr",
1710
+ openTag: (t) => {}
1711
+ }), h.registerVisitor({
1712
+ from: "outlinePr",
1713
+ to: null,
1714
+ openTag: (t) => {
1715
+ const s = {};
1716
+ t.copyToObject(s, "summaryBelow", de), t.copyToObject(s, "summaryRight", de), t.copyToObject(s, "showOutlineSymbols", de), t.copyToObject(s, "applyStyles", de), Object.keys(s).length > 0 && (e.outline = s);
1717
+ }
1718
+ }), h.registerVisitor({
1719
+ from: "pageMargins",
1720
+ to: "pageMargins",
1721
+ openTag: (t) => {
1722
+ t.copyTo("bottom", ge), t.copyTo("footer", ge), t.copyTo("header", ge), t.copyTo("left", ge), t.copyTo("right", ge), t.copyTo("top", ge), t.copyTo("bottom", ge);
1723
+ }
1724
+ }), h.registerVisitor({
1725
+ from: "pageSetup",
1726
+ to: "pageSetup",
1727
+ openTag: (t) => {
1728
+ t.copyTo("blackAndWhite", de), t.copyTo("cellComments"), t.copyTo("copies", fe), t.copyTo("draft", de), t.copyTo("errors"), t.copyTo("firstPageNumber", fe), t.copyTo("fitToHeight", fe), t.copyTo("fitToWidth", fe), t.copyTo("horizontalDpi", fe), t.copyTo("orientation"), t.copyTo("pageOrder"), t.copyTo("paperSize", fe), t.copyTo("scale", fe), t.copyTo("useFirstPageNumber", de), t.copyTo("usePrinterDefaults", de), t.copyTo("verticalDpi", fe);
1729
+ }
1730
+ }), h.registerVisitor({
1731
+ from: "printOptions",
1732
+ to: "printOptions",
1733
+ openTag: (t) => {
1734
+ t.copyTo("gridLines", de), t.copyTo("gridLinesSet", de), t.copyTo("headings", de), t.copyTo("horizontalCentered", de), t.copyTo("verticalCentered", de);
1735
+ }
1736
+ }), h.registerVisitor({
1737
+ from: "headerFoot",
1738
+ to: "headerFoot",
1739
+ openTag: (t) => {}
1740
+ }), h.registerVisitor({
1741
+ from: "mergeCells",
1742
+ to: "merges",
1743
+ openTag: (t) => {
1744
+ t.setSource([]);
1745
+ }
1746
+ }), h.registerVisitor({
1747
+ from: "dataValidations",
1748
+ to: "validations",
1749
+ openTag: (t) => {
1750
+ t.setSource([]);
1751
+ }
1752
+ });
1753
+ const w = {
1754
+ from: "dataValidation",
1755
+ to: [],
1756
+ openTag: (t) => {
1757
+ let e = t.getAttribute("sqref");
1758
+ e && (e = e.trim().split(/\s+/).join(","));
1759
+ const s = {}, o = {
1760
+ r: e,
1761
+ v: s,
1762
+ rule: {
1763
+ type: t.getAttribute("type") ?? void 0,
1764
+ operator: t.getAttribute("operator") ?? void 0
1765
+ }
1766
+ };
1767
+ !0 === t.getAttribute("showDropDown", de) && (s.hideDropdown = !0), t.copyToObject(s, "alert", me, "error"), t.copyToObject(s, "alertTitle", me, "errorTitle"), t.copyToObject(s, "showAlertMessage", de, "showErrorMessage"), s.alertStyle = t.getAttribute("errorStyle") ?? "stop", t.copyToObject(s, "imeMode"), t.copyToObject(s, "prompt"), t.copyToObject(s, "promptTitle"), t.copyToObject(s, "showPromptMessage", de, "showInputMessage"), t.setSource(o);
1768
+ },
1769
+ closeTag: (t) => {
1770
+ const e = t.getSource();
1771
+ if (!e?.rule) return;
1772
+ const s = L(e.rule, n);
1773
+ s && (t.getAttribute("allowBlank", de) && (s.includeBlanks = !0), e.v.condition = s), delete e.rule;
1774
+ }
1775
+ };
1776
+ h.registerVisitor(w), h.registerVisitor({
1777
+ from: "formula1",
1778
+ to: {},
1779
+ text: (t, e) => {
1780
+ const s = e.getParent().rule;
1781
+ s?.type && (s.formula1 = P(g(t), s.type));
1782
+ }
1783
+ }), h.registerVisitor({
1784
+ from: "formula2",
1785
+ to: {},
1786
+ text: (t, e) => {
1787
+ const s = e.getParent().rule;
1788
+ s?.type && (s.formula2 = P(g(t), s.type));
1789
+ }
1790
+ }), h.registerVisitor({
1791
+ from: "picture",
1792
+ to: "picture",
1793
+ openTag: (t) => {
1794
+ const e = t.getAttribute("r:id");
1795
+ if (!e) return void t.warn("A picture names no image; it was not imported.", { onceKey: "xlsx.sheet.picture.noRel" });
1796
+ const o = s(e, "resource");
1797
+ t.getSource().resId = o;
1798
+ }
1799
+ });
1800
+ const S = {
1801
+ from: "slicer",
1802
+ to: {},
1803
+ openTag: (t) => {
1804
+ const e = t.getAttribute("r:id");
1805
+ if (!e) return void t.warn("A slicer names no cache; it was not imported.", { onceKey: "xlsx.sheet.slicer.noRel" });
1806
+ const o = s(e)?.slicers, r = t.getParent();
1807
+ r.slicers || (r.slicers = {});
1808
+ const i = Object.keys(o);
1809
+ for (const t of i) r.slicers[t] = o[t];
1810
+ }
1811
+ };
1812
+ h.registerVisitor(S);
1813
+ const k = (t, e) => ({
1814
+ from: t,
1815
+ to: {},
1816
+ openTag: (t) => {
1817
+ t.setSource("");
1818
+ },
1819
+ text: (t, e) => {
1820
+ e.setSource((e.getSource() ?? "") + t);
1821
+ },
1822
+ closeTag: (t) => {
1823
+ e(String(t.getSource() ?? ""), t);
1824
+ }
1825
+ }), E = /* @__PURE__ */ new Map();
1826
+ E.set("dataValidations", {
1827
+ from: "dataValidations",
1828
+ to: "validations",
1829
+ openTag: (t) => {
1830
+ const e = t.getParent();
1831
+ t.setSource(e.validations ?? []);
1832
+ },
1833
+ closeTag: (t) => {
1834
+ 0 === (t.getSource()?.length ?? 0) && t.setSource(void 0);
1835
+ }
1836
+ }), E.set("dataValidation", {
1837
+ ...w,
1838
+ closeTag: (t) => {
1839
+ w.closeTag(t);
1840
+ const e = t.getSource();
1841
+ e && !e.r && (t.warn("x14 dataValidation with no xm:sqref was dropped."), t.setSource(void 0));
1842
+ }
1843
+ });
1844
+ const _ = (t) => ({
1845
+ from: t,
1846
+ to: {},
1847
+ openTag: (e) => {
1848
+ e.setSource({
1849
+ rule: e.getParent()?.rule,
1850
+ key: t
1851
+ });
1852
+ }
1853
+ });
1854
+ E.set("formula1", _("formula1")), E.set("formula2", _("formula2")), E.set("f", k("f", (t, e) => {
1855
+ const s = e.getParent(), o = s?.rule;
1856
+ o && (o[s.key] = P(g(t), o.type));
1857
+ })), E.set("sqref", k("sqref", (t, e) => {
1858
+ const s = e.getParent(), o = t.trim();
1859
+ s && o && (s.r = o.split(/\s+/).join(","));
1860
+ }));
1861
+ const $ = /* @__PURE__ */ new Map(), B = [], H = /* @__PURE__ */ new Map();
1862
+ H.set("conditionalFormattings", {
1863
+ from: "conditionalFormattings",
1864
+ transparent: !0
1865
+ }), H.set("conditionalFormatting", {
1866
+ from: "conditionalFormatting",
1867
+ to: {},
1868
+ openTag: (t) => {
1869
+ t.setSource({ rules: [] });
1870
+ },
1871
+ closeTag: (t) => {
1872
+ const e = t.getSource(), s = e?.rules ?? [];
1873
+ for (let t = 0; t < s.length; t++) {
1874
+ const o = s[t];
1875
+ o.sqref = e.sqref, o.id ? $.set(o.id, o) : B.push(o);
1876
+ }
1877
+ }
1878
+ }), H.set("cfRule", {
1879
+ from: "cfRule",
1880
+ to: {},
1881
+ openTag: (t) => {
1882
+ t.copyTo("id", me), t.copyTo("type", me), t.copyTo("priority", fe), t.copyTo("stopIfTrue", de), t.copyTo("operator", me), t.copyTo("text", me), t.copyTo("timePeriod", me), t.copyTo("aboveAverage", de), t.copyTo("equalAverage", de), t.copyTo("stdDev", fe), t.copyTo("bottom", de), t.copyTo("percent", de), t.copyTo("rank", fe);
1883
+ },
1884
+ closeTag: (t) => {
1885
+ const e = t.getSource();
1886
+ e && t.getParent()?.rules?.push(e);
1887
+ }
1888
+ }), H.set("sqref", k("sqref", (t, e) => {
1889
+ const s = e.getParent(), o = t.trim();
1890
+ s && o && (s.sqref = o);
1891
+ })), H.set("dataBar", {
1892
+ from: "dataBar",
1893
+ to: {},
1894
+ openTag: (t) => {
1895
+ t.copyTo("minLength", fe), t.copyTo("maxLength", fe), t.copyTo("gradient", de), t.copyTo("border", de), t.copyTo("direction", me), t.copyTo("axisPosition", me), t.copyTo("negativeBarColorSameAsPositive", de), t.copyTo("negativeBarBorderColorSameAsPositive", de);
1896
+ },
1897
+ closeTag: (t) => {
1898
+ t.getParent().dataBar = t.getSource();
1899
+ }
1900
+ }), H.set("iconSet", {
1901
+ from: "iconSet",
1902
+ to: {},
1903
+ openTag: (t) => {
1904
+ t.copyTo("iconSet", me), t.copyTo("custom", de), t.copyTo("reverse", de), t.copyTo("showValue", de);
1905
+ },
1906
+ closeTag: (t) => {
1907
+ t.getParent().iconSet = t.getSource();
1908
+ }
1909
+ });
1910
+ const F = /* @__PURE__ */ new Map();
1911
+ F.set("f", k("f", (t, e) => {
1912
+ const s = e.getParent();
1913
+ if (!s) return;
1914
+ const o = t.trim(), r = Number(o);
1915
+ s.value = o.length > 0 && Number.isFinite(r) ? r : g(t);
1916
+ })), H.set("cfvo", {
1917
+ from: "cfvo",
1918
+ to: {},
1919
+ scope: () => F,
1920
+ openTag: (t) => {
1921
+ const e = t.getParent();
1922
+ e.conditions || (e.conditions = []);
1923
+ const s = t.getSource();
1924
+ e.conditions.push(s), t.copyTo("type", me), !1 === t.getAttribute("gte", de) && (s.exclusive = !0);
1925
+ }
1926
+ }), H.set("f", k("f", (t, e) => {
1927
+ const s = e.getParent();
1928
+ s && (s.formulas ??= []).push(g(t));
1929
+ })), H.set("dxf", {
1930
+ from: "dxf",
1931
+ to: {},
1932
+ raw: !0,
1933
+ closeTag: (t) => {
1934
+ if (!p) return;
1935
+ const e = t.getParent();
1936
+ if (!e) return;
1937
+ const s = p(t.getRawXml() ?? "");
1938
+ s && (e.style = s);
1939
+ }
1940
+ });
1941
+ const W = (t) => ({
1942
+ from: t,
1943
+ to: {},
1944
+ openTag: (e) => {
1945
+ const s = a((t) => e.getAttribute(t));
1946
+ s && (e.getParent()[t] = s);
1947
+ }
1948
+ });
1949
+ H.set("borderColor", W("borderColor")), H.set("negativeFillColor", W("negativeFillColor")), H.set("negativeBorderColor", W("negativeBorderColor")), H.set("axisColor", W("axisColor")), H.set("cfIcon", {
1950
+ from: "cfIcon",
1951
+ to: {},
1952
+ openTag: (t) => {
1953
+ const e = t.getAttribute("iconSet"), s = t.getAttribute("iconId", fe);
1954
+ if (null === e || null === s) return;
1955
+ const o = t.getParent();
1956
+ o.icons || (o.icons = []), o.icons.push({
1957
+ set: e,
1958
+ id: s
1959
+ });
1960
+ }
1961
+ });
1962
+ const X = /* @__PURE__ */ new Map();
1963
+ X.set("id", k("id", (t, e) => {
1964
+ const s = e.getParent(), o = t.trim();
1965
+ s && o && (s.x14Id = o);
1966
+ }));
1967
+ const q = /* @__PURE__ */ new Map();
1968
+ q.set("slicerList", {
1969
+ from: "slicerList",
1970
+ transparent: !0
1971
+ }), q.set("slicer", S);
1972
+ const U = /* @__PURE__ */ new Map([
1973
+ [V(x), E],
1974
+ [V(y), H],
1975
+ [V(N), H],
1976
+ [V(f), X],
1977
+ [V(O), q],
1978
+ [V(A), q]
1979
+ ]), Z = /* @__PURE__ */ new Set();
1980
+ h.registerVisitor({
1981
+ from: "extLst",
1982
+ transparent: !0
1983
+ }), h.registerVisitor({
1984
+ from: "ext",
1985
+ transparent: !0,
1986
+ scope: (t) => {
1987
+ const e = t.getAttribute("uri"), s = V(e), o = U.get(s);
1988
+ if (o) return o;
1989
+ if (!u.has(s) && !Z.has(s)) {
1990
+ Z.add(s);
1991
+ const o = I[s];
1992
+ t.warn(o ? `Extension content '${o}' (${e}) is not read; it will be lost on resave.` : `Unknown extension content (uri ${e}) is not read; it will be lost on resave.`);
1993
+ }
1994
+ return null;
1995
+ }
1996
+ }), h.registerVisitor({
1997
+ from: "mergeCell",
1998
+ to: [],
1999
+ openTag: (t) => {
2000
+ const e = t.getAttribute("ref");
2001
+ t.setSource(e);
2002
+ }
2003
+ }), h.registerVisitor({
2004
+ from: "hyperlinks",
2005
+ to: "hyperlinks",
2006
+ openTag: (t) => {
2007
+ t.setSource([]);
2008
+ }
2009
+ }), h.registerVisitor({
2010
+ from: "hyperlink",
2011
+ to: [],
2012
+ openTag: (t) => {
2013
+ const e = t.getAttribute("r:id"), o = t.getAttribute("ref");
2014
+ if (!o) return void t.warn("A hyperlink has no ref; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.noRef" });
2015
+ t.setKey(o);
2016
+ let r = e ? s(e) : "";
2017
+ if ("string" != typeof r) return void t.warn("A hyperlink has an invalid address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2018
+ r.endsWith("\\") && (r = r.substring(0, r.length - 1));
2019
+ const i = t.getAttribute("location");
2020
+ if (i && (r += "#" + i), !r) return void t.warn("A hyperlink has no address; it was dropped.", { onceKey: "xlsx.sheet.hyperlink.address" });
2021
+ let n;
2022
+ const a = t.getAttribute("tooltip");
2023
+ n = a ? {
2024
+ address: r,
2025
+ screenTip: a
2026
+ } : r, t.setSource({
2027
+ r: o,
2028
+ v: n
2029
+ });
2030
+ }
2031
+ }), h.registerVisitor({
2032
+ from: "drawing",
2033
+ to: "movables",
2034
+ openTag: (t) => {
2035
+ const e = t.getAttribute("r:id");
2036
+ if (!e) return;
2037
+ const o = s(e);
2038
+ o ? t.setSource(o.movables) : t.warn("A drawing part is missing; its shapes were not imported.", { onceKey: "xlsx.sheet.drawing.missing" });
2039
+ }
2040
+ }), h.registerVisitor({
2041
+ from: "legacyDrawing",
2042
+ to: "legacyDrawing",
2043
+ openTag: (t) => {
2044
+ t.setSource(s(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2045
+ }
2046
+ }), h.registerVisitor({
2047
+ from: "legacyDrawingHF",
2048
+ to: "legacyDrawingHF",
2049
+ openTag: (t) => {
2050
+ t.setSource(s(t.getAttribute("r:id"), "legacyDrawing") ?? void 0);
2051
+ }
2052
+ });
2053
+ let J = null, Q = !1;
2054
+ const Y = /* @__PURE__ */ new Map(), et = {
2055
+ from: "Fallback",
2056
+ to: null
2057
+ }, st = {
2058
+ from: "Choice",
2059
+ transparent: !0
2060
+ };
2061
+ Y.set("Fallback", et), Y.set("Choice", st), Y.set("control", {
2062
+ from: "control",
2063
+ transparent: !0,
2064
+ openTag: (t) => {
2065
+ const e = {}, o = parseInt(t.getAttribute("shapeId") ?? "", 10);
2066
+ isNaN(o) || (e.shapeId = o);
2067
+ const r = t.getAttribute("r:id"), i = r ? s(r, "part") : null;
2068
+ i && (e.part = i);
2069
+ const n = t.getAttribute("name"), a = {
2070
+ anchor: {
2071
+ tl: {
2072
+ c: 0,
2073
+ r: 0,
2074
+ x: 0,
2075
+ y: 0
2076
+ },
2077
+ br: {
2078
+ c: 0,
2079
+ r: 0,
2080
+ x: 0,
2081
+ y: 0
2082
+ }
2083
+ },
2084
+ content: {
2085
+ type: "control",
2086
+ json: e
2087
+ }
2088
+ };
2089
+ n && (a.name = n), J = {
2090
+ movable: a,
2091
+ control: e
2092
+ };
2093
+ },
2094
+ closeTag: () => {
2095
+ J && (e.movables || (e.movables = []), e.movables.push(J.movable), J = null);
2096
+ }
2097
+ }), Y.set("controlPr", {
2098
+ from: "controlPr",
2099
+ transparent: !0,
2100
+ raw: !0,
2101
+ openTag: (t) => {
2102
+ if (!J) return;
2103
+ const e = t.getFrom().attributes ?? {}, s = {};
2104
+ for (const t in e) {
2105
+ const o = e[t];
2106
+ s[t] = "string" == typeof o ? o : o?.value ?? "";
2107
+ }
2108
+ Object.keys(s).length > 0 && (J.control.props = s);
2109
+ },
2110
+ closeTag: (t) => {
2111
+ if (!J) return;
2112
+ const e = ((t) => {
2113
+ const e = /<(?:[\w.-]+:)?anchor\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?anchor>/.exec(t);
2114
+ if (!e) return null;
2115
+ const s = e[2], o = (t) => new RegExp(`<(?:[\\w.-]+:)?${t}\\b[^>]*>([\\s\\S]*?)<\\/(?:[\\w.-]+:)?${t}>`).exec(s)?.[1], r = e[1], i = /\bmoveWithCells="(?:1|true)"/.test(r), n = /\bsizeWithCells="(?:1|true)"/.test(r);
2116
+ return {
2117
+ anchor: {
2118
+ tl: Oe(o("from")),
2119
+ br: Oe(o("to"))
2120
+ },
2121
+ anchorType: i ? n ? "twoCell" : "oneCell" : "absolute",
2122
+ rest: (t.slice(0, e.index) + t.slice(e.index + e[0].length)).trim()
2123
+ };
2124
+ })(t.getRawXml() ?? "");
2125
+ e ? (J.movable.anchor = e.anchor, "twoCell" !== e.anchorType && (J.movable.anchorType = e.anchorType), e.rest && (J.control.xml = e.rest)) : Q || (Q = !0, t.warn("A form control has no anchor; it is placed at the top left of the sheet."));
2126
+ }
2127
+ });
2128
+ const ot = {
2129
+ from: "controls",
2130
+ transparent: !0,
2131
+ scope: () => Y
2132
+ };
2133
+ h.registerVisitor(ot);
2134
+ const rt = /* @__PURE__ */ new Map([
2135
+ ["Choice", st],
2136
+ ["Fallback", et],
2137
+ ["controls", ot]
2138
+ ]);
2139
+ h.registerVisitor({
2140
+ from: "AlternateContent",
2141
+ transparent: !0,
2142
+ scope: () => rt
2143
+ }), h.registerVisitor({
2144
+ from: "tableParts",
2145
+ to: "tables",
2146
+ openTag: (t) => {
2147
+ t.setSource([]);
2148
+ }
2149
+ }), h.registerVisitor({
2150
+ from: "tablePart",
2151
+ to: [],
2152
+ openTag: (t) => {
2153
+ const e = t.getAttribute("r:id");
2154
+ if (!e) return;
2155
+ const o = s(e);
2156
+ o ? t.setSource(o) : t.warn("A table part is missing; the table was not imported.", { onceKey: "xlsx.sheet.table.missing" });
2157
+ }
2158
+ });
2159
+ const it = (t, e) => {
2160
+ e.conditions?.length && (t.stops = T(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);
2161
+ }, nt = (t, e) => {
2162
+ e.conditions?.length && (t.stops = T(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);
2163
+ }, at = (t) => {
2164
+ if (!t.sqref) return null;
2165
+ const e = t.sqref.split(/\s+/).join(",");
2166
+ if ("iconSet" === t.type) {
2167
+ if (!t.iconSet) return null;
2168
+ const s = {
2169
+ type: K.ScaleType.IconSet,
2170
+ stops: []
2171
+ };
2172
+ return nt(s, t.iconSet), {
2173
+ r: e,
2174
+ v: { scale: s },
2175
+ priority: t.priority
2176
+ };
2177
+ }
2178
+ const s = R(t, n);
2179
+ if (!s) return null;
2180
+ const o = { condition: s };
2181
+ return t.style && (o.style = t.style), t.stopIfTrue && (o.stopIfTrue = !0), {
2182
+ r: e,
2183
+ v: o,
2184
+ priority: t.priority
2185
+ };
2186
+ };
2187
+ h.registerVisitor({
2188
+ from: "worksheet",
2189
+ to: {},
2190
+ openTag: (t) => {},
2191
+ closeTag: (t) => {
2192
+ const e = t.getSource();
2193
+ let s = e?.conditionals;
2194
+ if (s) for (let t = 0; t < s.length; t++) {
2195
+ const e = s[t], o = e.x14Id;
2196
+ if (!o) continue;
2197
+ delete e.x14Id;
2198
+ const r = $.get(o);
2199
+ if (!r) continue;
2200
+ $.delete(o);
2201
+ const i = e.v?.scale;
2202
+ r.dataBar && i?.type === K.ScaleType.DataBar ? it(i, r.dataBar) : r.iconSet && i?.type === K.ScaleType.IconSet && nt(i, r.iconSet);
2203
+ }
2204
+ const o = [...$.values(), ...B], r = /* @__PURE__ */ new Set();
2205
+ let i = 0;
2206
+ for (let t = 0; t < o.length; t++) {
2207
+ const n = at(o[t]);
2208
+ n ? (s || (s = [], e.conditionals = s), s.push(n)) : (r.add(o[t].type ?? "unknown"), i++);
2209
+ }
2210
+ if (i > 0) {
2211
+ const t = [...r].map((t) => `'${t}'`).join(", ");
2212
+ n?.(1 === i ? `An x14-only conditional formatting rule (type ${t}) is not read and will be lost on resave.` : `${i} x14-only conditional formatting rules (types ${t}) are not read and will be lost on resave.`);
2213
+ }
2214
+ if (s) {
2215
+ s.length > 1 && s.sort((t, e) => (t.priority ?? Infinity) - (e.priority ?? Infinity));
2216
+ for (let t = 0; t < s.length; t++) delete s[t].priority;
2217
+ }
2218
+ }
2219
+ }), h.registerVisitor({
2220
+ from: "customProperties",
2221
+ to: "customProperties",
2222
+ openTag: (t) => {
2223
+ t.setSource([]);
2224
+ },
2225
+ closeTag: (t) => {
2226
+ const e = t.getSource();
2227
+ if (e.length > 0) t.getParent().customProperties = e;
2228
+ }
2229
+ }), h.registerVisitor({
2230
+ from: "customPr",
2231
+ to: {},
2232
+ openTag: (t) => {
2233
+ const e = t.getParent();
2234
+ t.copyTo("name");
2235
+ const o = t.getAttribute("r:id");
2236
+ if (!o) return void t.warn("A custom property names no part; it was not imported.", { onceKey: "xlsx.sheet.customProperty.noRel" });
2237
+ const r = s(o, "resource"), i = t.getSource();
2238
+ i.resId = r, e.push(i);
2239
+ }
2240
+ }), h.registerVisitor({
2241
+ from: "sheetProtection",
2242
+ to: "protection",
2243
+ openTag: (t) => {
2244
+ const e = t.getSource();
2245
+ for (const s of M) {
2246
+ const o = t.hasAttribute(s.attribute) ? t.getAttribute(s.attribute) : null;
2247
+ e[s.key] = j(s, o);
2248
+ }
2249
+ if (e.sheet) return;
2250
+ const s = {};
2251
+ if (t.copyToObject(s, "hash", me, "hashValue"), t.copyToObject(s, "algorithm", me, "algorithmName"), t.copyToObject(s, "salt", me, "saltValue"), t.copyToObject(s, "spinCount", fe), Object.keys(s).length > 0) t.getSource().password = s;
2252
+ }
2253
+ }), h.registerVisitor({
2254
+ from: "protectedRanges",
2255
+ to: "protectedRanges",
2256
+ openTag: (t) => {
2257
+ t.setSource([]);
2258
+ }
2259
+ }), h.registerVisitor({
2260
+ from: "protectedRange",
2261
+ to: [],
2262
+ openTag: (t) => {
2263
+ let e = t.getAttribute("sqref");
2264
+ e && (e = e.trim().split(/\s+/).join(","));
2265
+ const s = {}, o = {
2266
+ r: e,
2267
+ v: s
2268
+ };
2269
+ t.copyToObject(s, "name"), t.copyToObject(s, "securityDescriptor");
2270
+ const r = {};
2271
+ t.copyToObject(r, "hash", me, "hashValue"), t.copyToObject(r, "algorithm", me, "algorithmName"), t.copyToObject(r, "salt", me, "saltValue"), t.copyToObject(r, "spinCount", fe), Object.keys(r).length > 0 && (s.password = r), t.setSource(o);
2272
+ },
2273
+ closeTag: (t) => {
2274
+ const e = t.getSource();
2275
+ e?.r && e.v.name || t.setSource(void 0);
2276
+ }
2277
+ }), h.registerVisitor({
2278
+ from: "sheetFormatPr",
2279
+ to: "sheetFormatPr",
2280
+ openTag: (t) => {
2281
+ t.copyToObject(e, "defaultColSize", ge, "defaultColWidth"), t.copyToObject(e, "outlineLevelCol", fe, "outlineLevelCol");
2282
+ const s = t.getAttribute("customHeight");
2283
+ "1" !== s && "true" !== s || t.copyToObject(e, "defaultRowSize", ge, "defaultRowHeight"), t.copyToObject(e, "outlineLevelRow", fe, "outlineLevelRow");
2284
+ }
2285
+ }), h.registerVisitor({
2286
+ from: "cols",
2287
+ to: "cols",
2288
+ openTag: (t) => {
2289
+ t.setSource([]);
2290
+ }
2291
+ }), h.registerVisitor({
2292
+ from: "col",
2293
+ to: [],
2294
+ openTag: (t) => {
2295
+ const e = t.getSource(), s = t.getAttribute("min"), o = t.getAttribute("max"), r = void 0 === s ? 0 : parseInt(s) - 1, i = void 0 === o ? r : parseInt(o) - 1;
2296
+ e.r = z.runToString(r, i, !0);
2297
+ const n = {};
2298
+ e.v = n, t.copyToObject(n, "sz", ge, "width"), t.copyToObject(n, "csz", de, "customWidth"), t.copyToObject(n, "h", de, "hidden"), t.copyToObject(n, "l", fe, "outlineLevel"), t.copyToObject(n, "s", fe, "style");
2299
+ }
2300
+ }), h.registerVisitor({
2301
+ from: "oleObjects",
2302
+ to: null,
2303
+ openTag: (t) => {
2304
+ t.warn("'OLE Objects' are not supported.");
2305
+ }
2306
+ });
2307
+ let ct = !1, lt = !1, ht = 0, ut = "";
2308
+ const pt = (t) => {
2309
+ const e = t.indexOf(":");
2310
+ return -1 === e ? t : t.slice(e + 1);
2311
+ };
2312
+ return Ve(m, e, h.createEventHandler(e, i, n), n, c, {
2313
+ onOpenTag: (t) => {
2314
+ ct = !0;
2315
+ const e = pt(t.name);
2316
+ "t" === e || "v" === e ? 0 === ht && (lt = !0) : "rPh" !== e && "phoneticPr" !== e || ht++;
2317
+ },
2318
+ onText: (t) => {
2319
+ lt && (ut += t);
2320
+ },
2321
+ onCloseTag: (t) => {
2322
+ const e = pt(t.name);
2323
+ "t" === e || "v" === e ? lt = !1 : "rPh" !== e && "phoneticPr" !== e || ht > 0 && ht--;
2324
+ },
2325
+ onEnd: () => {
2326
+ if (!ct) return;
2327
+ const t = o(C(ut));
2328
+ return ct = !1, lt = !1, ht = 0, ut = "", t;
2329
+ },
2330
+ onError: (t) => {}
2331
+ }, l);
2332
+ }, Ie = class {
2333
+ static {
2334
+ this.Collapsed = 1;
2335
+ }
2336
+ static {
2337
+ this.CustomFormat = 2;
2338
+ }
2339
+ static {
2340
+ this.CustomHeight = 4;
2341
+ }
2342
+ static {
2343
+ this.Hidden = 8;
2344
+ }
2345
+ static {
2346
+ this.Ht = 16;
2347
+ }
2348
+ static {
2349
+ this.OutlineLevel = 32;
2350
+ }
2351
+ static {
2352
+ this.Ph = 64;
2353
+ }
2354
+ static {
2355
+ this.R = 128;
2356
+ }
2357
+ static {
2358
+ this.S = 256;
2359
+ }
2360
+ static {
2361
+ this.Spans = 512;
2362
+ }
2363
+ static {
2364
+ this.ThickBot = 1024;
2365
+ }
2366
+ static {
2367
+ this.ThickTop = 2048;
2368
+ }
2369
+ }, De = (t, e, s) => {
2370
+ if (t[0].value[0] === t[1].value[0]) return e;
2371
+ }, _e = {
2372
+ colStart: 0,
2373
+ colEnd: 0,
2374
+ rowStart: 0,
2375
+ rowEnd: 0
2376
+ }, Ve = (t, e, s, o, r, i, n) => {
2377
+ let a = !1, c = !1, l = [], h = !1, u = null, p = null, d = null, f = null, g = null, m = null;
2378
+ const x = n?.get("richData") ?? X.EmptyArray, y = n?.get("dummyWrapped") ?? null, b = z.normalizeA1ToR1C1, T = q.createConflatingRanges(), v = /* @__PURE__ */ new Map(), w = [];
2379
+ let S = !1, C = !1, k = null;
2380
+ let A = !1;
2381
+ const O = q.createConflatingRanges();
2382
+ let E = !1, P = -1, I = -1, D = null, _ = null, V = null;
2383
+ const L = [];
2384
+ let N = null, $ = -2, R = 0, j = "", M = "", B = "", H = "", F = "", W = "", G = "", K = "", J = "", Q = "", Y = "", tt = "", et = "", st = "", ot = !0, rt = null, it = !1, nt = !1, at = !1, ct = null, lt = 0;
2385
+ const ht = (t) => {
2386
+ let o = t.name;
2387
+ const d = o.indexOf(":");
2388
+ if (-1 !== d && (o = o.slice(d + 1)), lt++, lt % 196608 == 0 && r?.(lt), _) {
2389
+ const e = t.attributes;
2390
+ switch (o) {
2391
+ case "v":
2392
+ c = !0;
2393
+ break;
2394
+ case "f":
2395
+ switch (h = !0, e.t ?? null) {
2396
+ case null:
2397
+ case "normal": break;
2398
+ case "shared":
2399
+ const t = e.si;
2400
+ p = e.ref, u = t;
2401
+ break;
2402
+ case "array":
2403
+ p = e.ref, k = p;
2404
+ break;
2405
+ case "datatable": p = e.ref, h = !0;
2406
+ }
2407
+ const t = e.ca;
2408
+ void 0 !== t && (A = "1" === t);
2409
+ break;
2410
+ case "is":
2411
+ E = !0;
2412
+ return;
2413
+ }
2414
+ E && !h && i?.onOpenTag?.(t);
2415
+ return;
2416
+ }
2417
+ if (a) {
2418
+ if ("c" === o) {
2419
+ _ = t;
2420
+ const e = t.attributes, s = e.r;
2421
+ I = z.fastStringToCol(s);
2422
+ const o = e.t;
2423
+ void 0 === o ? V = null : (V = o, "str" === V && (E = !0));
2424
+ let r = e.s;
2425
+ void 0 === r && (null !== ct || at) && (r = "0"), void 0 !== r && (r = parseInt(r), rt && rt.value === r && rt.colEnd + 1 === I ? rt.colEnd = I : (rt = {
2426
+ colStart: I,
2427
+ rowStart: P,
2428
+ colEnd: I,
2429
+ rowEnd: P,
2430
+ value: r
2431
+ }, l.push(rt))), k = null, C = !1;
2432
+ const i = e.cm;
2433
+ S = void 0 !== i && ((t) => {
2434
+ const e = (n?.get("metadata"))?.cells;
2435
+ if (!e) return !1;
2436
+ const s = parseInt(t, 10);
2437
+ return !(!Number.isFinite(s) || s < 1) && !0 === (e[s - 1]?.get("XLDAPR"))?.fDynamic;
2438
+ })(i);
2439
+ const a = e.vm;
2440
+ if (void 0 !== a) {
2441
+ const t = x[parseInt(a) - 1];
2442
+ if (U.isError(t)) {
2443
+ const e = t.getCode();
2444
+ D = {
2445
+ t: "e",
2446
+ v: e
2447
+ }, S && e === U.Code.Spill && (C = !0);
2448
+ }
2449
+ }
2450
+ }
2451
+ } else {
2452
+ if (nt && "row" === o) {
2453
+ a = !0;
2454
+ const e = t.attributes.r;
2455
+ if (P = parseInt(e) - 1, R = 0, M = t.attributes.customHeight, void 0 !== M && (R |= Ie.CustomHeight), M !== J && (ot = !0, J = M), j = t.attributes.ht, void 0 !== j && (R |= Ie.Ht), j !== K && (ot = !0, K = j), B = t.attributes.hidden, void 0 !== B && (R |= Ie.Hidden), B !== Q && (ot = !0, Q = B), F = t.attributes.s, void 0 !== F && (R |= Ie.S), F !== tt && (ot = !0, tt = F), H = t.attributes.customFormat, void 0 !== H && (R |= Ie.CustomFormat), H !== Y && (ot = !0, Y = H), W = t.attributes.outlineLevel, void 0 !== W && (R |= Ie.OutlineLevel), W !== et && (ot = !0, et = W), G = t.attributes.collapsed, void 0 !== G && (R |= Ie.Collapsed), G !== st && (ot = !0, st = G), 0 !== R) if ($ + 1 !== P || ot) {
2456
+ const t = void 0 !== M && ("1" === M || "true" === M), e = void 0 !== H && ("1" === H || "true" === H);
2457
+ ct = e && void 0 !== F ? F : null, e && null === ct && (ct = "0"), N = {
2458
+ min: P,
2459
+ max: P,
2460
+ value: {
2461
+ sz: void 0 === j ? -1 : parseFloat(j),
2462
+ csz: t,
2463
+ h: void 0 !== B && ("1" === B || "true" === B),
2464
+ s: null === ct ? void 0 : "0" === ct ? 0 : parseInt(ct),
2465
+ l: void 0 === W || "0" === W ? 0 : parseInt(W),
2466
+ cl: void 0 !== G && ("1" === G || "true" === G)
2467
+ }
2468
+ }, L.push(N);
2469
+ } else N.max = P;
2470
+ $ = P, ot = !1;
2471
+ return;
2472
+ }
2473
+ if ("sheetData" === o && (nt = !0), !it && "sheetData" === o) {
2474
+ it = !0;
2475
+ const t = e.cols, s = t ? t.length : 0;
2476
+ for (let e = 0; !at && e < s; e++) t[e].v.s && (at = !0);
2477
+ }
2478
+ s?.onOpenTag?.(t);
2479
+ }
2480
+ }, ut = (e) => {
2481
+ let o = e.name;
2482
+ if ("sheetData" === o && (nt = !1), !h || "c" !== o && "f" !== o || (u && (f = v.get(u) ?? null), f && (T.append(P, I, f), A && O.append(P, I)), null !== k && w.push([k, S ? C ? "error" : "dynamic" : "fixed"]), h = !1, f = null, u = null, p = null, c = !1, A = !1, k = null, S = !1, C = !1), _) {
2483
+ const s = o.indexOf(":");
2484
+ if (-1 !== s && (o = o.slice(s + 1)), E) if ("is" === o || "v" === o) {
2485
+ const e = i?.onEnd?.();
2486
+ null != e && t.pushAt(P, I, "" + e);
2487
+ } else "f" !== o && i?.onCloseTag?.(e);
2488
+ c && (c = !1), "c" === o && (_ = null, E = !1);
2489
+ return;
2490
+ }
2491
+ if (a) return a = !1, void (rt = null);
2492
+ s?.onCloseTag?.(e);
2493
+ }, pt = (r) => {
2494
+ const n = r.trim();
2495
+ if (c) {
2496
+ switch (D = null, V) {
2497
+ case null:
2498
+ case "n":
2499
+ D = parseFloat(n);
2500
+ break;
2501
+ case "b":
2502
+ D = "1" === n || "true" === n;
2503
+ break;
2504
+ case "s":
2505
+ D = n;
2506
+ break;
2507
+ case "e":
2508
+ if ("#VALUE!" === n) {
2509
+ const t = _.attributes.vm;
2510
+ if (void 0 !== t) {
2511
+ const e = x[parseInt(t) - 1];
2512
+ if (U.isError(e)) {
2513
+ D = {
2514
+ t: "e",
2515
+ v: e.getCode()
2516
+ };
2517
+ break;
2518
+ }
2519
+ }
2520
+ }
2521
+ const t = U.getBuiltInByLabel(n);
2522
+ t ? D = {
2523
+ t: "e",
2524
+ v: t.getCode()
2525
+ } : (D = n, o?.(`Unknown formula error '${n}' in cell ${z.cellToString({
2526
+ colIndex: I,
2527
+ rowIndex: P
2528
+ })}`));
2529
+ break;
2530
+ case "str":
2531
+ case "inlineStr": E = !0;
2532
+ }
2533
+ null !== D && t.pushAt(P, I, D);
2534
+ }
2535
+ if (u) {
2536
+ if (g === u) f = m;
2537
+ else {
2538
+ if (f = v.get(u) ?? null, !f) {
2539
+ const t = [];
2540
+ d = b(n, P, I, t), f = [
2541
+ d,
2542
+ t,
2543
+ n
2544
+ ], v.set(u, f);
2545
+ }
2546
+ g = u, m = f;
2547
+ }
2548
+ u = null;
2549
+ }
2550
+ if (h) {
2551
+ if (null !== y) {
2552
+ const t = ((t) => {
2553
+ if (t.length < Te.length) return Se;
2554
+ if (t.slice(0, Te.length).toUpperCase() !== ve) return Se;
2555
+ const e = ke(t, Te.length);
2556
+ if (null === e) return Se;
2557
+ if (41 !== t.charCodeAt(e.end)) return Se;
2558
+ if (44 !== t.charCodeAt(e.end + 1)) return Se;
2559
+ if (41 !== t.charCodeAt(t.length - 1)) return Se;
2560
+ const s = e.value;
2561
+ return s.toUpperCase() === we ? Ce : 0 === s.length ? Se : {
2562
+ kind: "formula",
2563
+ formula: s
2564
+ };
2565
+ })(n);
2566
+ "none" !== t.kind && y.push({
2567
+ sheet: e,
2568
+ rowIndex: P,
2569
+ colIndex: I,
2570
+ formula: "formula" === t.kind ? t.formula : null
2571
+ });
2572
+ }
2573
+ const t = [];
2574
+ d = b(n, P, I, t), f = [
2575
+ d,
2576
+ t,
2577
+ n
2578
+ ];
2579
+ }
2580
+ E ? i?.onText?.(r) : a || s?.onText?.(n);
2581
+ }, dt = {
2582
+ r: void 0,
2583
+ t: void 0,
2584
+ s: void 0,
2585
+ cm: void 0,
2586
+ vm: void 0
2587
+ }, ft = {
2588
+ name: "c",
2589
+ attributes: dt,
2590
+ isSelfClosing: !1
2591
+ }, gt = {
2592
+ t: void 0,
2593
+ si: void 0,
2594
+ ref: void 0,
2595
+ ca: void 0
2596
+ }, mt = {
2597
+ name: "f",
2598
+ attributes: gt,
2599
+ isSelfClosing: !1
2600
+ }, xt = {
2601
+ name: "v",
2602
+ attributes: {},
2603
+ isSelfClosing: !1
2604
+ }, yt = {
2605
+ r: void 0,
2606
+ s: void 0,
2607
+ ht: void 0,
2608
+ hidden: void 0,
2609
+ collapsed: void 0,
2610
+ customHeight: void 0,
2611
+ customFormat: void 0,
2612
+ outlineLevel: void 0
2613
+ }, bt = {
2614
+ name: "row",
2615
+ attributes: yt,
2616
+ isSelfClosing: !1
2617
+ }, Tt = pe.NEED_MORE, vt = pe.NOT_HANDLED, wt = pe.decodeText;
2618
+ let St = !1;
2619
+ const Ct = (t, e, s, o) => {
2620
+ for (;;) {
2621
+ let r = 0;
2622
+ for (; e < s && (32 === (r = t.charCodeAt(e)) || 9 === r || 10 === r || 13 === r);) e++;
2623
+ if (e >= s) return Tt;
2624
+ if (62 === r) return St = !1, e + 1;
2625
+ if (47 === r) return e + 1 >= s ? Tt : 62 !== t.charCodeAt(e + 1) ? vt : (St = !0, e + 2);
2626
+ const i = e;
2627
+ for (; e < s && 61 !== (r = t.charCodeAt(e));) {
2628
+ if (62 === r || 47 === r || 32 === r || 9 === r || 10 === r || 13 === r) return vt;
2629
+ e++;
2630
+ }
2631
+ if (e + 1 >= s) return Tt;
2632
+ const n = e - i, a = t.charCodeAt(e + 1);
2633
+ if (34 !== a && 39 !== a) return vt;
2634
+ const c = e + 2;
2635
+ let l = c;
2636
+ for (; l < s && (r = t.charCodeAt(l)) !== a;) {
2637
+ if (38 === r || r < 32) return vt;
2638
+ l++;
2639
+ }
2640
+ if (l >= s) return Tt;
2641
+ e = l + 1;
2642
+ const h = t.charCodeAt(i);
2643
+ if (2 === o) switch (n) {
2644
+ case 1:
2645
+ 114 === h ? yt.r = t.slice(c, l) : 115 === h && (yt.s = t.slice(c, l));
2646
+ break;
2647
+ case 2:
2648
+ t.startsWith("ht", i) && (yt.ht = t.slice(c, l));
2649
+ break;
2650
+ case 6:
2651
+ t.startsWith("hidden", i) && (yt.hidden = t.slice(c, l));
2652
+ break;
2653
+ case 9:
2654
+ t.startsWith("collapsed", i) && (yt.collapsed = t.slice(c, l));
2655
+ break;
2656
+ case 12: t.startsWith("customHeight", i) ? yt.customHeight = t.slice(c, l) : t.startsWith("customFormat", i) ? yt.customFormat = t.slice(c, l) : t.startsWith("outlineLevel", i) && (yt.outlineLevel = t.slice(c, l));
2657
+ }
2658
+ else if (0 === o) 1 === n ? 114 === h ? dt.r = t.slice(c, l) : 116 === h ? dt.t = t.slice(c, l) : 115 === h && (dt.s = t.slice(c, l)) : 2 === n && 109 === t.charCodeAt(i + 1) && (99 === h ? dt.cm = t.slice(c, l) : 118 === h && (dt.vm = t.slice(c, l)));
2659
+ else if (1 === n) 116 === h && (gt.t = t.slice(c, l));
2660
+ else if (2 === n) {
2661
+ const e = t.charCodeAt(i + 1);
2662
+ 115 === h && 105 === e ? gt.si = t.slice(c, l) : 99 === h && 97 === e && (gt.ca = t.slice(c, l));
2663
+ } else 3 === n && t.startsWith("ref", i) && (gt.ref = t.slice(c, l));
2664
+ }
2665
+ }, kt = (t, e, s) => 47 === t.charCodeAt(e + 1) && t.charCodeAt(e + 2) === s && 62 === t.charCodeAt(e + 3);
2666
+ return {
2667
+ ...s,
2668
+ onEnd: () => {
2669
+ L.length > 0 && (e.rows = z.runsToRefs(L, !1));
2670
+ let o = T.done(De);
2671
+ const r = o.length;
2672
+ if (r > 0) {
2673
+ const t = new Array(r);
2674
+ for (let e = 0; e < r; e++) {
2675
+ const s = o[e], r = z.rangeToString(s), i = s.value[1];
2676
+ t[e] = [r, z.resolveRelativeToA1(i, s.rowStart, s.colStart)];
2677
+ }
2678
+ e.formulas = t;
2679
+ }
2680
+ const i = O.done(!0), n = i.length;
2681
+ if (n > 0) {
2682
+ const t = new Array(n);
2683
+ for (let e = 0; e < n; e++) {
2684
+ const s = i[e];
2685
+ t[e] = z.rangeToString(s);
2686
+ }
2687
+ e.volatile = t;
2688
+ }
2689
+ w.length > 0 && (e.formulaArray = [...w]);
2690
+ const a = l.length;
2691
+ if (a > 0) {
2692
+ l.sort(q.createRangeComparator(Z.Axis.Column));
2693
+ let t = l[0], s = t.colStart, o = t.colEnd, r = t.rowEnd, i = t.value;
2694
+ const n = [];
2695
+ n.push(t);
2696
+ let c = null;
2697
+ for (let e = 1; e < a; e++) c = l[e], i !== c.value || s !== c.colStart || o !== c.colEnd || r + 1 !== c.rowEnd ? (n.push(c), t = c, s = t.colStart, o = t.colEnd, r = t.rowEnd, i = t.value) : (r = c.rowEnd, t.rowEnd = r);
2698
+ const h = n.length, u = new Array(h);
2699
+ for (let t = 0; t < h; t++) {
2700
+ const e = n[t];
2701
+ u[t] = [z.rangeToString(e), e.value];
2702
+ }
2703
+ e.directStyles = u;
2704
+ }
2705
+ const c = t.build();
2706
+ c && (e.data = c.tuples), s?.onEnd?.();
2707
+ },
2708
+ onOpenTag: ht,
2709
+ onCloseTag: ut,
2710
+ onText: pt,
2711
+ elementScanners: [{
2712
+ name: "c",
2713
+ scan: (t, e, s) => {
2714
+ if (!a || null !== _) return vt;
2715
+ dt.r = dt.t = dt.s = dt.cm = dt.vm = void 0;
2716
+ let o = Ct(t, e + 2, s, 0);
2717
+ if (o < 0) return o;
2718
+ const r = dt.t;
2719
+ if (void 0 === dt.r || "str" === r || "inlineStr" === r) return vt;
2720
+ let i = !1, n = -1, c = -1, l = -1, h = -1, u = o;
2721
+ if (!St) for (gt.t = gt.si = gt.ref = gt.ca = void 0;;) {
2722
+ const e = t.indexOf("<", o);
2723
+ if (-1 === e || e + 3 >= s) return Tt;
2724
+ for (let s = o; s < e; s++) {
2725
+ const e = t.charCodeAt(s);
2726
+ if (32 !== e && 9 !== e && 10 !== e && 13 !== e) return vt;
2727
+ }
2728
+ const r = t.charCodeAt(e + 1), a = t.charCodeAt(e + 2);
2729
+ if (47 === r) {
2730
+ if (!kt(t, e, 99)) return vt;
2731
+ u = e + 4;
2732
+ break;
2733
+ }
2734
+ if (102 === r && !i && -1 === l && (32 === a || 62 === a || 47 === a)) {
2735
+ if (i = !0, o = Ct(t, e + 2, s, 1), o < 0) return o;
2736
+ if (St) continue;
2737
+ const r = t.indexOf("<", o);
2738
+ if (-1 === r || r + 3 >= s) return Tt;
2739
+ if (!kt(t, r, 102)) return vt;
2740
+ n = o, c = r, o = r + 4;
2741
+ continue;
2742
+ }
2743
+ if (118 === r && 62 === a && -1 === l) {
2744
+ const r = t.indexOf("<", e + 3);
2745
+ if (-1 === r || r + 3 >= s) return Tt;
2746
+ if (!kt(t, r, 118)) return vt;
2747
+ l = e + 3, h = r, o = r + 4;
2748
+ continue;
2749
+ }
2750
+ return vt;
2751
+ }
2752
+ return ht(ft), i && (ht(mt), c > n && pt(wt(t.slice(n, c))), ut(mt)), -1 !== l && (ht(xt), h > l && pt(wt(t.slice(l, h))), ut(xt)), ut(ft), u;
2753
+ }
2754
+ }, {
2755
+ name: "row",
2756
+ openTag: bt,
2757
+ scan: (t, e, s) => {
2758
+ if (!nt || a || null !== _) return vt;
2759
+ yt.r = yt.s = yt.ht = yt.hidden = yt.collapsed = yt.customHeight = yt.customFormat = yt.outlineLevel = void 0;
2760
+ const o = Ct(t, e + 4, s, 2);
2761
+ return o < 0 ? o : St || void 0 === yt.r ? vt : (ht(bt), o);
2762
+ }
2763
+ }]
2764
+ };
2765
+ }, Le = (t) => {
2766
+ const e = t.indexOf(":");
2767
+ return -1 === e ? t : t.slice(e + 1);
2768
+ }, Ne = {
2769
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
2770
+ "application/vnd.ms-excel.sheet.macroEnabled.main+xml": "workbooks",
2771
+ "application/vnd.ms-excel.sheet.binary.macroEnabled.main": "workbooks",
2772
+ "application/vnd.ms-excel.addin.macroEnabled.main+xml": "workbooks",
2773
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": "workbooks",
2774
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": "sheets",
2775
+ "application/vnd.ms-excel.worksheet": "sheets",
2776
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "charts",
2777
+ "application/vnd.ms-excel.chartsheet": "charts",
2778
+ "application/vnd.ms-excel.macrosheet+xml": "macros",
2779
+ "application/vnd.ms-excel.macrosheet": "macros",
2780
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "dialogs",
2781
+ "application/vnd.ms-excel.dialogsheet": "dialogs",
2782
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml": "strs",
2783
+ "application/vnd.ms-excel.sharedStrings": "strs",
2784
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": "styles",
2785
+ "application/vnd.ms-excel.styles": "styles",
2786
+ "application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
2787
+ "application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
2788
+ "application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
2789
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
2790
+ "application/vnd.ms-excel.comments": "comments",
2791
+ "application/vnd.ms-excel.threadedcomments+xml": "threadedcomments",
2792
+ "application/vnd.ms-excel.person+xml": "people",
2793
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "metadata",
2794
+ "application/vnd.ms-excel.sheetMetadata": "metadata",
2795
+ "application/vnd.ms-excel.externalLink": "links",
2796
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "links",
2797
+ "application/vnd.openxmlformats-officedocument.theme+xml": "themes"
2798
+ }, $e = (t) => t.startsWith("/") ? t.slice(1) : t, Re = /^xl\/(worksheets|chartsheets)\/[^/]+\.xml$/i, je = (t) => "string" == typeof t ? t : (t?.runs ?? []).map((t) => t.text ?? "").join(""), Me = async (t, a) => {
2799
+ const { password: c, onVBA: u, profile: p, calcOnLoad: f = "auto", createWorkbookOptions: x = {}, ...y } = a ?? {}, v = !!x.origin && "string" != typeof x.origin, k = p ? new ct("function" == typeof p ? p : void 0) : null, A = [], O = (t, e, s) => {
2800
+ A.push([
2801
+ t,
2802
+ e ?? "",
2803
+ s
2804
+ ]);
2805
+ }, P = { onWarning: O }, I = a?.progress, D = I?.onProgress ? I.onProgress.bind(I) : void 0, V = t.byteLength;
2806
+ let L = 0, N = 0;
2807
+ const R = D ? (t) => {
2808
+ if (L <= 0) return;
2809
+ N += t;
2810
+ const e = Math.min(V, Math.round(N / L * V));
2811
+ D(e, V);
2812
+ } : void 0, j = import("./DOXXVsfrZi_6L0V7.mjs");
2813
+ let M = null;
2814
+ try {
2815
+ M = new DOMParser();
2816
+ } catch (t) {}
2817
+ let X = null;
2818
+ try {
2819
+ X = new XMLSerializer();
2820
+ } catch (t) {}
2821
+ let q, U, G, K = null;
2822
+ M || (K = import("@xmldom/xmldom"));
2823
+ try {
2824
+ const [t, e] = await Promise.all([K, j]);
2825
+ q = new e.DOMTransformer(), U = M ?? new t.DOMParser(), G = X ?? new t.XMLSerializer();
2826
+ } catch (t) {
2827
+ throw new Error("Unable to load XLSX parser.", { cause: t });
2828
+ }
2829
+ const Z = (t) => G.serializeToString(t);
2830
+ let tt;
2831
+ try {
2832
+ tt = await at.create(t);
2833
+ } catch (t) {
2834
+ throw new W("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.", { cause: t });
2835
+ }
2836
+ k?.mark("zip-open");
2837
+ try {
2838
+ if (!tt.has("[Content_Types].xml")) throw new W("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
2839
+ const t = (t) => {
2840
+ const e = tt.getEntry(t);
2841
+ return e ? { content: e } : void 0;
2842
+ }, a = {
2843
+ workbooks: [],
2844
+ sheets: [],
2845
+ charts: [],
2846
+ dialogs: [],
2847
+ macros: [],
2848
+ strs: [],
2849
+ comments: [],
2850
+ threadedcomments: [],
2851
+ links: [],
2852
+ coreprops: [],
2853
+ extprops: [],
2854
+ custprops: [],
2855
+ themes: [],
2856
+ styles: [],
2857
+ metadata: [],
2858
+ people: [],
2859
+ overrides: {},
2860
+ sst: "",
2861
+ style: "",
2862
+ defaults: {}
2863
+ };
2864
+ {
2865
+ const t = ((t, e) => ({
2866
+ onOpenTag: (e) => {
2867
+ const s = ((t) => {
2868
+ const e = t.indexOf(":");
2869
+ return -1 === e ? t : t.slice(e + 1);
2870
+ })(e.name), o = e.attributes;
2871
+ if ("Override" === s) {
2872
+ const e = o.ContentType, s = o.PartName;
2873
+ if (!e || !s) return;
2874
+ t.overrides[s.startsWith("/") ? s.slice(1) : s] = e;
2875
+ const r = Ne[e], i = r ? t[r] : void 0;
2876
+ Array.isArray(i) && i.push(s);
2877
+ } else if ("Default" === s) {
2878
+ const e = o.Extension, s = o.ContentType;
2879
+ e && (t.defaults[e.toLowerCase()] = s);
2880
+ }
2881
+ },
2882
+ onEnd: () => {
2883
+ t.sst = t.strs.length > 0 ? t.strs[0] : "", t.style = t.styles.length > 0 ? t.styles[0] : "";
2884
+ },
2885
+ onError: (t) => {
2886
+ e?.(`Error parsing content types: ${t?.message ?? t}`);
2887
+ }
2888
+ }))(a, (t) => {
2889
+ A.push([t, "[Content_Types].xml"]);
2890
+ }), e = await tt.getTextStream("[Content_Types].xml");
2891
+ if (!e) throw new Error("Error parsing content types: '[Content_Types].xml'");
2892
+ try {
2893
+ await ee.parseStream(e, t, { xmlns: !1 });
2894
+ } catch (t) {
2895
+ throw new Error("Error parsing content types: '[Content_Types].xml'", { cause: t });
2896
+ }
2897
+ v && await tt.getBuffer("[Content_Types].xml");
2898
+ }
2899
+ k?.mark("content-types");
2900
+ const c = a.sst, y = /* @__PURE__ */ new Set();
2901
+ for (const t of a.sheets) y.add($e(t));
2902
+ c && y.add($e(c));
2903
+ for (const t of y) L += tt.uncompressedSize(t);
2904
+ if (await tt.prefetch((t) => !y.has(t) && !Re.test(t)), k?.mark("prefetch-side-parts"), 0 === a.workbooks.length) {
2905
+ const e = r("_rels/.rels", t, U, q, P), s = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
2906
+ if (e) {
2907
+ for (const t of e.values()) if (t.type === s && t.target) {
2908
+ a.workbooks.push(t.target);
2909
+ break;
2910
+ }
2911
+ }
2912
+ }
2913
+ if (0 === a.workbooks.length) throw new W("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
2914
+ a.richstructure = ["/xl/richData/rdrichvaluestructure.xml"], a.richdata = ["/xl/richData/rdrichvalue.xml"];
2915
+ const N = x?.resources ?? new Q(), j = N.beginPersist(), M = {}, X = /* @__PURE__ */ new Set(), G = /* @__PURE__ */ new Map();
2916
+ G.set("richTypes", []), G.set("parseInlineDxf", (t) => {
2917
+ if (!t) return;
2918
+ const e = U.parseFromString(`<dxf xmlns:x14="${E}" xmlns:xm="${w}">${t}</dxf>`, "text/xml")?.documentElement;
2919
+ if (!e) return;
2920
+ const s = q.parseDxf(e, "", P);
2921
+ return Object.keys(s).length > 0 ? s : void 0;
2922
+ });
2923
+ const K = [];
2924
+ G.set("dummyWrapped", K);
2925
+ const J = s("metadata", a, t, U, q, P).entries().next()?.value?.[1]?.metadata;
2926
+ J && G.set("metadata", J), G.set(Ee, S());
2927
+ const st = /* @__PURE__ */ new Map(), ot = [], rt = /* @__PURE__ */ new Set(), it = (t) => {
2928
+ rt.add($e(t));
2929
+ }, nt = (e, s = st) => {
2930
+ const o = e.lastIndexOf("/"), i = e.substring(0, o + 1) + "_rels/" + e.substring(o + 1, e.length) + ".rels";
2931
+ let n = s.get(i);
2932
+ return n || (n = r(i, t, U, q, xt), s.set(i, n)), n;
2933
+ }, at = (s, r, i, n = st) => {
2934
+ let a = nt(r, n).get(s), c = a?.target;
2935
+ if (!c) return null;
2936
+ if ("External" === a.targetMode) {
2937
+ if (!i) return a.target;
2938
+ const t = N.add({ source: { external: a.target } });
2939
+ return t.addReference(M), X.add(t), j.toResourceId(t);
2940
+ }
2941
+ const l = r.lastIndexOf("/"), u = r.substring(0, l + 1);
2942
+ c.startsWith("/") || (c = u + c), c = o(c);
2943
+ const p = q?.getVisitorParamsState().get("dxfs");
2944
+ let d = n.get(c);
2945
+ if (!d) {
2946
+ const s = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", o = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink";
2947
+ if (a.type === s) {
2948
+ const t = {};
2949
+ d = t;
2950
+ const e = async () => {
2951
+ const e = Pe(t, (t, e) => "legacyDrawing" === e ? ht(t, c) : "part" === e ? ut(t, c) : at(t, c, "resource" === e) ?? null, wt, p, () => {}, (t, e, s) => {
2952
+ O(t, e ? `${e} (${c})` : c, s);
2953
+ }, void 0, G), s = await tt.getTextStream(c, R);
2954
+ if (s) try {
2955
+ await ee.parseStream(s, e, {
2956
+ xmlns: !1,
2957
+ lean: !0
2958
+ });
2959
+ } catch (t) {
2960
+ throw new Error(`Error parsing sheet: '${c}'`, { cause: t });
2961
+ }
2962
+ const o = nt(c, n);
2963
+ if (o) {
2964
+ lt(t, c, o, n);
2965
+ const e = [];
2966
+ o.forEach((t, s) => {
2967
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" !== t.type) return;
2968
+ const o = ut(s, c, t.type, (t) => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" !== t);
2969
+ if (!o?.xml) return;
2970
+ const r = /<pivotTableDefinition\b[^>]*>/.exec(o.xml)?.[0] ?? "", i = parseInt(/\scacheId="(\d+)"/.exec(r)?.[1] ?? "", 10);
2971
+ if (isNaN(i)) return void A.push([`Pivot table '${o.name}' names no cache and was dropped.`, c]);
2972
+ const n = /\sname="([^"]*)"/.exec(r)?.[1];
2973
+ e.push({
2974
+ ...n ? { name: g(n) } : {},
2975
+ cacheId: i,
2976
+ part: o
2977
+ });
2978
+ }), e.length > 0 && (t.pivotTables = e);
2979
+ }
2980
+ };
2981
+ ot.push(e());
2982
+ } else if (a.type === o) {
2983
+ const s = e(c, t, U, q, xt);
2984
+ if (s && 0 !== Object.keys(s).length) {
2985
+ const t = s, e = t.__bookRelId, o = t.__absoluteUrlRelId;
2986
+ delete t.__bookRelId, delete t.__absoluteUrlRelId;
2987
+ const r = [];
2988
+ nt(c, n)?.forEach((t, s) => {
2989
+ if ("External" === t.targetMode && t.type && t.target) {
2990
+ const i = {
2991
+ type: t.type,
2992
+ target: t.target
2993
+ };
2994
+ s === e ? i.role = "book" : s === o && (i.role = "absoluteUrl"), r.push(i);
2995
+ }
2996
+ }), r.sort((t, e) => ("book" === t.role ? 0 : 1) - ("book" === e.role ? 0 : 1)), t.sources = r, it(c), d = t;
2997
+ } else d = null;
2998
+ } else d = i ? h(c, t, (t, e) => {
2999
+ const s = N.add({ source: { buffer: t } });
3000
+ return s.addReference(M), X.add(s), j.toResourceId(s);
3001
+ }, xt) : e(c, t, U, q, xt);
3002
+ }
3003
+ return d;
3004
+ }, ct = (t, e) => {
3005
+ if (!t) return null;
3006
+ const s = nt(e, st)?.get(t);
3007
+ if (!s?.target || "External" === s.targetMode) return null;
3008
+ let r = s.target;
3009
+ return r.startsWith("/") || (r = e.substring(0, e.lastIndexOf("/") + 1) + r), o(r);
3010
+ }, lt = (t, e, s, o) => {
3011
+ const r = [], n = /* @__PURE__ */ new Map(), a = [];
3012
+ s.forEach((t, s) => {
3013
+ if ("http://schemas.microsoft.com/office/2017/10/relationships/threadedComment" !== t.type) return;
3014
+ const i = at(s, e, !1, o)?.comments;
3015
+ if (!i) return;
3016
+ for (let t = 0; t < i.length; t++) {
3017
+ const e = i[t];
3018
+ if (!e?.v?.id) continue;
3019
+ const { parentId: s, done: o, content: c, ...l } = e.v, h = {
3020
+ ...l,
3021
+ content: je(c)
3022
+ };
3023
+ s ? a.push({
3024
+ parentId: s,
3025
+ json: h
3026
+ }) : (o && (h.done = !0), n.set(h.id, h), r.push({
3027
+ r: e.r,
3028
+ v: h
3029
+ }));
3030
+ }
3031
+ const c = ct(s, e);
3032
+ c && it(c);
3033
+ });
3034
+ for (let t = 0; t < a.length; t++) {
3035
+ const { parentId: e, json: s } = a[t], o = n.get(e);
3036
+ o && (o.replies ??= []).push(s);
3037
+ }
3038
+ const c = [];
3039
+ if (s.forEach((t, s) => {
3040
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" !== t.type) return;
3041
+ const r = at(s, e, !1, o), a = r?.comments;
3042
+ if (!a) return;
3043
+ const l = r?.authors;
3044
+ for (let t = 0; t < a.length; t++) {
3045
+ const e = a[t];
3046
+ if (!e?.r) continue;
3047
+ let s = l && void 0 !== e.v.authorId ? l[e.v.authorId] : void 0;
3048
+ if (s && s.startsWith("tc=")) {
3049
+ if (n.has(i(s.substring(3)))) continue;
3050
+ s = void 0;
3051
+ }
3052
+ const o = {
3053
+ id: F.uuidV4().toUpperCase(),
3054
+ asNote: !0,
3055
+ content: e.v.content ?? ""
3056
+ }, r = s ? mt({ displayName: s }) : void 0;
3057
+ r && (o.personId = r.id), c.push({
3058
+ r: e.r,
3059
+ v: o
3060
+ });
3061
+ }
3062
+ const h = ct(s, e);
3063
+ h && it(h);
3064
+ }), 0 === r.length && 0 === c.length) return;
3065
+ const l = [...r, ...c], h = t.legacyDrawing;
3066
+ if (h?.xml) {
3067
+ const { rest: e, notes: s } = $(h.xml);
3068
+ if (s.length > 0) {
3069
+ const o = /* @__PURE__ */ new Map();
3070
+ for (let t = 0; t < s.length; t++) {
3071
+ const e = s[t];
3072
+ o.set(z.cellToString({
3073
+ rowIndex: e.row,
3074
+ colIndex: e.col
3075
+ }), e);
3076
+ }
3077
+ for (let t = 0; t < l.length; t++) {
3078
+ const e = l[t], s = o.get(String(e.r).toUpperCase());
3079
+ s && (e.v.box = { xml: s.xml }, o.delete(String(e.r).toUpperCase()));
3080
+ }
3081
+ const r = [];
3082
+ o.forEach((t) => {
3083
+ r.push(t.xml);
3084
+ });
3085
+ const i = _(e, r);
3086
+ i ? h.xml = i : delete t.legacyDrawing;
3087
+ }
3088
+ }
3089
+ t.comments = l;
3090
+ }, ht = (e, s) => {
3091
+ const o = ct(e, s);
3092
+ if (!o) return null;
3093
+ const r = t($e(o));
3094
+ if (!r) return null;
3095
+ const i = { xml: new TextDecoder("utf-8").decode(r.content) }, n = [];
3096
+ return nt(o, st)?.forEach((t, e) => {
3097
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" !== t.type) return;
3098
+ const s = at(e, o, !0);
3099
+ "number" == typeof s && n.push({
3100
+ id: e,
3101
+ resId: s
3102
+ });
3103
+ }), n.length > 0 && (i.images = n), it(o), i;
3104
+ }, ut = (e, s, o, r, i = /* @__PURE__ */ new Set()) => {
3105
+ const n = ct(e, s);
3106
+ if (!n || i.has(n)) return null;
3107
+ const c = o ?? nt(s, st)?.get(e)?.type;
3108
+ if (!c) return null;
3109
+ const l = t($e(n));
3110
+ if (!l) return null;
3111
+ i.add(n);
3112
+ const h = n.substring(n.lastIndexOf("/") + 1), u = a.overrides[$e(n)] ?? a.defaults[h.substring(h.lastIndexOf(".") + 1).toLowerCase()], p = {
3113
+ id: e,
3114
+ type: c,
3115
+ name: h
3116
+ };
3117
+ if (u && (p.contentType = u), ((t, e) => t ? t.endsWith("+xml") || "application/xml" === t : /\.(xml|rels|vml)$/i.test(e))(u, h)) p.xml = new TextDecoder("utf-8").decode(l.content);
3118
+ else {
3119
+ const t = at(e, s, !0);
3120
+ if ("number" != typeof t) return null;
3121
+ p.resId = t;
3122
+ }
3123
+ const d = [];
3124
+ return nt(n, st)?.forEach((t, e) => {
3125
+ if (!t?.type) return;
3126
+ if (r && !r(t.type)) return;
3127
+ if ("External" === t.targetMode) {
3128
+ const s = at(e, n, !0);
3129
+ "number" == typeof s && d.push({
3130
+ id: e,
3131
+ type: t.type,
3132
+ resId: s
3133
+ });
3134
+ return;
3135
+ }
3136
+ const s = ut(e, n, t.type, r, i);
3137
+ s && d.push(s);
3138
+ }), d.length > 0 && (p.parts = d), it(n), p;
3139
+ };
3140
+ s("coreprops", a, t, U, q, P), s("extprops", a, t, U, q, P);
3141
+ const pt = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Map(), ft = s("people", a, t, U, q, P);
3142
+ let gt = null;
3143
+ if (ft.size > 0) {
3144
+ const [t, e] = ft.entries().next().value;
3145
+ if (gt = e?.persons, it(t), gt) {
3146
+ const t = gt.length;
3147
+ for (let e = 0; e < t; e++) {
3148
+ const t = gt[e];
3149
+ pt.set(t.id, t), void 0 !== t.displayName && dt.set(t.displayName, t);
3150
+ }
3151
+ }
3152
+ }
3153
+ const mt = (t) => {
3154
+ if (!t) return;
3155
+ if (t.id && pt.has(t.id)) return pt.get(t.id);
3156
+ let e = t.displayName;
3157
+ if (!t.id) {
3158
+ if (e) {
3159
+ const t = dt.get(e);
3160
+ if (t) return t;
3161
+ }
3162
+ t.id = F.uuidV4();
3163
+ }
3164
+ const s = pt.get(t.id);
3165
+ if (s) return s;
3166
+ const o = t;
3167
+ return pt.set(t.id, o), e && dt.set(e, o), gt || (gt = []), gt.push(o), o;
3168
+ }, xt = {
3169
+ paramMap: G,
3170
+ getRefs: nt,
3171
+ getRef: at,
3172
+ parsedRefs: st,
3173
+ readEmbeddedPart: (t, e) => ut(t, e),
3174
+ addPerson: mt,
3175
+ serializeElement: Z,
3176
+ onWarning: O
3177
+ }, yt = [];
3178
+ if (c) {
3179
+ const t = await tt.getTextStream(c, R);
3180
+ if (t) {
3181
+ const e = ((t, e) => {
3182
+ let s = !1, o = !1, r = 0, i = "";
3183
+ return {
3184
+ onOpenTag: (t) => {
3185
+ const e = Le(t.name);
3186
+ "t" === e ? s && 0 === r && (o = !0) : "si" === e ? (s = !0, i = "", r = 0) : "rPh" !== e && "phoneticPr" !== e || r++;
3187
+ },
3188
+ onText: (t) => {
3189
+ o && (i += t);
3190
+ },
3191
+ onCloseTag: (e) => {
3192
+ const n = Le(e.name);
3193
+ "t" === n ? o = !1 : "si" === n ? (t(C(i)), s = !1, i = "") : "rPh" !== n && "phoneticPr" !== n || r > 0 && r--;
3194
+ },
3195
+ onError: (t) => {
3196
+ e?.(`Error parsing shared strings: ${t?.message ?? t}`);
3197
+ }
3198
+ };
3199
+ })((t) => {
3200
+ yt.push(t);
3201
+ }, (t) => {
3202
+ O(t, c);
3203
+ });
3204
+ try {
3205
+ await ee.parseStream(t, e, { xmlns: !1 });
3206
+ } catch (t) {
3207
+ throw new Error(`Error parsing shared strings: '${c}'`, { cause: t });
3208
+ }
3209
+ }
3210
+ }
3211
+ k?.mark("shared-strings");
3212
+ let bt = yt.length;
3213
+ const Tt = /* @__PURE__ */ new Map();
3214
+ let vt = bt;
3215
+ const wt = (t) => {
3216
+ const e = Tt.get(t);
3217
+ if (void 0 !== e) return e;
3218
+ const s = vt;
3219
+ return Tt.set(t, vt++), yt.push(t), s;
3220
+ }, St = [];
3221
+ a.slicersCache = St;
3222
+ const Ct = tt.getNames(), kt = Ct.length;
3223
+ for (let t = 0; t < kt; t++) {
3224
+ const e = Ct[t];
3225
+ e && e.startsWith("xl/slicerCache") && St.push(`/${e}`);
3226
+ }
3227
+ const At = s("slicersCache", a, t, U, q, xt), Ot = /* @__PURE__ */ new Map();
3228
+ At.forEach((t) => {
3229
+ const e = t.name;
3230
+ delete t.name, Ot.set(e, t);
3231
+ }), G.set("slicerCaches", Ot), s("richstructure", a, t, U, q, xt), s("richdata", a, t, U, q, xt);
3232
+ const Et = s("themes", a, t, U, q, xt);
3233
+ let Pt = null;
3234
+ if (Et && Et.entries) {
3235
+ let t = Et.entries().next();
3236
+ t?.value?.[1] && (Pt = t.value[1]);
3237
+ }
3238
+ const It = new Y(Pt);
3239
+ let Dt = s("styles", a, t, U, q, xt).entries().next()?.value?.[1];
3240
+ Dt && (Dt = JSON.parse(H.JSONStableStringify(Dt)));
3241
+ const _t = s("workbooks", a, t, U, q, xt);
3242
+ k?.mark("side-parts-json"), await Promise.all(ot);
3243
+ {
3244
+ const t = _t.entries().next().value?.[1], e = S(t?.names), s = t?.sheets ?? [];
3245
+ for (let t = 0; t < s.length; t++) {
3246
+ const o = s[t]?.sheet;
3247
+ o && B(o, e);
3248
+ }
3249
+ const o = t?.names;
3250
+ if (o) for (let t = 0; t < o.length; t++) {
3251
+ const s = o[t]?.ref;
3252
+ "string" == typeof s && (o[t].ref = e.readDetached(s));
3253
+ }
3254
+ }
3255
+ D && L > 0 && (D(V, V), await new Promise((t) => setTimeout(t, 0))), k?.mark("sheets");
3256
+ const Vt = {
3257
+ ..._t.entries().next().value?.[1],
3258
+ styles: Dt,
3259
+ theme: It.toJSON()
3260
+ };
3261
+ n(Vt, G.get(l)), Vt.calc = {
3262
+ ...Vt.calc ?? {},
3263
+ legacyIntersect: !0
3264
+ }, yt.length > 0 && (Vt.strings = yt), gt && gt.length > 0 && (Vt.people = gt);
3265
+ const Lt = tt.getEntry("xl/vbaProject.bin");
3266
+ if (Lt) try {
3267
+ const { VBAProject: t } = await import("./CsTuNxyS02vBz0Tk.mjs"), e = t.extract(Lt);
3268
+ if (e) {
3269
+ const s = /* @__PURE__ */ new Map();
3270
+ for (const t of Vt.sheets ?? []) {
3271
+ const e = t?.sheet?.codeName;
3272
+ e && s.set(e, t.sheet);
3273
+ }
3274
+ for (const o of e.modules) {
3275
+ const e = { language: "vba" }, { header: r, body: i } = t.splitAttributes(o.code);
3276
+ i && (e.source = i), r && (e.sourceHeader = r);
3277
+ const n = "document" === o.type ? s.get(o.name) : void 0;
3278
+ n || "document" !== o.type || (e.scope = "workbook");
3279
+ const a = n ? n.modules ??= {} : Vt.modules ??= {};
3280
+ a[o.name] || (a[o.name] = e);
3281
+ }
3282
+ u?.(e);
3283
+ } else A.push(["Unable to parse VBA project.", "xl/vbaProject.bin"]);
3284
+ } catch (t) {
3285
+ A.push([`Error extracting VBA: ${t?.message ?? t}`, "xl/vbaProject.bin"]);
3286
+ }
3287
+ const Nt = G.get("calcId"), $t = void 0 === Nt || !(Number(Nt) >= 191029), Rt = x.calcOnLoad ?? ("auto" === f && $t ? "full" : f), jt = {
3288
+ ...x,
3289
+ calcOnLoad: Rt,
3290
+ resources: N,
3291
+ json: Vt
3292
+ };
3293
+ void 0 === jt.disableLoadAutoFit && (jt.disableLoadAutoFit = !1), k?.mark("json-assembled");
3294
+ const Mt = new et(jt);
3295
+ if (k?.mark("workbook-constructed"), K.length > 0 && "none" !== Rt) {
3296
+ await Mt.whenCalculationReady();
3297
+ const t = /* @__PURE__ */ new Map(), e = Vt.sheets ?? [], s = Mt.getSheets().getItems();
3298
+ for (let o = 0; o < e.length; o++) {
3299
+ const r = e[o]?.sheet, i = s[o];
3300
+ r && i && t.set(r, i);
3301
+ }
3302
+ ((t, e, s) => {
3303
+ if (0 === e.length) return;
3304
+ const o = t.getCalculation().getFunctions(), r = /* @__PURE__ */ new Map(), i = (t) => {
3305
+ let e = r.get(t);
3306
+ return void 0 === e && (e = null !== o.getByName(t), r.set(t, e)), e;
3307
+ }, n = /* @__PURE__ */ new Map();
3308
+ for (const t of e) {
3309
+ let e = n.get(t.sheet);
3310
+ e || (e = [], n.set(t.sheet, e)), e.push(t);
3311
+ }
3312
+ for (const [t, e] of n) {
3313
+ const o = s.get(t);
3314
+ if (!o) continue;
3315
+ const r = (t, e) => `${t},${e}`, n = /* @__PURE__ */ new Set();
3316
+ for (const t of e) null === t.formula && n.add(r(t.rowIndex, t.colIndex));
3317
+ for (const t of e) {
3318
+ if (null === t.formula) continue;
3319
+ const e = Ae(t.formula);
3320
+ let s = !0;
3321
+ for (const t of e) if (!i(t)) {
3322
+ s = !1;
3323
+ break;
3324
+ }
3325
+ if (!s) continue;
3326
+ const a = [], c = [[t.rowIndex, t.colIndex]], l = /* @__PURE__ */ new Set([r(t.rowIndex, t.colIndex)]);
3327
+ for (; c.length > 0;) {
3328
+ const [t, e] = c.pop(), s = [
3329
+ [t + 1, e],
3330
+ [t - 1, e],
3331
+ [t, e + 1],
3332
+ [t, e - 1]
3333
+ ];
3334
+ for (const [t, e] of s) {
3335
+ const s = r(t, e);
3336
+ !l.has(s) && n.has(s) && (l.add(s), a.push([t, e]), c.push([t, e]));
3337
+ }
3338
+ }
3339
+ for (const [t, e] of a) n.delete(r(t, e)), o.getRange({
3340
+ rowStart: t,
3341
+ colStart: e,
3342
+ rowEnd: t,
3343
+ colEnd: e
3344
+ }).clear();
3345
+ o.getRange({
3346
+ rowStart: t.rowIndex,
3347
+ colStart: t.colIndex,
3348
+ rowEnd: t.rowIndex,
3349
+ colEnd: t.colIndex
3350
+ }).setValue("=" + t.formula);
3351
+ }
3352
+ }
3353
+ })(Mt, K, t);
3354
+ }
3355
+ if (X.forEach((t) => {
3356
+ t.deleteReference(M);
3357
+ }), j.endPersist(), v) {
3358
+ d(Mt);
3359
+ const t = /* @__PURE__ */ new Map();
3360
+ let e = 0;
3361
+ for (const s of tt.getNames()) {
3362
+ const o = tt.getEntry(s);
3363
+ if (!o) continue;
3364
+ const r = tt.getRawEntry(s), i = r ? {
3365
+ data: o,
3366
+ uncompressedSize: tt.uncompressedSize(s),
3367
+ raw: {
3368
+ compressedData: r.data,
3369
+ compressionMethod: r.compressionMethod,
3370
+ signature: r.signature
3371
+ }
3372
+ } : {
3373
+ data: o,
3374
+ uncompressedSize: tt.uncompressedSize(s)
3375
+ };
3376
+ t.set(s, i), e += o.byteLength;
3377
+ }
3378
+ if (e > 67108864) A.push([`Source package too large to retain (${e} bytes, limit ${b}); unmodeled parts will be dropped on save.`, "SourcePackage"]);
3379
+ else if (t.size > 0) {
3380
+ const e = new T(t, rt);
3381
+ m(Mt, e);
3382
+ let s = Mt.getSheets().getItems();
3383
+ const o = Mt.getTransactions().addListener({ onCommitEnd: (t) => {
3384
+ const s = t.getOperation()?.name;
3385
+ "insertCells" !== s && "deleteCells" !== s || e.markStructuralChange();
3386
+ } }), r = Mt.addListeners({ onSheetsChange: () => {
3387
+ const t = Mt.getSheets().getItems();
3388
+ (t.length !== s.length || t.some((t, e) => t !== s[e])) && e.markStructuralChange(), s = t;
3389
+ } });
3390
+ Mt.addListeners({ onClose: () => {
3391
+ o(), r(), d(Mt);
3392
+ } });
3393
+ }
3394
+ }
3395
+ if (A.length && I?.onWarning) {
3396
+ const t = /* @__PURE__ */ new Set();
3397
+ for (const e of A) {
3398
+ const [s, o, r] = e, i = r ?? s;
3399
+ t.has(i) || (t.add(i), I.onWarning(s, o));
3400
+ }
3401
+ }
3402
+ return k && !0 === p && console.table(k.toTable()), Mt;
3403
+ } catch (t) {
3404
+ let e = "Unable to parse XLSX.";
3405
+ throw t instanceof J && (e = "Unable to open XLSX. There are too many rows or columns."), new Error(e, { cause: t });
3406
+ } finally {
3407
+ await tt.close().catch(() => {});
3408
+ }
3409
+ };
3410
+ export { Me as readXLSX };