diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index b481937a8a..aa04634147 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 8ecb3977bf..9f67d3d130 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 593098aa22..a1b0a32553 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 5e5ed0f603..d64b30aac0 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/init-action.js b/lib/init-action.js index 3ce55149db..45171d3c29 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -61986,38 +61986,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -62031,7 +62031,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -62039,28 +62039,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -62068,26 +62068,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -62103,9 +62103,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -62116,88 +62116,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62205,19 +62205,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62226,146 +62226,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62382,9 +62434,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62404,14 +62454,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62419,97 +62474,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62532,410 +62583,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt2, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt2(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt2(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62944,13 +63174,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt2(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62959,131 +63189,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -63091,173 +63324,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index e057e9063d..02342c09bc 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index b6774fddb7..c8bdab7fd0 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index b975d618ec..00a390c1fc 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index af1ffe1659..2207e140e2 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -62657,38 +62657,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -62702,7 +62702,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -62710,28 +62710,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -62739,26 +62739,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -62774,9 +62774,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -62787,88 +62787,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62876,19 +62876,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62897,146 +62897,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -63053,9 +63105,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -63075,14 +63125,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -63090,97 +63145,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -63203,410 +63254,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -63615,13 +63845,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -63630,131 +63860,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -63762,173 +63995,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 6f742c3530..9f6f047e3d 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 8c9311eead..00baeb3605 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -64040,38 +64040,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -64085,7 +64085,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -64093,28 +64093,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -64122,26 +64122,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -64157,9 +64157,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -64170,88 +64170,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -64259,19 +64259,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -64280,146 +64280,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _2(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _2(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _2(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _2(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -64436,9 +64488,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -64458,14 +64508,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -64473,97 +64528,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -64586,410 +64637,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } } } - function nt(t2, e2, i2) { + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -64998,13 +65228,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -65013,131 +65243,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -65145,173 +65378,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index c36f7c4956..ba5d5c838c 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -61835,38 +61835,38 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, i2) => { - for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); + var t = { d: (e2, n2) => { + for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); - const i = ":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", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); + const n = ":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", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const i2 = []; - let n2 = e2.exec(t2); - for (; n2; ) { + const n2 = []; + let i2 = e2.exec(t2); + for (; i2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - n2[0].length; - const r2 = n2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); - i2.push(s2), n2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - i2[0].length; + const r2 = i2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); + n2.push(s2), i2 = e2.exec(t2); } - return i2; + return n2; } const r = function(t2) { - return !(null == n.exec(t2)); + return !(null == i.exec(t2)); }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { e2 = Object.assign({}, h, e2); - const i2 = []; - let n2 = false, s2 = false; + const n2 = []; + let i2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; + if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (p(t2[r2])) continue; + if (u(t2[r2])) continue; return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { @@ -61880,7 +61880,7 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { let e3; return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } @@ -61888,28 +61888,28 @@ var require_fxp = __commonJS({ if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); let d2 = l2.value; if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const i3 = r2 - d2.length; + const n3 = r2 - d2.length; d2 = d2.substring(0, d2.length - 1); const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); - n2 = true; + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + i2 = true; } else if (a2) { if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = i2.pop(); + const e3 = n2.pop(); if (h2 !== e3.tagName) { - let i3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + let n3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == i2.length && (s2 = true); + 0 == n2.length && (s2 = true); } } else { const a3 = x(d2, e2); if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; + -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { @@ -61917,26 +61917,26 @@ var require_fxp = __commonJS({ continue; } if ("?" !== t2[r2 + 1]) break; - if (r2 = u(t2, ++r2), r2.err) return r2; + if (r2 = p(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { const e3 = N(t2, r2); if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); + } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function p(t2) { + function u(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } - function u(t2, e2) { - const i2 = e2; + function p(t2, e2) { + const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const n2 = t2.substr(i2, e2 - i2); - if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + const i2 = t2.substr(n2, e2 - n2); + if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61952,9 +61952,9 @@ var require_fxp = __commonJS({ break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let i2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; - else if (">" === t2[e2] && (i2--, 0 === i2)) break; + let n2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; + else if (">" === t2[e2] && (n2--, 0 === n2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61965,88 +61965,88 @@ var require_fxp = __commonJS({ } const d = '"', f = "'"; function g(t2, e2) { - let i2 = "", n2 = "", s2 = false; + let n2 = "", i2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); - else if (">" === t2[e2] && "" === n2) { + if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + else if (">" === t2[e2] && "" === i2) { s2 = true; break; } - i2 += t2[e2]; + n2 += t2[e2]; } - return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; } const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); function x(t2, e2) { - const i2 = s(t2, m), n2 = {}; - for (let t3 = 0; t3 < i2.length; t3++) { - if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); - if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); - if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); - const s2 = i2[t3][2]; - if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); - if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); - n2[s2] = 1; + const n2 = s(t2, m), i2 = {}; + for (let t3 = 0; t3 < n2.length; t3++) { + if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); + const s2 = n2[t3][2]; + if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); + i2[s2] = 1; } return true; } function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let i3 = /\d/; - for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let n3 = /\d/; + for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(i3)) break; + if (!t3[e3].match(n3)) break; } return -1; })(t2, ++e2); - let i2 = 0; - for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { + let n2 = 0; + for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function b(t2, e2, i2) { - return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; + function b(t2, e2, n2) { + return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function E(t2) { + function y(t2) { return r(t2); } - function y(t2) { + function E(t2) { return r(t2); } function w(t2, e2) { - const i2 = t2.substring(0, e2).split(/\r?\n/); - return { line: i2.length, col: i2[i2.length - 1].length + 1 }; + const n2 = t2.substring(0, e2).split(/\r?\n/); + return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } function v(t2) { return t2.startIndex + t2[1].length; } - const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _ = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; - function S(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; + function A(t2, e2) { if ("string" != typeof t2) return; - const i2 = t2.toLowerCase(); - if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + const n2 = t2.toLowerCase(); + if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function A(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 10), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1e3), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 100), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + function T(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); } const C = function(t2) { - const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const e2 = Object.assign({}, _, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let O; - O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class $ { + let P; + P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class O { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62054,19 +62054,19 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][O] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); } static getMetaDataSymbol() { - return O; + return P; } } - class I { + class $ { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const i2 = /* @__PURE__ */ Object.create(null); - let n2 = 0; + const n2 = /* @__PURE__ */ Object.create(null); + let i2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; @@ -62075,146 +62075,198 @@ var require_fxp = __commonJS({ if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (r2 && _(t2, "!ENTITY", e2)) { + if (r2 && D(t2, "!ENTITY", e2)) { let s3, r3; if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { - if (false !== this.options.enabled && null != this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; + if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + n2[s3] = r3, i2++; } - } else if (r2 && _(t2, "!ELEMENT", e2)) { + } else if (r2 && D(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: i3 } = this.readElementExp(t2, e2 + 1); - e2 = i3; - } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && _(t2, "!NOTATION", e2)) { + const { index: n3 } = this.readElementExp(t2, e2 + 1); + e2 = n3; + } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && D(t2, "!NOTATION", e2)) { e2 += 9; - const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = i3; + const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = n3; } else { - if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } s2++, a2 = ""; } if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: i2, i: e2 }; + return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; - let n2 = t2.substring(i2, e2); - if (D(n2), e2 = j(t2, e2), !this.suppressValidationErr) { + let i2 = t2.substring(n2, e2); + if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, s2, --e2]; + if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, s2, --e2]; } readNotationExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - !this.suppressValidationErr && D(n2), e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + !this.suppressValidationErr && M(i2), e2 = I(t2, e2); const s2 = t2.substring(e2, e2 + 6).toUpperCase(); if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = j(t2, e2); + e2 += s2.length, e2 = I(t2, e2); let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; } - readIdentifierVal(t2, e2, i2) { - let n2 = ""; + readIdentifierVal(t2, e2, n2) { + let i2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); const r2 = ++e2; for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (n2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); - return [++e2, n2]; + if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + return [++e2, i2]; } readElementExp(t2, e2) { - const i2 = e2 = j(t2, e2); + const n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + let i2 = t2.substring(n2, e2); + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); let s2 = ""; - if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; + if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - const i3 = ++e2; + const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(i3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: s2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let i2 = e2 = j(t2, e2); + let n2 = e2 = I(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let n2 = t2.substring(i2, e2); - for (D(n2), i2 = e2 = j(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(i2, e2); - if (!D(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = j(t2, e2); + let i2 = t2.substring(n2, e2); + for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let s2 = t2.substring(n2, e2); + if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); + e2 = I(t2, e2); let r2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let i3 = []; + let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - const n3 = e2; + const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(n3, e2); - if (s3 = s3.trim(), !D(s3)) throw new Error(`Invalid notation name: "${s3}"`); - i3.push(s3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); + let s3 = t2.substring(i3, e2); + if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); + n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + i3.join("|") + ")"; + e2++, r2 += " (" + n3.join("|") + ")"; } else { - const i3 = e2; + const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(i3, e2); - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + r2 += t2.substring(n3, e2); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); } - e2 = j(t2, e2); + e2 = I(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; } } - const j = (t2, e2) => { + const I = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function _(t2, e2, i2) { - for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; + function D(t2, e2, n2) { + for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function D(t2) { + function M(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, M = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const F = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; + const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class F { + constructor(t2) { + this._matcher = t2; + } + get separator() { + return this._matcher.separator; + } + getCurrentTag() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].tag : void 0; + } + getCurrentNamespace() { + const t2 = this._matcher.path; + return t2.length > 0 ? t2[t2.length - 1].namespace : void 0; + } + getAttrValue(t2) { + const e2 = this._matcher.path; + if (0 !== e2.length) return e2[e2.length - 1].values?.[t2]; + } + hasAttr(t2) { + const e2 = this._matcher.path; + if (0 === e2.length) return false; + const n2 = e2[e2.length - 1]; + return void 0 !== n2.values && t2 in n2.values; + } + getPosition() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; + } + getCounter() { + const t2 = this._matcher.path; + return 0 === t2.length ? -1 : t2[t2.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this._matcher.path.length; + } + toString(t2, e2 = true) { + return this._matcher.toString(t2, e2); + } + toArray() { + return this._matcher.path.map((t2) => t2.tag); + } + matches(t2) { + return this._matcher.matches(t2); + } + matchesAny(t2) { + return t2.matchesAny(this._matcher); + } + } + class R { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); } - push(t2, e2 = null, i2 = null) { - this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const n2 = this.path.length; - this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + push(t2, e2 = null, n2 = null) { + this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const i2 = this.path.length; + this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; let a2 = 0; for (const t3 of s2.values()) a2 += t3; s2.set(r2, o2 + 1); const h2 = { tag: t2, position: a2, counter: o2 }; - null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); } pop() { if (0 === this.path.length) return; + this._pathStringCache = null; const t2 = this.path.pop(); return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; } @@ -62231,9 +62283,7 @@ var require_fxp = __commonJS({ return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; } getAttrValue(t2) { - if (0 === this.path.length) return; - const e2 = this.path[this.path.length - 1]; - return e2.values?.[t2]; + if (0 !== this.path.length) return this.path[this.path.length - 1].values?.[t2]; } hasAttr(t2) { if (0 === this.path.length) return false; @@ -62253,14 +62303,19 @@ var require_fxp = __commonJS({ return this.path.length; } toString(t2, e2 = true) { - const i2 = t2 || this.separator; - return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + const n2 = t2 || this.separator; + if (n2 === this.separator && true === e2) { + if (null !== this._pathStringCache) return this._pathStringCache; + const t3 = this.path.map((t4) => t4.namespace ? `${t4.namespace}:${t4.tag}` : t4.tag).join(n2); + return this._pathStringCache = t3, t3; + } + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(n2); } toArray() { return this.path.map((t2) => t2.tag); } reset() { - this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = []; } matches(t2) { const e2 = t2.segments; @@ -62268,97 +62323,93 @@ var require_fxp = __commonJS({ } _matchSimple(t2) { if (this.path.length !== t2.length) return false; - for (let e2 = 0; e2 < t2.length; e2++) { - const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; - if (!this._matchSegment(i2, n2, s2)) return false; - } + for (let e2 = 0; e2 < t2.length; e2++) if (!this._matchSegment(t2[e2], this.path[e2], e2 === this.path.length - 1)) return false; return true; } _matchWithDeepWildcard(t2) { - let e2 = this.path.length - 1, i2 = t2.length - 1; - for (; i2 >= 0 && e2 >= 0; ) { - const n2 = t2[i2]; - if ("deep-wildcard" === n2.type) { - if (i2--, i2 < 0) return true; - const n3 = t2[i2]; + let e2 = this.path.length - 1, n2 = t2.length - 1; + for (; n2 >= 0 && e2 >= 0; ) { + const i2 = t2[n2]; + if ("deep-wildcard" === i2.type) { + if (n2--, n2 < 0) return true; + const i3 = t2[n2]; let s2 = false; - for (let t3 = e2; t3 >= 0; t3--) { - const r2 = t3 === this.path.length - 1; - if (this._matchSegment(n3, this.path[t3], r2)) { - e2 = t3 - 1, i2--, s2 = true; - break; - } + for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { + e2 = t3 - 1, n2--, s2 = true; + break; } if (!s2) return false; } else { - const t3 = e2 === this.path.length - 1; - if (!this._matchSegment(n2, this.path[e2], t3)) return false; - e2--, i2--; + if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; + e2--, n2--; } } - return i2 < 0; + return n2 < 0; } - _matchSegment(t2, e2, i2) { + _matchSegment(t2, e2, n2) { if ("*" !== t2.tag && t2.tag !== e2.tag) return false; if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; if (void 0 !== t2.attrName) { - if (!i2) return false; + if (!n2) return false; if (!e2.values || !(t2.attrName in e2.values)) return false; - if (void 0 !== t2.attrValue) { - const i3 = e2.values[t2.attrName]; - if (String(i3) !== String(t2.attrValue)) return false; - } + if (void 0 !== t2.attrValue && String(e2.values[t2.attrName]) !== String(t2.attrValue)) return false; } if (void 0 !== t2.position) { - if (!i2) return false; - const n2 = e2.counter ?? 0; - if ("first" === t2.position && 0 !== n2) return false; - if ("odd" === t2.position && n2 % 2 != 1) return false; - if ("even" === t2.position && n2 % 2 != 0) return false; - if ("nth" === t2.position && n2 !== t2.positionValue) return false; + if (!n2) return false; + const i2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== i2) return false; + if ("odd" === t2.position && i2 % 2 != 1) return false; + if ("even" === t2.position && i2 % 2 != 0) return false; + if ("nth" === t2.position && i2 !== t2.positionValue) return false; } return true; } + matchesAny(t2) { + return t2.matchesAny(this); + } snapshot() { return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; } restore(t2) { - this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + readOnly() { + return this._view; } } class G { - constructor(t2, e2 = {}) { - this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + constructor(t2, e2 = {}, n2) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } _parse(t2) { const e2 = []; - let i2 = 0, n2 = ""; - for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); - return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + let n2 = 0, i2 = ""; + for (; n2 < t2.length; ) t2[n2] === this.separator ? n2 + 1 < t2.length && t2[n2 + 1] === this.separator ? (i2.trim() && (e2.push(this._parseSegment(i2.trim())), i2 = ""), e2.push({ type: "deep-wildcard" }), n2 += 2) : (i2.trim() && e2.push(this._parseSegment(i2.trim())), i2 = "", n2++) : (i2 += t2[n2], n2++); + return i2.trim() && e2.push(this._parseSegment(i2.trim())), e2; } _parseSegment(t2) { const e2 = { type: "tag" }; - let i2 = null, n2 = t2; + let n2 = null, i2 = t2; const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + if (s2 && (i2 = s2[1] + s2[3], s2[2])) { const t3 = s2[2].slice(1, -1); - t3 && (i2 = t3); + t3 && (n2 = t3); } - let r2, o2, a2 = n2; - if (n2.includes("::")) { - const e3 = n2.indexOf("::"); - if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + let r2, o2, a2 = i2; + if (i2.includes("::")) { + const e3 = i2.indexOf("::"); + if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); } let h2 = null; if (a2.includes(":")) { - const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { - const t3 = i2.indexOf("="); - e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); - } else e2.attrName = i2.trim(); + if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + const t3 = n2.indexOf("="); + e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); + } else e2.attrName = n2.trim(); if (h2) { const t3 = h2.match(/^nth\((\d+)\)$/); t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; @@ -62381,410 +62432,589 @@ var require_fxp = __commonJS({ return this.pattern; } } - function R(t2, e2) { + class B { + constructor() { + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + } + add(t2) { + if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); + if (this._patterns.has(t2.pattern)) return this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; + if (i2 && "*" !== i2) { + const n3 = `${e2}:${i2}`; + this._byDepthAndTag.has(n3) || this._byDepthAndTag.set(n3, []), this._byDepthAndTag.get(n3).push(t2); + } else this._wildcardByDepth.has(e2) || this._wildcardByDepth.set(e2, []), this._wildcardByDepth.get(e2).push(t2); + return this; + } + addAll(t2) { + for (const e2 of t2) this.add(e2); + return this; + } + has(t2) { + return this._patterns.has(t2.pattern); + } + get size() { + return this._patterns.size; + } + seal() { + return this._sealed = true, this; + } + get isSealed() { + return this._sealed; + } + matchesAny(t2) { + return null !== this.findMatch(t2); + } + findMatch(t2) { + const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); + if (i2) { + for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + } + const s2 = this._wildcardByDepth.get(e2); + if (s2) { + for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; + } + for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; + return null; + } + } + const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function z(t2) { + if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); + for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + return t2; + } + function q(...t2) { + const e2 = /* @__PURE__ */ Object.create(null); + for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { + const i2 = n2[t3]; + if ("string" == typeof i2) e2[t3] = i2; + else if (i2 && "object" == typeof i2 && void 0 !== i2.val) { + const n3 = i2.val; + "string" == typeof n3 && (e2[t3] = n3); + } + } + return e2; + } + const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); + class tt { + constructor(t2 = {}) { + var e2; + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + const n2 = (function(t3) { + if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + })(t2.ncr); + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + } + setExternalEntities(t2) { + if (t2) for (const e2 of Object.keys(t2)) z(e2); + this._externalMap = q(t2); + } + addExternalEntity(t2, e2) { + z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + } + addInputEntities(t2) { + this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + } + reset() { + return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; + } + setXmlVersion(t2) { + this._ncrXmlVersion = 1.1 === t2 ? 1.1 : 1; + } + decode(t2) { + if ("string" != typeof t2 || 0 === t2.length) return t2; + const e2 = t2, n2 = [], i2 = t2.length; + let s2 = 0, r2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; + for (; r2 < i2; ) { + if (38 !== t2.charCodeAt(r2)) { + r2++; + continue; + } + let e3 = r2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { + r2++; + continue; + } + const l3 = t2.slice(r2 + 1, e3); + if (0 === l3.length) { + r2++; + continue; + } + let u2, p2; + if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + else { + if (this._leaveSet.has(l3)) { + r2++; + continue; + } + if (35 === l3.charCodeAt(0)) { + const t3 = this._resolveNCR(l3); + if (void 0 === t3) { + r2++; + continue; + } + u2 = t3, p2 = J; + } else { + const t3 = this._resolveName(l3); + u2 = t3?.value, p2 = t3?.tier; + } + } + if (void 0 !== u2) { + if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); + if (a2) { + const t3 = u2.length - (l3.length + 2); + if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); + } + } + } else r2++; + } + s2 < i2 && n2.push(t2.slice(s2)); + const l2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(l2, e2); + } + _tierCounts(t2) { + return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + } + _resolveName(t2) { + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + } + _classifyNCR(t2) { + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + } + _applyNCRAction(t2, e2, n2) { + switch (t2) { + case Q.allow: + return String.fromCodePoint(n2); + case Q.remove: + return ""; + case Q.leave: + return; + case Q.throw: + throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); + default: + return String.fromCodePoint(n2); + } + } + _resolveNCR(t2) { + const e2 = t2.charCodeAt(1); + let n2; + if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; + const i2 = this._classifyNCR(n2); + if (!this._numericAllowed && i2 < Q.remove) return; + const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(s2, t2, n2); + } + } + function et(t2, e2) { if (!t2) return {}; - const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; - if (!i2) return {}; - const n2 = {}; - for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; - return n2; + const n2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!n2) return {}; + const i2 = {}; + for (const t3 in n2) t3.startsWith(e2.attributeNamePrefix) ? i2[t3.substring(e2.attributeNamePrefix.length)] = n2[t3] : i2[t3] = n2[t3]; + return i2; } - function U(t2) { + function nt(t2) { if (!t2 || "string" != typeof t2) return; const e2 = t2.indexOf(":"); if (-1 !== e2 && e2 > 0) { - const i2 = t2.substring(0, e2); - if ("xmlns" !== i2) return i2; + const n2 = t2.substring(0, e2); + if ("xmlns" !== n2) return n2; } } - class B { + class it { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.parseXml = ht, this.parseTextData = st, this.resolveNameSpace = rt, this.buildAttributesMap = at, this.isItStopNode = ct, this.replaceEntitiesValue = ut, this.readStopNodeData = mt, this.saveTextToParentTag = pt, this.addChild = lt, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const n3 of e2) { + if ("string" == typeof n3 && t3 === n3) return true; + if (n3 instanceof RegExp && n3.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new L(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodeExpressions = []; - for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { - const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0; + let n2 = { ...W }; + this.options.entityDecoder ? this.entityDecoder = this.options.entityDecoder : ("object" == typeof this.options.htmlEntities ? n2 = this.options.htmlEntities : true === this.options.htmlEntities && (n2 = { ...X, ...U }), this.entityDecoder = new tt({ namedEntities: n2, numericAllowed: this.options.htmlEntities, limit: { maxTotalExpansions: this.options.processEntities.maxTotalExpansions, maxExpandedLength: this.options.processEntities.maxExpandedLength, applyLimitsTo: this.options.processEntities.appliesTo } })), this.matcher = new R(), this.readonlyMatcher = this.matcher.readOnly(), this.isCurrentNodeStopNode = false, this.stopNodeExpressionsSet = new B(); + const i2 = this.options.stopNodes; + if (i2 && i2.length > 0) { + for (let t3 = 0; t3 < i2.length; t3++) { + const e3 = i2[t3]; + "string" == typeof e3 ? this.stopNodeExpressionsSet.add(new G(e3)) : e3 instanceof G && this.stopNodeExpressionsSet.add(e3); } + this.stopNodeExpressionsSet.seal(); } } } - function W(t2) { - const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; - } - } - function Y(t2, e2, i2, n2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); - const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); - return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function st(t2, e2, n2, i2, s2, r2, o2) { + const a2 = this.options; + if (void 0 !== t2 && (a2.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); + const i3 = a2.jPath ? n2.toString() : n2, h2 = a2.tagValueProcessor(e2, t2, i3, s2, r2); + return null == h2 ? t2 : typeof h2 != typeof t2 || h2 !== t2 ? h2 : a2.trimValues || t2.trim() === t2 ? xt(t2, a2.parseTagValue, a2.numberParseOptions) : t2; } } - function X(t2) { + function rt(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = i2 + e2[1]); + 2 === e2.length && (t2 = n2 + e2[1]); } return t2; } - const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function q(t2, e2, i2) { - if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; - if (s2.length && void 0 !== r3) { - let t4 = r3; - this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; - } - } - Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); - for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; - if (this.ignoreAttributesFn(s2, r3)) continue; - let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { - this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); - const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); - o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[h2] = true); - } - if (!Object.keys(o2).length) return; - if (this.options.attributesGroupName) { + const ot = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function at(t2, e2, n2, i2 = false) { + const r2 = this.options; + if (true === i2 || true !== r2.ignoreAttributes && "string" == typeof t2) { + const i3 = s(t2, ot), o2 = i3.length, a2 = {}, h2 = new Array(o2); + let l2 = false; + const u2 = {}; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]), s2 = i3[t3][4]; + if (e3.length && void 0 !== s2) { + let i4 = s2; + r2.trimValues && (i4 = i4.trim()), i4 = this.replaceEntitiesValue(i4, n2, this.readonlyMatcher), h2[t3] = i4, u2[e3] = i4, l2 = true; + } + } + l2 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(u2); + const p2 = r2.jPath ? e2.toString() : this.readonlyMatcher; + let c2 = false; + for (let t3 = 0; t3 < o2; t3++) { + const e3 = this.resolveNameSpace(i3[t3][1]); + if (this.ignoreAttributesFn(e3, p2)) continue; + let n3 = r2.attributeNamePrefix + e3; + if (e3.length) if (r2.transformAttributeName && (n3 = r2.transformAttributeName(n3)), n3 = bt(n3, r2), void 0 !== i3[t3][4]) { + const i4 = h2[t3], s2 = r2.attributeValueProcessor(e3, i4, p2); + a2[n3] = null == s2 ? i4 : typeof s2 != typeof i4 || s2 !== i4 ? s2 : xt(i4, r2.parseAttributeValue, r2.numberParseOptions), c2 = true; + } else r2.allowBooleanAttributes && (a2[n3] = true, c2 = true); + } + if (!c2) return; + if (r2.attributesGroupName) { const t3 = {}; - return t3[this.options.attributesGroupName] = o2, t3; + return t3[r2.attributesGroupName] = a2, t3; } - return o2; + return a2; } } - const Z = function(t2) { + const ht = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new $("!xml"); - let i2 = e2, n2 = ""; - this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const s2 = new I(this.options.processEntities); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { - const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); - let s3 = t2.substring(r2 + 2, e3).trim(); - if (this.options.removeNSPrefix) { - const t3 = s3.indexOf(":"); - -1 !== t3 && (s3 = s3.substr(t3 + 1)); - } - s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); - const o2 = this.matcher.getCurrentTag(); - if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; - } else if ("?" === t2[r2 + 1]) { - let e3 = et(t2, r2, false, "?>"); - if (!e3) throw new Error("Pi Tag is not closed."); - if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; - else { - const t3 = new $(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); - } - r2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(r2 + 1, 3)) { - const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); - if (this.options.commentPropName) { - const s3 = t2.substring(r2 + 4, e3 - 2); - n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); - } - r2 = e3; - } else if ("!D" === t2.substr(r2 + 1, 2)) { - const e3 = s2.readDocType(t2, r2); - this.docTypeEntities = e3.entities, r2 = e3.i; - } else if ("![" === t2.substr(r2 + 1, 2)) { - const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); - n2 = this.saveTextToParentTag(n2, i2, this.matcher); - let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); - null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; - } else { - let s3 = et(t2, r2, this.options.removeNSPrefix); - if (!s3) { - const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); - throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); - } - let o2 = s3.tagName; - const a2 = s3.rawTagName; - let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; - if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName || o2 === this.options.textNodeName || o2 === this.options.attributesGroupName)) throw new Error(`Invalid tag name: ${o2}`); - i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); - const u2 = i2; - u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); - let c2 = false; - h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); - let d2, f2 = null, g2 = {}; - d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); - const m2 = r2; - if (this.isCurrentNodeStopNode) { - let e3 = ""; - if (c2) r2 = s3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; + const e2 = new O("!xml"); + let n2 = e2, i2 = ""; + this.matcher.reset(), this.entityDecoder.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = this.options, r2 = new $(s2.processEntities), o2 = t2.length; + for (let a2 = 0; a2 < o2; a2++) if ("<" === t2[a2]) { + const h2 = t2.charCodeAt(a2 + 1); + if (47 === h2) { + const e3 = dt(t2, ">", a2, "Closing Tag is not closed."); + let r3 = t2.substring(a2 + 2, e3).trim(); + if (s2.removeNSPrefix) { + const t3 = r3.indexOf(":"); + -1 !== t3 && (r3 = r3.substr(t3 + 1)); + } + r3 = Nt(s2.transformTagName, r3, "", s2).tagName, n2 && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher)); + const o3 = this.matcher.getCurrentTag(); + if (r3 && s2.unpairedTagsSet.has(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o3 && s2.unpairedTagsSet.has(o3) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, n2 = this.tagsNodeStack.pop(), i2 = "", a2 = e3; + } else if (63 === h2) { + let e3 = gt(t2, a2, false, "?>"); + if (!e3) throw new Error("Pi Tag is not closed."); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + const r3 = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName, true); + if (r3) { + const t3 = r3[this.options.attributeNamePrefix + "version"]; + this.entityDecoder.setXmlVersion(Number(t3) || 1); + } + if (s2.ignoreDeclaration && "?xml" === e3.tagName || s2.ignorePiTags) ; else { - const i3 = this.readStopNodeData(t2, a2, p2 + 1); - if (!i3) throw new Error(`Unexpected end of ${a2}`); - r2 = i3.i, e3 = i3.tagContent; - } - const n3 = new $(o2); - f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); + const t3 = new O(e3.tagName); + t3.add(s2.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && true !== s2.ignoreAttributes && (t3[":@"] = r3), this.addChild(n2, t3, this.readonlyMatcher, a2); + } + a2 = e3.closeIndex + 1; + } else if (33 === h2 && 45 === t2.charCodeAt(a2 + 2) && 45 === t2.charCodeAt(a2 + 3)) { + const e3 = dt(t2, "-->", a2 + 4, "Comment is not closed."); + if (s2.commentPropName) { + const r3 = t2.substring(a2 + 4, e3 - 2); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher), n2.add(s2.commentPropName, [{ [s2.textNodeName]: r3 }]); + } + a2 = e3; + } else if (33 === h2 && 68 === t2.charCodeAt(a2 + 2)) { + const e3 = r2.readDocType(t2, a2); + this.entityDecoder.addInputEntities(e3.entities), a2 = e3.i; + } else if (33 === h2 && 91 === t2.charCodeAt(a2 + 2)) { + const e3 = dt(t2, "]]>", a2, "CDATA is not closed.") - 2, r3 = t2.substring(a2 + 9, e3); + i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher); + let o3 = this.parseTextData(r3, n2.tagname, this.readonlyMatcher, true, false, true, true); + null == o3 && (o3 = ""), s2.cdataPropName ? n2.add(s2.cdataPropName, [{ [s2.textNodeName]: r3 }]) : n2.add(s2.textNodeName, o3), a2 = e3 + 2; } else { - if (c2) { - ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; - } else { - if (-1 !== this.options.unpairedTags.indexOf(o2)) { - const t3 = new $(o2); - f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; - continue; + let r3 = gt(t2, a2, s2.removeNSPrefix); + if (!r3) { + const e3 = t2.substring(Math.max(0, a2 - 50), Math.min(o2, a2 + 50)); + throw new Error(`readTagExp returned undefined at position ${a2}. Context: "${e3}"`); + } + let h3 = r3.tagName; + const l2 = r3.rawTagName; + let u2 = r3.tagExp, p2 = r3.attrExpPresent, c2 = r3.closeIndex; + if ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2), s2.strictReservedNames && (h3 === s2.commentPropName || h3 === s2.cdataPropName || h3 === s2.textNodeName || h3 === s2.attributesGroupName)) throw new Error(`Invalid tag name: ${h3}`); + n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, this.readonlyMatcher, false)); + const d2 = n2; + d2 && s2.unpairedTagsSet.has(d2.tagname) && (n2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let f2 = false; + u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1 && (f2 = true, "/" === h3[h3.length - 1] ? (h3 = h3.substr(0, h3.length - 1), u2 = h3) : u2 = u2.substr(0, u2.length - 1), p2 = h3 !== u2); + let g2, m2 = null, x2 = {}; + g2 = nt(l2), h3 !== e2.tagname && this.matcher.push(h3, {}, g2), h3 !== u2 && p2 && (m2 = this.buildAttributesMap(u2, this.matcher, h3), m2 && (x2 = et(m2, s2))), h3 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode()); + const N2 = a2; + if (this.isCurrentNodeStopNode) { + let e3 = ""; + if (f2) a2 = r3.closeIndex; + else if (s2.unpairedTagsSet.has(h3)) a2 = r3.closeIndex; + else { + const n3 = this.readStopNodeData(t2, l2, c2 + 1); + if (!n3) throw new Error(`Unexpected end of ${l2}`); + a2 = n3.i, e3 = n3.tagContent; } - { - const t3 = new $(o2); - if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; + const i3 = new O(h3); + m2 && (i3[":@"] = m2), i3.add(s2.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(n2, i3, this.readonlyMatcher, N2); + } else { + if (f2) { + ({ tagName: h3, tagExp: u2 } = Nt(s2.transformTagName, h3, u2, s2)); + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false; + } else { + if (s2.unpairedTagsSet.has(h3)) { + const t3 = new O(h3); + m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), this.matcher.pop(), this.isCurrentNodeStopNode = false, a2 = r3.closeIndex; + continue; + } + { + const t3 = new O(h3); + if (this.tagsNodeStack.length > s2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + this.tagsNodeStack.push(n2), m2 && (t3[":@"] = m2), this.addChild(n2, t3, this.readonlyMatcher, N2), n2 = t3; + } } + i2 = "", a2 = c2; } - n2 = "", r2 = p2; } - } - else n2 += t2[r2]; + } else i2 += t2[a2]; return e2.child; }; - function J(t2, e2, i2, n2) { - this.options.captureMetaData || (n2 = void 0); - const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); - false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); - } - function K(t2, e2, i2) { - const n2 = this.options.processEntities; - if (!n2 || !n2.enabled) return t2; - if (n2.allowedTags) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; - } - if (n2.tagFilter) { - const s2 = this.options.jPath ? i2.toString() : i2; - if (!n2.tagFilter(e2, s2)) return t2; - } - for (const e3 of Object.keys(this.docTypeEntities)) { - const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); - if (s2) { - if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - const e4 = t2.length; - if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); - } - } - for (const e3 of Object.keys(this.lastEntities)) { - const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + function lt(t2, e2, n2, i2) { + this.options.captureMetaData || (i2 = void 0); + const s2 = this.options.jPath ? n2.toString() : n2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); + } + function ut(t2, e2, n2) { + const i2 = this.options.processEntities; + if (!i2 || !i2.enabled) return t2; + if (i2.allowedTags) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!(Array.isArray(i2.allowedTags) ? i2.allowedTags.includes(e2) : i2.allowedTags(e2, s2))) return t2; } - if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { - const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); - if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); - t2 = t2.replace(i3.regex, i3.val); + if (i2.tagFilter) { + const s2 = this.options.jPath ? n2.toString() : n2; + if (!i2.tagFilter(e2, s2)) return t2; } - return t2.replace(this.ampEntity.regex, this.ampEntity.val); + return this.entityDecoder.decode(t2); } - function Q(t2, e2, i2, n2) { - return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + function pt(t2, e2, n2, i2) { + return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function H(t2, e2) { - if (!t2 || 0 === t2.length) return false; - for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; - return false; + function ct() { + return 0 !== this.stopNodeExpressionsSet.size && this.matcher.matchesAny(this.stopNodeExpressionsSet); } - function tt(t2, e2, i2, n2) { - const s2 = t2.indexOf(e2, i2); - if (-1 === s2) throw new Error(n2); + function dt(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); return s2 + e2.length - 1; } - function et(t2, e2, i2, n2 = ">") { - const s2 = (function(t3, e3, i3 = ">") { - let n3, s3 = ""; - for (let r3 = e3; r3 < t3.length; r3++) { - let e4 = t3[r3]; - if (n3) e4 === n3 && (n3 = ""); - else if ('"' === e4 || "'" === e4) n3 = e4; - else if (e4 === i3[0]) { - if (!i3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; - } else " " === e4 && (e4 = " "); - s3 += e4; - } - })(t2, e2 + 1, n2); + function ft(t2, e2, n2, i2) { + const s2 = t2.indexOf(e2, n2); + if (-1 === s2) throw new Error(i2); + return s2; + } + function gt(t2, e2, n2, i2 = ">") { + const s2 = (function(t3, e3, n3 = ">") { + let i3 = 0; + const s3 = [], r3 = t3.length, o3 = n3.charCodeAt(0), a3 = n3.length > 1 ? n3.charCodeAt(1) : -1; + for (let n4 = e3; n4 < r3; n4++) { + const e4 = t3.charCodeAt(n4); + if (i3) e4 === i3 && (i3 = 0); + else if (34 === e4 || 39 === e4) i3 = e4; + else if (e4 === o3) { + if (-1 === a3) return { data: String.fromCharCode(...s3), index: n4 }; + if (t3.charCodeAt(n4 + 1) === a3) return { data: String.fromCharCode(...s3), index: n4 }; + } else if (9 === e4) { + s3.push(32); + continue; + } + s3.push(e4); + } + })(t2, e2 + 1, i2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); let h2 = r2, l2 = true; -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const p2 = h2; - if (i2) { + const u2 = h2; + if (n2) { const t3 = h2.indexOf(":"); -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: u2 }; } - function it(t2, e2, i2) { - const n2 = i2; + function mt(t2, e2, n2) { + const i2 = n2; let s2 = 1; - for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { - const r2 = tt(t2, ">", i2, `${e2} is not closed`); - if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; - i2 = r2; - } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; - else { - const n3 = et(t2, i2, ">"); - n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); - } - } - function nt(t2, e2, i2) { + const r2 = t2.length; + for (; n2 < r2; n2++) if ("<" === t2[n2]) { + const r3 = t2.charCodeAt(n2 + 1); + if (47 === r3) { + const r4 = ft(t2, ">", n2, `${e2} is not closed`); + if (t2.substring(n2 + 2, r4).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r4 }; + n2 = r4; + } else if (63 === r3) n2 = dt(t2, "?>", n2 + 1, "StopNode is not closed."); + else if (33 === r3 && 45 === t2.charCodeAt(n2 + 2) && 45 === t2.charCodeAt(n2 + 3)) n2 = dt(t2, "-->", n2 + 3, "StopNode is not closed."); + else if (33 === r3 && 91 === t2.charCodeAt(n2 + 2)) n2 = dt(t2, "]]>", n2, "StopNode is not closed.") - 2; + else { + const i3 = gt(t2, n2, ">"); + i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + } + } + } + function xt(t2, e2, n2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, M, e4), !t3 || "string" != typeof t3) return t3; - let i3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; - if ("0" === t3) return 0; - if (e4.hex && V.test(i3)) return (function(t4) { + if (e4 = Object.assign({}, L, e4), !t3 || "string" != typeof t3) return t3; + let n3 = t3.trim(); + if (0 === n3.length) return t3; + if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if ("0" === n3) return 0; + if (e4.hex && j.test(n3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(i3); - if (isFinite(i3)) { - if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { - if (!i4.eNotation) return t4; - const n3 = e5.match(F); - if (n3) { - let s2 = n3[1] || ""; - const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2) && o2.length > 0 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); + })(n3); + if (isFinite(n3)) { + if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { + if (!n4.eNotation) return t4; + const i3 = e5.match(k); + if (i3) { + let s2 = i3[1] || ""; + const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : (1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2) && o2.length > 0 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, i3, e4); + })(t3, n3, e4); { - const s2 = k.exec(i3); + const s2 = V.exec(n3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const n3 = Number(i3), s3 = String(n3); - if (0 === n3) return n3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; - if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; - let h3 = o2 ? a2 : i3; - return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; + const i3 = Number(n3), s3 = String(i3); + if (0 === i3) return i3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; + if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; + let h3 = o2 ? a2 : n3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? i3 : t3 : h3 === s3 || h3 === r2 + s3 ? i3 : t3; } } return t3; } } - var n2; - return (function(t4, e5, i4) { - const n3 = e5 === 1 / 0; - switch (i4.infinity.toLowerCase()) { + var i2; + return (function(t4, e5, n4) { + const i3 = e5 === 1 / 0; + switch (n4.infinity.toLowerCase()) { case "null": return null; case "infinity": return e5; case "string": - return n3 ? "Infinity" : "-Infinity"; + return i3 ? "Infinity" : "-Infinity"; default: return t4; } - })(t3, Number(i3), e4); - })(t2, i2); + })(t3, Number(n3), e4); + })(t2, n2); } return void 0 !== t2 ? t2 : ""; } - function st(t2, e2, i2) { - const n2 = Number.parseInt(t2, e2); - return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; - } - function rt(t2, e2, i2, n2) { + function Nt(t2, e2, n2, i2) { if (t2) { - const n3 = t2(e2); - i2 === e2 && (i2 = n3), e2 = n3; + const i3 = t2(e2); + n2 === e2 && (n2 = i3), e2 = i3; } - return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + return { tagName: e2 = bt(e2, i2), tagExp: n2 }; } - function ot(t2, e2) { + function bt(t2, e2) { if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - const at = $.getMetaDataSymbol(); - function ht(t2, e2) { + const yt = O.getMetaDataSymbol(); + function Et(t2, e2) { if (!t2 || "object" != typeof t2) return {}; if (!e2) return t2; - const i2 = {}; - for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; - return i2; + const n2 = {}; + for (const i2 in t2) i2.startsWith(e2) ? n2[i2.substring(e2.length)] = t2[i2] : n2[i2] = t2[i2]; + return n2; } - function lt(t2, e2, i2) { - return pt(t2, e2, i2); + function wt(t2, e2, n2, i2) { + return vt(t2, e2, n2, i2); } - function pt(t2, e2, i2) { - let n2; - const s2 = {}; - for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = ut(o2); - if (void 0 !== a2 && a2 !== e2.textNodeName) { - const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); - i2.push(a2, t3); + function vt(t2, e2, n2, i2) { + let s2; + const r2 = {}; + for (let o2 = 0; o2 < t2.length; o2++) { + const a2 = t2[o2], h2 = St(a2); + if (void 0 !== h2 && h2 !== e2.textNodeName) { + const t3 = Et(a2[":@"] || {}, e2.attributeNamePrefix); + n2.push(h2, t3); } - if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; + if (h2 === e2.textNodeName) void 0 === s2 ? s2 = a2[h2] : s2 += "" + a2[h2]; else { - if (void 0 === a2) continue; - if (o2[a2]) { - let t3 = pt(o2[a2], e2, i2); - const n3 = dt(t3, e2); - if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + if (void 0 === h2) continue; + if (a2[h2]) { + let t3 = vt(a2[h2], e2, n2, i2); + const s3 = At(t3, e2); + if (a2[":@"] ? _t(t3, a2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== a2[yt] && "object" == typeof t3 && null !== t3 && (t3[yt] = a2[yt]), void 0 !== r2[h2] && Object.prototype.hasOwnProperty.call(r2, h2)) Array.isArray(r2[h2]) || (r2[h2] = [r2[h2]]), r2[h2].push(t3); else { - const r3 = e2.jPath ? i2.toString() : i2; - e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + const n3 = e2.jPath ? i2.toString() : i2; + e2.isArray(h2, n3, s3) ? r2[h2] = [t3] : r2[h2] = t3; } - void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); + void 0 !== h2 && h2 !== e2.textNodeName && n2.pop(); } } } - return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; + return "string" == typeof s2 ? s2.length > 0 && (r2[e2.textNodeName] = s2) : void 0 !== s2 && (r2[e2.textNodeName] = s2), r2; } - function ut(t2) { + function St(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const i2 = e2[t3]; - if (":@" !== i2) return i2; + const n2 = e2[t3]; + if (":@" !== n2) return n2; } } - function ct(t2, e2, i2, n2) { + function _t(t2, e2, n2, i2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; - n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(i2.attributeNamePrefix) ? r3.substring(i2.attributeNamePrefix.length) : r3, h2 = i2.jPath ? n2.toString() + "." + a2 : n2; + i2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function dt(t2, e2) { - const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; - return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); + function At(t2, e2) { + const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; + return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); } - class ft { + class Tt { constructor(t2) { this.externalEntities = {}, this.options = C(t2); } @@ -62793,13 +63023,13 @@ var require_fxp = __commonJS({ else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const i3 = l(t2, e2); - if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); + const n3 = l(t2, e2); + if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); } - const i2 = new B(this.options); - i2.addExternalEntities(this.externalEntities); - const n2 = i2.parseXml(t2); - return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); + const n2 = new it(this.options); + n2.entityDecoder.setExternalEntities(this.externalEntities); + const i2 = n2.parseXml(t2); + return this.options.preserveOrder || void 0 === i2 ? i2 : wt(i2, this.options, n2.matcher, n2.readonlyMatcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62808,131 +63038,134 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return $.getMetaDataSymbol(); + return O.getMetaDataSymbol(); } } - function gt(t2, e2) { - let i2 = ""; - e2.format && e2.indentBy.length > 0 && (i2 = "\n"); - const n2 = []; + function Ct(t2, e2) { + let n2 = ""; + e2.format && e2.indentBy.length > 0 && (n2 = "\n"); + const i2 = []; if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { - const i3 = e2.stopNodes[t3]; - "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + const n3 = e2.stopNodes[t3]; + "string" == typeof n3 ? i2.push(new G(n3)) : n3 instanceof G && i2.push(n3); } - return mt(t2, e2, i2, new L(), n2); + return Pt(t2, e2, n2, new R(), i2); } - function mt(t2, e2, i2, n2, s2) { + function Pt(t2, e2, n2, i2, s2) { let r2 = "", o2 = false; - if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + if (e2.maxNestedTags && i2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let i3 = t2.toString(); - return i3 = vt(i3, e2), i3; + let n3 = t2.toString(); + return n3 = Vt(n3, e2), n3; } return ""; } for (let a2 = 0; a2 < t2.length; a2++) { - const h2 = t2[a2], l2 = Et(h2); + const h2 = t2[a2], l2 = Dt(h2); if (void 0 === l2) continue; - const p2 = xt(h2[":@"], e2); - n2.push(l2, p2); - const u2 = wt(n2, s2); + const u2 = Ot(h2[":@"], e2); + i2.push(l2, u2); + const p2 = jt(i2, s2); if (l2 === e2.textNodeName) { let t3 = h2[l2]; - u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); + p2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = Vt(t3, e2)), o2 && (r2 += n2), r2 += t3, o2 = false, i2.pop(); continue; } if (l2 === e2.cdataPropName) { - o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); + o2 && (r2 += n2); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += `/g, "]]]]>")}]]>`, o2 = false, i2.pop(); continue; } if (l2 === e2.commentPropName) { - r2 += i2 + ``, o2 = true, n2.pop(); + const t3 = h2[l2][0][e2.textNodeName]; + r2 += n2 + ``, o2 = true, i2.pop(); continue; } if ("?" === l2[0]) { - const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + const t3 = Mt(h2[":@"], e2, p2), s3 = "?xml" === l2 ? "" : n2; let a3 = h2[l2][0][e2.textNodeName]; - a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, i2.pop(); continue; } - let c2 = i2; + let c2 = n2; "" !== c2 && (c2 += e2.indentBy); - const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + const d2 = n2 + `<${l2}${Mt(h2[":@"], e2, p2)}`; let f2; - f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + f2 = p2 ? $t(h2[l2], e2) : Pt(h2[l2], e2, c2, i2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${n2}` : (r2 += d2 + ">", f2 && "" !== n2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, i2.pop(); } return r2; } - function xt(t2, e2) { + function Ot(t2, e2) { if (!t2 || e2.ignoreAttributes) return null; - const i2 = {}; - let n2 = false; - for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); - return n2 ? i2 : null; + const n2 = {}; + let i2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (n2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], i2 = true); + return i2 ? n2 : null; } - function Nt(t2, e2) { + function $t(t2, e2) { if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; - let i2 = ""; - for (let n2 = 0; n2 < t2.length; n2++) { - const s2 = t2[n2], r2 = Et(s2); - if (r2 === e2.textNodeName) i2 += s2[r2]; - else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; - else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + let n2 = ""; + for (let i2 = 0; i2 < t2.length; i2++) { + const s2 = t2[i2], r2 = Dt(s2); + if (r2 === e2.textNodeName) n2 += s2[r2]; + else if (r2 === e2.cdataPropName) n2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) n2 += s2[r2][0][e2.textNodeName]; else { if (r2 && "?" === r2[0]) continue; if (r2) { - const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); - n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + const t3 = It(s2[":@"], e2), i3 = $t(s2[r2], e2); + i3 && 0 !== i3.length ? n2 += `<${r2}${t3}>${i3}` : n2 += `<${r2}${t3}/>`; } } } - return i2; + return n2; } - function bt(t2, e2) { - let i2 = ""; - if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; - let s2 = t2[n2]; - true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + function It(t2, e2) { + let n2 = ""; + if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + let s2 = t2[i2]; + true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return i2; + return n2; } - function Et(t2) { + function Dt(t2) { const e2 = Object.keys(t2); - for (let i2 = 0; i2 < e2.length; i2++) { - const n2 = e2[i2]; - if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; + for (let n2 = 0; n2 < e2.length; n2++) { + const i2 = e2[n2]; + if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; } } - function yt(t2, e2, i2) { - let n2 = ""; + function Mt(t2, e2, n2) { + let i2 = ""; if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; let r2; - i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; + n2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = Vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } - return n2; + return i2; } - function wt(t2, e2) { + function jt(t2, e2) { if (!e2 || 0 === e2.length) return false; - for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; + for (let n2 = 0; n2 < e2.length; n2++) if (t2.matches(e2[n2])) return true; return false; } - function vt(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { - const n2 = e2.entities[i2]; - t2 = t2.replace(n2.regex, n2.val); + function Vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { + const i2 = e2.entities[n2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; } - const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Lt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; - function Pt(t2) { - if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + function kt(t2) { + if (this.options = Object.assign({}, Lt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } @@ -62940,173 +63173,179 @@ var require_fxp = __commonJS({ true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const i2 of e2) { - if ("string" == typeof i2 && t3 === i2) return true; - if (i2 instanceof RegExp && i2.test(t3)) return true; + for (const n2 of e2) { + if ("string" == typeof n2 && t3 === n2) return true; + if (n2 instanceof RegExp && n2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Gt), this.processTextOrObjNode = Ft, this.options.format ? (this.indentate = Rt, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function St(t2, e2, i2, n2) { + function Ft(t2, e2, n2, i2) { const s2 = this.extractAttributes(t2); - if (n2.push(e2, s2), this.checkStopNode(n2)) { + if (i2.push(e2, s2), this.checkStopNode(i2)) { const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); - return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + return i2.pop(), this.buildObjectNode(s3, e2, r3, n2); } - const r2 = this.j2x(t2, i2 + 1, n2); - return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); + const r2 = this.j2x(t2, n2 + 1, i2); + return i2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, n2, i2) : this.buildObjectNode(r2.val, e2, r2.attrStr, n2); } - function At(t2) { + function Rt(t2) { return this.options.indentBy.repeat(t2); } - function Ct(t2) { + function Gt(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - Pt.prototype.build = function(t2) { - if (this.options.preserveOrder) return gt(t2, this.options); + kt.prototype.build = function(t2) { + if (this.options.preserveOrder) return Ct(t2, this.options); { Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); - const e2 = new L(); + const e2 = new R(); return this.j2x(t2, 0, e2).val; } - }, Pt.prototype.j2x = function(t2, e2, i2) { - let n2 = "", s2 = ""; - if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + }, kt.prototype.j2x = function(t2, e2, n2) { + let i2 = "", s2 = ""; + if (this.options.maxNestedTags && n2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? n2.toString() : n2, o2 = this.checkStopNode(n2); for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; - else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, n2); else if ("object" != typeof t2[a2]) { const h2 = this.isAttribute(a2); - if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) i2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); else if (!h2) if (a2 === this.options.textNodeName) { let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); } else { - i2.push(a2); - const n3 = this.checkStopNode(i2); - if (i2.pop(), n3) { - const i3 = "" + t2[a2]; - s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + n3 + "" + t4 + "${t3}`; + for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + if (this.isAttribute(n2)) continue; + if (this.options.attributesGroupName && n2 === this.options.attributesGroupName) continue; + const i2 = t2[n2]; + if (n2 === this.options.textNodeName) e2 += i2; + else if (Array.isArray(i2)) { + for (let t3 of i2) if ("string" == typeof t3 || "number" == typeof t3) e2 += `<${n2}>${t3}`; else if ("object" == typeof t3 && null !== t3) { - const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); - e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + const i3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === i3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${i3}`; } - } else if ("object" == typeof n2 && null !== n2) { - const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); - e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; - } else e2 += `<${i2}>${n2}`; + } else if ("object" == typeof i2 && null !== i2) { + const t3 = this.buildRawContent(i2), s2 = this.buildAttributesForStopNode(i2); + e2 += "" === t3 ? `<${n2}${s2}/>` : `<${n2}${s2}>${t3}`; + } else e2 += `<${n2}>${i2}`; } return e2; - }, Pt.prototype.buildAttributesForStopNode = function(t2) { + }, kt.prototype.buildAttributesForStopNode = function(t2) { if (!t2 || "object" != typeof t2) return ""; let e2 = ""; if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { - const i2 = t2[this.options.attributesGroupName]; - for (let t3 in i2) { - if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; - const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + const n2 = t2[this.options.attributesGroupName]; + for (let t3 in n2) { + if (!Object.prototype.hasOwnProperty.call(n2, t3)) continue; + const i2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = n2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } - } else for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - const n2 = this.isAttribute(i2); - if (n2) { - const s2 = t2[i2]; - true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } else for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + const i2 = this.isAttribute(n2); + if (i2) { + const s2 = t2[n2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + i2 : e2 += " " + i2 + '="' + s2 + '"'; } } return e2; - }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { - if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; + }, kt.prototype.buildObjectNode = function(t2, e2, n2, i2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !n2 && "" !== n2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(i2) + `` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; } - }, Pt.prototype.closeTag = function(t2) { + }, kt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; + }, kt.prototype.buildTextValNode = function(t2, e2, n2, i2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) { + const e3 = String(t2).replace(/\]\]>/g, "]]]]>"); + return this.indentate(i2) + `` + this.newLine; + } + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) { + const e3 = String(t2).replace(/--/g, "- -").replace(/-$/, "- "); + return this.indentate(i2) + `` + this.newLine; + } + if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; { let s3 = this.options.tagValueProcessor(e2, t2); - return s3 = this.replaceEntitiesValue(s3), "" === s3 ? this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + ">" + s3 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const i2 = this.options.entities[e2]; - t2 = t2.replace(i2.regex, i2.val); + const n2 = this.options.entities[e2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; }; - const Ot = Pt, $t = { validate: l }; + const Bt = kt, Ut = { validate: l }; module2.exports = e; })(); } diff --git a/package-lock.json b/package-lock.json index 4772a096f9..4281c814f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1988,6 +1988,18 @@ "@tybys/wasm-util": "^0.10.0" } }, + "node_modules/@nodable/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/nodable" + } + ], + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -5679,9 +5691,9 @@ "license": "MIT" }, "node_modules/fast-xml-builder": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", - "integrity": "sha512-f2jhpN4Eccy0/Uz9csxh3Nu6q4ErKxf0XIsasomfOihuSUa3/xw6w8dnOtCDgEItQFJG8KyXPzQXzcODDrrbOg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.5.tgz", + "integrity": "sha512-4TJn/8FKLeslLAH3dnohXqE3QSoxkhvaMzepOIZytwJXZO69Bfz0HBdDHzOTOon6G59Zrk6VQ2bEiv1t61rfkA==", "funding": [ { "type": "github", @@ -5694,9 +5706,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "5.5.7", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.7.tgz", - "integrity": "sha512-LteOsISQ2GEiDHZch6L9hB0+MLoYVLToR7xotrzU0opCICBkxOPgHAy1HxAvtxfJNXDJpgAsQN30mkrfpO2Prg==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.1.tgz", + "integrity": "sha512-8Cc3f8GUGUULg34pBch/KGyPLglS+OFs05deyOlY7fL2MTagYPKrVQNmR1fLF/yJ9PH5ZSTd3YDF6pnmeZU+zA==", "funding": [ { "type": "github", @@ -5705,9 +5717,10 @@ ], "license": "MIT", "dependencies": { - "fast-xml-builder": "^1.1.4", - "path-expression-matcher": "^1.1.3", - "strnum": "^2.2.0" + "@nodable/entities": "^2.1.0", + "fast-xml-builder": "^1.1.5", + "path-expression-matcher": "^1.5.0", + "strnum": "^2.2.3" }, "bin": { "fxparser": "src/cli/cli.js" @@ -7840,9 +7853,9 @@ } }, "node_modules/path-expression-matcher": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.1.3.tgz", - "integrity": "sha512-qdVgY8KXmVdJZRSS1JdEPOKPdTiEK/pi0RkcT2sw1RhXxohdujUlJFPuS1TSkevZ9vzd3ZlL7ULl1MHGTApKzQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz", + "integrity": "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ==", "funding": [ { "type": "github", @@ -8835,9 +8848,9 @@ } }, "node_modules/strnum": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.1.tgz", - "integrity": "sha512-BwRvNd5/QoAtyW1na1y1LsJGQNvRlkde6Q/ipqqEaivoMdV+B1OMOTVdwR+N/cwVUcIt9PYyHmV8HyexCZSupg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz", + "integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==", "funding": [ { "type": "github",