@sheetxl/io-xlsx 0.8.0-beta.10 → 0.8.0-beta.12

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