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

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