@sheetxl/io-xlsx 0.8.0-beta.9 → 1.0.2

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