projen-pipelines 0.3.21 → 0.3.23

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 (123) hide show
  1. package/.jsii +7 -4
  2. package/API.md +420 -0
  3. package/lib/assign-approver/base.js +3 -4
  4. package/lib/assign-approver/github.js +4 -4
  5. package/lib/awscdk/base.js +48 -6
  6. package/lib/awscdk/bash.js +2 -4
  7. package/lib/awscdk/github.js +13 -6
  8. package/lib/awscdk/gitlab.js +11 -6
  9. package/lib/drift/base.js +8 -4
  10. package/lib/drift/bash.js +3 -4
  11. package/lib/drift/detect-drift.js +3 -2
  12. package/lib/drift/github.js +5 -4
  13. package/lib/drift/gitlab.js +5 -4
  14. package/lib/drift/step.js +2 -4
  15. package/lib/release.js +5 -2
  16. package/lib/steps/amplify-deploy.step.js +5 -4
  17. package/lib/steps/artifact-steps.js +5 -6
  18. package/lib/steps/aws-assume-role.step.js +3 -4
  19. package/lib/steps/github-summary.step.js +3 -4
  20. package/lib/steps/package-manager-setup.step.js +4 -6
  21. package/lib/steps/registries.js +7 -8
  22. package/lib/steps/set-env.step.js +2 -1
  23. package/lib/steps/step.js +9 -10
  24. package/lib/versioning/computation.js +6 -8
  25. package/lib/versioning/config.js +3 -6
  26. package/lib/versioning/outputs.js +13 -16
  27. package/lib/versioning/setup.js +9 -9
  28. package/lib/versioning/strategy.js +4 -4
  29. package/lib/versioning/version-info.js +18 -9
  30. package/node_modules/@babel/code-frame/package.json +2 -2
  31. package/node_modules/@babel/helper-validator-identifier/package.json +1 -1
  32. package/node_modules/@nodable/entities/README.md +52 -1
  33. package/node_modules/@nodable/entities/package.json +4 -1
  34. package/node_modules/@nodable/entities/src/EntityDecoder.js +105 -4
  35. package/node_modules/@nodable/entities/src/EntityEncoder.js +79 -34
  36. package/node_modules/@nodable/entities/src/all-entities.js +53 -0
  37. package/node_modules/@nodable/entities/src/entities.js +0 -38
  38. package/node_modules/@nodable/entities/src/entityTries.js +48 -37
  39. package/node_modules/@nodable/entities/src/index.d.ts +93 -2
  40. package/node_modules/@nodable/entities/src/index.js +2 -2
  41. package/node_modules/anynum/LICENSE +21 -0
  42. package/node_modules/anynum/README.md +142 -0
  43. package/node_modules/anynum/anynum.js +135 -0
  44. package/node_modules/anynum/digitTable.js +116 -0
  45. package/node_modules/anynum/package.json +42 -0
  46. package/node_modules/dotgitignore/node_modules/brace-expansion/README.md +23 -1
  47. package/node_modules/dotgitignore/node_modules/brace-expansion/index.js +265 -86
  48. package/node_modules/dotgitignore/node_modules/brace-expansion/package.json +1 -1
  49. package/node_modules/fast-xml-builder/CHANGELOG.md +12 -0
  50. package/node_modules/fast-xml-builder/README.md +4 -1
  51. package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -1
  52. package/node_modules/fast-xml-builder/lib/fxb.min.js +1 -1
  53. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -1
  54. package/node_modules/fast-xml-builder/package.json +6 -10
  55. package/node_modules/fast-xml-builder/src/fxb.js +34 -24
  56. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +18 -17
  57. package/node_modules/fast-xml-builder/src/util.js +10 -3
  58. package/node_modules/fast-xml-parser/CHANGELOG.md +34 -0
  59. package/node_modules/fast-xml-parser/README.md +10 -6
  60. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
  61. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
  62. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
  63. package/node_modules/fast-xml-parser/lib/fxp.d.cts +3 -1
  64. package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
  65. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
  66. package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
  67. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
  68. package/node_modules/fast-xml-parser/package.json +8 -10
  69. package/node_modules/fast-xml-parser/src/fxp.d.ts +5 -1
  70. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +16 -1
  71. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +2 -1
  72. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +36 -3
  73. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +14 -0
  74. package/node_modules/get-pkg-repo/node_modules/yargs/package.json +27 -26
  75. package/node_modules/get-pkg-repo/node_modules/yargs/yargs +5 -9
  76. package/node_modules/get-pkg-repo/node_modules/yargs/yargs.cjs +15 -0
  77. package/node_modules/hasown/CHANGELOG.md +7 -0
  78. package/node_modules/hasown/index.d.ts +0 -1
  79. package/node_modules/hasown/package.json +4 -5
  80. package/node_modules/is-unsafe/LICENSE +21 -0
  81. package/node_modules/is-unsafe/README.md +599 -0
  82. package/node_modules/is-unsafe/package.json +56 -0
  83. package/node_modules/is-unsafe/src/contexts/html.js +102 -0
  84. package/node_modules/is-unsafe/src/contexts/log.js +98 -0
  85. package/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
  86. package/node_modules/is-unsafe/src/contexts/redos.js +60 -0
  87. package/node_modules/is-unsafe/src/contexts/shell.js +105 -0
  88. package/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
  89. package/node_modules/is-unsafe/src/contexts/sql.js +95 -0
  90. package/node_modules/is-unsafe/src/contexts/svg.js +81 -0
  91. package/node_modules/is-unsafe/src/contexts/xml.js +79 -0
  92. package/node_modules/is-unsafe/src/index.cjs +27 -0
  93. package/node_modules/is-unsafe/src/index.d.ts +95 -0
  94. package/node_modules/is-unsafe/src/index.js +265 -0
  95. package/node_modules/path-expression-matcher/README.md +82 -7
  96. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -1
  97. package/node_modules/path-expression-matcher/lib/pem.d.cts +94 -3
  98. package/node_modules/path-expression-matcher/lib/pem.min.js +1 -1
  99. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -1
  100. package/node_modules/path-expression-matcher/package.json +2 -1
  101. package/node_modules/path-expression-matcher/src/ExpressionSet.js +18 -2
  102. package/node_modules/path-expression-matcher/src/Matcher.js +109 -16
  103. package/node_modules/path-expression-matcher/src/index.d.ts +67 -1
  104. package/node_modules/path-expression-matcher/src/index.js +3 -2
  105. package/node_modules/semver/classes/range.js +24 -4
  106. package/node_modules/semver/classes/semver.js +19 -2
  107. package/node_modules/semver/package.json +2 -2
  108. package/node_modules/semver/ranges/subset.js +2 -2
  109. package/node_modules/strnum/CHANGELOG.md +14 -0
  110. package/node_modules/strnum/README.md +9 -0
  111. package/node_modules/strnum/package.json +7 -3
  112. package/node_modules/strnum/strnum.js +14 -2
  113. package/node_modules/xml-naming/LICENSE +21 -0
  114. package/node_modules/xml-naming/README.md +99 -1
  115. package/node_modules/xml-naming/package.json +4 -2
  116. package/node_modules/xml-naming/src/index.d.ts +34 -0
  117. package/node_modules/xml-naming/src/index.js +134 -22
  118. package/node_modules/yargs/build/index.cjs +1 -1
  119. package/node_modules/yargs/package.json +6 -4
  120. package/node_modules/yargs/yargs +5 -9
  121. package/node_modules/yargs/yargs.cjs +15 -0
  122. package/package.json +8 -9
  123. package/node_modules/yargs/browser.d.ts +0 -5
@@ -9,6 +9,20 @@ var escClose = '\0CLOSE'+Math.random()+'\0';
9
9
  var escComma = '\0COMMA'+Math.random()+'\0';
10
10
  var escPeriod = '\0PERIOD'+Math.random()+'\0';
11
11
 
12
+ var EXPANSION_MAX = 100000
13
+
14
+ // `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
15
+ // input like `'{a,b}'.repeat(1500)` stays under that count - its output is
16
+ // truncated to 100k results - while making every result ~1500 characters
17
+ // long. The result set, and the intermediate arrays built while combining
18
+ // brace sets, then grow large enough to exhaust memory and crash the process
19
+ // (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
20
+ // characters the accumulator may hold at any point, so memory stays flat no
21
+ // matter how many brace groups are chained. The limit sits well above any
22
+ // realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
23
+ // characters) so legitimate input is unaffected.
24
+ var EXPANSION_MAX_LENGTH = 4000000
25
+
12
26
  function numeric(str) {
13
27
  return parseInt(str, 10) == str
14
28
  ? parseInt(str, 10)
@@ -67,7 +81,8 @@ function expandTop(str, options) {
67
81
  return [];
68
82
 
69
83
  options = options || {};
70
- var max = options.max == null ? Infinity : options.max;
84
+ var max = options.max == null ? EXPANSION_MAX : options.max;
85
+ var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
71
86
 
72
87
  // I don't know why Bash 4.3 does this, but it does.
73
88
  // Anything starting with {} will have the first two bytes preserved
@@ -79,7 +94,7 @@ function expandTop(str, options) {
79
94
  str = '\\{\\}' + str.substr(2);
80
95
  }
81
96
 
82
- return expand(escapeBraces(str), max, true).map(unescapeBraces);
97
+ return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
83
98
  }
84
99
 
85
100
  function identity(e) {
@@ -100,104 +115,268 @@ function gte(i, y) {
100
115
  return i >= y;
101
116
  }
102
117
 
103
- function expand(str, max, isTop) {
104
- var expansions = [];
105
-
106
- var m = balanced('{', '}', str);
107
- if (!m || /\$$/.test(m.pre)) return [str];
108
-
109
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
110
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
111
- var isSequence = isNumericSequence || isAlphaSequence;
112
- var isOptions = m.body.indexOf(',') >= 0;
113
- if (!isSequence && !isOptions) {
114
- // {a},b}
115
- if (m.post.match(/,(?!,).*\}/)) {
116
- str = m.pre + '{' + m.body + escClose + m.post;
117
- return expand(str, max, true);
118
+ // Build `{ acc[a] + pre + values[v] }` for every combination, capping the
119
+ // number of results at `max` and the total number of characters at `maxLength`.
120
+ // This is the one place output grows, so bounding it here keeps the single
121
+ // accumulator - and therefore memory - flat regardless of how many brace groups
122
+ // are combined (CVE-2026-14257).
123
+ //
124
+ // `base[a]` is the length of the part of `acc[a]` that predates the current
125
+ // empty-drop baseline (see `expand`). The matching baselines for the results
126
+ // are appended to `outBase`, which the caller carries forward alongside them.
127
+ function combine(
128
+ acc,
129
+ base,
130
+ pre,
131
+ values,
132
+ max,
133
+ maxLength,
134
+ dropEmpties,
135
+ outBase
136
+ ) {
137
+ var out = []
138
+ var length = 0
139
+ for (var a = 0; a < acc.length; a++) {
140
+ for (var v = 0; v < values.length; v++) {
141
+ if (out.length >= max) return out
142
+ var expansion = acc[a] + pre + values[v]
143
+ // Bash drops empty results at the top level. Skip them before they count
144
+ // against `max`, so `max` bounds the number of *kept* results. "Empty"
145
+ // means "adds nothing past the baseline", not "empty overall".
146
+ if (dropEmpties && expansion.length === base[a]) continue
147
+ if (length + expansion.length > maxLength) return out
148
+ out.push(expansion)
149
+ outBase.push(base[a])
150
+ length += expansion.length
118
151
  }
119
- return [str];
120
152
  }
153
+ return out
154
+ }
121
155
 
122
- var n;
123
- if (isSequence) {
124
- n = m.body.split(/\.\./);
125
- } else {
126
- n = parseCommaParts(m.body);
127
- if (n.length === 1) {
128
- // x{{a,b}}y ==> x{a}y x{b}y
129
- n = expand(n[0], max, false).map(embrace);
130
- if (n.length === 1) {
131
- var post = m.post.length
132
- ? expand(m.post, max, false)
133
- : [''];
134
- return post.map(function(p) {
135
- return m.pre + n[0] + p;
136
- });
156
+ // The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
157
+ // sequence body.
158
+ function expandSequence(
159
+ body,
160
+ isAlphaSequence,
161
+ max,
162
+ maxLength
163
+ ) {
164
+ var n = body.split(/\.\./)
165
+ var N = []
166
+ // A sequence body always splits into two or three parts, but the compiler
167
+ // can't know that.
168
+ /* c8 ignore start */
169
+ if (n[0] === undefined || n[1] === undefined) {
170
+ return N
171
+ }
172
+ /* c8 ignore stop */
173
+ var x = numeric(n[0])
174
+ var y = numeric(n[1])
175
+ var width = Math.max(n[0].length, n[1].length)
176
+ var incr =
177
+ n.length === 3 && n[2] !== undefined ?
178
+ Math.max(Math.abs(numeric(n[2])), 1)
179
+ : 1
180
+ var test = lte
181
+ var reverse = y < x
182
+ if (reverse) {
183
+ incr *= -1
184
+ test = gte
185
+ }
186
+ var pad = n.some(isPadded)
187
+
188
+ var length = 0
189
+ for (var i = x; test(i, y) && N.length < max; i += incr) {
190
+ var c
191
+ if (isAlphaSequence) {
192
+ c = String.fromCharCode(i)
193
+ if (c === '\\') {
194
+ c = ''
195
+ }
196
+ } else {
197
+ c = String(i)
198
+ if (pad) {
199
+ var need = width - c.length
200
+ if (need > 0) {
201
+ var z = new Array(need + 1).join('0')
202
+ if (i < 0) {
203
+ c = '-' + z + c.slice(1)
204
+ } else {
205
+ c = z + c
206
+ }
207
+ }
137
208
  }
138
209
  }
210
+ if (length + c.length > maxLength) break
211
+ N.push(c)
212
+ length += c.length
139
213
  }
214
+ return N
215
+ }
140
216
 
141
- // at this point, n is the parts, and we know it's not a comma set
142
- // with a single entry.
217
+ function expand(
218
+ str,
219
+ max,
220
+ maxLength,
221
+ isTop
222
+ ) {
223
+ // Consume the string's top-level brace groups left to right, threading a
224
+ // running set of combined prefixes (`acc`). Expanding the tail iteratively -
225
+ // rather than recursing on `m.post` once per group - keeps the native stack
226
+ // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
227
+ // longer overflow the stack, and leaves a single accumulator whose size
228
+ // `maxLength` bounds directly (CVE-2026-14257).
229
+ var acc = ['']
230
+
231
+ // Bash drops empty results, but only when the *first* group of the run is a
232
+ // comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
233
+ // is on the final strings, so it is applied to whichever `combine` produces
234
+ // them (the one with no brace set left in the tail).
235
+ //
236
+ // The old implementation recursed on `m.post`, so the drop tested only the
237
+ // expansion of the current call's substring. The `{a},b}` rewrite below turns
238
+ // `isTop` back on part-way through a string, starting a fresh such run, so
239
+ // the drop must ignore whatever `acc` already holds from earlier groups.
240
+ // `accBase[a]` records how much of `acc[a]` predates the current run;
241
+ // `combine` treats an expansion as empty when it adds nothing past that.
242
+ var accBase = [0]
243
+ var dropEmpties = false
244
+ var firstGroup = true
245
+ var nextBase
246
+
247
+ for (;;) {
248
+ var m = balanced('{', '}', str);
249
+
250
+ // No brace set left: the rest of the string is literal.
251
+ if (!m) {
252
+ return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, [])
253
+ }
143
254
 
144
- // no need to expand pre, since it is guaranteed to be free of brace-sets
145
- var pre = m.pre;
146
- var post = m.post.length
147
- ? expand(m.post, max, false)
148
- : [''];
149
-
150
- var N;
151
-
152
- if (isSequence) {
153
- var x = numeric(n[0]);
154
- var y = numeric(n[1]);
155
- var width = Math.max(n[0].length, n[1].length)
156
- var incr = n.length == 3
157
- ? Math.max(Math.abs(numeric(n[2])), 1)
158
- : 1;
159
- var test = lte;
160
- var reverse = y < x;
161
- if (reverse) {
162
- incr *= -1;
163
- test = gte;
255
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
256
+ var pre = m.pre;
257
+
258
+ // For compatibility reasons, `${` is not eligible for brace expansion, and
259
+ // on the 1.x line it suppresses expansion of the rest of the string too:
260
+ // the whole remainder is literal. The 2.x and 5.x lines instead keep
261
+ // expanding the tail, which is what bash does, but changing that here would
262
+ // be a breaking change for 1.x consumers. Routed through `combine` so the
263
+ // result is still bounded by `max` and `maxLength`.
264
+ if (/\$$/.test(pre)) {
265
+ return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, [])
164
266
  }
165
- var pad = n.some(isPadded);
166
-
167
- N = [];
168
-
169
- for (var i = x; test(i, y); i += incr) {
170
- var c;
171
- if (isAlphaSequence) {
172
- c = String.fromCharCode(i);
173
- if (c === '\\')
174
- c = '';
175
- } else {
176
- c = String(i);
177
- if (pad) {
178
- var need = width - c.length;
179
- if (need > 0) {
180
- var z = new Array(need + 1).join('0');
181
- if (i < 0)
182
- c = '-' + z + c.slice(1);
183
- else
184
- c = z + c;
185
- }
267
+
268
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
269
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
270
+ var isSequence = isNumericSequence || isAlphaSequence;
271
+ var isOptions = m.body.indexOf(',') >= 0;
272
+ if (!isSequence && !isOptions) {
273
+ // {a},b}
274
+ if (m.post.match(/,(?!,).*\}/)) {
275
+ str = m.pre + '{' + m.body + escClose + m.post;
276
+ // The rewritten string is expanded as if it were a fresh top-level one,
277
+ // so start a new empty-drop run: anchor the baseline at what `acc`
278
+ // holds now, and let the next expanding group decide whether to drop.
279
+ isTop = true
280
+ firstGroup = true
281
+ dropEmpties = false
282
+ accBase = []
283
+ for (var b = 0; b < acc.length; b++) {
284
+ accBase.push(acc[b].length)
186
285
  }
286
+ continue
187
287
  }
188
- N.push(c);
288
+ // Nothing here expands, so the whole remaining string is literal.
289
+ return combine(
290
+ acc,
291
+ accBase,
292
+ pre + '{' + m.body + '}' + m.post,
293
+ [''],
294
+ max,
295
+ maxLength,
296
+ dropEmpties,
297
+ []
298
+ )
189
299
  }
190
- } else {
191
- N = concatMap(n, function(el) { return expand(el, max, false) });
192
- }
193
300
 
194
- for (var j = 0; j < N.length; j++) {
195
- for (var k = 0; k < post.length && expansions.length < max; k++) {
196
- var expansion = pre + N[j] + post[k];
197
- if (!isTop || isSequence || expansion)
198
- expansions.push(expansion);
301
+ if (firstGroup) {
302
+ dropEmpties = isTop && !isSequence
303
+ firstGroup = false
199
304
  }
305
+
306
+ var values;
307
+ if (isSequence) {
308
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
309
+ } else {
310
+ var n = parseCommaParts(m.body);
311
+ if (n.length === 1 && n[0] !== undefined) {
312
+ // x{{a,b}}y ==> x{a}y x{b}y
313
+ n = expand(n[0], max, maxLength, false).map(embrace);
314
+ //XXX is this necessary? Can't seem to hit it in tests.
315
+ /* c8 ignore start */
316
+ if (n.length === 1) {
317
+ nextBase = []
318
+ acc = combine(
319
+ acc,
320
+ accBase,
321
+ pre + n[0],
322
+ [''],
323
+ max,
324
+ maxLength,
325
+ dropEmpties && !m.post.length,
326
+ nextBase
327
+ )
328
+ accBase = nextBase
329
+ if (!m.post.length) break
330
+ str = m.post
331
+ continue
332
+ }
333
+ /* c8 ignore stop */
334
+ }
335
+
336
+ // Values that `combine` is going to drop as empty produce no result, so
337
+ // they must not count against `max` - otherwise `{a,,b}` with `max: 2`
338
+ // would stop at `['a', '']` and yield one result instead of two. Skipping
339
+ // them outright keeps `values` bounded while leaving `max` a bound on
340
+ // *kept* results. A value is dropped when it adds nothing past the
341
+ // baseline, which is what `combine` tests.
342
+ var dropsEmpties = dropEmpties && !m.post.length && !pre
343
+ for (var d = 0; dropsEmpties && d < acc.length; d++) {
344
+ if (acc[d].length !== accBase[d]) {
345
+ dropsEmpties = false
346
+ }
347
+ }
348
+
349
+ values = []
350
+ var valuesLength = 0
351
+ outer: for (var j = 0; j < n.length; j++) {
352
+ var expanded = expand(n[j], max, maxLength, false)
353
+ for (var k = 0; k < expanded.length; k++) {
354
+ var v = expanded[k]
355
+ if (dropsEmpties && !v) continue
356
+ if (values.length >= max || valuesLength + v.length > maxLength) {
357
+ break outer
358
+ }
359
+ values.push(v)
360
+ valuesLength += v.length
361
+ }
362
+ }
363
+ }
364
+
365
+ nextBase = []
366
+ acc = combine(
367
+ acc,
368
+ accBase,
369
+ pre,
370
+ values,
371
+ max,
372
+ maxLength,
373
+ dropEmpties && !m.post.length,
374
+ nextBase
375
+ )
376
+ accBase = nextBase
377
+ if (!m.post.length) break
378
+ str = m.post
200
379
  }
201
380
 
202
- return expansions;
381
+ return acc
203
382
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "brace-expansion",
3
3
  "description": "Brace expansion as known from sh/bash",
4
- "version": "1.1.14",
4
+ "version": "1.1.18",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git://github.com/juliangruber/brace-expansion.git"
@@ -1,4 +1,16 @@
1
1
 
2
+ **1.3.1** (2026-08-14)
3
+ - fix: preserve negative sign for zero (By [rajanpanth](https://github.com/rajanpanth))
4
+
5
+ **1.3.0** (2026-07-11)
6
+ - upgrade:
7
+ - xml-naming v0.3.0: cache support
8
+ - PEM v1.6.2: sibling bug fix
9
+
10
+
11
+ **1.2.1** (2026-07-03)
12
+ - fix: escape quotes in stopNode attribute values (By [greymoth](https://github.com/greymoth-jp))
13
+ - fix: neutralize double hyphen in multi-key comment object (By [spokodev](https://github.com/spokodev))
2
14
 
3
15
 
4
16
  **1.2.0** (2026-05-08)
@@ -1,6 +1,9 @@
1
1
  # fast-xml-builder
2
2
  Build XML from JSON
3
3
 
4
+ [![fast-xml-builder downloads](https://img.shields.io/npm/dw/fast-xml-builder.svg)](https://npm-compare.com/fast-xml-builder)
5
+ [![fast-xml-builder version](https://img.shields.io/npm/v/fast-xml-builder.svg)](https://www.npmjs.com/package/fast-xml-builder)
6
+ [![fast-xml-builder license](https://img.shields.io/npm/l/fast-xml-builder.svg)](https://github.com/NaturalIntelligence/fast-xml-builder)
4
7
 
5
8
  XML Builder was part of [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) for years. But considering that any bug in the parser may false-alarm users who are only using the builder, we have decided to split it into a separate package.
6
9
 
@@ -71,4 +74,4 @@ Check [Options reference](docs/Builder_v1.md) for more detail and examples.
71
74
  - **suppressUnpairedNode**: When `true` (default), unpaired tags are rendered without a closing slash (`<br>`). When `false`, they are rendered as `<br/>`.
72
75
  - **tagValueProcessor**: Customize how tag text values are serialized. Receives the tag name and value.
73
76
  - **textNodeName**: Property name representing the text content of a tag in the JS object. Default: `'#text'`.
74
- - **unpairedTags**: List of tag names that have no matching closing tag (e.g. `<br>` in HTML).
77
+ - **unpairedTags**: List of tag names that have no matching closing tag (e.g. `<br>` in HTML).
@@ -1 +1 @@
1
- (()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>w});class i{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,s="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(s.trim()&&(e.push(this._parseSegment(s.trim())),s=""),e.push({type:"deep-wildcard"}),i+=2):(s.trim()&&e.push(this._parseSegment(s.trim())),s="",i++):(s+=t[i],i++);return s.trim()&&e.push(this._parseSegment(s.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,s=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(s=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(i=t)}let r,o,a=s;if(s.includes("::")){const e=s.indexOf("::");if(r=s.substring(0,e).trim(),a=s.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let h=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),i=a.substring(t+1).trim();["first","last","odd","even"].includes(i)||/^nth\(\d+\)$/.test(i)?(o=e,h=i):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,r&&(e.namespace=r),i)if(i.includes("=")){const t=i.indexOf("=");e.attrName=i.substring(0,t).trim(),e.attrValue=i.substring(t+1).trim()}else e.attrName=i.trim();if(h){const t=h.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=h}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class s{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class n{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new s(this)}push(t,e=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const s=this.path.length;this.siblingStacks[s]||(this.siblingStacks[s]=new Map);const n=this.siblingStacks[s],r=i?`${i}:${t}`:t,o=n.get(r)||0;let a=0;for(const t of n.values())a+=t;n.set(r,o+1);const h={tag:t,position:a,counter:o};null!=i&&(h.namespace=i),null!=e&&(h.values=e),this.path.push(h)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const s=t[i];if("deep-wildcard"===s.type){if(i--,i<0)return!0;const s=t[i];let n=!1;for(let t=e;t>=0;t--)if(this._matchSegment(s,this.path[t],t===this.path.length-1)){e=t-1,i--,n=!0;break}if(!n)return!1}else{if(!this._matchSegment(s,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!i)return!1;const s=e.counter??0;if("first"===t.position&&0!==s)return!1;if("odd"===t.position&&s%2!=1)return!1;if("even"===t.position&&s%2!=0)return!1;if("nth"===t.position&&s!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}function r(t){return String(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function o(t){return String(t).replace(/\]\]>/g,"]]]]><![CDATA[>")}function a(t){return String(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const h=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",p=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",u=p+"\\-\\.\\d·̀-ͯ҇‿-⁀",l=(t,e,i="")=>{const s=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${s}$`,i),qName:new RegExp(`^${s}(?::${s})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},c=l(h,h+"\\-\\.\\d·̀-ͯ‿-⁀"),g=l(p,u,"u"),d=(t,{xmlVersion:e="1.0"}={})=>((t="1.0")=>"1.1"===t?g:c)(e).qName.test(t);function f(t,e,i,s,n){return i.sanitizeName?d(t,{xmlVersion:n})?t:i.sanitizeName(t,{isAttribute:e,matcher:s.readOnly()}):t}function m(t,e){let s="";e.format&&(s="\n");const r=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const s=e.stopNodes[t];"string"==typeof s?r.push(new i(s)):s instanceof i&&r.push(s)}const o=function(t,e){if(!Array.isArray(t)||0===t.length)return"1.0";const i=t[0];if("?xml"===A(i)){const t=i[":@"];if(t){const i=e.attributeNamePrefix+"version";if(t[i])return t[i]}}return"1.0"}(t,e);return N(t,e,s,new n,r,o)}function N(t,e,i,s,n,a){let h="",p=!1;if(e.maxNestedTags&&s.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=S(i,e),i}return""}for(let u=0;u<t.length;u++){const l=t[u],c=A(l);if(void 0===c)continue;const g=c===e.textNodeName||c===e.cdataPropName||c===e.commentPropName||"?"===c[0]?c:f(c,!1,e,s,a),d=b(l[":@"],e);s.push(g,d);const m=P(s,n);if(g===e.textNodeName){let t=l[c];m||(t=e.tagValueProcessor(g,t),t=S(t,e)),p&&(h+=i),h+=t,p=!1,s.pop();continue}if(g===e.cdataPropName){p&&(h+=i),h+=`<![CDATA[${o(l[c][0][e.textNodeName])}]]>`,p=!1,s.pop();continue}if(g===e.commentPropName){h+=i+`\x3c!--${r(l[c][0][e.textNodeName])}--\x3e`,p=!0,s.pop();continue}if("?"===g[0]){h+=("?xml"===g?"":i)+`<${g}${$(l[":@"],e,m,s,a)}?>`,p=!0,s.pop();continue}let y=i;""!==y&&(y+=e.indentBy);const v=i+`<${g}${$(l[":@"],e,m,s,a)}`;let w;w=m?x(l[c],e):N(l[c],e,y,s,n,a),-1!==e.unpairedTags.indexOf(g)?e.suppressUnpairedNode?h+=v+">":h+=v+"/>":w&&0!==w.length||!e.suppressEmptyNode?w&&w.endsWith(">")?h+=v+`>${w}${i}</${g}>`:(h+=v+">",w&&""!==i&&(w.includes("/>")||w.includes("</"))?h+=i+e.indentBy+w+i:h+=w,h+=`</${g}>`):h+=v+"/>",p=!0,s.pop()}return h}function b(t,e){if(!t||e.ignoreAttributes)return null;const i={};let s=!1;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n.startsWith(e.attributeNamePrefix)?n.substr(e.attributeNamePrefix.length):n]=a(t[n]),s=!0);return s?i:null}function x(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let i="";for(let s=0;s<t.length;s++){const n=t[s],r=A(n);if(r===e.textNodeName)i+=n[r];else if(r===e.cdataPropName)i+=n[r][0][e.textNodeName];else if(r===e.commentPropName)i+=n[r][0][e.textNodeName];else{if(r&&"?"===r[0])continue;if(r){const t=y(n[":@"],e),s=x(n[r],e);s&&0!==s.length?i+=`<${r}${t}>${s}</${r}>`:i+=`<${r}${t}/>`}}}return i}function y(t,e){let i="";if(t&&!e.ignoreAttributes)for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=t[s];!0===n&&e.suppressBooleanAttributes?i+=` ${s.substr(e.attributeNamePrefix.length)}`:i+=` ${s.substr(e.attributeNamePrefix.length)}="${a(n)}"`}return i}function A(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];if(Object.prototype.hasOwnProperty.call(t,s)&&":@"!==s)return s}}function $(t,e,i,s,n){let r="";if(t&&!e.ignoreAttributes)for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const h=o.substr(e.attributeNamePrefix.length),p=i?h:f(h,!0,e,s,n);let u;i?u=t[o]:(u=e.attributeValueProcessor(o,t[o]),u=S(u,e)),!0===u&&e.suppressBooleanAttributes?r+=` ${p}`:r+=` ${p}="${a(u)}"`}return r}function P(t,e){if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t.matches(e[i]))return!0;return!1}function S(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const s=e.entities[i];t=t.replace(s.regex,s.val)}return t}const v={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function w(t){if(this.options=Object.assign({},v,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new i(e)):e instanceof i&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=C),this.processTextOrObjNode=O,this.options.format?(this.indentate=_,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function E(t,e,i,s,n){return i.sanitizeName?d(t,{xmlVersion:n})?t:i.sanitizeName(t,{isAttribute:e,matcher:s.readOnly()}):t}function O(t,e,i,s,n){const r=this.extractAttributes(t);if(s.push(e,r),this.checkStopNode(s)){const n=this.buildRawContent(t),r=this.buildAttributesForStopNode(t);return s.pop(),this.buildObjectNode(n,e,r,i)}const o=this.j2x(t,i+1,s,n);return s.pop(),"?"===e[0]?this.buildTextValNode("",e,o.attrStr,i,s):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,o.attrStr,i,s):this.buildObjectNode(o.val,e,o.attrStr,i)}function _(t){return this.options.indentBy.repeat(t)}function C(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}w.prototype.build=function(t){if(this.options.preserveOrder)return m(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new n,i=function(t,e){const i=t["?xml"];if(i&&"object"==typeof i){if(e.attributesGroupName&&i[e.attributesGroupName]){const t=i[e.attributesGroupName][e.attributeNamePrefix+"version"];if(t)return t}const t=i[e.attributeNamePrefix+"version"];if(t)return t}return"1.0"}(t,this.options);return this.j2x(t,0,e,i).val}},w.prototype.j2x=function(t,e,i,s){let n="",r="";if(this.options.maxNestedTags&&i.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const o=this.options.jPath?i.toString():i,a=this.checkStopNode(i);for(let h in t){if(!Object.prototype.hasOwnProperty.call(t,h))continue;const p=h===this.options.textNodeName||h===this.options.cdataPropName||h===this.options.commentPropName||this.options.attributesGroupName&&h===this.options.attributesGroupName||this.isAttribute(h)||"?"===h[0]?h:E(h,!1,this.options,i,s);if(void 0===t[h])this.isAttribute(h)&&(r+="");else if(null===t[h])this.isAttribute(h)||p===this.options.cdataPropName||p===this.options.commentPropName?r+="":"?"===p[0]?r+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if(t[h]instanceof Date)r+=this.buildTextValNode(t[h],p,"",e,i);else if("object"!=typeof t[h]){const u=this.isAttribute(h);if(u&&!this.ignoreAttributesFn(u,o)){const e=E(u,!0,this.options,i,s);n+=this.buildAttrPairStr(e,""+t[h],a)}else if(!u)if(h===this.options.textNodeName){let e=this.options.tagValueProcessor(h,""+t[h]);r+=this.replaceEntitiesValue(e)}else{i.push(p);const s=this.checkStopNode(i);if(i.pop(),s){const i=""+t[h];r+=""===i?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+i+"</"+p+this.tagEndChar}else r+=this.buildTextValNode(t[h],p,"",e,i)}}else if(Array.isArray(t[h])){const n=t[h].length;let o="",a="";for(let u=0;u<n;u++){const n=t[h][u];if(void 0===n);else if(null===n)"?"===p[0]?r+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if("object"==typeof n)if(this.options.oneListGroup){i.push(p);const t=this.j2x(n,e+1,i,s);i.pop(),o+=t.val,this.options.attributesGroupName&&n.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else o+=this.processTextOrObjNode(n,p,e,i,s);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(p,n);t=this.replaceEntitiesValue(t),o+=t}else{i.push(p);const t=this.checkStopNode(i);if(i.pop(),t){const t=""+n;o+=""===t?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+t+"</"+p+this.tagEndChar}else o+=this.buildTextValNode(n,p,"",e,i)}}this.options.oneListGroup&&(o=this.buildObjectNode(o,p,a,e)),r+=o}else if(this.options.attributesGroupName&&h===this.options.attributesGroupName){const e=Object.keys(t[h]),r=e.length;for(let o=0;o<r;o++){const r=E(e[o],!0,this.options,i,s);n+=this.buildAttrPairStr(r,""+t[h][e[o]],a)}}else r+=this.processTextOrObjNode(t[h],p,e,i,s)}return{attrStr:n,val:r}},w.prototype.buildAttrPairStr=function(t,e,i){return i||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+a(e)+'"'},w.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let i=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const s=t[this.options.attributesGroupName];for(let t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=a(s[t]),i=!0)}else for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const n=this.isAttribute(s);n&&(e[n]=a(t[s]),i=!0)}return i?e:null},w.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(this.isAttribute(i))continue;if(this.options.attributesGroupName&&i===this.options.attributesGroupName)continue;const s=t[i];if(i===this.options.textNodeName)e+=s;else if(Array.isArray(s)){for(let t of s)if("string"==typeof t||"number"==typeof t)e+=`<${i}>${t}</${i}>`;else if("object"==typeof t&&null!==t){const s=this.buildRawContent(t),n=this.buildAttributesForStopNode(t);e+=""===s?`<${i}${n}/>`:`<${i}${n}>${s}</${i}>`}}else if("object"==typeof s&&null!==s){const t=this.buildRawContent(s),n=this.buildAttributesForStopNode(s);e+=""===t?`<${i}${n}/>`:`<${i}${n}>${t}</${i}>`}else e+=`<${i}>${s}</${i}>`}return e},w.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const i=t[this.options.attributesGroupName];for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;const s=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,n=i[t];!0===n&&this.options.suppressBooleanAttributes?e+=" "+s:e+=" "+s+'="'+n+'"'}}else for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const s=this.isAttribute(i);if(s){const n=t[i];!0===n&&this.options.suppressBooleanAttributes?e+=" "+s:e+=" "+s+'="'+n+'"'}}return e},w.prototype.buildObjectNode=function(t,e,i,s){if(""===t)return"?"===e[0]?this.indentate(s)+"<"+e+i+"?"+this.tagEndChar:this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(s)+"<"+e+i+"?"+this.tagEndChar;{let n="</"+e+this.tagEndChar,r="";return"?"===e[0]&&(r="?",n=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===r.length?this.indentate(s)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(s)+"<"+e+i+r+this.tagEndChar+t+this.indentate(s)+n:this.indentate(s)+"<"+e+i+r+">"+t+n}},w.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},w.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},w.prototype.buildTextValNode=function(t,e,i,s,n){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName){const e=o(t);return this.indentate(s)+`<![CDATA[${e}]]>`+this.newLine}if(!1!==this.options.commentPropName&&e===this.options.commentPropName){const e=r(t);return this.indentate(s)+`\x3c!--${e}--\x3e`+this.newLine}if("?"===e[0])return this.indentate(s)+"<"+e+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),""===n?this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+i+">"+n+"</"+e+this.tagEndChar}},w.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t},module.exports=e})();
1
+ (()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>C});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(i=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(s=t)}let r,o,a=i;if(i.includes("::")){const e=i.indexOf("::");if(r=i.substring(0,e).trim(),a=i.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let h=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),s=a.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(o=e,h=s):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(h){const t=h.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=h}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const s=e[e.length-1];return void 0!==s.values&&t in s.values}getAnyParentAttr(t){return this._matcher.getAnyParentAttr(t)}hasAnyParentAttr(t){return this._matcher.hasAnyParentAttr(t)}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class n{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this),this._keptAttrs=[]}push(t,e=null,s=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;let r=this.siblingStacks[n];r||(r={counts:new Map,total:0},this.siblingStacks[n]=r);const o=s?`${s}:${t}`:t,a=r.counts.get(o)||0,h=r.total;r.counts.set(o,a+1),r.total++;const p={tag:t,position:h,counter:a};null!=s&&(p.namespace=s),null!=e&&(p.values=e),this.path.push(p);const u=this.path.length,l=null!==i?i.keep:null;if(null!=l&&l.length>0&&e)for(let t=0;t<l.length;t++){const s=l[t];void 0!==e[s]&&this._keptAttrs.push({depth:u,name:s,value:e[s]})}}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);const e=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=e;)this._keptAttrs.pop();return t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getAnyParentAttr(t){const e=this._keptAttrs;for(let s=e.length-1;s>=0;s--)if(e[s].name===t)return e[s].value}hasAnyParentAttr(t){const e=this._keptAttrs;for(let s=e.length-1;s>=0;s--)if(e[s].name===t)return!0;return!1}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let n=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,s--,n=!0;break}if(!n)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),keptAttrs:this._keptAttrs.map(t=>({...t}))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),this._keptAttrs=(t.keptAttrs||[]).map(t=>({...t}))}readOnly(){return this._view}}function r(t){return"number"==typeof t&&Object.is(t,-0)?"-0":String(t)}function o(t){return r(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function a(t){return r(t).replace(/\]\]>/g,"]]]]><![CDATA[>")}function h(t){return r(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const p=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",u=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",l=u+"\\-\\.\\d·̀-ͯ҇‿-⁀",c=(t,e,s="")=>{const i=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,s),ncName:new RegExp(`^${i}$`,s),qName:new RegExp(`^${i}(?::${i})?$`,s),nmToken:new RegExp(`^[${e}]+$`,s),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,s)}},g=c(p,p+"\\-\\.\\d·̀-ͯ‿-⁀"),d=c(u,l,"u"),f=":A-Za-z_",m=c(f,f+"\\-\\.\\d"),N=["name","ncName","qName","nmToken","nmTokens"],b=(t,{xmlVersion:e="1.0",asciiOnly:s=!1,maxCacheSize:i=2048}={})=>{if(!N.includes(t))throw new TypeError(`Unknown production "${t}". Must be one of: ${N.join(", ")}`);const n=((t="1.0",e=!1)=>e?m:"1.1"===t?d:g)(e,s)[t];let r=new Map;const o=t=>{const e=r.get(t);if(void 0!==e)return e;const s=n.test(t);return r.size<i&&r.set(t,s),s};return o.reset=()=>{r=new Map},o};function y(t,e,s,i,n){return s.sanitizeName?n(t)?t:s.sanitizeName(t,{isAttribute:e,matcher:i.readOnly()}):t}function x(t,e){let i="";e.format&&(i="\n");const r=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const i=e.stopNodes[t];"string"==typeof i?r.push(new s(i)):i instanceof s&&r.push(i)}const o=function(t,e){if(!Array.isArray(t)||0===t.length)return"1.0";const s=t[0];if("?xml"===_(s)){const t=s[":@"];if(t){const s=e.attributeNamePrefix+"version";if(t[s])return t[s]}}return"1.0"}(t,e),a=b("qName",{xmlVersion:o});return A(t,e,i,new n,r,a)}function A(t,e,s,i,n,h){let p="",u=!1;if(e.maxNestedTags&&i.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let s=r(t);return s=O(s,e),s}return""}for(let l=0;l<t.length;l++){const c=t[l],g=_(c);if(void 0===g)continue;const d=g===e.textNodeName||g===e.cdataPropName||g===e.commentPropName||"?"===g[0]?g:y(g,!1,e,i,h),f=P(c[":@"],e);i.push(d,f);const m=w(i,n);if(d===e.textNodeName){let t=c[g];m||(t=e.tagValueProcessor(d,t),t=O(t,e)),t=r(t),u&&(p+=s),p+=t,u=!1,i.pop();continue}if(d===e.cdataPropName){u&&(p+=s),p+=`<![CDATA[${a(c[g][0][e.textNodeName])}]]>`,u=!1,i.pop();continue}if(d===e.commentPropName){p+=s+`\x3c!--${o(c[g][0][e.textNodeName])}--\x3e`,u=!0,i.pop();continue}if("?"===d[0]){p+=("?xml"===d?"":s)+`<${d}${v(c[":@"],e,m,i,h)}?>`,u=!0,i.pop();continue}let N=s;""!==N&&(N+=e.indentBy);const b=s+`<${d}${v(c[":@"],e,m,i,h)}`;let x;x=m?$(c[g],e):A(c[g],e,N,i,n,h),-1!==e.unpairedTags.indexOf(d)?e.suppressUnpairedNode?p+=b+">":p+=b+"/>":x&&0!==x.length||!e.suppressEmptyNode?x&&x.endsWith(">")?p+=b+`>${x}${s}</${d}>`:(p+=b+">",x&&""!==s&&(x.includes("/>")||x.includes("</"))?p+=s+e.indentBy+x+s:p+=x,p+=`</${d}>`):p+=b+"/>",u=!0,i.pop()}return p}function P(t,e){if(!t||e.ignoreAttributes)return null;const s={};let i=!1;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n.startsWith(e.attributeNamePrefix)?n.substr(e.attributeNamePrefix.length):n]=h(t[n]),i=!0);return i?s:null}function $(t,e){if(!Array.isArray(t))return null!=t?r(t):"";let s="";for(let i=0;i<t.length;i++){const n=t[i],o=_(n);if(o===e.textNodeName)s+=r(n[o]);else if(o===e.cdataPropName)s+=n[o][0][e.textNodeName];else if(o===e.commentPropName)s+=n[o][0][e.textNodeName];else{if(o&&"?"===o[0])continue;if(o){const t=S(n[":@"],e),i=$(n[o],e);i&&0!==i.length?s+=`<${o}${t}>${i}</${o}>`:s+=`<${o}${t}/>`}}}return s}function S(t,e){let s="";if(t&&!e.ignoreAttributes)for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let n=t[i];!0===n&&e.suppressBooleanAttributes?s+=` ${i.substr(e.attributeNamePrefix.length)}`:s+=` ${i.substr(e.attributeNamePrefix.length)}="${h(n)}"`}return s}function _(t){const e=Object.keys(t);for(let s=0;s<e.length;s++){const i=e[s];if(Object.prototype.hasOwnProperty.call(t,i)&&":@"!==i)return i}}function v(t,e,s,i,n){let r="";if(t&&!e.ignoreAttributes)for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const a=o.substr(e.attributeNamePrefix.length),p=s?a:y(a,!0,e,i,n);let u;s?u=t[o]:(u=e.attributeValueProcessor(o,t[o]),u=O(u,e)),!0===u&&e.suppressBooleanAttributes?r+=` ${p}`:r+=` ${p}="${h(u)}"`}return r}function w(t,e){if(!e||0===e.length)return!1;for(let s=0;s<e.length;s++)if(t.matches(e[s]))return!0;return!1}function O(t,e){if(t&&t.length>0&&e.processEntities)for(let s=0;s<e.entities.length;s++){const i=e.entities[s];t=t.replace(i.regex,i.val)}return t}const E={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function C(t){if(this.options=Object.assign({},E,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new s(e)):e instanceof s&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const s of e){if("string"==typeof s&&t===s)return!0;if(s instanceof RegExp&&s.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=V),this.processTextOrObjNode=k,this.options.format?(this.indentate=T,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function j(t,e,s,i,n){return s.sanitizeName?n(t)?t:s.sanitizeName(t,{isAttribute:e,matcher:i.readOnly()}):t}function k(t,e,s,i,n){const r=this.extractAttributes(t);if(i.push(e,r),this.checkStopNode(i)){const n=this.buildRawContent(t),r=this.buildAttributesForStopNode(t);return i.pop(),this.buildObjectNode(n,e,r,s)}const o=this.j2x(t,s+1,i,n);return i.pop(),"?"===e[0]?this.buildTextValNode("",e,o.attrStr,s,i):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,o.attrStr,s,i):this.buildObjectNode(o.val,e,o.attrStr,s)}function T(t){return this.options.indentBy.repeat(t)}function V(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}C.prototype.build=function(t){if(this.options.preserveOrder)return x(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new n,s=function(t,e){const s=t["?xml"];if(s&&"object"==typeof s){if(e.attributesGroupName&&s[e.attributesGroupName]){const t=s[e.attributesGroupName][e.attributeNamePrefix+"version"];if(t)return t}const t=s[e.attributeNamePrefix+"version"];if(t)return t}return"1.0"}(t,this.options),i=b("qName",{xmlVersion:s});return this.j2x(t,0,e,i).val}},C.prototype.j2x=function(t,e,s,i){let n="",o="";if(this.options.maxNestedTags&&s.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const a=this.options.jPath?s.toString():s,h=this.checkStopNode(s);for(let p in t){if(!Object.prototype.hasOwnProperty.call(t,p))continue;const u=p===this.options.textNodeName||p===this.options.cdataPropName||p===this.options.commentPropName||this.options.attributesGroupName&&p===this.options.attributesGroupName||this.isAttribute(p)||"?"===p[0]?p:j(p,!1,this.options,s,i);if(void 0===t[p])this.isAttribute(p)&&(o+="");else if(null===t[p])this.isAttribute(p)||u===this.options.cdataPropName||u===this.options.commentPropName?o+="":"?"===u[0]?o+=this.indentate(e)+"<"+u+"?"+this.tagEndChar:o+=this.indentate(e)+"<"+u+"/"+this.tagEndChar;else if(t[p]instanceof Date)o+=this.buildTextValNode(t[p],u,"",e,s);else if("object"!=typeof t[p]){const l=this.isAttribute(p);if(l&&!this.ignoreAttributesFn(l,a)){const e=j(l,!0,this.options,s,i);n+=this.buildAttrPairStr(e,r(t[p]),h)}else if(!l)if(p===this.options.textNodeName){let e=this.options.tagValueProcessor(p,r(t[p]));o+=this.replaceEntitiesValue(e)}else{s.push(u);const i=this.checkStopNode(s);if(s.pop(),i){const s=r(t[p]);o+=""===s?this.indentate(e)+"<"+u+this.closeTag(u)+this.tagEndChar:this.indentate(e)+"<"+u+">"+s+"</"+u+this.tagEndChar}else o+=this.buildTextValNode(t[p],u,"",e,s)}}else if(Array.isArray(t[p])){const n=t[p].length;let a="",h="";for(let l=0;l<n;l++){const n=t[p][l];if(void 0===n);else if(null===n)"?"===u[0]?o+=this.indentate(e)+"<"+u+"?"+this.tagEndChar:o+=this.indentate(e)+"<"+u+"/"+this.tagEndChar;else if("object"==typeof n)if(this.options.oneListGroup){s.push(u);const t=this.j2x(n,e+1,s,i);s.pop(),a+=t.val,this.options.attributesGroupName&&n.hasOwnProperty(this.options.attributesGroupName)&&(h+=t.attrStr)}else a+=this.processTextOrObjNode(n,u,e,s,i);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(u,n);t=this.replaceEntitiesValue(t),t=r(t),a+=t}else{s.push(u);const t=this.checkStopNode(s);if(s.pop(),t){const t=r(n);a+=""===t?this.indentate(e)+"<"+u+this.closeTag(u)+this.tagEndChar:this.indentate(e)+"<"+u+">"+t+"</"+u+this.tagEndChar}else a+=this.buildTextValNode(n,u,"",e,s)}}this.options.oneListGroup&&(a=this.buildObjectNode(a,u,h,e)),o+=a}else if(this.options.attributesGroupName&&p===this.options.attributesGroupName){const e=Object.keys(t[p]),o=e.length;for(let a=0;a<o;a++){const o=j(e[a],!0,this.options,s,i);n+=this.buildAttrPairStr(o,r(t[p][e[a]]),h)}}else o+=this.processTextOrObjNode(t[p],u,e,s,i)}return{attrStr:n,val:o}},C.prototype.buildAttrPairStr=function(t,e,s){return s||(e=this.options.attributeValueProcessor(t,r(e)),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+h(e)+'"'},C.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let s=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const i=t[this.options.attributesGroupName];for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=h(i[t]),s=!0)}else for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const n=this.isAttribute(i);n&&(e[n]=h(t[i]),s=!0)}return s?e:null},C.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;if(this.isAttribute(s))continue;if(this.options.attributesGroupName&&s===this.options.attributesGroupName)continue;const i=t[s];if(s===this.options.textNodeName)e+=i;else if(Array.isArray(i)){for(let t of i)if("string"==typeof t||"number"==typeof t)e+=`<${s}>${t}</${s}>`;else if("object"==typeof t&&null!==t){const i=this.buildRawContent(t),n=this.buildAttributesForStopNode(t);e+=""===i?`<${s}${n}/>`:`<${s}${n}>${i}</${s}>`}}else if("object"==typeof i&&null!==i){const t=this.buildRawContent(i),n=this.buildAttributesForStopNode(i);e+=""===t?`<${s}${n}/>`:`<${s}${n}>${t}</${s}>`}else e+=`<${s}>${i}</${s}>`}return e},C.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const s=t[this.options.attributesGroupName];for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;const i=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,n=s[t];!0===n&&this.options.suppressBooleanAttributes?e+=" "+i:e+=" "+i+'="'+h(n)+'"'}}else for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const i=this.isAttribute(s);if(i){const n=t[s];!0===n&&this.options.suppressBooleanAttributes?e+=" "+i:e+=" "+i+'="'+h(n)+'"'}}return e},C.prototype.buildObjectNode=function(t,e,s,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+s+"?"+this.tagEndChar:this.indentate(i)+"<"+e+s+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(i)+"<"+e+s+"?"+this.tagEndChar;{let n="</"+e+this.tagEndChar,r="";return"?"===e[0]&&(r="?",n=""),!s&&""!==s||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===r.length?this.indentate(i)+`\x3c!--${o(t)}--\x3e`+this.newLine:this.indentate(i)+"<"+e+s+r+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+s+r+">"+t+n}},C.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},C.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},C.prototype.buildTextValNode=function(t,e,s,i,n){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName){const e=a(t);return this.indentate(i)+`<![CDATA[${e}]]>`+this.newLine}if(!1!==this.options.commentPropName&&e===this.options.commentPropName){const e=o(t);return this.indentate(i)+`\x3c!--${e}--\x3e`+this.newLine}if("?"===e[0])return this.indentate(i)+"<"+e+s+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),n=r(n),""===n?this.indentate(i)+"<"+e+s+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+s+">"+n+"</"+e+this.tagEndChar}},C.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const s=this.options.entities[e];t=t.replace(s.regex,s.val)}return t},module.exports=e})();