@loaders.gl/scientific 5.0.0-beta.1 → 5.0.0-beta.11

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 (173) hide show
  1. package/README.md +11 -4
  2. package/dist/hdf5/http-range-reader.d.ts.map +1 -1
  3. package/dist/hdf5/http-range-reader.js +2 -12
  4. package/dist/hdf5/http-range-reader.js.map +1 -1
  5. package/dist/hdf5/index.cjs +2 -11
  6. package/dist/hdf5/index.cjs.map +2 -2
  7. package/dist/index.cjs +136 -4152
  8. package/dist/index.cjs.map +4 -3
  9. package/dist/index.d.ts +14 -7
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +7 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/parsers/parse-npy.d.ts +15 -0
  14. package/dist/lib/parsers/parse-npy.d.ts.map +1 -0
  15. package/dist/lib/parsers/parse-npy.js +81 -0
  16. package/dist/lib/parsers/parse-npy.js.map +1 -0
  17. package/dist/netcdf/bundled.cjs +47 -46
  18. package/dist/netcdf/index.cjs +47 -46
  19. package/dist/netcdf/index.cjs.map +3 -3
  20. package/dist/netcdf/index.d.ts +2 -1
  21. package/dist/netcdf/index.d.ts.map +1 -1
  22. package/dist/netcdf/index.js +2 -1
  23. package/dist/netcdf/index.js.map +1 -1
  24. package/dist/netcdf/netcdf-loader-with-parser.cjs +396 -2
  25. package/dist/netcdf/netcdf-loader-with-parser.d.ts +10 -0
  26. package/dist/netcdf/netcdf-loader-with-parser.d.ts.map +1 -1
  27. package/dist/netcdf/netcdf-loader-with-parser.js +3 -1
  28. package/dist/netcdf/netcdf-loader-with-parser.js.map +1 -1
  29. package/dist/netcdf/netcdf-loader.cjs +12 -9
  30. package/dist/netcdf/netcdf-loader.cjs.map +7 -0
  31. package/dist/netcdf/netcdf-loader.d.ts +10 -21
  32. package/dist/netcdf/netcdf-loader.d.ts.map +1 -1
  33. package/dist/netcdf/netcdf-loader.js +6 -3
  34. package/dist/netcdf/netcdf-loader.js.map +1 -1
  35. package/dist/netcdf/netcdf-source-loader.cjs +17 -31
  36. package/dist/netcdf/netcdf-source-loader.d.ts +2 -20
  37. package/dist/netcdf/netcdf-source-loader.d.ts.map +1 -1
  38. package/dist/netcdf/netcdf-source-loader.js +22 -20
  39. package/dist/netcdf/netcdf-source-loader.js.map +1 -1
  40. package/dist/netcdf/unbundled.cjs +47 -46
  41. package/dist/netcdf.dev.js +3097 -2654
  42. package/dist/netcdf.min.js +4 -4
  43. package/dist/npy-format.d.ts +12 -0
  44. package/dist/npy-format.d.ts.map +1 -0
  45. package/dist/npy-format.js +15 -0
  46. package/dist/npy-format.js.map +1 -0
  47. package/dist/{netcdf/netcdf-source-loader-types.cjs → npy-loader-types.cjs} +34 -35
  48. package/dist/npy-loader-types.cjs.map +7 -0
  49. package/dist/npy-loader-types.d.ts +53 -0
  50. package/dist/npy-loader-types.d.ts.map +1 -0
  51. package/dist/npy-loader-types.js +32 -0
  52. package/dist/npy-loader-types.js.map +1 -0
  53. package/dist/npy-loader.cjs +273 -0
  54. package/dist/npy-loader.cjs.map +6 -0
  55. package/dist/npy-loader.d.ts +27 -0
  56. package/dist/npy-loader.d.ts.map +1 -0
  57. package/dist/npy-loader.js +15 -0
  58. package/dist/npy-loader.js.map +1 -0
  59. package/dist/npy-worker.d.ts +2 -0
  60. package/dist/npy-worker.d.ts.map +1 -0
  61. package/dist/npy-worker.js +1285 -0
  62. package/dist/npy-worker.js.map +1 -0
  63. package/dist/nrrd/parse-nrrd.d.ts +22 -0
  64. package/dist/nrrd/parse-nrrd.d.ts.map +1 -0
  65. package/dist/nrrd/parse-nrrd.js +228 -0
  66. package/dist/nrrd/parse-nrrd.js.map +1 -0
  67. package/dist/nrrd-loader-types.cjs +58 -0
  68. package/dist/nrrd-loader-types.cjs.map +7 -0
  69. package/dist/nrrd-loader-types.d.ts +31 -0
  70. package/dist/nrrd-loader-types.d.ts.map +1 -0
  71. package/dist/nrrd-loader-types.js +25 -0
  72. package/dist/nrrd-loader-types.js.map +1 -0
  73. package/dist/nrrd-loader.cjs +252 -0
  74. package/dist/nrrd-loader.cjs.map +6 -0
  75. package/dist/nrrd-loader.d.ts +16 -0
  76. package/dist/nrrd-loader.d.ts.map +1 -0
  77. package/dist/nrrd-loader.js +8 -0
  78. package/dist/nrrd-loader.js.map +1 -0
  79. package/dist/vtk/index.cjs +26 -4117
  80. package/dist/vtk/index.cjs.map +3 -3
  81. package/dist/vtk/vtk-xml.js +4 -4
  82. package/dist/vtk/vtk-xml.js.map +1 -1
  83. package/dist/vtk/vtk.d.ts.map +1 -1
  84. package/dist/vtk/vtk.js +19 -1
  85. package/dist/vtk/vtk.js.map +1 -1
  86. package/dist/vtk-loader-types.cjs +58 -0
  87. package/dist/vtk-loader-types.cjs.map +7 -0
  88. package/dist/vtk-loader-types.d.ts +34 -0
  89. package/dist/vtk-loader-types.d.ts.map +1 -0
  90. package/dist/vtk-loader-types.js +25 -0
  91. package/dist/vtk-loader-types.js.map +1 -0
  92. package/dist/vtk-loader.cjs +384 -0
  93. package/dist/vtk-loader.cjs.map +6 -0
  94. package/dist/vtk-loader.d.ts +21 -0
  95. package/dist/vtk-loader.d.ts.map +1 -0
  96. package/dist/vtk-loader.js +21 -0
  97. package/dist/vtk-loader.js.map +1 -0
  98. package/dist/workers/npy-worker.d.ts +2 -0
  99. package/dist/workers/npy-worker.d.ts.map +1 -0
  100. package/dist/workers/npy-worker.js +7 -0
  101. package/dist/workers/npy-worker.js.map +1 -0
  102. package/dist/zarr/{geo-zarr-source-loader.d.ts → geo-zarr-loader.d.ts} +9 -9
  103. package/dist/zarr/geo-zarr-loader.d.ts.map +1 -0
  104. package/dist/zarr/{geo-zarr-source-loader.js → geo-zarr-loader.js} +167 -48
  105. package/dist/zarr/geo-zarr-loader.js.map +1 -0
  106. package/dist/zarr/index.cjs +221 -70
  107. package/dist/zarr/index.cjs.map +3 -3
  108. package/dist/zarr/index.d.ts +8 -8
  109. package/dist/zarr/index.d.ts.map +1 -1
  110. package/dist/zarr/index.js +4 -4
  111. package/dist/zarr/index.js.map +1 -1
  112. package/dist/zarr/lib/spatial-multiscales.d.ts +13 -2
  113. package/dist/zarr/lib/spatial-multiscales.d.ts.map +1 -1
  114. package/dist/zarr/lib/spatial-multiscales.js +94 -8
  115. package/dist/zarr/lib/spatial-multiscales.js.map +1 -1
  116. package/dist/zarr/{ome-zarr-source-loader.d.ts → ome-zarr-loader.d.ts} +9 -9
  117. package/dist/zarr/ome-zarr-loader.d.ts.map +1 -0
  118. package/dist/zarr/{ome-zarr-source-loader.js → ome-zarr-loader.js} +5 -5
  119. package/dist/zarr/ome-zarr-loader.js.map +1 -0
  120. package/dist/zarr/{spatial-data-source.d.ts → spatial-data-loader.d.ts} +11 -11
  121. package/dist/zarr/spatial-data-loader.d.ts.map +1 -0
  122. package/dist/zarr/{spatial-data-source.js → spatial-data-loader.js} +7 -7
  123. package/dist/zarr/spatial-data-loader.js.map +1 -0
  124. package/dist/zarr/{zarr-array-source.d.ts → zarr-array-loader.d.ts} +9 -9
  125. package/dist/zarr/{zarr-array-source.d.ts.map → zarr-array-loader.d.ts.map} +1 -1
  126. package/dist/zarr/{zarr-array-source.js → zarr-array-loader.js} +5 -5
  127. package/dist/zarr/{zarr-array-source.js.map → zarr-array-loader.js.map} +1 -1
  128. package/dist/zarr/zarr-loader-types.cjs +161 -0
  129. package/dist/zarr/zarr-loader-types.cjs.map +7 -0
  130. package/dist/zarr/zarr-loader-types.d.ts +32 -32
  131. package/dist/zarr/zarr-loader-types.d.ts.map +1 -1
  132. package/dist/zarr/zarr-loader-types.js +24 -24
  133. package/dist/zarr/zarr-loader-types.js.map +1 -1
  134. package/dist/zarr.dev.js +296 -80
  135. package/dist/zarr.min.js +40 -40
  136. package/package.json +54 -7
  137. package/src/hdf5/http-range-reader.ts +3 -11
  138. package/src/index.ts +27 -16
  139. package/src/lib/parsers/parse-npy.ts +123 -0
  140. package/src/netcdf/index.ts +2 -5
  141. package/src/netcdf/netcdf-loader-with-parser.ts +3 -1
  142. package/src/netcdf/netcdf-loader.ts +5 -3
  143. package/src/netcdf/netcdf-source-loader.ts +32 -24
  144. package/src/npy-format.ts +17 -0
  145. package/src/npy-loader-types.ts +47 -0
  146. package/src/npy-loader.ts +21 -0
  147. package/src/npy-worker.ts +6 -0
  148. package/src/nrrd/parse-nrrd.ts +267 -0
  149. package/src/nrrd-loader-types.ts +25 -0
  150. package/src/nrrd-loader.ts +7 -0
  151. package/src/vtk/vtk-xml.ts +4 -4
  152. package/src/vtk/vtk.ts +28 -1
  153. package/src/vtk-loader-types.ts +25 -0
  154. package/src/vtk-loader.ts +19 -0
  155. package/src/workers/npy-worker.ts +8 -0
  156. package/src/zarr/{geo-zarr-source-loader.ts → geo-zarr-loader.ts} +206 -55
  157. package/src/zarr/index.ts +17 -17
  158. package/src/zarr/lib/spatial-multiscales.ts +104 -8
  159. package/src/zarr/{ome-zarr-source-loader.ts → ome-zarr-loader.ts} +11 -11
  160. package/src/zarr/{spatial-data-source.ts → spatial-data-loader.ts} +16 -16
  161. package/src/zarr/{zarr-array-source.ts → zarr-array-loader.ts} +10 -10
  162. package/src/zarr/zarr-loader-types.ts +35 -35
  163. package/dist/netcdf/netcdf-source-loader-types.d.ts +0 -28
  164. package/dist/netcdf/netcdf-source-loader-types.d.ts.map +0 -1
  165. package/dist/netcdf/netcdf-source-loader-types.js +0 -32
  166. package/dist/netcdf/netcdf-source-loader-types.js.map +0 -1
  167. package/dist/zarr/geo-zarr-source-loader.d.ts.map +0 -1
  168. package/dist/zarr/geo-zarr-source-loader.js.map +0 -1
  169. package/dist/zarr/ome-zarr-source-loader.d.ts.map +0 -1
  170. package/dist/zarr/ome-zarr-source-loader.js.map +0 -1
  171. package/dist/zarr/spatial-data-source.d.ts.map +0 -1
  172. package/dist/zarr/spatial-data-source.js.map +0 -1
  173. package/src/netcdf/netcdf-source-loader-types.ts +0 -45
@@ -50,6 +50,7 @@ function numbers(tokens, index, count) {
50
50
  const value = Number(tokens[index + i]);
51
51
  requireVTK(Number.isFinite(value), "invalid numeric value");
52
52
  data[i] = value;
53
+ requireVTK(Number.isFinite(data[i]), "float32 overflow");
53
54
  }
54
55
  return [data, index + count];
55
56
  }
@@ -96,13 +97,13 @@ function parseVTKLegacy(input) {
96
97
  } else if (keyword === "ORIGIN") result.origin = triple;
97
98
  else result.spacing = triple;
98
99
  } else if (keyword === "VERTICES" || keyword === "LINES" || keyword === "POLYGONS" || keyword === "TRIANGLE_STRIPS" || keyword === "CELLS") {
99
- const cellCount = Number(tokens[i++]), size = Number(tokens[i++]);
100
+ const cellCount2 = Number(tokens[i++]), size = Number(tokens[i++]);
100
101
  const [packed, next] = numbers(tokens, i, size);
101
102
  i = next;
102
- const offsets = new Uint32Array(cellCount + 1);
103
+ const offsets = new Uint32Array(cellCount2 + 1);
103
104
  const connectivity = [];
104
105
  let cursor = 0;
105
- for (let cell = 0; cell < cellCount; cell++) {
106
+ for (let cell = 0; cell < cellCount2; cell++) {
106
107
  requireVTK(cursor < packed.length, "truncated cell");
107
108
  const length = packed[cursor++];
108
109
  requireVTK(
@@ -161,4125 +162,33 @@ function parseVTKLegacy(input) {
161
162
  throw new Error("VTK: unsupported keyword " + keyword);
162
163
  }
163
164
  }
164
- return result;
165
- }
166
-
167
- // ../../node_modules/fast-xml-parser/src/util.js
168
- var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
169
- var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
170
- var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
171
- var regexName = new RegExp("^" + nameRegexp + "$");
172
- function getAllMatches(string, regex) {
173
- const matches = [];
174
- let match = regex.exec(string);
175
- while (match) {
176
- const allmatches = [];
177
- allmatches.startIndex = regex.lastIndex - match[0].length;
178
- const len = match.length;
179
- for (let index = 0; index < len; index++) {
180
- allmatches.push(match[index]);
181
- }
182
- matches.push(allmatches);
183
- match = regex.exec(string);
184
- }
185
- return matches;
186
- }
187
- var isName = function(string) {
188
- const match = regexName.exec(string);
189
- return !(match === null || typeof match === "undefined");
190
- };
191
- function isExist(v) {
192
- return typeof v !== "undefined";
193
- }
194
- var DANGEROUS_PROPERTY_NAMES = [
195
- // '__proto__',
196
- // 'constructor',
197
- // 'prototype',
198
- "hasOwnProperty",
199
- "toString",
200
- "valueOf",
201
- "__defineGetter__",
202
- "__defineSetter__",
203
- "__lookupGetter__",
204
- "__lookupSetter__"
205
- ];
206
- var criticalProperties = ["__proto__", "constructor", "prototype"];
207
-
208
- // ../../node_modules/fast-xml-parser/src/validator.js
209
- var defaultOptions = {
210
- allowBooleanAttributes: false,
211
- //A tag can have attributes without any value
212
- unpairedTags: []
213
- };
214
- function validate(xmlData, options) {
215
- options = Object.assign({}, defaultOptions, options);
216
- const tags = [];
217
- let tagFound = false;
218
- let reachedRoot = false;
219
- if (xmlData[0] === "\uFEFF") {
220
- xmlData = xmlData.substr(1);
221
- }
222
- for (let i = 0; i < xmlData.length; i++) {
223
- if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
224
- i += 2;
225
- i = readPI(xmlData, i);
226
- if (i.err) return i;
227
- } else if (xmlData[i] === "<") {
228
- let tagStartPos = i;
229
- i++;
230
- if (xmlData[i] === "!") {
231
- i = readCommentAndCDATA(xmlData, i);
232
- continue;
233
- } else {
234
- let closingTag = false;
235
- if (xmlData[i] === "/") {
236
- closingTag = true;
237
- i++;
238
- }
239
- let tagName = "";
240
- for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
241
- tagName += xmlData[i];
242
- }
243
- tagName = tagName.trim();
244
- if (tagName[tagName.length - 1] === "/") {
245
- tagName = tagName.substring(0, tagName.length - 1);
246
- i--;
247
- }
248
- if (!validateTagName(tagName)) {
249
- let msg;
250
- if (tagName.trim().length === 0) {
251
- msg = "Invalid space after '<'.";
252
- } else {
253
- msg = "Tag '" + tagName + "' is an invalid name.";
254
- }
255
- return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
256
- }
257
- const result = readAttributeStr(xmlData, i);
258
- if (result === false) {
259
- return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
260
- }
261
- let attrStr = result.value;
262
- i = result.index;
263
- if (attrStr[attrStr.length - 1] === "/") {
264
- const attrStrStart = i - attrStr.length;
265
- attrStr = attrStr.substring(0, attrStr.length - 1);
266
- const isValid = validateAttributeString(attrStr, options);
267
- if (isValid === true) {
268
- tagFound = true;
269
- } else {
270
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
271
- }
272
- } else if (closingTag) {
273
- if (!result.tagClosed) {
274
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
275
- } else if (attrStr.trim().length > 0) {
276
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
277
- } else if (tags.length === 0) {
278
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
279
- } else {
280
- const otg = tags.pop();
281
- if (tagName !== otg.tagName) {
282
- let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
283
- return getErrorObject(
284
- "InvalidTag",
285
- "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
286
- getLineNumberForPosition(xmlData, tagStartPos)
287
- );
288
- }
289
- if (tags.length == 0) {
290
- reachedRoot = true;
291
- }
292
- }
293
- } else {
294
- const isValid = validateAttributeString(attrStr, options);
295
- if (isValid !== true) {
296
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
297
- }
298
- if (reachedRoot === true) {
299
- return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
300
- } else if (options.unpairedTags.indexOf(tagName) !== -1) {
301
- } else {
302
- tags.push({ tagName, tagStartPos });
303
- }
304
- tagFound = true;
305
- }
306
- for (i++; i < xmlData.length; i++) {
307
- if (xmlData[i] === "<") {
308
- if (xmlData[i + 1] === "!") {
309
- i++;
310
- i = readCommentAndCDATA(xmlData, i);
311
- continue;
312
- } else if (xmlData[i + 1] === "?") {
313
- i = readPI(xmlData, ++i);
314
- if (i.err) return i;
315
- } else {
316
- break;
317
- }
318
- } else if (xmlData[i] === "&") {
319
- const afterAmp = validateAmpersand(xmlData, i);
320
- if (afterAmp == -1)
321
- return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
322
- i = afterAmp;
323
- } else {
324
- if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
325
- return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
326
- }
327
- }
328
- }
329
- if (xmlData[i] === "<") {
330
- i--;
331
- }
332
- }
333
- } else {
334
- if (isWhiteSpace(xmlData[i])) {
335
- continue;
336
- }
337
- return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
338
- }
339
- }
340
- if (!tagFound) {
341
- return getErrorObject("InvalidXml", "Start tag expected.", 1);
342
- } else if (tags.length == 1) {
343
- return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
344
- } else if (tags.length > 0) {
345
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
346
- }
347
- return true;
348
- }
349
- function isWhiteSpace(char) {
350
- return char === " " || char === " " || char === "\n" || char === "\r";
351
- }
352
- function readPI(xmlData, i) {
353
- const start = i;
354
- for (; i < xmlData.length; i++) {
355
- if (xmlData[i] == "?" || xmlData[i] == " ") {
356
- const tagname = xmlData.substr(start, i - start);
357
- if (i > 5 && tagname === "xml") {
358
- return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
359
- } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
360
- i++;
361
- break;
362
- } else {
363
- continue;
364
- }
365
- }
366
- }
367
- return i;
368
- }
369
- function readCommentAndCDATA(xmlData, i) {
370
- if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
371
- for (i += 3; i < xmlData.length; i++) {
372
- if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
373
- i += 2;
374
- break;
375
- }
376
- }
377
- } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
378
- let angleBracketsCount = 1;
379
- for (i += 8; i < xmlData.length; i++) {
380
- if (xmlData[i] === "<") {
381
- angleBracketsCount++;
382
- } else if (xmlData[i] === ">") {
383
- angleBracketsCount--;
384
- if (angleBracketsCount === 0) {
385
- break;
386
- }
387
- }
388
- }
389
- } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
390
- for (i += 8; i < xmlData.length; i++) {
391
- if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
392
- i += 2;
393
- break;
394
- }
395
- }
396
- }
397
- return i;
398
- }
399
- var doubleQuote = '"';
400
- var singleQuote = "'";
401
- function readAttributeStr(xmlData, i) {
402
- let attrStr = "";
403
- let startChar = "";
404
- let tagClosed = false;
405
- for (; i < xmlData.length; i++) {
406
- if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
407
- if (startChar === "") {
408
- startChar = xmlData[i];
409
- } else if (startChar !== xmlData[i]) {
410
- } else {
411
- startChar = "";
412
- }
413
- } else if (xmlData[i] === ">") {
414
- if (startChar === "") {
415
- tagClosed = true;
416
- break;
417
- }
418
- }
419
- attrStr += xmlData[i];
420
- }
421
- if (startChar !== "") {
422
- return false;
423
- }
424
- return {
425
- value: attrStr,
426
- index: i,
427
- tagClosed
428
- };
429
- }
430
- function scanAttributeTokens(attrStr) {
431
- const tokens = [];
432
- const len = attrStr.length;
433
- let i = 0;
434
- while (i < len) {
435
- const tokenStart = i;
436
- while (i < len && isWhiteSpace(attrStr[i])) i++;
437
- if (i >= len) break;
438
- if (attrStr[i] === "=") {
439
- i = tokenStart + 1;
440
- continue;
441
- }
442
- const leadingWs = attrStr.slice(tokenStart, i);
443
- const nameStart = i;
444
- while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== "=") i++;
445
- const name = attrStr.slice(nameStart, i);
446
- let equalsGroup;
447
- let j = i;
448
- while (j < len && isWhiteSpace(attrStr[j])) j++;
449
- if (j < len && attrStr[j] === "=") {
450
- equalsGroup = attrStr.slice(i, j + 1);
451
- i = j + 1;
452
- }
453
- let quoteChar;
454
- let value;
455
- let k = i;
456
- while (k < len && isWhiteSpace(attrStr[k])) k++;
457
- if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
458
- const valueStart = k + 1;
459
- const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
460
- if (closeIdx !== -1) {
461
- quoteChar = attrStr[k];
462
- value = attrStr.slice(valueStart, closeIdx);
463
- i = closeIdx + 1;
464
- }
465
- }
466
- const token = { startIndex: tokenStart };
467
- token[1] = leadingWs;
468
- token[2] = name;
469
- token[3] = equalsGroup;
470
- token[4] = quoteChar !== void 0 ? true : void 0;
471
- token[5] = quoteChar;
472
- token[6] = value;
473
- tokens.push(token);
474
- }
475
- return tokens;
476
- }
477
- function validateAttributeString(attrStr, options) {
478
- const matches = scanAttributeTokens(attrStr);
479
- const attrNames = {};
480
- for (let i = 0; i < matches.length; i++) {
481
- if (matches[i][1].length === 0) {
482
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
483
- } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
484
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
485
- } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
486
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
487
- }
488
- const attrName = matches[i][2];
489
- if (!validateAttrName(attrName)) {
490
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
491
- }
492
- if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
493
- attrNames[attrName] = 1;
494
- } else {
495
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
496
- }
497
- }
498
- return true;
499
- }
500
- function validateNumberAmpersand(xmlData, i) {
501
- let re = /\d/;
502
- if (xmlData[i] === "x") {
503
- i++;
504
- re = /[\da-fA-F]/;
505
- }
506
- for (; i < xmlData.length; i++) {
507
- if (xmlData[i] === ";")
508
- return i;
509
- if (!xmlData[i].match(re))
510
- break;
511
- }
512
- return -1;
513
- }
514
- function validateAmpersand(xmlData, i) {
515
- i++;
516
- if (xmlData[i] === ";")
517
- return -1;
518
- if (xmlData[i] === "#") {
519
- i++;
520
- return validateNumberAmpersand(xmlData, i);
521
- }
522
- let count = 0;
523
- for (; i < xmlData.length; i++, count++) {
524
- if (xmlData[i].match(/\w/) && count < 20)
525
- continue;
526
- if (xmlData[i] === ";")
527
- break;
528
- return -1;
529
- }
530
- return i;
531
- }
532
- function getErrorObject(code, message, lineNumber) {
533
- return {
534
- err: {
535
- code,
536
- msg: message,
537
- line: lineNumber.line || lineNumber,
538
- col: lineNumber.col
539
- }
540
- };
541
- }
542
- function validateAttrName(attrName) {
543
- return isName(attrName);
544
- }
545
- function validateTagName(tagname) {
546
- return isName(tagname);
547
- }
548
- function getLineNumberForPosition(xmlData, index) {
549
- const lines = xmlData.substring(0, index).split(/\r?\n/);
550
- return {
551
- line: lines.length,
552
- // column number is last line's length + 1, because column numbering starts at 1:
553
- col: lines[lines.length - 1].length + 1
554
- };
555
- }
556
- function getPositionFromMatch(match) {
557
- return match.startIndex + match[1].length;
558
- }
559
-
560
- // ../../node_modules/@nodable/entities/src/entities.js
561
- var CURRENCY = {
562
- cent: "\xA2",
563
- pound: "\xA3",
564
- curren: "\xA4",
565
- yen: "\xA5",
566
- euro: "\u20AC",
567
- dollar: "$",
568
- fnof: "\u0192",
569
- inr: "\u20B9",
570
- af: "\u060B",
571
- birr: "\u1265\u122D",
572
- peso: "\u20B1",
573
- rub: "\u20BD",
574
- won: "\u20A9",
575
- yuan: "\xA5",
576
- cedil: "\xB8"
577
- };
578
- var XML = {
579
- amp: "&",
580
- apos: "'",
581
- gt: ">",
582
- lt: "<",
583
- quot: '"'
584
- };
585
- var COMMON_HTML = {
586
- nbsp: "\xA0",
587
- copy: "\xA9",
588
- reg: "\xAE",
589
- trade: "\u2122",
590
- mdash: "\u2014",
591
- ndash: "\u2013",
592
- hellip: "\u2026",
593
- laquo: "\xAB",
594
- raquo: "\xBB",
595
- lsquo: "\u2018",
596
- rsquo: "\u2019",
597
- ldquo: "\u201C",
598
- rdquo: "\u201D",
599
- bull: "\u2022",
600
- para: "\xB6",
601
- sect: "\xA7",
602
- deg: "\xB0",
603
- frac12: "\xBD",
604
- frac14: "\xBC",
605
- frac34: "\xBE"
606
- };
607
-
608
- // ../../node_modules/@nodable/entities/src/EntityDecoder.js
609
- var ENTITY_ACTION = Object.freeze({
610
- /** Resolve and expand the entity normally. */
611
- ALLOW: "allow",
612
- /** Silently skip this entity — it will not be registered. */
613
- BLOCK: "block",
614
- /** Throw an error, aborting entity registration entirely. */
615
- THROW: "throw"
616
- });
617
- var SPECIAL_CHARS = new Set("!?\\\\/[]$%{}^&*()<>|+");
618
- function validateEntityName(name) {
619
- if (name[0] === "#") {
620
- throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${name}"`);
621
- }
622
- for (const ch of name) {
623
- if (SPECIAL_CHARS.has(ch)) {
624
- throw new Error(`[EntityReplacer] Invalid character '${ch}' in entity name: "${name}"`);
625
- }
626
- }
627
- return name;
628
- }
629
- function mergeEntityMaps(...maps) {
630
- const out = /* @__PURE__ */ Object.create(null);
631
- for (const map of maps) {
632
- if (!map) continue;
633
- for (const key of Object.keys(map)) {
634
- const raw = map[key];
635
- if (typeof raw === "string") {
636
- out[key] = raw;
637
- } else if (raw && typeof raw === "object" && raw.val !== void 0) {
638
- const val = raw.val;
639
- if (typeof val === "string") {
640
- out[key] = val;
641
- }
642
- }
643
- }
644
- }
645
- return out;
646
- }
647
- var LIMIT_TIER_EXTERNAL = "external";
648
- var LIMIT_TIER_BASE = "base";
649
- var LIMIT_TIER_ALL = "all";
650
- function parseLimitTiers(raw) {
651
- if (!raw || raw === LIMIT_TIER_EXTERNAL) return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL]);
652
- if (raw === LIMIT_TIER_ALL) return /* @__PURE__ */ new Set([LIMIT_TIER_ALL]);
653
- if (raw === LIMIT_TIER_BASE) return /* @__PURE__ */ new Set([LIMIT_TIER_BASE]);
654
- if (Array.isArray(raw)) return new Set(raw);
655
- return /* @__PURE__ */ new Set([LIMIT_TIER_EXTERNAL]);
656
- }
657
- var NCR_LEVEL = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 });
658
- var XML10_ALLOWED_C0 = /* @__PURE__ */ new Set([9, 10, 13]);
659
- function parseNCRConfig(ncr) {
660
- if (!ncr) {
661
- return { xmlVersion: 1, onLevel: NCR_LEVEL.allow, nullLevel: NCR_LEVEL.remove };
662
- }
663
- const xmlVersion = ncr.xmlVersion === 1.1 ? 1.1 : 1;
664
- const onLevel = NCR_LEVEL[ncr.onNCR] ?? NCR_LEVEL.allow;
665
- const nullLevel = NCR_LEVEL[ncr.nullNCR] ?? NCR_LEVEL.remove;
666
- const clampedNull = Math.max(nullLevel, NCR_LEVEL.remove);
667
- return { xmlVersion, onLevel, nullLevel: clampedNull };
668
- }
669
- var EntityDecoder = class {
670
- /**
671
- * @param {object} [options]
672
- * @param {object|null} [options.namedEntities] — extra named entities merged into base map
673
- * @param {object} [options.limit] — security limits
674
- * @param {number} [options.limit.maxTotalExpansions=0] — 0 = unlimited
675
- * @param {number} [options.limit.maxExpandedLength=0] — 0 = unlimited
676
- * @param {'external'|'base'|'all'|string[]} [options.limit.applyLimitsTo='external']
677
- * Which entity tiers count against the security limits:
678
- * - 'external' (default) — only input/runtime + persistent external entities
679
- * - 'base' — only DEFAULT_XML_ENTITIES + namedEntities
680
- * - 'all' — every entity regardless of tier
681
- * - string[] — explicit combination, e.g. ['external', 'base']
682
- * @param {((resolved: string, original: string) => string)|null} [options.postCheck=null]
683
- * @param {string[]} [options.remove=[]] — entity names (e.g. ['nbsp', '#13']) to delete (replace with empty string)
684
- * @param {string[]} [options.leave=[]] — entity names to keep as literal (unchanged in output)
685
- * @param {object} [options.ncr] — Numeric Character Reference controls
686
- * @param {1.0|1.1} [options.ncr.xmlVersion=1.0]
687
- * XML version governing which codepoint ranges are restricted:
688
- * - 1.0 — C0 controls U+0001–U+001F (except U+0009/000A/000D) are prohibited
689
- * - 1.1 — C0 controls are allowed when written as NCRs; C1 (U+007F–U+009F) decoded as-is
690
- * @param {'allow'|'leave'|'remove'|'throw'} [options.ncr.onNCR='allow']
691
- * Base action for numeric references. Severity order: allow < leave < remove < throw.
692
- * For codepoint ranges that carry a minimum level (surrogates → remove, XML 1.0 C0 → remove),
693
- * the effective action is max(onNCR, rangeMinimum).
694
- * @param {'remove'|'throw'} [options.ncr.nullNCR='remove']
695
- * Action for U+0000 (null). 'allow' and 'leave' are clamped to 'remove' since null is never safe.
696
- * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} [options.onExternalEntity=null]
697
- * Hook called when an external entity is registered via `setExternalEntities()` or
698
- * `addExternalEntity()`. Return `ENTITY_ACTION.ALLOW` to accept the entity,
699
- * `ENTITY_ACTION.BLOCK` to silently skip it, or `ENTITY_ACTION.THROW` to abort with an error.
700
- * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} [options.onInputEntity=null]
701
- * Hook called when an input entity is registered via `addInputEntities()`. Return
702
- * `ENTITY_ACTION.ALLOW` to accept, `ENTITY_ACTION.BLOCK` to silently skip, or
703
- * `ENTITY_ACTION.THROW` to abort with an error.
704
- */
705
- constructor(options = {}) {
706
- this._limit = options.limit || {};
707
- this._maxTotalExpansions = this._limit.maxTotalExpansions || 0;
708
- this._maxExpandedLength = this._limit.maxExpandedLength || 0;
709
- this._postCheck = typeof options.postCheck === "function" ? options.postCheck : (r) => r;
710
- this._limitTiers = parseLimitTiers(this._limit.applyLimitsTo ?? LIMIT_TIER_EXTERNAL);
711
- this._numericAllowed = options.numericAllowed ?? true;
712
- this._baseMap = mergeEntityMaps(XML, options.namedEntities || null);
713
- this._externalMap = /* @__PURE__ */ Object.create(null);
714
- this._inputMap = /* @__PURE__ */ Object.create(null);
715
- this._totalExpansions = 0;
716
- this._expandedLength = 0;
717
- this._removeSet = new Set(options.remove && Array.isArray(options.remove) ? options.remove : []);
718
- this._leaveSet = new Set(options.leave && Array.isArray(options.leave) ? options.leave : []);
719
- const ncrCfg = parseNCRConfig(options.ncr);
720
- this._ncrXmlVersion = ncrCfg.xmlVersion;
721
- this._ncrOnLevel = ncrCfg.onLevel;
722
- this._ncrNullLevel = ncrCfg.nullLevel;
723
- this._onExternalEntity = typeof options.onExternalEntity === "function" ? options.onExternalEntity : null;
724
- this._onInputEntity = typeof options.onInputEntity === "function" ? options.onInputEntity : null;
725
- }
726
- // -------------------------------------------------------------------------
727
- // Private: registration hook dispatch
728
- // -------------------------------------------------------------------------
729
- /**
730
- * Invoke a registration hook for a single entity name/value pair.
731
- * Returns true when the entity should be accepted, false when it should be
732
- * silently skipped (BLOCK), and throws when the hook returns THROW.
733
- *
734
- * @param {((name: string, value: string) => 'allow'|'block'|'throw')|null} hook
735
- * @param {string} name
736
- * @param {string} value
737
- * @param {string} context — used in error messages ('external' | 'input')
738
- * @returns {boolean} true = accept, false = skip
739
- */
740
- _applyRegistrationHook(hook, name, value, context) {
741
- if (!hook) return true;
742
- const action = hook(name, value);
743
- if (action === ENTITY_ACTION.BLOCK) return false;
744
- if (action === ENTITY_ACTION.THROW) {
745
- throw new Error(
746
- `[EntityDecoder] Registration of ${context} entity "&${name};" was rejected by hook`
747
- );
748
- }
749
- return true;
750
- }
751
- // -------------------------------------------------------------------------
752
- // Persistent external entity registration
753
- // -------------------------------------------------------------------------
754
- /**
755
- * Replace the full set of persistent external entities.
756
- * All keys are validated — throws on invalid characters.
757
- * If `onExternalEntity` is set, it is called once per entry; entries that
758
- * return `ENTITY_ACTION.BLOCK` are silently omitted, `ENTITY_ACTION.THROW`
759
- * aborts the whole call.
760
- * @param {Record<string, string | { regex?: RegExp, val: string }>} map
761
- */
762
- setExternalEntities(map) {
763
- if (map) {
764
- for (const key of Object.keys(map)) {
765
- validateEntityName(key);
766
- }
767
- }
768
- if (!this._onExternalEntity) {
769
- this._externalMap = mergeEntityMaps(map);
770
- return;
771
- }
772
- const flat = mergeEntityMaps(map);
773
- const filtered = /* @__PURE__ */ Object.create(null);
774
- for (const [name, value] of Object.entries(flat)) {
775
- if (this._applyRegistrationHook(this._onExternalEntity, name, value, "external")) {
776
- filtered[name] = value;
777
- }
778
- }
779
- this._externalMap = filtered;
780
- }
781
- /**
782
- * Add a single persistent external entity.
783
- * If `onExternalEntity` is set it is called before the entity is stored;
784
- * `ENTITY_ACTION.BLOCK` silently skips storage, `ENTITY_ACTION.THROW` raises.
785
- * @param {string} key
786
- * @param {string} value
787
- */
788
- addExternalEntity(key, value) {
789
- validateEntityName(key);
790
- if (typeof value === "string" && value.indexOf("&") === -1) {
791
- if (this._applyRegistrationHook(this._onExternalEntity, key, value, "external")) {
792
- this._externalMap[key] = value;
793
- }
794
- }
795
- }
796
- // -------------------------------------------------------------------------
797
- // Input / runtime entity registration (per document)
798
- // -------------------------------------------------------------------------
799
- /**
800
- * Inject DOCTYPE entities for the current document.
801
- * Also resets per-document expansion counters.
802
- * If `onInputEntity` is set it is called once per entry; entries returning
803
- * `ENTITY_ACTION.BLOCK` are silently omitted, `ENTITY_ACTION.THROW` aborts.
804
- * @param {Record<string, string | { regx?: RegExp, regex?: RegExp, val: string }>} map
805
- */
806
- addInputEntities(map) {
807
- this._totalExpansions = 0;
808
- this._expandedLength = 0;
809
- if (!this._onInputEntity) {
810
- this._inputMap = mergeEntityMaps(map);
811
- return;
812
- }
813
- const flat = mergeEntityMaps(map);
814
- const filtered = /* @__PURE__ */ Object.create(null);
815
- for (const [name, value] of Object.entries(flat)) {
816
- if (this._applyRegistrationHook(this._onInputEntity, name, value, "input")) {
817
- filtered[name] = value;
818
- }
819
- }
820
- this._inputMap = filtered;
821
- }
822
- // -------------------------------------------------------------------------
823
- // Per-document reset
824
- // -------------------------------------------------------------------------
825
- /**
826
- * Wipe input/runtime entities and reset counters.
827
- * Call this before processing each new document.
828
- * @returns {this}
829
- */
830
- reset() {
831
- this._inputMap = /* @__PURE__ */ Object.create(null);
832
- this._totalExpansions = 0;
833
- this._expandedLength = 0;
834
- return this;
835
- }
836
- // -------------------------------------------------------------------------
837
- // XML version (can be set after construction, e.g. once parser reads <?xml?>)
838
- // -------------------------------------------------------------------------
839
- /**
840
- * Update the XML version used for NCR classification.
841
- * Call this as soon as the document's `<?xml version="...">` declaration is parsed.
842
- * @param {1.0|1.1|number} version
843
- */
844
- setXmlVersion(version) {
845
- this._ncrXmlVersion = version === 1.1 ? 1.1 : 1;
846
- }
847
- // -------------------------------------------------------------------------
848
- // Primary API
849
- // -------------------------------------------------------------------------
850
- /**
851
- * Replace all entity references in `str` in a single pass.
852
- *
853
- * @param {string} str
854
- * @returns {string}
855
- */
856
- decode(str) {
857
- if (typeof str !== "string" || str.length === 0) return str;
858
- if (str.indexOf("&") === -1) return str;
859
- const original = str;
860
- const chunks = [];
861
- const len = str.length;
862
- let last = 0;
863
- let i = 0;
864
- const limitExpansions = this._maxTotalExpansions > 0;
865
- const limitLength = this._maxExpandedLength > 0;
866
- const checkLimits = limitExpansions || limitLength;
867
- while (i < len) {
868
- if (str.charCodeAt(i) !== 38) {
869
- i++;
870
- continue;
871
- }
872
- let j = i + 1;
873
- while (j < len && str.charCodeAt(j) !== 59 && j - i <= 32) j++;
874
- if (j >= len || str.charCodeAt(j) !== 59) {
875
- i++;
876
- continue;
877
- }
878
- const token = str.slice(i + 1, j);
879
- if (token.length === 0) {
880
- i++;
881
- continue;
882
- }
883
- let replacement;
884
- let tier;
885
- if (this._removeSet.has(token)) {
886
- replacement = "";
887
- if (tier === void 0) {
888
- tier = LIMIT_TIER_EXTERNAL;
889
- }
890
- } else if (this._leaveSet.has(token)) {
891
- i++;
892
- continue;
893
- } else if (token.charCodeAt(0) === 35) {
894
- const ncrResult = this._resolveNCR(token);
895
- if (ncrResult === void 0) {
896
- i++;
897
- continue;
898
- }
899
- replacement = ncrResult;
900
- tier = LIMIT_TIER_BASE;
901
- } else {
902
- const resolved = this._resolveName(token);
903
- replacement = resolved?.value;
904
- tier = resolved?.tier;
905
- }
906
- if (replacement === void 0) {
907
- i++;
908
- continue;
909
- }
910
- if (i > last) chunks.push(str.slice(last, i));
911
- chunks.push(replacement);
912
- last = j + 1;
913
- i = last;
914
- if (checkLimits && this._tierCounts(tier)) {
915
- if (limitExpansions) {
916
- this._totalExpansions++;
917
- if (this._totalExpansions > this._maxTotalExpansions) {
918
- throw new Error(
919
- `[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`
920
- );
921
- }
922
- }
923
- if (limitLength) {
924
- const delta = replacement.length - (token.length + 2);
925
- if (delta > 0) {
926
- this._expandedLength += delta;
927
- if (this._expandedLength > this._maxExpandedLength) {
928
- throw new Error(
929
- `[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`
930
- );
931
- }
932
- }
933
- }
934
- }
935
- }
936
- if (last < len) chunks.push(str.slice(last));
937
- const result = chunks.length === 0 ? str : chunks.join("");
938
- return this._postCheck(result, original);
939
- }
940
- // -------------------------------------------------------------------------
941
- // Private: limit tier check
942
- // -------------------------------------------------------------------------
943
- /**
944
- * Returns true if a resolved entity of the given tier should count
945
- * against the expansion/length limits.
946
- * @param {string} tier — LIMIT_TIER_EXTERNAL | LIMIT_TIER_BASE
947
- * @returns {boolean}
948
- */
949
- _tierCounts(tier) {
950
- if (this._limitTiers.has(LIMIT_TIER_ALL)) return true;
951
- return this._limitTiers.has(tier);
952
- }
953
- // -------------------------------------------------------------------------
954
- // Private: entity resolution
955
- // -------------------------------------------------------------------------
956
- /**
957
- * Resolve a named entity token (without & and ;).
958
- * Priority: inputMap > externalMap > baseMap
959
- * Returns the resolved value tagged with its limit tier.
960
- *
961
- * @param {string} name
962
- * @returns {{ value: string, tier: string }|undefined}
963
- */
964
- _resolveName(name) {
965
- if (name in this._inputMap) return { value: this._inputMap[name], tier: LIMIT_TIER_EXTERNAL };
966
- if (name in this._externalMap) return { value: this._externalMap[name], tier: LIMIT_TIER_EXTERNAL };
967
- if (name in this._baseMap) return { value: this._baseMap[name], tier: LIMIT_TIER_BASE };
968
- return void 0;
969
- }
970
- /**
971
- * Classify a codepoint and return the minimum action level that must be applied.
972
- * Returns -1 when no minimum is imposed (normal allow path).
973
- *
974
- * Ranges checked (in priority order):
975
- * 1. U+0000 — null, governed by nullNCR (always ≥ remove)
976
- * 2. U+D800–U+DFFF — surrogates, always prohibited (min: remove)
977
- * 3. U+0001–U+001F \ {0x09,0x0A,0x0D} — XML 1.0 restricted C0 (min: remove)
978
- * (skipped in XML 1.1 — C0 controls are allowed when written as NCRs)
979
- *
980
- * @param {number} cp — codepoint
981
- * @returns {number} — minimum NCR_LEVEL value, or -1 for no restriction
982
- */
983
- _classifyNCR(cp) {
984
- if (cp === 0) return this._ncrNullLevel;
985
- if (cp >= 55296 && cp <= 57343) return NCR_LEVEL.remove;
986
- if (this._ncrXmlVersion === 1) {
987
- if (cp >= 1 && cp <= 31 && !XML10_ALLOWED_C0.has(cp)) return NCR_LEVEL.remove;
988
- }
989
- return -1;
990
- }
991
- /**
992
- * Execute a resolved NCR action.
993
- *
994
- * @param {number} action — NCR_LEVEL value
995
- * @param {string} token — raw token (e.g. '#38') for error messages
996
- * @param {number} cp — codepoint, used only for error messages
997
- * @returns {string|undefined}
998
- * - decoded character string → 'allow'
999
- * - '' → 'remove'
1000
- * - undefined → 'leave' (caller must skip past '&' only)
1001
- * - throws Error → 'throw'
1002
- */
1003
- _applyNCRAction(action, token, cp) {
1004
- switch (action) {
1005
- case NCR_LEVEL.allow:
1006
- return String.fromCodePoint(cp);
1007
- case NCR_LEVEL.remove:
1008
- return "";
1009
- case NCR_LEVEL.leave:
1010
- return void 0;
1011
- // signal: keep literal
1012
- case NCR_LEVEL.throw:
1013
- throw new Error(
1014
- `[EntityDecoder] Prohibited numeric character reference &${token}; (U+${cp.toString(16).toUpperCase().padStart(4, "0")})`
1015
- );
1016
- default:
1017
- return String.fromCodePoint(cp);
1018
- }
1019
- }
1020
- /**
1021
- * Full NCR resolution pipeline for a numeric token.
1022
- *
1023
- * Steps:
1024
- * 1. Parse the codepoint (decimal or hex).
1025
- * 2. Validate the raw codepoint range (NaN, <0, >0x10FFFF).
1026
- * 3. If numericAllowed is false and no minimum restriction applies → leave as-is.
1027
- * 4. Classify the codepoint to find the minimum required action level.
1028
- * 5. Resolve effective action = max(onNCR, minimum).
1029
- * 6. Apply and return.
1030
- *
1031
- * @param {string} token — e.g. '#38', '#x26', '#X26'
1032
- * @returns {string|undefined}
1033
- * - string (incl. '') — replacement ('' = remove)
1034
- * - undefined — leave original &token; as-is
1035
- */
1036
- _resolveNCR(token) {
1037
- const second = token.charCodeAt(1);
1038
- let cp;
1039
- if (second === 120 || second === 88) {
1040
- cp = parseInt(token.slice(2), 16);
1041
- } else {
1042
- cp = parseInt(token.slice(1), 10);
1043
- }
1044
- if (Number.isNaN(cp) || cp < 0 || cp > 1114111) return void 0;
1045
- const minimum = this._classifyNCR(cp);
1046
- if (!this._numericAllowed && minimum < NCR_LEVEL.remove) return void 0;
1047
- const effective = minimum === -1 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, minimum);
1048
- return this._applyNCRAction(effective, token, cp);
1049
- }
1050
- };
1051
-
1052
- // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
1053
- var defaultOnDangerousProperty = (name) => {
1054
- if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
1055
- return "__" + name;
1056
- }
1057
- return name;
1058
- };
1059
- var defaultOptions2 = {
1060
- preserveOrder: false,
1061
- attributeNamePrefix: "@_",
1062
- attributesGroupName: false,
1063
- textNodeName: "#text",
1064
- ignoreAttributes: true,
1065
- removeNSPrefix: false,
1066
- // remove NS from tag name or attribute name if true
1067
- allowBooleanAttributes: false,
1068
- //a tag can have attributes without any value
1069
- //ignoreRootElement : false,
1070
- parseTagValue: true,
1071
- parseAttributeValue: false,
1072
- trimValues: true,
1073
- //Trim string values of tag and attributes
1074
- cdataPropName: false,
1075
- numberParseOptions: {
1076
- hex: true,
1077
- leadingZeros: true,
1078
- eNotation: true,
1079
- unicode: false
1080
- },
1081
- tagValueProcessor: function(tagName, val) {
1082
- return val;
1083
- },
1084
- attributeValueProcessor: function(attrName, val) {
1085
- return val;
1086
- },
1087
- stopNodes: [],
1088
- //nested tags will not be parsed even for errors
1089
- alwaysCreateTextNode: false,
1090
- isArray: () => false,
1091
- commentPropName: false,
1092
- unpairedTags: [],
1093
- processEntities: true,
1094
- htmlEntities: false,
1095
- entityDecoder: null,
1096
- ignoreDeclaration: false,
1097
- ignorePiTags: false,
1098
- transformTagName: false,
1099
- transformAttributeName: false,
1100
- updateTag: function(tagName, jPath, attrs) {
1101
- return tagName;
1102
- },
1103
- // skipEmptyListItem: false
1104
- captureMetaData: false,
1105
- maxNestedTags: 100,
1106
- strictReservedNames: true,
1107
- jPath: true,
1108
- // if true, pass jPath string to callbacks; if false, pass matcher instance
1109
- onDangerousProperty: defaultOnDangerousProperty
1110
- };
1111
- function validatePropertyName(propertyName, optionName) {
1112
- if (typeof propertyName !== "string") {
1113
- return;
1114
- }
1115
- const normalized = propertyName.toLowerCase();
1116
- if (DANGEROUS_PROPERTY_NAMES.some((dangerous) => normalized === dangerous.toLowerCase())) {
1117
- throw new Error(
1118
- `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
1119
- );
1120
- }
1121
- if (criticalProperties.some((dangerous) => normalized === dangerous.toLowerCase())) {
1122
- throw new Error(
1123
- `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
1124
- );
1125
- }
1126
- }
1127
- function normalizeProcessEntities(value, htmlEntities) {
1128
- if (typeof value === "boolean") {
1129
- return {
1130
- enabled: value,
1131
- // true or false
1132
- maxEntitySize: 1e4,
1133
- maxExpansionDepth: 1e4,
1134
- maxTotalExpansions: Infinity,
1135
- maxExpandedLength: 1e5,
1136
- maxEntityCount: 1e3,
1137
- allowedTags: null,
1138
- tagFilter: null,
1139
- appliesTo: "all"
1140
- };
1141
- }
1142
- if (typeof value === "object" && value !== null) {
1143
- return {
1144
- enabled: value.enabled !== false,
1145
- maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
1146
- maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 1e4),
1147
- maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? Infinity),
1148
- maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
1149
- maxEntityCount: Math.max(1, value.maxEntityCount ?? 1e3),
1150
- allowedTags: value.allowedTags ?? null,
1151
- tagFilter: value.tagFilter ?? null,
1152
- appliesTo: value.appliesTo ?? "all"
1153
- };
1154
- }
1155
- return normalizeProcessEntities(true);
1156
- }
1157
- var buildOptions = function(options) {
1158
- const built = Object.assign({}, defaultOptions2, options);
1159
- const propertyNameOptions = [
1160
- { value: built.attributeNamePrefix, name: "attributeNamePrefix" },
1161
- { value: built.attributesGroupName, name: "attributesGroupName" },
1162
- { value: built.textNodeName, name: "textNodeName" },
1163
- { value: built.cdataPropName, name: "cdataPropName" },
1164
- { value: built.commentPropName, name: "commentPropName" }
1165
- ];
1166
- for (const { value, name } of propertyNameOptions) {
1167
- if (value) {
1168
- validatePropertyName(value, name);
1169
- }
1170
- }
1171
- if (built.onDangerousProperty === null) {
1172
- built.onDangerousProperty = defaultOnDangerousProperty;
1173
- }
1174
- built.processEntities = normalizeProcessEntities(built.processEntities, built.htmlEntities);
1175
- built.unpairedTagsSet = new Set(built.unpairedTags);
1176
- if (built.stopNodes && Array.isArray(built.stopNodes)) {
1177
- built.stopNodes = built.stopNodes.map((node) => {
1178
- if (typeof node === "string" && node.startsWith("*.")) {
1179
- return ".." + node.substring(2);
1180
- }
1181
- return node;
1182
- });
1183
- }
1184
- return built;
1185
- };
1186
-
1187
- // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
1188
- var METADATA_SYMBOL;
1189
- if (typeof Symbol !== "function") {
1190
- METADATA_SYMBOL = "@@xmlMetadata";
1191
- } else {
1192
- METADATA_SYMBOL = /* @__PURE__ */ Symbol("XML Node Metadata");
1193
- }
1194
- var XmlNode = class {
1195
- constructor(tagname) {
1196
- this.tagname = tagname;
1197
- this.child = [];
1198
- this[":@"] = /* @__PURE__ */ Object.create(null);
1199
- }
1200
- add(key, val) {
1201
- if (key === "__proto__") key = "#__proto__";
1202
- this.child.push({ [key]: val });
1203
- }
1204
- addChild(node, startIndex) {
1205
- if (node.tagname === "__proto__") node.tagname = "#__proto__";
1206
- if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1207
- this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1208
- } else {
1209
- this.child.push({ [node.tagname]: node.child });
1210
- }
1211
- this.addStartIndex(startIndex);
1212
- }
1213
- addStartIndex(startIndex) {
1214
- if (startIndex !== void 0) {
1215
- this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
1216
- }
1217
- }
1218
- addEndIndex(endIndex) {
1219
- const lastChild = this.child[this.child.length - 1];
1220
- if (lastChild !== void 0 && lastChild[METADATA_SYMBOL] !== void 0 && lastChild[METADATA_SYMBOL].endIndex === void 0) {
1221
- lastChild[METADATA_SYMBOL].endIndex = endIndex;
1222
- }
1223
- }
1224
- /** symbol used for metadata */
1225
- static getMetaDataSymbol() {
1226
- return METADATA_SYMBOL;
1227
- }
1228
- };
1229
-
1230
- // ../../node_modules/xml-naming/src/index.js
1231
- var nameStartChar10 = ":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
1232
- var nameChar10 = nameStartChar10 + "\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040";
1233
- var nameStartChar11 = ":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";
1234
- var nameChar11 = nameStartChar11 + "\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040";
1235
- var buildRegexes = (startChar, char, flags = "") => {
1236
- const ncStart = startChar.replace(":", "");
1237
- const ncChar = char.replace(":", "");
1238
- const ncNamePat = `[${ncStart}][${ncChar}]*`;
1239
- return {
1240
- name: new RegExp(`^[${startChar}][${char}]*$`, flags),
1241
- ncName: new RegExp(`^${ncNamePat}$`, flags),
1242
- qName: new RegExp(`^${ncNamePat}(?::${ncNamePat})?$`, flags),
1243
- nmToken: new RegExp(`^[${char}]+$`, flags),
1244
- nmTokens: new RegExp(`^[${char}]+(?:\\s+[${char}]+)*$`, flags)
1245
- };
1246
- };
1247
- var regexes10 = buildRegexes(nameStartChar10, nameChar10);
1248
- var regexes11 = buildRegexes(nameStartChar11, nameChar11, "u");
1249
- var nameStartCharAscii = ":A-Za-z_";
1250
- var nameCharAscii = nameStartCharAscii + "\\-\\.\\d";
1251
- var regexesAscii = buildRegexes(nameStartCharAscii, nameCharAscii);
1252
- var getRegexes = (xmlVersion = "1.0", asciiOnly = false) => {
1253
- if (asciiOnly) return regexesAscii;
1254
- return xmlVersion === "1.1" ? regexes11 : regexes10;
1255
- };
1256
- var qName = (str, { xmlVersion = "1.0", asciiOnly = false } = {}) => getRegexes(xmlVersion, asciiOnly).qName.test(str);
1257
-
1258
- // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
1259
- var DocTypeReader = class {
1260
- constructor(options, xmlVersion) {
1261
- this.suppressValidationErr = !options;
1262
- this.options = options;
1263
- this.xmlVersion = xmlVersion || 1;
1264
- }
1265
- setXmlVersion(xmlVersion = 1) {
1266
- this.xmlVersion = xmlVersion;
1267
- }
1268
- readDocType(xmlData, i) {
1269
- const entities = /* @__PURE__ */ Object.create(null);
1270
- let entityCount = 0;
1271
- if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
1272
- i = i + 9;
1273
- let angleBracketsCount = 1;
1274
- let hasBody = false, comment = false;
1275
- let quoteChar = null;
1276
- let exp = "";
1277
- for (; i < xmlData.length; i++) {
1278
- if (quoteChar !== null) {
1279
- if (xmlData[i] === quoteChar) quoteChar = null;
1280
- exp += xmlData[i];
1281
- continue;
1282
- }
1283
- if (!hasBody && !comment && (xmlData[i] === '"' || xmlData[i] === "'")) {
1284
- quoteChar = xmlData[i];
1285
- exp += xmlData[i];
1286
- continue;
1287
- }
1288
- if (xmlData[i] === "<" && !comment) {
1289
- if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
1290
- i += 7;
1291
- let entityName, val;
1292
- [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
1293
- if (val.indexOf("&") === -1) {
1294
- if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
1295
- throw new Error(
1296
- `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
1297
- );
1298
- }
1299
- entities[entityName] = val;
1300
- entityCount++;
1301
- }
1302
- } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
1303
- i += 8;
1304
- const { index } = this.readElementExp(xmlData, i + 1);
1305
- i = index;
1306
- } else if (hasBody && hasSeq(xmlData, "!ATTLIST", i)) {
1307
- i += 8;
1308
- } else if (hasBody && hasSeq(xmlData, "!NOTATION", i)) {
1309
- i += 9;
1310
- const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
1311
- i = index;
1312
- } else if (hasSeq(xmlData, "!--", i)) comment = true;
1313
- else throw new Error(`Invalid DOCTYPE`);
1314
- angleBracketsCount++;
1315
- exp = "";
1316
- } else if (xmlData[i] === ">") {
1317
- if (comment) {
1318
- if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1319
- comment = false;
1320
- angleBracketsCount--;
1321
- }
1322
- } else {
1323
- angleBracketsCount--;
1324
- }
1325
- if (angleBracketsCount === 0) {
1326
- break;
1327
- }
1328
- } else if (xmlData[i] === "[") {
1329
- hasBody = true;
1330
- } else {
1331
- exp += xmlData[i];
1332
- }
1333
- }
1334
- if (quoteChar !== null || angleBracketsCount !== 0) {
1335
- throw new Error(`Unclosed DOCTYPE`);
1336
- }
1337
- } else {
1338
- throw new Error(`Invalid Tag instead of DOCTYPE`);
1339
- }
1340
- return { entities, i };
1341
- }
1342
- readEntityExp(xmlData, i) {
1343
- i = skipWhitespace(xmlData, i);
1344
- const startIndex = i;
1345
- while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
1346
- i++;
1347
- }
1348
- let entityName = xmlData.substring(startIndex, i);
1349
- validateEntityName2(entityName, { xmlVersion: this.xmlVersion });
1350
- i = skipWhitespace(xmlData, i);
1351
- if (!this.suppressValidationErr) {
1352
- if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
1353
- throw new Error("External entities are not supported");
1354
- } else if (xmlData[i] === "%") {
1355
- throw new Error("Parameter entities are not supported");
1356
- }
1357
- }
1358
- let entityValue = "";
1359
- [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
1360
- if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
1361
- throw new Error(
1362
- `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
1363
- );
1364
- }
1365
- i--;
1366
- return [entityName, entityValue, i];
1367
- }
1368
- readNotationExp(xmlData, i) {
1369
- i = skipWhitespace(xmlData, i);
1370
- const startIndex = i;
1371
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1372
- i++;
1373
- }
1374
- let notationName = xmlData.substring(startIndex, i);
1375
- !this.suppressValidationErr && validateEntityName2(notationName, { xmlVersion: this.xmlVersion });
1376
- i = skipWhitespace(xmlData, i);
1377
- const identifierType = xmlData.substring(i, i + 6).toUpperCase();
1378
- if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
1379
- throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
1380
- }
1381
- i += identifierType.length;
1382
- i = skipWhitespace(xmlData, i);
1383
- let publicIdentifier = null;
1384
- let systemIdentifier = null;
1385
- if (identifierType === "PUBLIC") {
1386
- [i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
1387
- i = skipWhitespace(xmlData, i);
1388
- if (xmlData[i] === '"' || xmlData[i] === "'") {
1389
- [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
1390
- }
1391
- } else if (identifierType === "SYSTEM") {
1392
- [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
1393
- if (!this.suppressValidationErr && !systemIdentifier) {
1394
- throw new Error("Missing mandatory system identifier for SYSTEM notation");
1395
- }
1396
- }
1397
- return { notationName, publicIdentifier, systemIdentifier, index: --i };
1398
- }
1399
- readIdentifierVal(xmlData, i, type) {
1400
- let identifierVal = "";
1401
- const startChar = xmlData[i];
1402
- if (startChar !== '"' && startChar !== "'") {
1403
- throw new Error(`Expected quoted string, found "${startChar}"`);
1404
- }
1405
- i++;
1406
- const startIndex = i;
1407
- while (i < xmlData.length && xmlData[i] !== startChar) {
1408
- i++;
1409
- }
1410
- identifierVal = xmlData.substring(startIndex, i);
1411
- if (xmlData[i] !== startChar) {
1412
- throw new Error(`Unterminated ${type} value`);
1413
- }
1414
- i++;
1415
- return [i, identifierVal];
1416
- }
1417
- readElementExp(xmlData, i) {
1418
- i = skipWhitespace(xmlData, i);
1419
- const startIndex = i;
1420
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1421
- i++;
1422
- }
1423
- let elementName = xmlData.substring(startIndex, i);
1424
- if (!this.suppressValidationErr && !qName(elementName, { xmlVersion: this.xmlVersion })) {
1425
- throw new Error(`Invalid element name: "${elementName}"`);
1426
- }
1427
- i = skipWhitespace(xmlData, i);
1428
- let contentModel = "";
1429
- if (xmlData[i] === "E" && hasSeq(xmlData, "MPTY", i)) i += 4;
1430
- else if (xmlData[i] === "A" && hasSeq(xmlData, "NY", i)) i += 2;
1431
- else if (xmlData[i] === "(") {
1432
- i++;
1433
- const startIndex2 = i;
1434
- while (i < xmlData.length && xmlData[i] !== ")") {
1435
- i++;
1436
- }
1437
- contentModel = xmlData.substring(startIndex2, i);
1438
- if (xmlData[i] !== ")") {
1439
- throw new Error("Unterminated content model");
1440
- }
1441
- } else if (!this.suppressValidationErr) {
1442
- throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
1443
- }
1444
- return {
1445
- elementName,
1446
- contentModel: contentModel.trim(),
1447
- index: i
1448
- };
1449
- }
1450
- readAttlistExp(xmlData, i) {
1451
- i = skipWhitespace(xmlData, i);
1452
- let startIndex = i;
1453
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1454
- i++;
1455
- }
1456
- let elementName = xmlData.substring(startIndex, i);
1457
- validateEntityName2(elementName, { xmlVersion: this.xmlVersion });
1458
- i = skipWhitespace(xmlData, i);
1459
- startIndex = i;
1460
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1461
- i++;
1462
- }
1463
- let attributeName = xmlData.substring(startIndex, i);
1464
- if (!validateEntityName2(attributeName, { xmlVersion: this.xmlVersion })) {
1465
- throw new Error(`Invalid attribute name: "${attributeName}"`);
1466
- }
1467
- i = skipWhitespace(xmlData, i);
1468
- let attributeType = "";
1469
- if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
1470
- attributeType = "NOTATION";
1471
- i += 8;
1472
- i = skipWhitespace(xmlData, i);
1473
- if (xmlData[i] !== "(") {
1474
- throw new Error(`Expected '(', found "${xmlData[i]}"`);
1475
- }
1476
- i++;
1477
- let allowedNotations = [];
1478
- while (i < xmlData.length && xmlData[i] !== ")") {
1479
- const startIndex2 = i;
1480
- while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
1481
- i++;
1482
- }
1483
- let notation = xmlData.substring(startIndex2, i);
1484
- notation = notation.trim();
1485
- if (!validateEntityName2(notation, { xmlVersion: this.xmlVersion })) {
1486
- throw new Error(`Invalid notation name: "${notation}"`);
1487
- }
1488
- allowedNotations.push(notation);
1489
- if (xmlData[i] === "|") {
1490
- i++;
1491
- i = skipWhitespace(xmlData, i);
1492
- }
1493
- }
1494
- if (xmlData[i] !== ")") {
1495
- throw new Error("Unterminated list of notations");
1496
- }
1497
- i++;
1498
- attributeType += " (" + allowedNotations.join("|") + ")";
1499
- } else {
1500
- const startIndex2 = i;
1501
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1502
- i++;
1503
- }
1504
- attributeType += xmlData.substring(startIndex2, i);
1505
- const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
1506
- if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
1507
- throw new Error(`Invalid attribute type: "${attributeType}"`);
1508
- }
1509
- }
1510
- i = skipWhitespace(xmlData, i);
1511
- let defaultValue = "";
1512
- if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
1513
- defaultValue = "#REQUIRED";
1514
- i += 8;
1515
- } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
1516
- defaultValue = "#IMPLIED";
1517
- i += 7;
1518
- } else {
1519
- [i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
1520
- }
1521
- return {
1522
- elementName,
1523
- attributeName,
1524
- attributeType,
1525
- defaultValue,
1526
- index: i
1527
- };
1528
- }
1529
- };
1530
- var skipWhitespace = (data, index) => {
1531
- while (index < data.length && /\s/.test(data[index])) {
1532
- index++;
1533
- }
1534
- return index;
1535
- };
1536
- function hasSeq(data, seq, i) {
1537
- for (let j = 0; j < seq.length; j++) {
1538
- if (seq[j] !== data[i + j + 1]) return false;
1539
- }
1540
- return true;
1541
- }
1542
- function validateEntityName2(name, xmlVersion) {
1543
- if (qName(name, { xmlVersion }))
1544
- return name;
1545
- else
1546
- throw new Error(`Invalid entity name ${name}`);
1547
- }
1548
-
1549
- // ../../node_modules/anynum/digitTable.js
1550
- var SCRIPT_ZEROS = [
1551
- // Basic Latin (ASCII) — included for completeness / pass-through
1552
- 48,
1553
- // 0-9
1554
- // Arabic scripts
1555
- 1632,
1556
- // Arabic-Indic ٠١٢٣٤٥٦٧٨٩
1557
- 1776,
1558
- // Extended Arabic-Indic (Urdu/Persian/Sindhi) ۰۱۲۳
1559
- // Indic scripts
1560
- 2406,
1561
- // Devanagari ०१२३४५६७८९
1562
- 2534,
1563
- // Bengali ০১২৩৪৫৬৭৮৯
1564
- 2662,
1565
- // Gurmukhi ੦੧੨੩੪੫੬੭੮੯
1566
- 2790,
1567
- // Gujarati ૦૧૨૩૪૫૬૭૮૯
1568
- 2918,
1569
- // Odia ୦୧୨୩୪୫୬୭୮୯
1570
- 3046,
1571
- // Tamil ௦௧௨௩௪௫௬௭௮௯
1572
- 3174,
1573
- // Telugu ౦౧౨౩౪౫౬౭౮౯
1574
- 3302,
1575
- // Kannada ೦೧೨೩೪೫೬೭೮೯
1576
- 3430,
1577
- // Malayalam ൦൧൨൩൪൫൬൭൮൯
1578
- 3558,
1579
- // Sinhala Archaic ෦෧෨෩෪෫෬෭෮෯
1580
- // Southeast Asian scripts
1581
- 3664,
1582
- // Thai ๐๑๒๓๔๕๖๗๘๙
1583
- 3792,
1584
- // Lao ໐໑໒໓໔໕໖໗໘໙
1585
- 3872,
1586
- // Tibetan ༠༡༢༣༤༥༦༧༨༩
1587
- 4160,
1588
- // Myanmar ၀၁၂၃၄၅၆၇၈၉
1589
- 4240,
1590
- // Myanmar Shan ႐႑႒႓႔႕႖႗႘႙
1591
- 6112,
1592
- // Khmer ០១២៣៤៥៦៧៨៩
1593
- 6160,
1594
- // Mongolian ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙
1595
- 6470,
1596
- // Limbu ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏
1597
- 6608,
1598
- // New Tai Lue ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙
1599
- 6784,
1600
- // Tai Tham Hora ᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉
1601
- 6800,
1602
- // Tai Tham Tham ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙
1603
- 6992,
1604
- // Balinese ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙
1605
- 7088,
1606
- // Sundanese ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹
1607
- 7232,
1608
- // Lepcha ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉
1609
- 7248,
1610
- // Ol Chiki ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙
1611
- // Fullwidth (CJK context)
1612
- 65296,
1613
- // Fullwidth 0123456789
1614
- // Mathematical digit variants (Unicode math block)
1615
- 120782,
1616
- // Mathematical Bold
1617
- 120792,
1618
- // Mathematical Double-Struck
1619
- 120802,
1620
- // Mathematical Sans-Serif
1621
- 120812,
1622
- // Mathematical Sans-Serif Bold
1623
- 120822,
1624
- // Mathematical Monospace
1625
- // Other scripts
1626
- 66720,
1627
- // Osmanya 𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩
1628
- 68912,
1629
- // Hanifi Rohingya 𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹
1630
- 69734,
1631
- // Brahmi 𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯
1632
- 69872,
1633
- // Sora Sompeng 𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹
1634
- 69942,
1635
- // Chakma 𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿
1636
- 70096,
1637
- // Sharada 𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙
1638
- 70384,
1639
- // Khudawadi 𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹
1640
- 70736,
1641
- // Newa 𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙
1642
- 70864,
1643
- // Tirhuta 𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙
1644
- 71248,
1645
- // Modi 𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙
1646
- 71360,
1647
- // Takri 𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉
1648
- 71472,
1649
- // Ahom 𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹
1650
- 71904,
1651
- // Warang Citi 𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩
1652
- 72016,
1653
- // Dives Akuru 𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙
1654
- 72688,
1655
- // Khitan Small Script 𑯰𑯱𑯲𑯳𑯴𑯵𑯶𑯷𑯸𑯹
1656
- 72784,
1657
- // Bhaiksuki 𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙
1658
- 73040,
1659
- // Masaram Gondi 𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙
1660
- 73120,
1661
- // Gunjala Gondi 𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩
1662
- 73552,
1663
- // Kawi 𑽐𑽑𑽒𑽓𑽔𑽕𑽖𑽗𑽘𑽙
1664
- 92768,
1665
- // Mro 𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩
1666
- 92864,
1667
- // Tangsa 𖫀𖫁𖫂𖫃𖫄𖫅𖫆𖫇𖫈𖫉
1668
- 93008,
1669
- // Pahawh Hmong 𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙
1670
- 123200,
1671
- // Nyiakeng Puachue Hmong 𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉
1672
- 123632,
1673
- // Wancho 𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹
1674
- 124144,
1675
- // Nag Mundari 𞓰𞓱𞓲𞓳𞓴𞓵𞓶𞓷𞓸𞓹
1676
- 125264,
1677
- // Adlam 𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙
1678
- 130032
1679
- // Segmented digit symbols 🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹
1680
- ];
1681
- var NOT_DIGIT = 255;
1682
- var HIGH_MAP = /* @__PURE__ */ new Map();
1683
- var LOW_MAX = 65535;
1684
- var LOW_MIN = 1632;
1685
- var TABLE_OFFSET = LOW_MIN;
1686
- var TABLE_SIZE = LOW_MAX - LOW_MIN + 1;
1687
- var TABLE = new Uint8Array(TABLE_SIZE).fill(NOT_DIGIT);
1688
- for (const zero of SCRIPT_ZEROS) {
1689
- for (let d = 0; d < 10; d++) {
1690
- const cp = zero + d;
1691
- if (cp <= LOW_MAX) {
1692
- TABLE[cp - TABLE_OFFSET] = d;
1693
- } else {
1694
- HIGH_MAP.set(cp, d);
1695
- }
1696
- }
1697
- }
1698
-
1699
- // ../../node_modules/anynum/anynum.js
1700
- var CHAR_0 = 48;
1701
- var CHAR_9 = 57;
1702
- var CHAR_MINUS = 45;
1703
- var MINUS_SET = /* @__PURE__ */ new Set([8722, 65293, 65123]);
1704
- function anynum(str) {
1705
- if (typeof str !== "string") return str;
1706
- const len = str.length;
1707
- if (len === 0) return str;
1708
- let firstHit = -1;
1709
- for (let i = 0; i < len; i++) {
1710
- const cc = str.charCodeAt(i);
1711
- if (cc >= CHAR_0 && cc <= CHAR_9 || cc === CHAR_MINUS) continue;
1712
- if (cc < TABLE_OFFSET) {
1713
- if (MINUS_SET.has(cc)) {
1714
- firstHit = i;
1715
- break;
1716
- }
1717
- continue;
1718
- }
1719
- if (cc >= 55296 && cc <= 56319) {
1720
- if (i + 1 < len) {
1721
- const low = str.charCodeAt(i + 1);
1722
- if (low >= 56320 && low <= 57343) {
1723
- const cp = 65536 + (cc - 55296 << 10) + (low - 56320);
1724
- if (HIGH_MAP.has(cp)) {
1725
- firstHit = i;
1726
- break;
1727
- }
1728
- }
1729
- }
1730
- continue;
1731
- }
1732
- if (TABLE[cc - TABLE_OFFSET] !== NOT_DIGIT || MINUS_SET.has(cc)) {
1733
- firstHit = i;
1734
- break;
1735
- }
1736
- }
1737
- if (firstHit === -1) return str;
1738
- const chars = [];
1739
- if (firstHit > 0) chars.push(str.slice(0, firstHit));
1740
- for (let i = firstHit; i < len; i++) {
1741
- const cc = str.charCodeAt(i);
1742
- if (cc >= CHAR_0 && cc <= CHAR_9 || cc === CHAR_MINUS) {
1743
- chars.push(str[i]);
1744
- continue;
1745
- }
1746
- if (cc < TABLE_OFFSET) {
1747
- chars.push(MINUS_SET.has(cc) ? "-" : str[i]);
1748
- continue;
1749
- }
1750
- if (cc >= 55296 && cc <= 56319) {
1751
- if (i + 1 < len) {
1752
- const low = str.charCodeAt(i + 1);
1753
- if (low >= 56320 && low <= 57343) {
1754
- const cp = 65536 + (cc - 55296 << 10) + (low - 56320);
1755
- const d2 = HIGH_MAP.get(cp);
1756
- if (d2 !== void 0) {
1757
- chars.push(String.fromCharCode(d2 + 48));
1758
- i++;
1759
- continue;
1760
- }
1761
- }
1762
- }
1763
- chars.push(str[i]);
1764
- continue;
1765
- }
1766
- if (MINUS_SET.has(cc)) {
1767
- chars.push("-");
1768
- continue;
1769
- }
1770
- const d = TABLE[cc - TABLE_OFFSET];
1771
- chars.push(d !== NOT_DIGIT ? String.fromCharCode(d + 48) : str[i]);
1772
- }
1773
- return chars.join("");
1774
- }
1775
- var anynum_default = anynum;
1776
-
1777
- // ../../node_modules/strnum/strnum.js
1778
- var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
1779
- var binRegex = /^0b[01]+$/;
1780
- var octRegex = /^0o[0-7]+$/;
1781
- var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
1782
- var consider = {
1783
- hex: true,
1784
- binary: false,
1785
- octal: false,
1786
- leadingZeros: true,
1787
- decimalPoint: ".",
1788
- eNotation: true,
1789
- //skipLike: /regex/,
1790
- infinity: "original",
1791
- // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
1792
- unicode: false
1793
- };
1794
- function toNumber(str, options = {}) {
1795
- options = Object.assign({}, consider, options);
1796
- if (!str || typeof str !== "string") return str;
1797
- let trimmedStr = str.trim();
1798
- if (trimmedStr.length === 0) return str;
1799
- else if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1800
- else if (trimmedStr === "0") return 0;
1801
- if (options.unicode) {
1802
- trimmedStr = anynum_default(trimmedStr);
1803
- if (trimmedStr === "0") return 0;
1804
- }
1805
- if (options.hex && hexRegex.test(trimmedStr)) {
1806
- return parse_int(trimmedStr, 16);
1807
- } else if (options.binary && binRegex.test(trimmedStr)) {
1808
- return parse_int(trimmedStr, 2);
1809
- } else if (options.octal && octRegex.test(trimmedStr)) {
1810
- return parse_int(trimmedStr, 8);
1811
- } else if (!isFinite(trimmedStr)) {
1812
- return handleInfinity(str, Number(trimmedStr), options);
1813
- } else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
1814
- return resolveEnotation(str, trimmedStr, options);
1815
- } else {
1816
- const match = numRegex.exec(trimmedStr);
1817
- if (match) {
1818
- const sign = match[1] || "";
1819
- const leadingZeros = match[2];
1820
- let numTrimmedByZeros = trimZeros(match[3]);
1821
- const decimalAdjacentToLeadingZeros = sign ? (
1822
- // 0., -00., 000.
1823
- str[leadingZeros.length + 1] === "."
1824
- ) : str[leadingZeros.length] === ".";
1825
- if (!options.leadingZeros && (leadingZeros.length > 1 || leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros)) {
1826
- return str;
1827
- } else {
1828
- const num = Number(trimmedStr);
1829
- const parsedStr = String(num);
1830
- if (num === 0) return num;
1831
- if (parsedStr.search(/[eE]/) !== -1) {
1832
- if (options.eNotation) return num;
1833
- else return str;
1834
- } else if (trimmedStr.indexOf(".") !== -1) {
1835
- if (parsedStr === "0") return num;
1836
- else if (parsedStr === numTrimmedByZeros) return num;
1837
- else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
1838
- else return str;
1839
- }
1840
- let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
1841
- if (leadingZeros) {
1842
- return n === parsedStr || sign + n === parsedStr ? num : str;
1843
- } else {
1844
- return n === parsedStr || n === sign + parsedStr ? num : str;
1845
- }
1846
- }
1847
- } else {
1848
- return str;
1849
- }
1850
- }
1851
- }
1852
- var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
1853
- function resolveEnotation(str, trimmedStr, options) {
1854
- if (!options.eNotation) return str;
1855
- const notation = trimmedStr.match(eNotationRegx);
1856
- if (notation) {
1857
- let sign = notation[1] || "";
1858
- const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
1859
- const leadingZeros = notation[2];
1860
- const eAdjacentToLeadingZeros = sign ? (
1861
- // 0E.
1862
- str[leadingZeros.length + 1] === eChar
1863
- ) : str[leadingZeros.length] === eChar;
1864
- if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
1865
- else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
1866
- return Number(trimmedStr);
1867
- } else if (leadingZeros.length > 0) {
1868
- if (options.leadingZeros && !eAdjacentToLeadingZeros) {
1869
- trimmedStr = (notation[1] || "") + notation[3];
1870
- return Number(trimmedStr);
1871
- } else return str;
1872
- } else {
1873
- return Number(trimmedStr);
1874
- }
1875
- } else {
1876
- return str;
1877
- }
1878
- }
1879
- function trimZeros(numStr) {
1880
- if (numStr && numStr.indexOf(".") !== -1) {
1881
- let end = numStr.length;
1882
- while (end > 0 && numStr.charCodeAt(end - 1) === 48) end--;
1883
- numStr = numStr.slice(0, end);
1884
- if (numStr === ".") numStr = "0";
1885
- else if (numStr[0] === ".") numStr = "0" + numStr;
1886
- else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
1887
- return numStr;
1888
- }
1889
- return numStr;
1890
- }
1891
- function parse_int(numStr, base) {
1892
- const str = numStr.trim();
1893
- if (base === 2 || base === 8) numStr = str.substring(2);
1894
- if (parseInt) return parseInt(numStr, base);
1895
- else if (Number.parseInt) return Number.parseInt(numStr, base);
1896
- else if (window && window.parseInt) return window.parseInt(numStr, base);
1897
- else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
1898
- }
1899
- function handleInfinity(str, num, options) {
1900
- const isPositive = num === Infinity;
1901
- switch (options.infinity.toLowerCase()) {
1902
- case "null":
1903
- return null;
1904
- case "infinity":
1905
- return num;
1906
- // Return Infinity or -Infinity
1907
- case "string":
1908
- return isPositive ? "Infinity" : "-Infinity";
1909
- case "original":
1910
- default:
1911
- return str;
1912
- }
1913
- }
1914
-
1915
- // ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
1916
- function getIgnoreAttributesFn(ignoreAttributes) {
1917
- if (typeof ignoreAttributes === "function") {
1918
- return ignoreAttributes;
1919
- }
1920
- if (Array.isArray(ignoreAttributes)) {
1921
- return (attrName) => {
1922
- for (const pattern of ignoreAttributes) {
1923
- if (typeof pattern === "string" && attrName === pattern) {
1924
- return true;
1925
- }
1926
- if (pattern instanceof RegExp && pattern.test(attrName)) {
1927
- return true;
1928
- }
1929
- }
1930
- };
1931
- }
1932
- return () => false;
1933
- }
1934
-
1935
- // ../../node_modules/path-expression-matcher/src/Expression.js
1936
- var Expression = class {
1937
- /**
1938
- * Create a new Expression
1939
- * @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
1940
- * @param {Object} options - Configuration options
1941
- * @param {string} options.separator - Path separator (default: '.')
1942
- */
1943
- constructor(pattern, options = {}, data) {
1944
- this.pattern = pattern;
1945
- this.separator = options.separator || ".";
1946
- this.segments = this._parse(pattern);
1947
- this.data = data;
1948
- this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
1949
- this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
1950
- this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
1951
- }
1952
- /**
1953
- * Parse pattern string into segments
1954
- * @private
1955
- * @param {string} pattern - Pattern to parse
1956
- * @returns {Array} Array of segment objects
1957
- */
1958
- _parse(pattern) {
1959
- const segments = [];
1960
- let i = 0;
1961
- let currentPart = "";
1962
- while (i < pattern.length) {
1963
- if (pattern[i] === this.separator) {
1964
- if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
1965
- if (currentPart.trim()) {
1966
- segments.push(this._parseSegment(currentPart.trim()));
1967
- currentPart = "";
1968
- }
1969
- segments.push({ type: "deep-wildcard" });
1970
- i += 2;
1971
- } else {
1972
- if (currentPart.trim()) {
1973
- segments.push(this._parseSegment(currentPart.trim()));
1974
- }
1975
- currentPart = "";
1976
- i++;
1977
- }
1978
- } else {
1979
- currentPart += pattern[i];
1980
- i++;
1981
- }
1982
- }
1983
- if (currentPart.trim()) {
1984
- segments.push(this._parseSegment(currentPart.trim()));
1985
- }
1986
- return segments;
1987
- }
1988
- /**
1989
- * Parse a single segment
1990
- * @private
1991
- * @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
1992
- * @returns {Object} Segment object
1993
- */
1994
- _parseSegment(part) {
1995
- const segment = { type: "tag" };
1996
- let bracketContent = null;
1997
- let withoutBrackets = part;
1998
- const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
1999
- if (bracketMatch) {
2000
- withoutBrackets = bracketMatch[1] + bracketMatch[3];
2001
- if (bracketMatch[2]) {
2002
- const content = bracketMatch[2].slice(1, -1);
2003
- if (content) {
2004
- bracketContent = content;
2005
- }
2006
- }
2007
- }
2008
- let namespace = void 0;
2009
- let tagAndPosition = withoutBrackets;
2010
- if (withoutBrackets.includes("::")) {
2011
- const nsIndex = withoutBrackets.indexOf("::");
2012
- namespace = withoutBrackets.substring(0, nsIndex).trim();
2013
- tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
2014
- if (!namespace) {
2015
- throw new Error(`Invalid namespace in pattern: ${part}`);
2016
- }
2017
- }
2018
- let tag = void 0;
2019
- let positionMatch = null;
2020
- if (tagAndPosition.includes(":")) {
2021
- const colonIndex = tagAndPosition.lastIndexOf(":");
2022
- const tagPart = tagAndPosition.substring(0, colonIndex).trim();
2023
- const posPart = tagAndPosition.substring(colonIndex + 1).trim();
2024
- const isPositionKeyword = ["first", "last", "odd", "even"].includes(posPart) || /^nth\(\d+\)$/.test(posPart);
2025
- if (isPositionKeyword) {
2026
- tag = tagPart;
2027
- positionMatch = posPart;
2028
- } else {
2029
- tag = tagAndPosition;
2030
- }
2031
- } else {
2032
- tag = tagAndPosition;
2033
- }
2034
- if (!tag) {
2035
- throw new Error(`Invalid segment pattern: ${part}`);
2036
- }
2037
- segment.tag = tag;
2038
- if (namespace) {
2039
- segment.namespace = namespace;
2040
- }
2041
- if (bracketContent) {
2042
- if (bracketContent.includes("=")) {
2043
- const eqIndex = bracketContent.indexOf("=");
2044
- segment.attrName = bracketContent.substring(0, eqIndex).trim();
2045
- segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
2046
- } else {
2047
- segment.attrName = bracketContent.trim();
2048
- }
2049
- }
2050
- if (positionMatch) {
2051
- const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
2052
- if (nthMatch) {
2053
- segment.position = "nth";
2054
- segment.positionValue = parseInt(nthMatch[1], 10);
2055
- } else {
2056
- segment.position = positionMatch;
2057
- }
2058
- }
2059
- return segment;
2060
- }
2061
- /**
2062
- * Get the number of segments
2063
- * @returns {number}
2064
- */
2065
- get length() {
2066
- return this.segments.length;
2067
- }
2068
- /**
2069
- * Check if expression contains deep wildcard
2070
- * @returns {boolean}
2071
- */
2072
- hasDeepWildcard() {
2073
- return this._hasDeepWildcard;
2074
- }
2075
- /**
2076
- * Check if expression has attribute conditions
2077
- * @returns {boolean}
2078
- */
2079
- hasAttributeCondition() {
2080
- return this._hasAttributeCondition;
2081
- }
2082
- /**
2083
- * Check if expression has position selectors
2084
- * @returns {boolean}
2085
- */
2086
- hasPositionSelector() {
2087
- return this._hasPositionSelector;
2088
- }
2089
- /**
2090
- * Get string representation
2091
- * @returns {string}
2092
- */
2093
- toString() {
2094
- return this.pattern;
2095
- }
2096
- };
2097
-
2098
- // ../../node_modules/path-expression-matcher/src/ExpressionSet.js
2099
- var ExpressionSet = class {
2100
- constructor() {
2101
- this._byDepthAndTag = /* @__PURE__ */ new Map();
2102
- this._wildcardByDepth = /* @__PURE__ */ new Map();
2103
- this._deepWildcards = [];
2104
- this._deepByTerminalTag = /* @__PURE__ */ new Map();
2105
- this._patterns = /* @__PURE__ */ new Set();
2106
- this._sealed = false;
2107
- }
2108
- /**
2109
- * Add an Expression to the set.
2110
- * Duplicate patterns (same pattern string) are silently ignored.
2111
- *
2112
- * @param {import('./Expression.js').default} expression - A pre-constructed Expression instance
2113
- * @returns {this} for chaining
2114
- * @throws {TypeError} if called after seal()
2115
- *
2116
- * @example
2117
- * set.add(new Expression('root.users.user'));
2118
- * set.add(new Expression('..script'));
2119
- */
2120
- add(expression) {
2121
- if (this._sealed) {
2122
- throw new TypeError(
2123
- "ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."
2124
- );
2125
- }
2126
- if (this._patterns.has(expression.pattern)) return this;
2127
- this._patterns.add(expression.pattern);
2128
- if (expression.hasDeepWildcard()) {
2129
- const lastSeg2 = expression.segments[expression.segments.length - 1];
2130
- if (lastSeg2 && lastSeg2.type !== "deep-wildcard" && lastSeg2.tag !== "*") {
2131
- const tag2 = lastSeg2.tag;
2132
- if (!this._deepByTerminalTag.has(tag2)) this._deepByTerminalTag.set(tag2, []);
2133
- this._deepByTerminalTag.get(tag2).push(expression);
2134
- } else {
2135
- this._deepWildcards.push(expression);
2136
- }
2137
- return this;
2138
- }
2139
- const depth = expression.length;
2140
- const lastSeg = expression.segments[expression.segments.length - 1];
2141
- const tag = lastSeg?.tag;
2142
- if (!tag || tag === "*") {
2143
- if (!this._wildcardByDepth.has(depth)) this._wildcardByDepth.set(depth, []);
2144
- this._wildcardByDepth.get(depth).push(expression);
2145
- } else {
2146
- const key = `${depth}:${tag}`;
2147
- if (!this._byDepthAndTag.has(key)) this._byDepthAndTag.set(key, []);
2148
- this._byDepthAndTag.get(key).push(expression);
2149
- }
2150
- return this;
2151
- }
2152
- /**
2153
- * Add multiple expressions at once.
2154
- *
2155
- * @param {import('./Expression.js').default[]} expressions - Array of Expression instances
2156
- * @returns {this} for chaining
2157
- *
2158
- * @example
2159
- * set.addAll([
2160
- * new Expression('root.users.user'),
2161
- * new Expression('root.config.setting'),
2162
- * ]);
2163
- */
2164
- addAll(expressions) {
2165
- for (const expr of expressions) this.add(expr);
2166
- return this;
2167
- }
2168
- /**
2169
- * Check whether a pattern string is already present in the set.
2170
- *
2171
- * @param {import('./Expression.js').default} expression
2172
- * @returns {boolean}
2173
- */
2174
- has(expression) {
2175
- return this._patterns.has(expression.pattern);
2176
- }
2177
- /**
2178
- * Number of expressions in the set.
2179
- * @type {number}
2180
- */
2181
- get size() {
2182
- return this._patterns.size;
2183
- }
2184
- /**
2185
- * Seal the set against further modifications.
2186
- * Useful to prevent accidental mutations after config is built.
2187
- * Calling add() or addAll() on a sealed set throws a TypeError.
2188
- *
2189
- * @returns {this}
2190
- */
2191
- seal() {
2192
- this._sealed = true;
2193
- return this;
2194
- }
2195
- /**
2196
- * Whether the set has been sealed.
2197
- * @type {boolean}
2198
- */
2199
- get isSealed() {
2200
- return this._sealed;
2201
- }
2202
- /**
2203
- * Test whether the matcher's current path matches any expression in the set.
2204
- *
2205
- * Evaluation order (cheapest → most expensive):
2206
- * 1. Exact depth + tag bucket — O(1) lookup, typically 0–2 expressions
2207
- * 2. Depth-only wildcard bucket — O(1) lookup, rare
2208
- * 3. Deep-wildcard list — always checked, but usually small
2209
- *
2210
- * @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
2211
- * @returns {boolean} true if any expression matches the current path
2212
- *
2213
- * @example
2214
- * if (stopNodes.matchesAny(matcher)) {
2215
- * // handle stop node
2216
- * }
2217
- */
2218
- matchesAny(matcher) {
2219
- return this.findMatch(matcher) !== null;
2220
- }
2221
- /**
2222
- * Find and return the first Expression that matches the matcher's current path.
2223
- *
2224
- * Uses the same evaluation order as matchesAny (cheapest → most expensive):
2225
- * 1. Exact depth + tag bucket
2226
- * 2. Depth-only wildcard bucket
2227
- * 3. Deep-wildcard list
2228
- *
2229
- * @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
2230
- * @returns {import('./Expression.js').default | null} the first matching Expression, or null
2231
- *
2232
- * @example
2233
- * const expr = stopNodes.findMatch(matcher);
2234
- * if (expr) {
2235
- * // access expr.config, expr.pattern, etc.
2236
- * }
2237
- */
2238
- findMatch(matcher) {
2239
- const depth = matcher.getDepth();
2240
- const tag = matcher.getCurrentTag();
2241
- const exactKey = `${depth}:${tag}`;
2242
- const exactBucket = this._byDepthAndTag.get(exactKey);
2243
- if (exactBucket) {
2244
- for (let i = 0; i < exactBucket.length; i++) {
2245
- if (matcher.matches(exactBucket[i])) return exactBucket[i];
2246
- }
2247
- }
2248
- const wildcardBucket = this._wildcardByDepth.get(depth);
2249
- if (wildcardBucket) {
2250
- for (let i = 0; i < wildcardBucket.length; i++) {
2251
- if (matcher.matches(wildcardBucket[i])) return wildcardBucket[i];
2252
- }
2253
- }
2254
- const deepBucket = this._deepByTerminalTag.get(tag);
2255
- if (deepBucket) {
2256
- for (let i = 0; i < deepBucket.length; i++) {
2257
- if (matcher.matches(deepBucket[i])) return deepBucket[i];
2258
- }
2259
- }
2260
- for (let i = 0; i < this._deepWildcards.length; i++) {
2261
- if (matcher.matches(this._deepWildcards[i])) return this._deepWildcards[i];
2262
- }
2263
- return null;
2264
- }
2265
- };
2266
-
2267
- // ../../node_modules/path-expression-matcher/src/Matcher.js
2268
- var MatcherView = class {
2269
- /**
2270
- * @param {Matcher} matcher - The parent Matcher instance to read from.
2271
- */
2272
- constructor(matcher) {
2273
- this._matcher = matcher;
2274
- }
2275
- /**
2276
- * Get the path separator used by the parent matcher.
2277
- * @returns {string}
2278
- */
2279
- get separator() {
2280
- return this._matcher.separator;
2281
- }
2282
- /**
2283
- * Get current tag name.
2284
- * @returns {string|undefined}
2285
- */
2286
- getCurrentTag() {
2287
- const path = this._matcher.path;
2288
- return path.length > 0 ? path[path.length - 1].tag : void 0;
2289
- }
2290
- /**
2291
- * Get current namespace.
2292
- * @returns {string|undefined}
2293
- */
2294
- getCurrentNamespace() {
2295
- const path = this._matcher.path;
2296
- return path.length > 0 ? path[path.length - 1].namespace : void 0;
2297
- }
2298
- /**
2299
- * Get current node's attribute value.
2300
- * @param {string} attrName
2301
- * @returns {*}
2302
- */
2303
- getAttrValue(attrName) {
2304
- const path = this._matcher.path;
2305
- if (path.length === 0) return void 0;
2306
- return path[path.length - 1].values?.[attrName];
2307
- }
2308
- /**
2309
- * Check if current node has an attribute.
2310
- * @param {string} attrName
2311
- * @returns {boolean}
2312
- */
2313
- hasAttr(attrName) {
2314
- const path = this._matcher.path;
2315
- if (path.length === 0) return false;
2316
- const current = path[path.length - 1];
2317
- return current.values !== void 0 && attrName in current.values;
2318
- }
2319
- /**
2320
- * Get the value of a "kept" attribute from the nearest ancestor (or
2321
- * current node) that declared it via `push(tag, attrs, ns, { keep: [...] })`.
2322
- * @param {string} attrName
2323
- * @returns {*}
2324
- */
2325
- getAnyParentAttr(attrName) {
2326
- return this._matcher.getAnyParentAttr(attrName);
2327
- }
2328
- /**
2329
- * Check whether any ancestor (or the current node) kept the given
2330
- * attribute via `push(tag, attrs, ns, { keep: [...] })`.
2331
- * @param {string} attrName
2332
- * @returns {boolean}
2333
- */
2334
- hasAnyParentAttr(attrName) {
2335
- return this._matcher.hasAnyParentAttr(attrName);
2336
- }
2337
- /**
2338
- * Get current node's sibling position (child index in parent).
2339
- * @returns {number}
2340
- */
2341
- getPosition() {
2342
- const path = this._matcher.path;
2343
- if (path.length === 0) return -1;
2344
- return path[path.length - 1].position ?? 0;
2345
- }
2346
- /**
2347
- * Get current node's repeat counter (occurrence count of this tag name).
2348
- * @returns {number}
2349
- */
2350
- getCounter() {
2351
- const path = this._matcher.path;
2352
- if (path.length === 0) return -1;
2353
- return path[path.length - 1].counter ?? 0;
2354
- }
2355
- /**
2356
- * Get current node's sibling index (alias for getPosition).
2357
- * @returns {number}
2358
- * @deprecated Use getPosition() or getCounter() instead
2359
- */
2360
- getIndex() {
2361
- return this.getPosition();
2362
- }
2363
- /**
2364
- * Get current path depth.
2365
- * @returns {number}
2366
- */
2367
- getDepth() {
2368
- return this._matcher.path.length;
2369
- }
2370
- /**
2371
- * Get path as string.
2372
- * @param {string} [separator] - Optional separator (uses default if not provided)
2373
- * @param {boolean} [includeNamespace=true]
2374
- * @returns {string}
2375
- */
2376
- toString(separator, includeNamespace = true) {
2377
- return this._matcher.toString(separator, includeNamespace);
2378
- }
2379
- /**
2380
- * Get path as array of tag names.
2381
- * @returns {string[]}
2382
- */
2383
- toArray() {
2384
- return this._matcher.path.map((n) => n.tag);
2385
- }
2386
- /**
2387
- * Match current path against an Expression.
2388
- * @param {Expression} expression
2389
- * @returns {boolean}
2390
- */
2391
- matches(expression) {
2392
- return this._matcher.matches(expression);
2393
- }
2394
- /**
2395
- * Match any expression in the given set against the current path.
2396
- * @param {ExpressionSet} exprSet
2397
- * @returns {boolean}
2398
- */
2399
- matchesAny(exprSet) {
2400
- return exprSet.matchesAny(this._matcher);
2401
- }
2402
- };
2403
- var Matcher = class {
2404
- /**
2405
- * Create a new Matcher.
2406
- * @param {Object} [options={}]
2407
- * @param {string} [options.separator='.'] - Default path separator
2408
- */
2409
- constructor(options = {}) {
2410
- this.separator = options.separator || ".";
2411
- this.path = [];
2412
- this.siblingStacks = [];
2413
- this._pathStringCache = null;
2414
- this._view = new MatcherView(this);
2415
- this._keptAttrs = [];
2416
- }
2417
- /**
2418
- * Push a new tag onto the path.
2419
- * @param {string} tagName
2420
- * @param {Object|null} [attrValues=null]
2421
- * @param {string|null} [namespace=null]
2422
- * @param {Object|null} [options=null]
2423
- * @param {string[]} [options.keep] - Names of attributes (from attrValues)
2424
- */
2425
- push(tagName, attrValues = null, namespace = null, options = null) {
2426
- this._pathStringCache = null;
2427
- if (this.path.length > 0) {
2428
- this.path[this.path.length - 1].values = void 0;
2429
- }
2430
- const currentLevel = this.path.length;
2431
- let level = this.siblingStacks[currentLevel];
2432
- if (!level) {
2433
- level = { counts: /* @__PURE__ */ new Map(), total: 0 };
2434
- this.siblingStacks[currentLevel] = level;
2435
- }
2436
- const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;
2437
- const counter = level.counts.get(siblingKey) || 0;
2438
- const position = level.total;
2439
- level.counts.set(siblingKey, counter + 1);
2440
- level.total++;
2441
- const node = {
2442
- tag: tagName,
2443
- position,
2444
- counter
2445
- };
2446
- if (namespace !== null && namespace !== void 0) {
2447
- node.namespace = namespace;
2448
- }
2449
- if (attrValues !== null && attrValues !== void 0) {
2450
- node.values = attrValues;
2451
- }
2452
- this.path.push(node);
2453
- const depth = this.path.length;
2454
- const keep = options !== null ? options.keep : null;
2455
- if (keep !== null && keep !== void 0 && keep.length > 0 && attrValues) {
2456
- for (let i = 0; i < keep.length; i++) {
2457
- const name = keep[i];
2458
- if (attrValues[name] !== void 0) {
2459
- this._keptAttrs.push({ depth, name, value: attrValues[name] });
2460
- }
2461
- }
2462
- }
2463
- }
2464
- /**
2465
- * Pop the last tag from the path.
2466
- * @returns {Object|undefined} The popped node
2467
- */
2468
- pop() {
2469
- if (this.path.length === 0) return void 0;
2470
- this._pathStringCache = null;
2471
- const node = this.path.pop();
2472
- if (this.siblingStacks.length > this.path.length + 1) {
2473
- this.siblingStacks.length = this.path.length + 1;
2474
- }
2475
- const poppedDepth = this.path.length + 1;
2476
- while (this._keptAttrs.length > 0 && this._keptAttrs[this._keptAttrs.length - 1].depth >= poppedDepth) {
2477
- this._keptAttrs.pop();
2478
- }
2479
- return node;
2480
- }
2481
- /**
2482
- * Update current node's attribute values.
2483
- * Useful when attributes are parsed after push.
2484
- * @param {Object} attrValues
2485
- */
2486
- updateCurrent(attrValues) {
2487
- if (this.path.length > 0) {
2488
- const current = this.path[this.path.length - 1];
2489
- if (attrValues !== null && attrValues !== void 0) {
2490
- current.values = attrValues;
2491
- }
2492
- }
2493
- }
2494
- /**
2495
- * Get current tag name.
2496
- * @returns {string|undefined}
2497
- */
2498
- getCurrentTag() {
2499
- return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0;
2500
- }
2501
- /**
2502
- * Get current namespace.
2503
- * @returns {string|undefined}
2504
- */
2505
- getCurrentNamespace() {
2506
- return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0;
2507
- }
2508
- /**
2509
- * Get current node's attribute value.
2510
- * @param {string} attrName
2511
- * @returns {*}
2512
- */
2513
- getAttrValue(attrName) {
2514
- if (this.path.length === 0) return void 0;
2515
- return this.path[this.path.length - 1].values?.[attrName];
2516
- }
2517
- /**
2518
- * Check if current node has an attribute.
2519
- * @param {string} attrName
2520
- * @returns {boolean}
2521
- */
2522
- hasAttr(attrName) {
2523
- if (this.path.length === 0) return false;
2524
- const current = this.path[this.path.length - 1];
2525
- return current.values !== void 0 && attrName in current.values;
2526
- }
2527
- /**
2528
- * Get the value of a "kept" attribute from the nearest ancestor (or
2529
- * current node) that declared it via `push(tag, attrs, ns, { keep: [...] })`.
2530
- * Unlike getAttrValue(), this works regardless of how deep the path has
2531
- * gone since the attribute was pushed — but only for attribute names that
2532
- * were explicitly marked with `keep` at push time. Cost is proportional to
2533
- * the number of currently-kept attributes (typically 0-3), not path depth.
2534
- * @param {string} attrName
2535
- * @returns {*} the value, or undefined if no ancestor kept this attribute
2536
- */
2537
- getAnyParentAttr(attrName) {
2538
- const kept = this._keptAttrs;
2539
- for (let i = kept.length - 1; i >= 0; i--) {
2540
- if (kept[i].name === attrName) return kept[i].value;
2541
- }
2542
- return void 0;
2543
- }
2544
- /**
2545
- * Check whether any ancestor (or the current node) kept the given
2546
- * attribute via `push(tag, attrs, ns, { keep: [...] })`.
2547
- * @param {string} attrName
2548
- * @returns {boolean}
2549
- */
2550
- hasAnyParentAttr(attrName) {
2551
- const kept = this._keptAttrs;
2552
- for (let i = kept.length - 1; i >= 0; i--) {
2553
- if (kept[i].name === attrName) return true;
2554
- }
2555
- return false;
2556
- }
2557
- /**
2558
- * Get current node's sibling position (child index in parent).
2559
- * @returns {number}
2560
- */
2561
- getPosition() {
2562
- if (this.path.length === 0) return -1;
2563
- return this.path[this.path.length - 1].position ?? 0;
2564
- }
2565
- /**
2566
- * Get current node's repeat counter (occurrence count of this tag name).
2567
- * @returns {number}
2568
- */
2569
- getCounter() {
2570
- if (this.path.length === 0) return -1;
2571
- return this.path[this.path.length - 1].counter ?? 0;
2572
- }
2573
- /**
2574
- * Get current node's sibling index (alias for getPosition).
2575
- * @returns {number}
2576
- * @deprecated Use getPosition() or getCounter() instead
2577
- */
2578
- getIndex() {
2579
- return this.getPosition();
2580
- }
2581
- /**
2582
- * Get current path depth.
2583
- * @returns {number}
2584
- */
2585
- getDepth() {
2586
- return this.path.length;
2587
- }
2588
- /**
2589
- * Get path as string.
2590
- * @param {string} [separator] - Optional separator (uses default if not provided)
2591
- * @param {boolean} [includeNamespace=true]
2592
- * @returns {string}
2593
- */
2594
- toString(separator, includeNamespace = true) {
2595
- const sep2 = separator || this.separator;
2596
- const isDefault = sep2 === this.separator && includeNamespace === true;
2597
- if (isDefault) {
2598
- if (this._pathStringCache !== null) {
2599
- return this._pathStringCache;
2600
- }
2601
- const result = this.path.map(
2602
- (n) => n.namespace ? `${n.namespace}:${n.tag}` : n.tag
2603
- ).join(sep2);
2604
- this._pathStringCache = result;
2605
- return result;
2606
- }
2607
- return this.path.map(
2608
- (n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
2609
- ).join(sep2);
2610
- }
2611
- /**
2612
- * Get path as array of tag names.
2613
- * @returns {string[]}
2614
- */
2615
- toArray() {
2616
- return this.path.map((n) => n.tag);
2617
- }
2618
- /**
2619
- * Reset the path to empty.
2620
- */
2621
- reset() {
2622
- this._pathStringCache = null;
2623
- this.path = [];
2624
- this.siblingStacks = [];
2625
- this._keptAttrs = [];
2626
- }
2627
- /**
2628
- * Match current path against an Expression.
2629
- * @param {Expression} expression
2630
- * @returns {boolean}
2631
- */
2632
- matches(expression) {
2633
- const segments = expression.segments;
2634
- if (segments.length === 0) {
2635
- return false;
2636
- }
2637
- if (expression.hasDeepWildcard()) {
2638
- return this._matchWithDeepWildcard(segments);
2639
- }
2640
- return this._matchSimple(segments);
2641
- }
2642
- /**
2643
- * @private
2644
- */
2645
- _matchSimple(segments) {
2646
- if (this.path.length !== segments.length) {
2647
- return false;
2648
- }
2649
- for (let i = 0; i < segments.length; i++) {
2650
- if (!this._matchSegment(segments[i], this.path[i], i === this.path.length - 1)) {
2651
- return false;
2652
- }
2653
- }
2654
- return true;
2655
- }
2656
- /**
2657
- * @private
2658
- */
2659
- _matchWithDeepWildcard(segments) {
2660
- let pathIdx = this.path.length - 1;
2661
- let segIdx = segments.length - 1;
2662
- while (segIdx >= 0 && pathIdx >= 0) {
2663
- const segment = segments[segIdx];
2664
- if (segment.type === "deep-wildcard") {
2665
- segIdx--;
2666
- if (segIdx < 0) {
2667
- return true;
2668
- }
2669
- const nextSeg = segments[segIdx];
2670
- let found = false;
2671
- for (let i = pathIdx; i >= 0; i--) {
2672
- if (this._matchSegment(nextSeg, this.path[i], i === this.path.length - 1)) {
2673
- pathIdx = i - 1;
2674
- segIdx--;
2675
- found = true;
2676
- break;
2677
- }
2678
- }
2679
- if (!found) {
2680
- return false;
2681
- }
2682
- } else {
2683
- if (!this._matchSegment(segment, this.path[pathIdx], pathIdx === this.path.length - 1)) {
2684
- return false;
2685
- }
2686
- pathIdx--;
2687
- segIdx--;
2688
- }
2689
- }
2690
- return segIdx < 0;
2691
- }
2692
- /**
2693
- * @private
2694
- */
2695
- _matchSegment(segment, node, isCurrentNode) {
2696
- if (segment.tag !== "*" && segment.tag !== node.tag) {
2697
- return false;
2698
- }
2699
- if (segment.namespace !== void 0) {
2700
- if (segment.namespace !== "*" && segment.namespace !== node.namespace) {
2701
- return false;
2702
- }
2703
- }
2704
- if (segment.attrName !== void 0) {
2705
- if (!isCurrentNode) {
2706
- return false;
2707
- }
2708
- if (!node.values || !(segment.attrName in node.values)) {
2709
- return false;
2710
- }
2711
- if (segment.attrValue !== void 0) {
2712
- if (String(node.values[segment.attrName]) !== String(segment.attrValue)) {
2713
- return false;
2714
- }
2715
- }
2716
- }
2717
- if (segment.position !== void 0) {
2718
- if (!isCurrentNode) {
2719
- return false;
2720
- }
2721
- const counter = node.counter ?? 0;
2722
- if (segment.position === "first" && counter !== 0) {
2723
- return false;
2724
- } else if (segment.position === "odd" && counter % 2 !== 1) {
2725
- return false;
2726
- } else if (segment.position === "even" && counter % 2 !== 0) {
2727
- return false;
2728
- } else if (segment.position === "nth" && counter !== segment.positionValue) {
2729
- return false;
2730
- }
2731
- }
2732
- return true;
2733
- }
2734
- /**
2735
- * Match any expression in the given set against the current path.
2736
- * @param {ExpressionSet} exprSet
2737
- * @returns {boolean}
2738
- */
2739
- matchesAny(exprSet) {
2740
- return exprSet.matchesAny(this);
2741
- }
2742
- /**
2743
- * Create a snapshot of current state.
2744
- * @returns {Object}
2745
- */
2746
- snapshot() {
2747
- return {
2748
- path: this.path.map((node) => ({ ...node })),
2749
- siblingStacks: this.siblingStacks.map((level) => level ? { counts: new Map(level.counts), total: level.total } : level),
2750
- keptAttrs: this._keptAttrs.map((entry) => ({ ...entry }))
2751
- };
2752
- }
2753
- /**
2754
- * Restore state from snapshot.
2755
- * @param {Object} snapshot
2756
- */
2757
- restore(snapshot) {
2758
- this._pathStringCache = null;
2759
- this.path = snapshot.path.map((node) => ({ ...node }));
2760
- this.siblingStacks = snapshot.siblingStacks.map((level) => level ? { counts: new Map(level.counts), total: level.total } : level);
2761
- this._keptAttrs = (snapshot.keptAttrs || []).map((entry) => ({ ...entry }));
2762
- }
2763
- /**
2764
- * Return the read-only {@link MatcherView} for this matcher.
2765
- *
2766
- * The same instance is returned on every call — no allocation occurs.
2767
- * It always reflects the current parser state and is safe to pass to
2768
- * user callbacks without risk of accidental mutation.
2769
- *
2770
- * @returns {MatcherView}
2771
- *
2772
- * @example
2773
- * const view = matcher.readOnly();
2774
- * // pass view to callbacks — it stays in sync automatically
2775
- * view.matches(expr); // ✓
2776
- * view.getCurrentTag(); // ✓
2777
- * // view.push(...) // ✗ method does not exist — caught by TypeScript
2778
- */
2779
- readOnly() {
2780
- return this._view;
2781
- }
2782
- };
2783
-
2784
- // ../../node_modules/is-unsafe/src/contexts/html.js
2785
- var HTML_PATTERNS = [
2786
- {
2787
- id: "html-script-open",
2788
- description: "<script opening tag",
2789
- pattern: /<script[\s>/]/i
2790
- },
2791
- {
2792
- id: "html-script-close",
2793
- description: "</script closing tag",
2794
- pattern: /<\/script[\s>]/i
2795
- },
2796
- {
2797
- id: "html-javascript-protocol",
2798
- description: "javascript: URI scheme (with optional whitespace/encoding)",
2799
- // Handles j&#x61;vascript:, j\u0061vascript:, and whitespace variants
2800
- pattern: /j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i
2801
- },
2802
- {
2803
- id: "html-vbscript-protocol",
2804
- description: "vbscript: URI scheme",
2805
- pattern: /vbscript[\t\n\r ]*:/i
2806
- },
2807
- {
2808
- id: "html-data-html",
2809
- description: "data:text/html URI \u2014 can execute scripts in browsers",
2810
- pattern: /data[\t\n\r ]*:[\t\n\r ]*text\/html/i
2811
- },
2812
- {
2813
- id: "html-data-xhtml",
2814
- description: "data:application/xhtml+xml URI",
2815
- pattern: /data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i
2816
- },
2817
- {
2818
- id: "html-data-svg",
2819
- description: "data:image/svg+xml URI \u2014 can execute scripts",
2820
- pattern: /data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i
2821
- },
2822
- {
2823
- id: "html-inline-event-handler",
2824
- description: "Inline event handler attributes: onclick=, onerror=, onload=, etc.",
2825
- // \bon ensures we match a word boundary so "phonetic=" is not caught
2826
- pattern: /\bon\w{1,30}\s*=/i
2827
- },
2828
- {
2829
- id: "html-entity-obfuscated-script",
2830
- description: "HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",
2831
- // Entities include optional trailing semicolon: &#x3C; or &#x3C (both valid in HTML5)
2832
- pattern: /(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i
2833
- },
2834
- {
2835
- id: "html-entity-obfuscated-javascript",
2836
- description: 'HTML-entity-encoded javascript: (partial \u2014 catches common &#106; or &#x6a; for "j")',
2837
- pattern: /(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i
2838
- },
2839
- {
2840
- id: "html-style-expression",
2841
- description: "CSS expression() \u2014 IE-era code execution in style attributes",
2842
- pattern: /style[\s\S]{0,20}expression\s*\(/i
2843
- },
2844
- {
2845
- id: "html-object-embed",
2846
- description: "<object or <embed tags that can load active content",
2847
- pattern: /<(?:object|embed)[\s>/]/i
2848
- },
2849
- {
2850
- id: "html-base-tag",
2851
- description: "<base href= \u2014 can hijack all relative URLs on a page",
2852
- pattern: /<base[\s>]/i
2853
- },
2854
- {
2855
- id: "html-meta-refresh",
2856
- description: '<meta http-equiv="refresh" \u2014 can redirect users',
2857
- pattern: /<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i
2858
- },
2859
- {
2860
- id: "html-srcdoc",
2861
- description: "srcdoc= attribute on iframes \u2014 embeds HTML that can run scripts",
2862
- pattern: /srcdoc\s*=/i
2863
- },
2864
- {
2865
- id: "html-iframe",
2866
- description: "<iframe tag",
2867
- pattern: /<iframe[\s>/]/i
2868
- },
2869
- {
2870
- id: "html-form",
2871
- description: "<form tag \u2014 can be used for phishing / credential harvesting injection",
2872
- pattern: /<form[\s>/]/i
2873
- }
2874
- ];
2875
- var html_default = HTML_PATTERNS;
2876
-
2877
- // ../../node_modules/is-unsafe/src/contexts/xml.js
2878
- var XML_PATTERNS = [
2879
- {
2880
- id: "xml-cdata-injection",
2881
- description: "CDATA section injection: <![CDATA[ breaks out of text node context",
2882
- pattern: /<!\[CDATA\[/i
2883
- },
2884
- {
2885
- id: "xml-cdata-close",
2886
- description: "CDATA close sequence: ]]> can terminate an enclosing CDATA section",
2887
- pattern: /\]\]>/
2888
- },
2889
- {
2890
- id: "xml-processing-instruction",
2891
- description: "XML processing instruction: <?xml-stylesheet or <?php etc.",
2892
- pattern: /<\?(?:xml[\- ]|php|asp)/i
2893
- },
2894
- {
2895
- id: "xml-doctype-injection",
2896
- description: "DOCTYPE declaration embedded in content \u2014 can define entities",
2897
- // Match <!DOCTYPE followed by end-of-string, whitespace, or [ (internal subset)
2898
- pattern: /<!DOCTYPE(?:[\s[]|$)/i
2899
- },
2900
- {
2901
- id: "xml-entity-system",
2902
- description: "SYSTEM keyword \u2014 used in external entity declarations (XXE)",
2903
- pattern: /\bSYSTEM\s+["']/i
2904
- },
2905
- {
2906
- id: "xml-entity-public",
2907
- description: "PUBLIC keyword \u2014 used in external entity declarations (XXE)",
2908
- pattern: /\bPUBLIC\s+["']/i
2909
- },
2910
- {
2911
- id: "xml-entity-declaration",
2912
- description: "<!ENTITY declaration \u2014 defines entities, potential XXE or entity expansion",
2913
- pattern: /<!ENTITY[\s%]/i
2914
- },
2915
- {
2916
- id: "xml-billion-laughs",
2917
- description: "Entity reference chaining / billion laughs: repeated &eX; style references",
2918
- // Heuristic: 3+ consecutive entity refs suggests expansion attack
2919
- pattern: /(?:&\w{1,20};){3,}/
2920
- },
2921
- {
2922
- id: "xml-namespace-confusion",
2923
- description: "xmlns: attribute injection \u2014 can redefine namespaces to confuse parsers",
2924
- // pattern: /\bxmlns\s*(?::\w{1,40})?\s*=/i,
2925
- pattern: /\bxmlns(?::\w{1,40})?\s*=/i
2926
- },
2927
- {
2928
- id: "xml-comment-injection",
2929
- description: "<!-- comment injection \u2014 can hide content from some parsers",
2930
- pattern: /<!--/
2931
- },
2932
- {
2933
- id: "xml-comment-close",
2934
- description: "--> closes an enclosing XML comment",
2935
- pattern: /-->/
2936
- },
2937
- {
2938
- id: "xml-pi-close",
2939
- description: "?> closes an enclosing processing instruction",
2940
- pattern: /\?>/
2941
- }
2942
- ];
2943
- var xml_default = XML_PATTERNS;
2944
-
2945
- // ../../node_modules/is-unsafe/src/contexts/svg.js
2946
- var SVG_PATTERNS = [
2947
- {
2948
- id: "svg-script-element",
2949
- description: "<script element inside SVG executes JavaScript",
2950
- pattern: /<script[\s>/]/i
2951
- },
2952
- {
2953
- id: "svg-xlink-href-javascript",
2954
- description: "xlink:href with javascript: \u2014 classic SVG XSS via <a> or <use>",
2955
- pattern: /xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i
2956
- },
2957
- {
2958
- id: "svg-href-javascript",
2959
- description: "href= with javascript: in SVG context (<a>, <animate>, etc.)",
2960
- pattern: /href\s*=\s*["']?\s*javascript\s*:/i
2961
- },
2962
- {
2963
- id: "svg-foreignobject",
2964
- description: "<foreignObject embeds HTML inside SVG \u2014 can execute scripts",
2965
- pattern: /<foreignObject[\s>/]/i
2966
- },
2967
- {
2968
- id: "svg-use-external",
2969
- description: "<use xlink:href or href pointing to external resource (non-fragment URL)",
2970
- // Match <use with href= where the value starts with a non-# character (external URL)
2971
- // [\"'][^#] catches quoted values not starting with #; [^\"'#\s>] catches unquoted
2972
- pattern: /<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i
2973
- },
2974
- {
2975
- id: "svg-animate-href",
2976
- description: '<animate attributeName="href" \u2014 can dynamically change href to javascript:',
2977
- pattern: /<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i
2978
- },
2979
- {
2980
- id: "svg-animate-xlinkhref",
2981
- description: '<animate attributeName="xlink:href"',
2982
- pattern: /<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i
2983
- },
2984
- {
2985
- id: "svg-set-javascript",
2986
- description: '<set to="javascript:..." \u2014 sets an attribute to a javascript: URI',
2987
- pattern: /<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i
2988
- },
2989
- {
2990
- id: "svg-event-handler",
2991
- description: "SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",
2992
- pattern: /\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i
2993
- },
2994
- {
2995
- id: "svg-handler-generic",
2996
- description: "Generic on* handler catch-all for SVG attributes",
2997
- pattern: /\bon\w{1,30}\s*=/i
2998
- },
2999
- {
3000
- id: "svg-filter-feimage",
3001
- description: "<feImage href= \u2014 filter primitive that can load external resources",
3002
- pattern: /<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i
3003
- },
3004
- {
3005
- id: "svg-image-external",
3006
- description: "<image xlink:href with http/https or javascript protocol",
3007
- pattern: /<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i
3008
- },
3009
- {
3010
- id: "svg-style-javascript",
3011
- description: "style= attribute containing javascript: (e.g. background:url(javascript:...))",
3012
- pattern: /style\s*=[\s\S]{0,60}javascript\s*:/i
3013
- }
3014
- ];
3015
- var svg_default = SVG_PATTERNS;
3016
-
3017
- // ../../node_modules/is-unsafe/src/contexts/sql.js
3018
- var SQL_PATTERNS = [
3019
- {
3020
- id: "sql-block-comment-open",
3021
- description: "SQL block comment open: /* ... */ \u2014 unusual in legitimate user text",
3022
- pattern: /\/\*/
3023
- },
3024
- {
3025
- id: "sql-union-select",
3026
- description: "UNION SELECT \u2014 most common SQL injection aggregation attack",
3027
- pattern: /\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i
3028
- },
3029
- {
3030
- id: "sql-drop-table",
3031
- description: "DROP TABLE \u2014 destructive DDL injection",
3032
- pattern: /\bDROP\s{1,20}TABLE\b/i
3033
- },
3034
- {
3035
- id: "sql-drop-database",
3036
- description: "DROP DATABASE \u2014 destructive DDL injection",
3037
- pattern: /\bDROP\s{1,20}DATABASE\b/i
3038
- },
3039
- {
3040
- id: "sql-insert-into",
3041
- description: "INSERT INTO \u2014 data injection",
3042
- pattern: /\bINSERT\s{1,20}INTO\b/i
3043
- },
3044
- {
3045
- id: "sql-delete-from",
3046
- description: "DELETE FROM \u2014 data deletion injection",
3047
- pattern: /\bDELETE\s{1,20}FROM\b/i
3048
- },
3049
- {
3050
- id: "sql-update-set",
3051
- description: "UPDATE ... SET \u2014 data modification injection",
3052
- // Allows arbitrary content between UPDATE and SET (table name, alias, etc.)
3053
- pattern: /\bUPDATE\b[\s\S]{1,60}\bSET\b/i
3054
- },
3055
- {
3056
- id: "sql-exec-xp",
3057
- description: "EXEC xp_ \u2014 MSSQL extended stored procedure execution",
3058
- pattern: /\bEXEC(?:UTE)?\s{1,20}xp_/i
3059
- },
3060
- {
3061
- id: "sql-tautology-string",
3062
- description: `Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,
3063
- // Last quote is optional — injection may truncate it: ' OR '1'='1--
3064
- pattern: /'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i
3065
- },
3066
- {
3067
- id: "sql-tautology-numeric",
3068
- description: "Numeric tautology: OR 1=1",
3069
- pattern: /\bOR\s{1,10}1\s*=\s*1\b/i
3070
- },
3071
- {
3072
- id: "sql-always-true-zero",
3073
- description: "Numeric tautology: OR 0=0",
3074
- pattern: /\bOR\s{1,10}0\s*=\s*0\b/i
3075
- },
3076
- {
3077
- id: "sql-sleep-benchmark",
3078
- description: "Time-based blind injection: SLEEP() or BENCHMARK()",
3079
- pattern: /\b(?:SLEEP|BENCHMARK)\s*\(/i
3080
- },
3081
- {
3082
- id: "sql-waitfor-delay",
3083
- description: "MSSQL time-based blind injection: WAITFOR DELAY",
3084
- pattern: /\bWAITFOR\s{1,20}DELAY\b/i
3085
- },
3086
- {
3087
- id: "sql-char-function",
3088
- description: "CHAR() function \u2014 used to obfuscate injected strings",
3089
- pattern: /\bCHAR\s*\(\s*\d{1,3}/i
3090
- },
3091
- {
3092
- id: "sql-information-schema",
3093
- description: "INFORMATION_SCHEMA \u2014 reconnaissance query for table/column enumeration",
3094
- pattern: /\bINFORMATION_SCHEMA\b/i
3095
- }
3096
- ];
3097
- var sql_default = SQL_PATTERNS;
3098
-
3099
- // ../../node_modules/is-unsafe/src/contexts/shell.js
3100
- var SHELL_PATTERNS = [
3101
- {
3102
- id: "shell-path-traversal-unix",
3103
- description: "Unix path traversal: ../ \u2014 climbing the directory tree",
3104
- pattern: /\.\.\//
3105
- },
3106
- {
3107
- id: "shell-path-traversal-windows",
3108
- description: "Windows path traversal: ..\\ \u2014 climbing the directory tree",
3109
- pattern: /\.\.\\/
3110
- },
3111
- {
3112
- id: "shell-path-traversal-encoded",
3113
- description: "URL-encoded path traversal: %2e%2e or %2f variants",
3114
- pattern: /%2e%2e|%2f\.\.|\.\.%2f/i
3115
- },
3116
- {
3117
- id: "shell-null-byte",
3118
- description: "Null byte injection: \\x00 or %00 \u2014 truncates strings in C-backed functions",
3119
- pattern: /\x00|%00/
3120
- },
3121
- {
3122
- id: "shell-semicolon",
3123
- description: "Semicolon command separator: cmd1; cmd2",
3124
- pattern: /;/
3125
- },
3126
- {
3127
- id: "shell-pipe",
3128
- description: "Pipe operator: cmd1 | cmd2",
3129
- pattern: /\|/
3130
- },
3131
- {
3132
- id: "shell-and-operator",
3133
- description: "AND operator: cmd1 && cmd2",
3134
- pattern: /&&/
3135
- },
3136
- {
3137
- id: "shell-or-operator",
3138
- description: "OR operator: cmd1 || cmd2",
3139
- pattern: /\|\|/
3140
- },
3141
- {
3142
- id: "shell-backtick",
3143
- description: "Backtick command substitution: `cmd`",
3144
- pattern: /`/
3145
- },
3146
- {
3147
- id: "shell-dollar-paren",
3148
- description: "Dollar-paren command substitution: $(cmd)",
3149
- pattern: /\$\(/
3150
- },
3151
- {
3152
- id: "shell-dollar-brace",
3153
- description: "Dollar-brace variable expansion: ${var} \u2014 can be abused for injection",
3154
- pattern: /\$\{/
3155
- },
3156
- {
3157
- id: "shell-redirect-out",
3158
- description: "Output redirection: cmd > file or cmd >> file",
3159
- pattern: />{1,2}/
3160
- },
3161
- {
3162
- id: "shell-redirect-in",
3163
- description: "Input redirection: cmd < file",
3164
- pattern: /</
3165
- },
3166
- {
3167
- id: "shell-newline-injection",
3168
- description: "Newline injection: \\n or \\r \u2014 can inject new shell commands",
3169
- pattern: /[\n\r]/
3170
- },
3171
- {
3172
- id: "shell-glob-star",
3173
- description: "Glob expansion: * or ? \u2014 can expand to unintended files",
3174
- // Only flag when combined with path separators to reduce false positives
3175
- pattern: /[/\\][*?]/
3176
- },
3177
- {
3178
- id: "shell-absolute-root",
3179
- description: "Absolute root path injection: string starting with / or \\ (Windows UNC)",
3180
- pattern: /^(?:\/|\\\\)/
3181
- },
3182
- {
3183
- id: "shell-windows-drive",
3184
- description: "Windows drive letter path injection: C:\\ or D:/",
3185
- pattern: /^[a-zA-Z]:[/\\]/
3186
- },
3187
- {
3188
- id: "shell-curl-wget",
3189
- description: "curl/wget with URL or flags \u2014 can exfiltrate data or download payloads",
3190
- // Require a URL scheme (http/https/ftp) or a flag (-) to reduce false positives
3191
- // "curl is a tool" won't match; "curl http://..." or "curl -s ..." will
3192
- pattern: /\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i
3193
- }
3194
- ];
3195
- var shell_default = SHELL_PATTERNS;
3196
-
3197
- // ../../node_modules/is-unsafe/src/contexts/redos.js
3198
- var REDOS_PATTERNS = [
3199
- {
3200
- id: "redos-nested-quantifier-plus",
3201
- description: "Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",
3202
- // Matches any group containing a + quantifier, with an outer * or + — catches (a+)+, (.+b)*, etc.
3203
- pattern: /\([^)]*\+[^)]*\)[+*]/
3204
- },
3205
- {
3206
- id: "redos-nested-quantifier-star",
3207
- description: "Nested * quantifier: (a*)* or (a*)+ \u2014 catastrophic backtracking",
3208
- pattern: /\([^)]*\*[^)]*\)[*+]/
3209
- },
3210
- {
3211
- id: "redos-nested-groups",
3212
- description: "Doubly nested quantified groups: ((a+)+) \u2014 guaranteed catastrophic",
3213
- pattern: /\(\([^)]{0,40}\)[+*]\)[+*]/
3214
- },
3215
- {
3216
- id: "redos-alternation-overlap",
3217
- description: "Overlapping alternation under quantifier: (a|a)+ \u2014 ambiguous NFA paths",
3218
- // Detect repeated identical alternatives under a quantifier
3219
- pattern: /\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/
3220
- },
3221
- {
3222
- id: "redos-star-plus-concat",
3223
- description: "(x*x)+ pattern \u2014 triggers super-linear backtracking",
3224
- pattern: /\([^)]{0,10}\*[^)]{0,10}\)[+*]/
3225
- },
3226
- {
3227
- id: "redos-dot-star-greedy",
3228
- description: "(.*){n,} or (.+){n,} \u2014 repeated greedy dot quantifiers",
3229
- pattern: /\(\.[*+]\)\{?\d/
3230
- },
3231
- {
3232
- id: "redos-large-repetition",
3233
- description: "Very large fixed or range repetition count {1000,} or {1000,n} \u2014 denial of service via backtracking",
3234
- // Matches { followed by 4+ digits (≥1000), then optional ,digits }
3235
- pattern: /\{\d{4,}(?:,\d*)?\}/
3236
- },
3237
- {
3238
- id: "redos-catastrophic-alternation",
3239
- description: "Long alternation with many similar branches \u2014 polynomial backtracking risk",
3240
- // Heuristic: 10+ pipe-separated alternatives in a single group
3241
- pattern: /\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/
3242
- }
3243
- ];
3244
- var redos_default = REDOS_PATTERNS;
3245
-
3246
- // ../../node_modules/is-unsafe/src/contexts/nosql.js
3247
- var sep = `["'\\s]*:`;
3248
- var NOSQL_PATTERNS = [
3249
- // ─── MongoDB $ operator injection ────────────────────────────────────────
3250
- {
3251
- id: "nosql-where-operator",
3252
- description: "$where \u2014 executes arbitrary JavaScript server-side in MongoDB",
3253
- pattern: new RegExp(`\\$where${sep}`, "i")
3254
- },
3255
- {
3256
- id: "nosql-ne-operator",
3257
- description: '$ne \u2014 "not equal" operator used to bypass equality checks',
3258
- pattern: new RegExp(`\\$ne${sep}`, "i")
3259
- },
3260
- {
3261
- id: "nosql-gt-operator",
3262
- description: '$gt \u2014 "greater than" used to bypass password/value checks',
3263
- pattern: new RegExp(`\\$gte?${sep}`, "i")
3264
- },
3265
- {
3266
- id: "nosql-lt-operator",
3267
- description: '$lt / $lte \u2014 "less than" bypass variants',
3268
- pattern: new RegExp(`\\$lte?${sep}`, "i")
3269
- },
3270
- {
3271
- id: "nosql-regex-operator",
3272
- description: "$regex \u2014 can be used to extract data character by character (blind injection)",
3273
- pattern: new RegExp(`\\$regex${sep}`, "i")
3274
- },
3275
- {
3276
- id: "nosql-or-operator",
3277
- description: "$or \u2014 logical OR; used to create always-true conditions",
3278
- pattern: new RegExp(`\\$or${sep}\\s*\\[`, "i")
3279
- },
3280
- {
3281
- id: "nosql-and-operator",
3282
- description: "$and \u2014 logical AND operator injection",
3283
- pattern: new RegExp(`\\$and${sep}\\s*\\[`, "i")
3284
- },
3285
- {
3286
- id: "nosql-nor-operator",
3287
- description: "$nor \u2014 logical NOR operator injection",
3288
- pattern: new RegExp(`\\$nor${sep}\\s*\\[`, "i")
3289
- },
3290
- {
3291
- id: "nosql-exists-operator",
3292
- description: "$exists \u2014 can enumerate fields to determine schema",
3293
- pattern: new RegExp(`\\$exists${sep}`, "i")
3294
- },
3295
- {
3296
- id: "nosql-in-operator",
3297
- description: "$in \u2014 matches any value in a list; can enumerate values",
3298
- pattern: new RegExp(`\\$in${sep}\\s*\\[`, "i")
3299
- },
3300
- {
3301
- id: "nosql-expr-operator",
3302
- description: "$expr \u2014 allows aggregation expressions in queries (MongoDB 3.6+)",
3303
- pattern: new RegExp(`\\$expr${sep}`, "i")
3304
- },
3305
- {
3306
- id: "nosql-function-operator",
3307
- description: "$function \u2014 executes arbitrary JavaScript in MongoDB 4.4+",
3308
- pattern: new RegExp(`\\$function${sep}`, "i")
3309
- },
3310
- {
3311
- id: "nosql-accumulator-operator",
3312
- description: "$accumulator \u2014 custom aggregation with arbitrary JS execution",
3313
- pattern: new RegExp(`\\$accumulator${sep}`, "i")
3314
- },
3315
- // ─── Prototype pollution ─────────────────────────────────────────────────
3316
- {
3317
- id: "nosql-proto-pollution",
3318
- description: "__proto__ \u2014 prototype pollution via object key injection",
3319
- pattern: /__proto__/
3320
- },
3321
- {
3322
- id: "nosql-constructor-prototype",
3323
- description: "constructor.prototype \u2014 alternative prototype pollution vector (dot notation or JSON key)",
3324
- // Matches dot-notation (obj.constructor.prototype) and JSON key adjacency
3325
- // ("constructor": {"prototype": ...})
3326
- pattern: /constructor[\s"':.,{\[]*prototype/i
3327
- },
3328
- {
3329
- id: "nosql-proto-bracket",
3330
- description: '["__proto__"] \u2014 bracket-notation prototype pollution',
3331
- pattern: /\[["']__proto__["']\]/
3332
- }
3333
- ];
3334
- var nosql_default = NOSQL_PATTERNS;
3335
-
3336
- // ../../node_modules/is-unsafe/src/contexts/log.js
3337
- var LOG_PATTERNS = [
3338
- // ─── CRLF / newline injection ─────────────────────────────────────────────
3339
- {
3340
- id: "log-crlf-injection",
3341
- description: "CRLF injection: literal \\r or \\n embeds fake log lines",
3342
- pattern: /[\r\n]/
3343
- },
3344
- {
3345
- id: "log-url-encoded-crlf",
3346
- description: "URL-encoded CRLF: %0d, %0a, %0D, %0A \u2014 decoded by some log parsers",
3347
- pattern: /%0[dDaA]/
3348
- },
3349
- {
3350
- id: "log-unicode-newline",
3351
- description: "Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",
3352
- pattern: /[\u2028\u2029]/
3353
- },
3354
- // ─── Log4Shell / JNDI injection (CVE-2021-44228) ─────────────────────────
3355
- {
3356
- id: "log-log4shell-jndi",
3357
- description: "Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",
3358
- pattern: /\$\{jndi\s*:/i
3359
- },
3360
- {
3361
- id: "log-log4shell-obfuscated",
3362
- description: "Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",
3363
- // ${::- is the Log4j lookup-bypass escape sequence; presence alone is suspicious
3364
- pattern: /\$\{::-/
3365
- },
3366
- {
3367
- id: "log-log4j-lookup",
3368
- description: "Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} \u2014 data exfiltration",
3369
- pattern: /\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i
3370
- },
3371
- // ─── Server-Side Template Injection (SSTI) in log messages ───────────────
3372
- {
3373
- id: "log-ssti-double-brace",
3374
- description: "SSTI double-brace: {{expression}} \u2014 Jinja2, Twig, Handlebars, etc.",
3375
- pattern: /\{\{[\s\S]{0,80}\}\}/
3376
- },
3377
- {
3378
- id: "log-ssti-hash-brace",
3379
- description: "SSTI hash-brace: #{expression} \u2014 Thymeleaf, Velocity, Ruby ERB",
3380
- pattern: /#\{[\s\S]{0,80}\}/
3381
- },
3382
- {
3383
- id: "log-ssti-dollar-brace",
3384
- description: "SSTI/EL injection: ${expression with operators or method calls} \u2014 JSP EL, Freemarker, SpEL",
3385
- // Require that the ${...} content looks like an expression, not a plain variable name.
3386
- // Flags if the content contains: . ( * + operators, or known SSTI keywords.
3387
- // This avoids flagging ${PATH}, ${HOME} etc. (plain shell variables).
3388
- pattern: /\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i
3389
- },
3390
- {
3391
- id: "log-ssti-percent-tag",
3392
- description: "SSTI ERB/ASP tag: <%= expression %> \u2014 Ruby ERB, ASP",
3393
- pattern: /<%=[\s\S]{0,80}%>/
3394
- },
3395
- // ─── Null byte ────────────────────────────────────────────────────────────
3396
- {
3397
- id: "log-null-byte",
3398
- description: "Null byte: \\x00 or %00 \u2014 can truncate log entries in C-backed loggers",
3399
- pattern: /\x00|%00/
3400
- },
3401
- // ─── ANSI escape injection ────────────────────────────────────────────────
3402
- {
3403
- id: "log-ansi-escape",
3404
- description: "ANSI escape sequence: ESC[ \u2014 can manipulate terminal output when logs are tailed",
3405
- pattern: /\x1b\[/
3406
- }
3407
- ];
3408
- var log_default = LOG_PATTERNS;
3409
-
3410
- // ../../node_modules/is-unsafe/src/contexts/sql-strict.js
3411
- var SQL_STRICT_EXTRA = [
3412
- {
3413
- id: "sql-line-comment",
3414
- description: "SQL line comment: -- followed by whitespace or end of string",
3415
- pattern: /--(?:\s|$)/
3416
- },
3417
- {
3418
- id: "sql-stacked-query",
3419
- description: "Stacked queries: semicolon immediately followed by a SQL keyword",
3420
- pattern: /;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i
3421
- },
3422
- {
3423
- id: "sql-hex-encoding",
3424
- description: "Hex-encoded string injection: 0x41414141 style (MySQL)",
3425
- pattern: /\b0x[0-9a-f]{4,}/i
3426
- }
3427
- ];
3428
- var SQL_STRICT_PATTERNS = [...sql_default, ...SQL_STRICT_EXTRA];
3429
- var sql_strict_default = SQL_STRICT_PATTERNS;
3430
-
3431
- // ../../node_modules/is-unsafe/src/index.js
3432
- html_default.label = "HTML";
3433
- xml_default.label = "XML";
3434
- svg_default.label = "SVG";
3435
- sql_default.label = "SQL";
3436
- sql_strict_default.label = "SQL-STRICT";
3437
- shell_default.label = "SHELL";
3438
- redos_default.label = "REDOS";
3439
- nosql_default.label = "NOSQL";
3440
- log_default.label = "LOG";
3441
- var VALID_CONTEXTS = Object.freeze({
3442
- HTML: html_default,
3443
- XML: xml_default,
3444
- SVG: svg_default,
3445
- SQL: sql_default,
3446
- "SQL-STRICT": sql_strict_default,
3447
- SHELL: shell_default,
3448
- REDOS: redos_default,
3449
- NOSQL: nosql_default,
3450
- LOG: log_default
3451
- });
3452
- function assertString(value) {
3453
- if (typeof value !== "string") {
3454
- throw new TypeError(
3455
- `is-unsafe: first argument must be a string, got ${typeof value}`
165
+ if (result.cells) {
166
+ requireVTK(result.points, "cells require points");
167
+ const pointCount2 = result.points.length / 3;
168
+ requireVTK(
169
+ result.cells.connectivity.every((index) => index < pointCount2),
170
+ "vertex index out of range"
3456
171
  );
3457
172
  }
3458
- }
3459
- function assertContext(context) {
3460
- if (context instanceof RegExp) return;
3461
- if (Array.isArray(context)) {
3462
- if (context.length === 0) {
3463
- throw new TypeError("is-unsafe: context must not be an empty array");
3464
- }
3465
- if (Array.isArray(context[0])) {
3466
- for (const list of context) {
3467
- if (!Array.isArray(list) || list.length === 0) {
3468
- throw new TypeError(
3469
- "is-unsafe: each context in the array must be a non-empty pattern array (PatternList)"
3470
- );
3471
- }
3472
- }
3473
- }
3474
- return;
3475
- }
3476
- throw new TypeError(
3477
- `is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof context}`
3478
- );
3479
- }
3480
- function normalise(context) {
3481
- if (context instanceof RegExp) return { lists: null, regex: context };
3482
- if (Array.isArray(context[0])) return { lists: context, regex: null };
3483
- return { lists: [context], regex: null };
3484
- }
3485
- function matchList(value, list) {
3486
- const label = list.label ?? "CUSTOM";
3487
- for (const rule of list) {
3488
- if (rule.pattern.test(value)) {
3489
- return { context: label, id: rule.id, description: rule.description, pattern: rule.pattern };
3490
- }
3491
- }
3492
- return null;
3493
- }
3494
- function isUnsafe(value, context) {
3495
- assertString(value);
3496
- assertContext(context);
3497
- const { lists, regex } = normalise(context);
3498
- if (regex) return regex.test(value);
3499
- for (const list of lists) {
3500
- if (matchList(value, list) !== null) return true;
3501
- }
3502
- return false;
3503
- }
3504
-
3505
- // ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
3506
- function extractRawAttributes(prefixedAttrs, options) {
3507
- if (!prefixedAttrs) return {};
3508
- const attrs = options.attributesGroupName ? prefixedAttrs[options.attributesGroupName] : prefixedAttrs;
3509
- if (!attrs) return {};
3510
- const rawAttrs = {};
3511
- for (const key in attrs) {
3512
- if (key.startsWith(options.attributeNamePrefix)) {
3513
- const rawName = key.substring(options.attributeNamePrefix.length);
3514
- rawAttrs[rawName] = attrs[key];
3515
- } else {
3516
- rawAttrs[key] = attrs[key];
3517
- }
3518
- }
3519
- return rawAttrs;
3520
- }
3521
- function extractNamespace(rawTagName) {
3522
- if (!rawTagName || typeof rawTagName !== "string") return void 0;
3523
- const colonIndex = rawTagName.indexOf(":");
3524
- if (colonIndex !== -1 && colonIndex > 0) {
3525
- const ns = rawTagName.substring(0, colonIndex);
3526
- if (ns !== "xmlns") {
3527
- return ns;
3528
- }
3529
- }
3530
- return void 0;
3531
- }
3532
- var OrderedObjParser = class {
3533
- constructor(options, externalEntities) {
3534
- this.options = options;
3535
- this.currentNode = null;
3536
- this.tagsNodeStack = [];
3537
- this.parseXml = parseXml;
3538
- this.parseTextData = parseTextData;
3539
- this.resolveNameSpace = resolveNameSpace;
3540
- this.buildAttributesMap = buildAttributesMap;
3541
- this.isItStopNode = isItStopNode;
3542
- this.replaceEntitiesValue = replaceEntitiesValue;
3543
- this.readStopNodeData = readStopNodeData;
3544
- this.saveTextToParentTag = saveTextToParentTag;
3545
- this.addChild = addChild;
3546
- this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
3547
- this.entityExpansionCount = 0;
3548
- this.currentExpandedLength = 0;
3549
- this.doctypefound = false;
3550
- let namedEntities = { ...XML };
3551
- if (this.options.entityDecoder) {
3552
- this.entityDecoder = this.options.entityDecoder;
3553
- } else {
3554
- if (typeof this.options.htmlEntities === "object") namedEntities = this.options.htmlEntities;
3555
- else if (this.options.htmlEntities === true) namedEntities = { ...COMMON_HTML, ...CURRENCY };
3556
- this.entityDecoder = new EntityDecoder({
3557
- namedEntities: { ...namedEntities, ...externalEntities },
3558
- numericAllowed: this.options.htmlEntities,
3559
- limit: {
3560
- maxTotalExpansions: this.options.processEntities.maxTotalExpansions,
3561
- maxExpandedLength: this.options.processEntities.maxExpandedLength,
3562
- applyLimitsTo: this.options.processEntities.appliesTo
3563
- },
3564
- // onExternalEntity: (name, value) => isUnsafe(value) ? 'block' : 'allow',
3565
- onInputEntity: (name, value) => (
3566
- //TODO: VALID_CONTEXTS.HTML should be set only if this.options.htmlEntities
3567
- isUnsafe(value, [html_default, xml_default]) ? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW
3568
- )
3569
- //postCheck: resolved => resolved
3570
- });
3571
- }
3572
- this.matcher = new Matcher();
3573
- this.readonlyMatcher = this.matcher.readOnly();
3574
- this.isCurrentNodeStopNode = false;
3575
- this.stopNodeExpressionsSet = new ExpressionSet();
3576
- const stopNodesOpts = this.options.stopNodes;
3577
- if (stopNodesOpts && stopNodesOpts.length > 0) {
3578
- for (let i = 0; i < stopNodesOpts.length; i++) {
3579
- const stopNodeExp = stopNodesOpts[i];
3580
- if (typeof stopNodeExp === "string") {
3581
- this.stopNodeExpressionsSet.add(new Expression(stopNodeExp));
3582
- } else if (stopNodeExp instanceof Expression) {
3583
- this.stopNodeExpressionsSet.add(stopNodeExp);
3584
- }
3585
- }
3586
- this.stopNodeExpressionsSet.seal();
3587
- }
3588
- }
3589
- };
3590
- function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
3591
- const options = this.options;
3592
- if (val !== void 0) {
3593
- if (options.trimValues && !dontTrim) {
3594
- val = val.trim();
3595
- }
3596
- if (val.length > 0) {
3597
- if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
3598
- const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
3599
- const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
3600
- if (newval === null || newval === void 0) {
3601
- return val;
3602
- } else if (typeof newval !== typeof val || newval !== val) {
3603
- return newval;
3604
- } else if (options.trimValues) {
3605
- return parseValue(val, options.parseTagValue, options.numberParseOptions);
3606
- } else {
3607
- const trimmedVal = val.trim();
3608
- if (trimmedVal === val) {
3609
- return parseValue(val, options.parseTagValue, options.numberParseOptions);
3610
- } else {
3611
- return val;
3612
- }
3613
- }
3614
- }
3615
- }
3616
- }
3617
- function resolveNameSpace(tagname) {
3618
- if (this.options.removeNSPrefix) {
3619
- const tags = tagname.split(":");
3620
- const prefix = tagname.charAt(0) === "/" ? "/" : "";
3621
- if (tags[0] === "xmlns") {
3622
- return "";
3623
- }
3624
- if (tags.length === 2) {
3625
- tagname = prefix + tags[1];
3626
- }
3627
- }
3628
- return tagname;
3629
- }
3630
- var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
3631
- function buildAttributesMap(attrStr, jPath, tagName, force = false) {
3632
- const options = this.options;
3633
- if (force === true || options.ignoreAttributes !== true && typeof attrStr === "string") {
3634
- const matches = getAllMatches(attrStr, attrsRegx);
3635
- const len = matches.length;
3636
- const attrs = {};
3637
- const processedVals = new Array(len);
3638
- let hasRawAttrs = false;
3639
- const rawAttrsForMatcher = {};
3640
- for (let i = 0; i < len; i++) {
3641
- const attrName = this.resolveNameSpace(matches[i][1]);
3642
- const oldVal = matches[i][4];
3643
- if (attrName.length && oldVal !== void 0) {
3644
- let val = oldVal;
3645
- if (options.trimValues) val = val.trim();
3646
- val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
3647
- processedVals[i] = val;
3648
- rawAttrsForMatcher[attrName] = val;
3649
- hasRawAttrs = true;
3650
- }
3651
- }
3652
- if (hasRawAttrs && typeof jPath === "object" && jPath.updateCurrent) {
3653
- jPath.updateCurrent(rawAttrsForMatcher);
3654
- }
3655
- const jPathStr = options.jPath ? jPath.toString() : this.readonlyMatcher;
3656
- let hasAttrs = false;
3657
- for (let i = 0; i < len; i++) {
3658
- const attrName = this.resolveNameSpace(matches[i][1]);
3659
- if (this.ignoreAttributesFn(attrName, jPathStr)) continue;
3660
- let aName = options.attributeNamePrefix + attrName;
3661
- if (attrName.length) {
3662
- if (options.transformAttributeName) {
3663
- aName = options.transformAttributeName(aName);
3664
- }
3665
- aName = sanitizeName(aName, options);
3666
- if (matches[i][4] !== void 0) {
3667
- const oldVal = processedVals[i];
3668
- const newVal = options.attributeValueProcessor(attrName, oldVal, jPathStr);
3669
- if (newVal === null || newVal === void 0) {
3670
- attrs[aName] = oldVal;
3671
- } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
3672
- attrs[aName] = newVal;
3673
- } else {
3674
- attrs[aName] = parseValue(oldVal, options.parseAttributeValue, options.numberParseOptions);
3675
- }
3676
- hasAttrs = true;
3677
- } else if (options.allowBooleanAttributes) {
3678
- attrs[aName] = true;
3679
- hasAttrs = true;
3680
- }
3681
- }
3682
- }
3683
- if (!hasAttrs) return;
3684
- if (options.attributesGroupName && !options.preserveOrder) {
3685
- const attrCollection = {};
3686
- attrCollection[options.attributesGroupName] = attrs;
3687
- return attrCollection;
3688
- }
3689
- return attrs;
3690
- }
3691
- }
3692
- var parseXml = function(xmlData) {
3693
- xmlData = xmlData.replace(/\r\n?/g, "\n");
3694
- const xmlObj = new XmlNode("!xml");
3695
- let currentNode = xmlObj;
3696
- let textData = "";
3697
- this.matcher.reset();
3698
- this.entityDecoder.reset();
3699
- this.entityExpansionCount = 0;
3700
- this.currentExpandedLength = 0;
3701
- this.doctypefound = false;
3702
- const options = this.options;
3703
- const docTypeReader = new DocTypeReader(options.processEntities);
3704
- const xmlLen = xmlData.length;
3705
- for (let i = 0; i < xmlLen; i++) {
3706
- const ch = xmlData[i];
3707
- if (ch === "<") {
3708
- const c1 = xmlData.charCodeAt(i + 1);
3709
- if (c1 === 47) {
3710
- const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
3711
- let tagName = xmlData.substring(i + 2, closeIndex).trim();
3712
- if (options.removeNSPrefix) {
3713
- const colonIndex = tagName.indexOf(":");
3714
- if (colonIndex !== -1) {
3715
- tagName = tagName.substr(colonIndex + 1);
3716
- }
3717
- }
3718
- tagName = transformTagName(options.transformTagName, tagName, "", options).tagName;
3719
- if (currentNode) {
3720
- textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3721
- }
3722
- const lastTagName = this.matcher.getCurrentTag();
3723
- if (tagName && options.unpairedTagsSet.has(tagName)) {
3724
- throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
3725
- }
3726
- if (lastTagName && options.unpairedTagsSet.has(lastTagName)) {
3727
- this.matcher.pop();
3728
- this.tagsNodeStack.pop();
3729
- }
3730
- this.matcher.pop();
3731
- this.isCurrentNodeStopNode = false;
3732
- currentNode = this.tagsNodeStack.pop() || xmlObj;
3733
- if (options.captureMetaData && currentNode) {
3734
- currentNode.addEndIndex(closeIndex + 1);
3735
- }
3736
- textData = "";
3737
- i = closeIndex;
3738
- } else if (c1 === 63) {
3739
- let tagData = readTagExp(xmlData, i, false, "?>");
3740
- if (!tagData) throw new Error("Pi Tag is not closed.");
3741
- textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3742
- const attsMap = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName, true);
3743
- if (attsMap) {
3744
- const ver = attsMap[this.options.attributeNamePrefix + "version"];
3745
- this.entityDecoder.setXmlVersion(Number(ver) || 1);
3746
- docTypeReader.setXmlVersion(Number(ver) || 1);
3747
- }
3748
- if (options.ignoreDeclaration && tagData.tagName === "?xml" || options.ignorePiTags) {
3749
- } else {
3750
- const childNode = new XmlNode(tagData.tagName);
3751
- childNode.add(options.textNodeName, "");
3752
- if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent && options.ignoreAttributes !== true) {
3753
- childNode[":@"] = attsMap;
3754
- }
3755
- this.addChild(currentNode, childNode, this.readonlyMatcher, i);
3756
- if (options.captureMetaData) {
3757
- currentNode.addEndIndex(tagData.closeIndex + 2);
3758
- }
3759
- }
3760
- i = tagData.closeIndex + 1;
3761
- } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
3762
- const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
3763
- if (options.commentPropName) {
3764
- const comment = xmlData.substring(i + 4, endIndex - 2);
3765
- textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3766
- currentNode.add(options.commentPropName, [{ [options.textNodeName]: comment }]);
3767
- }
3768
- i = endIndex;
3769
- } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 68) {
3770
- if (this.doctypefound) throw new Error("Multiple DOCTYPE declarations found.");
3771
- this.doctypefound = true;
3772
- const result = docTypeReader.readDocType(xmlData, i);
3773
- this.entityDecoder.addInputEntities(result.entities);
3774
- i = result.i;
3775
- } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
3776
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
3777
- const tagExp = xmlData.substring(i + 9, closeIndex);
3778
- textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
3779
- let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
3780
- if (val == void 0) val = "";
3781
- if (options.cdataPropName) {
3782
- currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
3783
- } else {
3784
- currentNode.add(options.textNodeName, val);
3785
- }
3786
- i = closeIndex + 2;
3787
- } else {
3788
- let result = readTagExp(xmlData, i, options.removeNSPrefix);
3789
- if (!result) {
3790
- const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlLen, i + 50));
3791
- throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
3792
- }
3793
- let tagName = result.tagName;
3794
- const rawTagName = result.rawTagName;
3795
- let tagExp = result.tagExp;
3796
- let attrExpPresent = result.attrExpPresent;
3797
- let closeIndex = result.closeIndex;
3798
- ({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
3799
- if (options.strictReservedNames && (tagName === options.commentPropName || tagName === options.cdataPropName || tagName === options.textNodeName || tagName === options.attributesGroupName)) {
3800
- throw new Error(`Invalid tag name: ${tagName}`);
3801
- }
3802
- if (currentNode && textData) {
3803
- if (currentNode.tagname !== "!xml") {
3804
- textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
3805
- }
3806
- }
3807
- const lastTag = currentNode;
3808
- if (lastTag && options.unpairedTagsSet.has(lastTag.tagname)) {
3809
- currentNode = this.tagsNodeStack.pop();
3810
- this.matcher.pop();
3811
- }
3812
- let isSelfClosing = false;
3813
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
3814
- isSelfClosing = true;
3815
- if (tagName[tagName.length - 1] === "/") {
3816
- tagName = tagName.substr(0, tagName.length - 1);
3817
- tagExp = tagName;
3818
- } else {
3819
- tagExp = tagExp.substr(0, tagExp.length - 1);
3820
- }
3821
- attrExpPresent = tagName !== tagExp;
3822
- }
3823
- let prefixedAttrs = null;
3824
- let rawAttrs = {};
3825
- let namespace = void 0;
3826
- namespace = extractNamespace(rawTagName);
3827
- if (tagName !== xmlObj.tagname) {
3828
- this.matcher.push(tagName, {}, namespace);
3829
- }
3830
- if (tagName !== tagExp && attrExpPresent) {
3831
- prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
3832
- if (prefixedAttrs) {
3833
- rawAttrs = extractRawAttributes(prefixedAttrs, options);
3834
- }
3835
- }
3836
- if (tagName !== xmlObj.tagname) {
3837
- this.isCurrentNodeStopNode = this.isItStopNode();
3838
- }
3839
- const startIndex = i;
3840
- if (this.isCurrentNodeStopNode) {
3841
- let tagContent = "";
3842
- if (isSelfClosing) {
3843
- i = result.closeIndex;
3844
- } else if (options.unpairedTagsSet.has(tagName)) {
3845
- i = result.closeIndex;
3846
- } else {
3847
- const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
3848
- if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
3849
- i = result2.i;
3850
- tagContent = result2.tagContent;
3851
- }
3852
- const childNode = new XmlNode(tagName);
3853
- if (prefixedAttrs) {
3854
- childNode[":@"] = prefixedAttrs;
3855
- }
3856
- childNode.add(options.textNodeName, tagContent);
3857
- this.matcher.pop();
3858
- this.isCurrentNodeStopNode = false;
3859
- this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3860
- if (options.captureMetaData) {
3861
- currentNode.addEndIndex(i + 1);
3862
- }
3863
- } else {
3864
- if (isSelfClosing) {
3865
- ({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
3866
- const childNode = new XmlNode(tagName);
3867
- if (prefixedAttrs) {
3868
- childNode[":@"] = prefixedAttrs;
3869
- }
3870
- this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3871
- if (options.captureMetaData) {
3872
- currentNode.addEndIndex(closeIndex + 1);
3873
- }
3874
- this.matcher.pop();
3875
- this.isCurrentNodeStopNode = false;
3876
- } else if (options.unpairedTagsSet.has(tagName)) {
3877
- const childNode = new XmlNode(tagName);
3878
- if (prefixedAttrs) {
3879
- childNode[":@"] = prefixedAttrs;
3880
- }
3881
- this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3882
- if (options.captureMetaData) {
3883
- currentNode.addEndIndex(result.closeIndex + 1);
3884
- }
3885
- this.matcher.pop();
3886
- this.isCurrentNodeStopNode = false;
3887
- i = result.closeIndex;
3888
- continue;
3889
- } else {
3890
- const childNode = new XmlNode(tagName);
3891
- if (this.tagsNodeStack.length > options.maxNestedTags) {
3892
- throw new Error("Maximum nested tags exceeded");
3893
- }
3894
- this.tagsNodeStack.push(currentNode);
3895
- if (prefixedAttrs) {
3896
- childNode[":@"] = prefixedAttrs;
3897
- }
3898
- this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
3899
- currentNode = childNode;
3900
- }
3901
- textData = "";
3902
- i = closeIndex;
3903
- }
3904
- }
3905
- } else {
3906
- textData += xmlData[i];
3907
- }
3908
- }
3909
- return xmlObj.child;
3910
- };
3911
- function addChild(currentNode, childNode, matcher, startIndex) {
3912
- if (!this.options.captureMetaData) startIndex = void 0;
3913
- const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher;
3914
- const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]);
3915
- if (result === false) {
3916
- } else if (typeof result === "string") {
3917
- childNode.tagname = result;
3918
- currentNode.addChild(childNode, startIndex);
3919
- } else {
3920
- currentNode.addChild(childNode, startIndex);
3921
- }
3922
- }
3923
- function replaceEntitiesValue(val, tagName, jPath) {
3924
- const entityConfig = this.options.processEntities;
3925
- if (!entityConfig || !entityConfig.enabled) {
3926
- return val;
3927
- }
3928
- if (entityConfig.allowedTags) {
3929
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
3930
- const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
3931
- if (!allowed) {
3932
- return val;
3933
- }
3934
- }
3935
- if (entityConfig.tagFilter) {
3936
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
3937
- if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
3938
- return val;
3939
- }
3940
- }
3941
- return this.entityDecoder.decode(val);
3942
- }
3943
- function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
3944
- if (textData) {
3945
- if (isLeafNode === void 0) isLeafNode = parentNode.child.length === 0;
3946
- textData = this.parseTextData(
3947
- textData,
3948
- parentNode.tagname,
3949
- matcher,
3950
- false,
3951
- parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
3952
- isLeafNode
173
+ const pointCount = result.points ? result.points.length / 3 : result.dimensions?.reduce((product, dimension) => product * dimension, 1);
174
+ if (pointCount !== void 0) {
175
+ requireVTK(
176
+ result.pointData.every((array) => array.data.length / array.components === pointCount),
177
+ "point attribute count mismatch"
3953
178
  );
3954
- if (textData !== void 0 && textData !== "")
3955
- parentNode.add(this.options.textNodeName, textData);
3956
- textData = "";
3957
- }
3958
- return textData;
3959
- }
3960
- function isItStopNode() {
3961
- if (this.stopNodeExpressionsSet.size === 0) return false;
3962
- return this.matcher.matchesAny(this.stopNodeExpressionsSet);
3963
- }
3964
- function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
3965
- let attrBoundary = 0;
3966
- const len = xmlData.length;
3967
- const closeCode0 = closingChar.charCodeAt(0);
3968
- const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
3969
- let result = "";
3970
- let segmentStart = i;
3971
- for (let index = i; index < len; index++) {
3972
- const code = xmlData.charCodeAt(index);
3973
- if (attrBoundary) {
3974
- if (code === attrBoundary) attrBoundary = 0;
3975
- } else if (code === 34 || code === 39) {
3976
- attrBoundary = code;
3977
- } else if (code === closeCode0) {
3978
- if (closeCode1 !== -1) {
3979
- if (xmlData.charCodeAt(index + 1) === closeCode1) {
3980
- result += xmlData.substring(segmentStart, index);
3981
- return { data: result, index };
3982
- }
3983
- } else {
3984
- result += xmlData.substring(segmentStart, index);
3985
- return { data: result, index };
3986
- }
3987
- } else if (code === 9 && !attrBoundary) {
3988
- result += xmlData.substring(segmentStart, index) + " ";
3989
- segmentStart = index + 1;
3990
- }
3991
- }
3992
- }
3993
- function findClosingIndex(xmlData, str, i, errMsg) {
3994
- const closingIndex = xmlData.indexOf(str, i);
3995
- if (closingIndex === -1) {
3996
- throw new Error(errMsg);
3997
- } else {
3998
- return closingIndex + str.length - 1;
3999
- }
4000
- }
4001
- function findClosingChar(xmlData, char, i, errMsg) {
4002
- const closingIndex = xmlData.indexOf(char, i);
4003
- if (closingIndex === -1) throw new Error(errMsg);
4004
- return closingIndex;
4005
- }
4006
- function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
4007
- const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
4008
- if (!result) return;
4009
- let tagExp = result.data;
4010
- const closeIndex = result.index;
4011
- const separatorIndex = tagExp.search(/\s/);
4012
- let tagName = tagExp;
4013
- let attrExpPresent = true;
4014
- if (separatorIndex !== -1) {
4015
- tagName = tagExp.substring(0, separatorIndex);
4016
- tagExp = tagExp.substring(separatorIndex + 1).trimStart();
4017
- }
4018
- const rawTagName = tagName;
4019
- if (removeNSPrefix) {
4020
- const colonIndex = tagName.indexOf(":");
4021
- if (colonIndex !== -1) {
4022
- tagName = tagName.substr(colonIndex + 1);
4023
- attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
4024
- }
4025
- }
4026
- return {
4027
- tagName,
4028
- tagExp,
4029
- closeIndex,
4030
- attrExpPresent,
4031
- rawTagName
4032
- };
4033
- }
4034
- function readStopNodeData(xmlData, tagName, i) {
4035
- const startIndex = i;
4036
- let openTagCount = 1;
4037
- const xmllen = xmlData.length;
4038
- for (; i < xmllen; i++) {
4039
- if (xmlData[i] === "<") {
4040
- const c1 = xmlData.charCodeAt(i + 1);
4041
- if (c1 === 47) {
4042
- const closeIndex = findClosingChar(xmlData, ">", i, `${tagName} is not closed`);
4043
- let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
4044
- if (closeTagName === tagName) {
4045
- openTagCount--;
4046
- if (openTagCount === 0) {
4047
- return {
4048
- tagContent: xmlData.substring(startIndex, i),
4049
- i: closeIndex
4050
- };
4051
- }
4052
- }
4053
- i = closeIndex;
4054
- } else if (c1 === 63) {
4055
- const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
4056
- i = closeIndex;
4057
- } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
4058
- const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
4059
- i = closeIndex;
4060
- } else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
4061
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
4062
- i = closeIndex;
4063
- } else {
4064
- const tagData = readTagExp(xmlData, i, false);
4065
- if (tagData) {
4066
- const openTagName = tagData && tagData.tagName;
4067
- if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
4068
- openTagCount++;
4069
- }
4070
- i = tagData.closeIndex;
4071
- }
4072
- }
4073
- }
4074
- }
4075
- }
4076
- function parseValue(val, shouldParse, options) {
4077
- if (shouldParse && typeof val === "string") {
4078
- const newval = val.trim();
4079
- if (newval === "true") return true;
4080
- else if (newval === "false") return false;
4081
- else return toNumber(val, options);
4082
- } else {
4083
- if (isExist(val)) {
4084
- return val;
4085
- } else {
4086
- return "";
4087
- }
4088
- }
4089
- }
4090
- function transformTagName(fn, tagName, tagExp, options) {
4091
- if (fn) {
4092
- const newTagName = fn(tagName);
4093
- if (tagExp === tagName) {
4094
- tagExp = newTagName;
4095
- }
4096
- tagName = newTagName;
4097
- }
4098
- tagName = sanitizeName(tagName, options);
4099
- return { tagName, tagExp };
4100
- }
4101
- function sanitizeName(name, options) {
4102
- if (criticalProperties.includes(name)) {
4103
- throw new Error(`[SECURITY] Invalid name: "${name}" is a reserved JavaScript keyword that could cause prototype pollution`);
4104
- } else if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
4105
- return options.onDangerousProperty(name);
4106
- }
4107
- return name;
4108
- }
4109
-
4110
- // ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
4111
- var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
4112
- function stripAttributePrefix(attrs, prefix) {
4113
- if (!attrs || typeof attrs !== "object") return {};
4114
- if (!prefix) return attrs;
4115
- const rawAttrs = {};
4116
- for (const key in attrs) {
4117
- if (key.startsWith(prefix)) {
4118
- const rawName = key.substring(prefix.length);
4119
- rawAttrs[rawName] = attrs[key];
4120
- } else {
4121
- rawAttrs[key] = attrs[key];
4122
- }
4123
- }
4124
- return rawAttrs;
4125
- }
4126
- function prettify(node, options, matcher, readonlyMatcher) {
4127
- return compress(node, options, matcher, readonlyMatcher);
4128
- }
4129
- function compress(arr, options, matcher, readonlyMatcher) {
4130
- let text;
4131
- const compressedObj = {};
4132
- for (let i = 0; i < arr.length; i++) {
4133
- const tagObj = arr[i];
4134
- const property = propName(tagObj);
4135
- if (property !== void 0 && property !== options.textNodeName) {
4136
- const rawAttrs = stripAttributePrefix(
4137
- tagObj[":@"] || {},
4138
- options.attributeNamePrefix
4139
- );
4140
- matcher.push(property, rawAttrs);
4141
- }
4142
- if (property === options.textNodeName) {
4143
- if (text === void 0) text = tagObj[property];
4144
- else text += "" + tagObj[property];
4145
- } else if (property === void 0) {
4146
- continue;
4147
- } else if (tagObj[property]) {
4148
- let val = compress(tagObj[property], options, matcher, readonlyMatcher);
4149
- const isLeaf = isLeafTag(val, options);
4150
- if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
4151
- val[options.textNodeName] = "";
4152
- }
4153
- if (tagObj[":@"]) {
4154
- assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
4155
- } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
4156
- val = val[options.textNodeName];
4157
- } else if (Object.keys(val).length === 0) {
4158
- if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
4159
- else val = "";
4160
- }
4161
- if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
4162
- val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
4163
- }
4164
- if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
4165
- if (!Array.isArray(compressedObj[property])) {
4166
- compressedObj[property] = [compressedObj[property]];
4167
- }
4168
- compressedObj[property].push(val);
4169
- } else {
4170
- const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
4171
- if (options.isArray(property, jPathOrMatcher, isLeaf)) {
4172
- compressedObj[property] = [val];
4173
- } else {
4174
- compressedObj[property] = val;
4175
- }
4176
- }
4177
- if (property !== void 0 && property !== options.textNodeName) {
4178
- matcher.pop();
4179
- }
4180
- }
4181
- }
4182
- if (typeof text === "string") {
4183
- if (text.length > 0) compressedObj[options.textNodeName] = text;
4184
- } else if (text !== void 0) compressedObj[options.textNodeName] = text;
4185
- return compressedObj;
4186
- }
4187
- function propName(obj) {
4188
- const keys = Object.keys(obj);
4189
- for (let i = 0; i < keys.length; i++) {
4190
- const key = keys[i];
4191
- if (key !== ":@") return key;
4192
- }
4193
- }
4194
- function assignAttributes(obj, attrMap, readonlyMatcher, options) {
4195
- if (attrMap) {
4196
- const keys = Object.keys(attrMap);
4197
- const len = keys.length;
4198
- for (let i = 0; i < len; i++) {
4199
- const atrrName = keys[i];
4200
- const rawAttrName = atrrName.startsWith(options.attributeNamePrefix) ? atrrName.substring(options.attributeNamePrefix.length) : atrrName;
4201
- const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() + "." + rawAttrName : readonlyMatcher;
4202
- if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
4203
- obj[atrrName] = [attrMap[atrrName]];
4204
- } else {
4205
- obj[atrrName] = attrMap[atrrName];
4206
- }
4207
- }
4208
179
  }
4209
- }
4210
- function isLeafTag(obj, options) {
4211
- const { textNodeName } = options;
4212
- const propCount = Object.keys(obj).length;
4213
- if (propCount === 0) {
4214
- return true;
4215
- }
4216
- if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
4217
- return true;
180
+ const cellCount = result.cells ? result.cells.offsets.length - 1 : result.dimensions?.reduce((product, dimension) => product * Math.max(dimension - 1, 1), 1);
181
+ if (cellCount !== void 0) {
182
+ requireVTK(
183
+ result.cellData.every((array) => array.data.length / array.components === cellCount),
184
+ "cell attribute count mismatch"
185
+ );
4218
186
  }
4219
- return false;
187
+ return result;
4220
188
  }
4221
189
 
4222
- // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
4223
- var XMLParser = class {
4224
- constructor(options) {
4225
- this.externalEntities = {};
4226
- this.options = buildOptions(options);
4227
- }
4228
- /**
4229
- * Parse XML dats to JS object
4230
- * @param {string|Uint8Array} xmlData
4231
- * @param {boolean|Object} validationOption
4232
- */
4233
- parse(xmlData, validationOption) {
4234
- if (typeof xmlData !== "string" && xmlData.toString) {
4235
- xmlData = xmlData.toString();
4236
- } else if (typeof xmlData !== "string") {
4237
- throw new Error("XML data is accepted in String or Bytes[] form.");
4238
- }
4239
- if (validationOption) {
4240
- if (validationOption === true) validationOption = {};
4241
- const result = validate(xmlData, validationOption);
4242
- if (result !== true) {
4243
- throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
4244
- }
4245
- }
4246
- const orderedObjParser = new OrderedObjParser(this.options, this.externalEntities);
4247
- const orderedResult = orderedObjParser.parseXml(xmlData);
4248
- if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
4249
- else return prettify(orderedResult, this.options, orderedObjParser.matcher, orderedObjParser.readonlyMatcher);
4250
- }
4251
- /**
4252
- * Add Entity which is not by default supported by this library
4253
- * @param {string} key
4254
- * @param {string} value
4255
- */
4256
- addEntity(key, value) {
4257
- if (value.indexOf("&") !== -1) {
4258
- throw new Error("Entity value can't have '&'");
4259
- } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
4260
- throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
4261
- } else if (value === "&") {
4262
- throw new Error("An entity with value '&' is not permitted");
4263
- } else {
4264
- this.externalEntities[key] = value;
4265
- }
4266
- }
4267
- /**
4268
- * Returns a Symbol that can be used to access the metadata
4269
- * property on a node.
4270
- *
4271
- * If Symbol is not available in the environment, an ordinary property is used
4272
- * and the name of the property is here returned.
4273
- *
4274
- * The XMLMetaData property is only present when `captureMetaData`
4275
- * is true in the options.
4276
- */
4277
- static getMetaDataSymbol() {
4278
- return XmlNode.getMetaDataSymbol();
4279
- }
4280
- };
4281
-
4282
190
  // src/vtk/vtk-xml.ts
191
+ var import_xml_parser = require("@loaders.gl/documents/xml-parser");
4283
192
  function check(value, message) {
4284
193
  if (!value) throw new Error("VTK XML: " + message);
4285
194
  }
@@ -4372,7 +281,7 @@ function extentDimensions(value) {
4372
281
  }
4373
282
  function parseVTKXML(xml) {
4374
283
  check(xml.length <= 512 * 1024 * 1024, "XML document too large");
4375
- const parser = new XMLParser({
284
+ const XML_OPTIONS = {
4376
285
  ignoreAttributes: false,
4377
286
  attributeNamePrefix: "",
4378
287
  textNodeName: "#text",
@@ -4380,8 +289,8 @@ function parseVTKXML(xml) {
4380
289
  parseAttributeValue: false,
4381
290
  processEntities: false,
4382
291
  trimValues: true
4383
- });
4384
- const root = parser.parse(xml)?.VTKFile;
292
+ };
293
+ const root = (0, import_xml_parser.parseXMLSync)(xml, XML_OPTIONS)?.VTKFile;
4385
294
  check(root, "missing VTKFile root");
4386
295
  const type = String(root.type ?? "");
4387
296
  check(