lakutata
Version:
An IoC-based universal application framework.
1,636 lines (1,538 loc) • 52.4 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
var e = {};
var t = {};
(function(e) {
const t = ":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";
const n = t + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
const i = "[" + t + "][" + n + "]*";
const s = new RegExp("^" + i + "$");
const r = function(e, t) {
const n = [];
let i = t.exec(e);
while (i) {
const s = [];
s.startIndex = t.lastIndex - i[0].length;
const r = i.length;
for (let e = 0; e < r; e++) {
s.push(i[e]);
}
n.push(s);
i = t.exec(e);
}
return n;
};
const o = function(e) {
const t = s.exec(e);
return !(t === null || typeof t === "undefined");
};
e.isExist = function(e) {
return typeof e !== "undefined";
};
e.isEmptyObject = function(e) {
return Object.keys(e).length === 0;
};
e.merge = function(e, t, n) {
if (t) {
const i = Object.keys(t);
const s = i.length;
for (let r = 0; r < s; r++) {
if (n === "strict") {
e[i[r]] = [ t[i[r]] ];
} else {
e[i[r]] = t[i[r]];
}
}
}
};
e.getValue = function(t) {
if (e.isExist(t)) {
return t;
} else {
return "";
}
};
e.isName = o;
e.getAllMatches = r;
e.nameRegexp = i;
})(t);
const n = t;
const i = {
allowBooleanAttributes: false,
unpairedTags: []
};
e.validate = function(e, t) {
t = Object.assign({}, i, t);
const n = [];
let a = false;
let l = false;
if (e[0] === "\ufeff") {
e = e.substr(1);
}
for (let i = 0; i < e.length; i++) {
if (e[i] === "<" && e[i + 1] === "?") {
i += 2;
i = r(e, i);
if (i.err) return i;
} else if (e[i] === "<") {
let f = i;
i++;
if (e[i] === "!") {
i = o(e, i);
continue;
} else {
let h = false;
if (e[i] === "/") {
h = true;
i++;
}
let g = "";
for (;i < e.length && e[i] !== ">" && e[i] !== " " && e[i] !== "\t" && e[i] !== "\n" && e[i] !== "\r"; i++) {
g += e[i];
}
g = g.trim();
if (g[g.length - 1] === "/") {
g = g.substring(0, g.length - 1);
i--;
}
if (!m(g)) {
let t;
if (g.trim().length === 0) {
t = "Invalid space after '<'.";
} else {
t = "Tag '" + g + "' is an invalid name.";
}
return p("InvalidTag", t, x(e, i));
}
const N = u(e, i);
if (N === false) {
return p("InvalidAttr", "Attributes for '" + g + "' have open quote.", x(e, i));
}
let b = N.value;
i = N.index;
if (b[b.length - 1] === "/") {
const n = i - b.length;
b = b.substring(0, b.length - 1);
const s = c(b, t);
if (s === true) {
a = true;
} else {
return p(s.err.code, s.err.msg, x(e, n + s.err.line));
}
} else if (h) {
if (!N.tagClosed) {
return p("InvalidTag", "Closing tag '" + g + "' doesn't have proper closing.", x(e, i));
} else if (b.trim().length > 0) {
return p("InvalidTag", "Closing tag '" + g + "' can't have attributes or invalid starting.", x(e, f));
} else if (n.length === 0) {
return p("InvalidTag", "Closing tag '" + g + "' has not been opened.", x(e, f));
} else {
const t = n.pop();
if (g !== t.tagName) {
let n = x(e, t.tagStartPos);
return p("InvalidTag", "Expected closing tag '" + t.tagName + "' (opened in line " + n.line + ", col " + n.col + ") instead of closing tag '" + g + "'.", x(e, f));
}
if (n.length == 0) {
l = true;
}
}
} else {
const s = c(b, t);
if (s !== true) {
return p(s.err.code, s.err.msg, x(e, i - b.length + s.err.line));
}
if (l === true) {
return p("InvalidXml", "Multiple possible root nodes found.", x(e, i));
} else if (t.unpairedTags.indexOf(g) !== -1) ; else {
n.push({
tagName: g,
tagStartPos: f
});
}
a = true;
}
for (i++; i < e.length; i++) {
if (e[i] === "<") {
if (e[i + 1] === "!") {
i++;
i = o(e, i);
continue;
} else if (e[i + 1] === "?") {
i = r(e, ++i);
if (i.err) return i;
} else {
break;
}
} else if (e[i] === "&") {
const t = d(e, i);
if (t == -1) return p("InvalidChar", "char '&' is not expected.", x(e, i));
i = t;
} else {
if (l === true && !s(e[i])) {
return p("InvalidXml", "Extra text at the end", x(e, i));
}
}
}
if (e[i] === "<") {
i--;
}
}
} else {
if (s(e[i])) {
continue;
}
return p("InvalidChar", "char '" + e[i] + "' is not expected.", x(e, i));
}
}
if (!a) {
return p("InvalidXml", "Start tag expected.", 1);
} else if (n.length == 1) {
return p("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", x(e, n[0].tagStartPos));
} else if (n.length > 0) {
return p("InvalidXml", "Invalid '" + JSON.stringify(n.map(e => e.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", {
line: 1,
col: 1
});
}
return true;
};
function s(e) {
return e === " " || e === "\t" || e === "\n" || e === "\r";
}
function r(e, t) {
const n = t;
for (;t < e.length; t++) {
if (e[t] == "?" || e[t] == " ") {
const i = e.substr(n, t - n);
if (t > 5 && i === "xml") {
return p("InvalidXml", "XML declaration allowed only at the start of the document.", x(e, t));
} else if (e[t] == "?" && e[t + 1] == ">") {
t++;
break;
} else {
continue;
}
}
}
return t;
}
function o(e, t) {
if (e.length > t + 5 && e[t + 1] === "-" && e[t + 2] === "-") {
for (t += 3; t < e.length; t++) {
if (e[t] === "-" && e[t + 1] === "-" && e[t + 2] === ">") {
t += 2;
break;
}
}
} else if (e.length > t + 8 && e[t + 1] === "D" && e[t + 2] === "O" && e[t + 3] === "C" && e[t + 4] === "T" && e[t + 5] === "Y" && e[t + 6] === "P" && e[t + 7] === "E") {
let n = 1;
for (t += 8; t < e.length; t++) {
if (e[t] === "<") {
n++;
} else if (e[t] === ">") {
n--;
if (n === 0) {
break;
}
}
}
} else if (e.length > t + 9 && e[t + 1] === "[" && e[t + 2] === "C" && e[t + 3] === "D" && e[t + 4] === "A" && e[t + 5] === "T" && e[t + 6] === "A" && e[t + 7] === "[") {
for (t += 8; t < e.length; t++) {
if (e[t] === "]" && e[t + 1] === "]" && e[t + 2] === ">") {
t += 2;
break;
}
}
}
return t;
}
const a = '"';
const l = "'";
function u(e, t) {
let n = "";
let i = "";
let s = false;
for (;t < e.length; t++) {
if (e[t] === a || e[t] === l) {
if (i === "") {
i = e[t];
} else if (i !== e[t]) ; else {
i = "";
}
} else if (e[t] === ">") {
if (i === "") {
s = true;
break;
}
}
n += e[t];
}
if (i !== "") {
return false;
}
return {
value: n,
index: t,
tagClosed: s
};
}
const f = new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g");
function c(e, t) {
const i = n.getAllMatches(e, f);
const s = {};
for (let e = 0; e < i.length; e++) {
if (i[e][1].length === 0) {
return p("InvalidAttr", "Attribute '" + i[e][2] + "' has no space in starting.", N(i[e]));
} else if (i[e][3] !== undefined && i[e][4] === undefined) {
return p("InvalidAttr", "Attribute '" + i[e][2] + "' is without value.", N(i[e]));
} else if (i[e][3] === undefined && !t.allowBooleanAttributes) {
return p("InvalidAttr", "boolean attribute '" + i[e][2] + "' is not allowed.", N(i[e]));
}
const n = i[e][2];
if (!g(n)) {
return p("InvalidAttr", "Attribute '" + n + "' is an invalid name.", N(i[e]));
}
if (!s.hasOwnProperty(n)) {
s[n] = 1;
} else {
return p("InvalidAttr", "Attribute '" + n + "' is repeated.", N(i[e]));
}
}
return true;
}
function h(e, t) {
let n = /\d/;
if (e[t] === "x") {
t++;
n = /[\da-fA-F]/;
}
for (;t < e.length; t++) {
if (e[t] === ";") return t;
if (!e[t].match(n)) break;
}
return -1;
}
function d(e, t) {
t++;
if (e[t] === ";") return -1;
if (e[t] === "#") {
t++;
return h(e, t);
}
let n = 0;
for (;t < e.length; t++, n++) {
if (e[t].match(/\w/) && n < 20) continue;
if (e[t] === ";") break;
return -1;
}
return t;
}
function p(e, t, n) {
return {
err: {
code: e,
msg: t,
line: n.line || n,
col: n.col
}
};
}
function g(e) {
return n.isName(e);
}
function m(e) {
return n.isName(e);
}
function x(e, t) {
const n = e.substring(0, t).split(/\r?\n/);
return {
line: n.length,
col: n[n.length - 1].length + 1
};
}
function N(e) {
return e.startIndex + e[1].length;
}
var b = {};
const E = {
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(e, t) {
return t;
},
attributeValueProcessor: function(e, t) {
return t;
},
stopNodes: [],
alwaysCreateTextNode: false,
isArray: () => false,
commentPropName: false,
unpairedTags: [],
processEntities: true,
htmlEntities: false,
ignoreDeclaration: false,
ignorePiTags: false,
transformTagName: false,
transformAttributeName: false,
updateTag: function(e, t, n) {
return e;
}
};
const v = function(e) {
return Object.assign({}, E, e);
};
b.buildOptions = v;
b.defaultOptions = E;
class XmlNode {
constructor(e) {
this.tagname = e;
this.child = [];
this[":@"] = {};
}
add(e, t) {
if (e === "__proto__") e = "#__proto__";
this.child.push({
[e]: t
});
}
addChild(e) {
if (e.tagname === "__proto__") e.tagname = "#__proto__";
if (e[":@"] && Object.keys(e[":@"]).length > 0) {
this.child.push({
[e.tagname]: e.child,
[":@"]: e[":@"]
});
} else {
this.child.push({
[e.tagname]: e.child
});
}
}
}
var y = XmlNode;
const T = t;
function O(e, t) {
const n = {};
if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
t = t + 9;
let i = 1;
let s = false, r = false;
let o = "";
for (;t < e.length; t++) {
if (e[t] === "<" && !r) {
if (s && P(e, t)) {
t += 7;
let i, s;
[i, s, t] = w(e, t + 1);
if (s.indexOf("&") === -1) n[V(i)] = {
regx: RegExp(`&${i};`, "g"),
val: s
};
} else if (s && I(e, t)) t += 8; else if (s && C(e, t)) t += 8; else if (s && S(e, t)) t += 9; else if (A) r = true; else throw new Error("Invalid DOCTYPE");
i++;
o = "";
} else if (e[t] === ">") {
if (r) {
if (e[t - 1] === "-" && e[t - 2] === "-") {
r = false;
i--;
}
} else {
i--;
}
if (i === 0) {
break;
}
} else if (e[t] === "[") {
s = true;
} else {
o += e[t];
}
}
if (i !== 0) {
throw new Error(`Unclosed DOCTYPE`);
}
} else {
throw new Error(`Invalid Tag instead of DOCTYPE`);
}
return {
entities: n,
i: t
};
}
function w(e, t) {
let n = "";
for (;t < e.length && (e[t] !== "'" && e[t] !== '"'); t++) {
n += e[t];
}
n = n.trim();
if (n.indexOf(" ") !== -1) throw new Error("External entites are not supported");
const i = e[t++];
let s = "";
for (;t < e.length && e[t] !== i; t++) {
s += e[t];
}
return [ n, s, t ];
}
function A(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "-" && e[t + 3] === "-") return true;
return false;
}
function P(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "N" && e[t + 4] === "T" && e[t + 5] === "I" && e[t + 6] === "T" && e[t + 7] === "Y") return true;
return false;
}
function I(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "L" && e[t + 4] === "E" && e[t + 5] === "M" && e[t + 6] === "E" && e[t + 7] === "N" && e[t + 8] === "T") return true;
return false;
}
function C(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "A" && e[t + 3] === "T" && e[t + 4] === "T" && e[t + 5] === "L" && e[t + 6] === "I" && e[t + 7] === "S" && e[t + 8] === "T") return true;
return false;
}
function S(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "N" && e[t + 3] === "O" && e[t + 4] === "T" && e[t + 5] === "A" && e[t + 6] === "T" && e[t + 7] === "I" && e[t + 8] === "O" && e[t + 9] === "N") return true;
return false;
}
function V(e) {
if (T.isName(e)) return e; else throw new Error(`Invalid entity name ${e}`);
}
var j = O;
const $ = /^[-+]?0x[a-fA-F0-9]+$/;
const k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
const F = {
hex: true,
leadingZeros: true,
decimalPoint: ".",
eNotation: true
};
function _(e, t = {}) {
t = Object.assign({}, F, t);
if (!e || typeof e !== "string") return e;
let n = e.trim();
if (t.skipLike !== undefined && t.skipLike.test(n)) return e; else if (e === "0") return 0; else if (t.hex && $.test(n)) {
return L(n, 16);
} else if (n.search(/[eE]/) !== -1) {
const i = n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);
if (i) {
if (t.leadingZeros) {
n = (i[1] || "") + i[3];
} else {
if (i[2] === "0" && i[3][0] === ".") ; else {
return e;
}
}
return t.eNotation ? Number(n) : e;
} else {
return e;
}
} else {
const i = k.exec(n);
if (i) {
const s = i[1];
const r = i[2];
let o = D(i[3]);
if (!t.leadingZeros && r.length > 0 && s && n[2] !== ".") return e; else if (!t.leadingZeros && r.length > 0 && !s && n[1] !== ".") return e; else if (t.leadingZeros && r === e) return 0; else {
const i = Number(n);
const a = "" + i;
if (a.search(/[eE]/) !== -1) {
if (t.eNotation) return i; else return e;
} else if (n.indexOf(".") !== -1) {
if (a === "0" && o === "") return i; else if (a === o) return i; else if (s && a === "-" + o) return i; else return e;
}
if (r) {
return o === a || s + o === a ? i : e;
} else {
return n === a || n === s + a ? i : e;
}
}
} else {
return e;
}
}
}
function D(e) {
if (e && e.indexOf(".") !== -1) {
e = e.replace(/0+$/, "");
if (e === ".") e = "0"; else if (e[0] === ".") e = "0" + e; else if (e[e.length - 1] === ".") e = e.substr(0, e.length - 1);
return e;
}
return e;
}
function L(e, t) {
if (parseInt) return parseInt(e, t); else if (Number.parseInt) return Number.parseInt(e, t); else if (window && window.parseInt) return window.parseInt(e, t); else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
}
var M = _;
function B(e) {
if (typeof e === "function") {
return e;
}
if (Array.isArray(e)) {
return t => {
for (const n of e) {
if (typeof n === "string" && t === n) {
return true;
}
if (n instanceof RegExp && n.test(t)) {
return true;
}
}
};
}
return () => false;
}
var X = B;
const G = t;
const R = y;
const U = j;
const Z = M;
const Y = X;
let q = class OrderedObjParser {
constructor(e) {
this.options = e;
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: "¢"
},
pound: {
regex: /&(pound|#163);/g,
val: "£"
},
yen: {
regex: /&(yen|#165);/g,
val: "¥"
},
euro: {
regex: /&(euro|#8364);/g,
val: "€"
},
copyright: {
regex: /&(copy|#169);/g,
val: "©"
},
reg: {
regex: /&(reg|#174);/g,
val: "®"
},
inr: {
regex: /&(inr|#8377);/g,
val: "₹"
},
num_dec: {
regex: /&#([0-9]{1,7});/g,
val: (e, t) => String.fromCharCode(Number.parseInt(t, 10))
},
num_hex: {
regex: /&#x([0-9a-fA-F]{1,6});/g,
val: (e, t) => String.fromCharCode(Number.parseInt(t, 16))
}
};
this.addExternalEntities = W;
this.parseXml = Q;
this.parseTextData = z;
this.resolveNameSpace = J;
this.buildAttributesMap = K;
this.isItStopNode = ie;
this.replaceEntitiesValue = te;
this.readStopNodeData = ae;
this.saveTextToParentTag = ne;
this.addChild = ee;
this.ignoreAttributesFn = Y(this.options.ignoreAttributes);
}
};
function W(e) {
const t = Object.keys(e);
for (let n = 0; n < t.length; n++) {
const i = t[n];
this.lastEntities[i] = {
regex: new RegExp("&" + i + ";", "g"),
val: e[i]
};
}
}
function z(e, t, n, i, s, r, o) {
if (e !== undefined) {
if (this.options.trimValues && !i) {
e = e.trim();
}
if (e.length > 0) {
if (!o) e = this.replaceEntitiesValue(e);
const i = this.options.tagValueProcessor(t, e, n, s, r);
if (i === null || i === undefined) {
return e;
} else if (typeof i !== typeof e || i !== e) {
return i;
} else if (this.options.trimValues) {
return le(e, this.options.parseTagValue, this.options.numberParseOptions);
} else {
const t = e.trim();
if (t === e) {
return le(e, this.options.parseTagValue, this.options.numberParseOptions);
} else {
return e;
}
}
}
}
}
function J(e) {
if (this.options.removeNSPrefix) {
const t = e.split(":");
const n = e.charAt(0) === "/" ? "/" : "";
if (t[0] === "xmlns") {
return "";
}
if (t.length === 2) {
e = n + t[1];
}
}
return e;
}
const H = new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
function K(e, t, n) {
if (this.options.ignoreAttributes !== true && typeof e === "string") {
const n = G.getAllMatches(e, H);
const i = n.length;
const s = {};
for (let e = 0; e < i; e++) {
const i = this.resolveNameSpace(n[e][1]);
if (this.ignoreAttributesFn(i, t)) {
continue;
}
let r = n[e][4];
let o = this.options.attributeNamePrefix + i;
if (i.length) {
if (this.options.transformAttributeName) {
o = this.options.transformAttributeName(o);
}
if (o === "__proto__") o = "#__proto__";
if (r !== undefined) {
if (this.options.trimValues) {
r = r.trim();
}
r = this.replaceEntitiesValue(r);
const e = this.options.attributeValueProcessor(i, r, t);
if (e === null || e === undefined) {
s[o] = r;
} else if (typeof e !== typeof r || e !== r) {
s[o] = e;
} else {
s[o] = le(r, this.options.parseAttributeValue, this.options.numberParseOptions);
}
} else if (this.options.allowBooleanAttributes) {
s[o] = true;
}
}
}
if (!Object.keys(s).length) {
return;
}
if (this.options.attributesGroupName) {
const e = {};
e[this.options.attributesGroupName] = s;
return e;
}
return s;
}
}
const Q = function(e) {
e = e.replace(/\r\n?/g, "\n");
const t = new R("!xml");
let n = t;
let i = "";
let s = "";
for (let r = 0; r < e.length; r++) {
const o = e[r];
if (o === "<") {
if (e[r + 1] === "/") {
const t = re(e, ">", r, "Closing Tag is not closed.");
let o = e.substring(r + 2, t).trim();
if (this.options.removeNSPrefix) {
const e = o.indexOf(":");
if (e !== -1) {
o = o.substr(e + 1);
}
}
if (this.options.transformTagName) {
o = this.options.transformTagName(o);
}
if (n) {
i = this.saveTextToParentTag(i, n, s);
}
const a = s.substring(s.lastIndexOf(".") + 1);
if (o && this.options.unpairedTags.indexOf(o) !== -1) {
throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);
}
let l = 0;
if (a && this.options.unpairedTags.indexOf(a) !== -1) {
l = s.lastIndexOf(".", s.lastIndexOf(".") - 1);
this.tagsNodeStack.pop();
} else {
l = s.lastIndexOf(".");
}
s = s.substring(0, l);
n = this.tagsNodeStack.pop();
i = "";
r = t;
} else if (e[r + 1] === "?") {
let t = oe(e, r, false, "?>");
if (!t) throw new Error("Pi Tag is not closed.");
i = this.saveTextToParentTag(i, n, s);
if (this.options.ignoreDeclaration && t.tagName === "?xml" || this.options.ignorePiTags) ; else {
const e = new R(t.tagName);
e.add(this.options.textNodeName, "");
if (t.tagName !== t.tagExp && t.attrExpPresent) {
e[":@"] = this.buildAttributesMap(t.tagExp, s, t.tagName);
}
this.addChild(n, e, s);
}
r = t.closeIndex + 1;
} else if (e.substr(r + 1, 3) === "!--") {
const t = re(e, "--\x3e", r + 4, "Comment is not closed.");
if (this.options.commentPropName) {
const o = e.substring(r + 4, t - 2);
i = this.saveTextToParentTag(i, n, s);
n.add(this.options.commentPropName, [ {
[this.options.textNodeName]: o
} ]);
}
r = t;
} else if (e.substr(r + 1, 2) === "!D") {
const t = U(e, r);
this.docTypeEntities = t.entities;
r = t.i;
} else if (e.substr(r + 1, 2) === "![") {
const t = re(e, "]]>", r, "CDATA is not closed.") - 2;
const o = e.substring(r + 9, t);
i = this.saveTextToParentTag(i, n, s);
let a = this.parseTextData(o, n.tagname, s, true, false, true, true);
if (a == undefined) a = "";
if (this.options.cdataPropName) {
n.add(this.options.cdataPropName, [ {
[this.options.textNodeName]: o
} ]);
} else {
n.add(this.options.textNodeName, a);
}
r = t + 2;
} else {
let o = oe(e, r, this.options.removeNSPrefix);
let a = o.tagName;
const l = o.rawTagName;
let u = o.tagExp;
let f = o.attrExpPresent;
let c = o.closeIndex;
if (this.options.transformTagName) {
a = this.options.transformTagName(a);
}
if (n && i) {
if (n.tagname !== "!xml") {
i = this.saveTextToParentTag(i, n, s, false);
}
}
const h = n;
if (h && this.options.unpairedTags.indexOf(h.tagname) !== -1) {
n = this.tagsNodeStack.pop();
s = s.substring(0, s.lastIndexOf("."));
}
if (a !== t.tagname) {
s += s ? "." + a : a;
}
if (this.isItStopNode(this.options.stopNodes, s, a)) {
let t = "";
if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
if (a[a.length - 1] === "/") {
a = a.substr(0, a.length - 1);
s = s.substr(0, s.length - 1);
u = a;
} else {
u = u.substr(0, u.length - 1);
}
r = o.closeIndex;
} else if (this.options.unpairedTags.indexOf(a) !== -1) {
r = o.closeIndex;
} else {
const n = this.readStopNodeData(e, l, c + 1);
if (!n) throw new Error(`Unexpected end of ${l}`);
r = n.i;
t = n.tagContent;
}
const i = new R(a);
if (a !== u && f) {
i[":@"] = this.buildAttributesMap(u, s, a);
}
if (t) {
t = this.parseTextData(t, a, s, true, f, true, true);
}
s = s.substr(0, s.lastIndexOf("."));
i.add(this.options.textNodeName, t);
this.addChild(n, i, s);
} else {
if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
if (a[a.length - 1] === "/") {
a = a.substr(0, a.length - 1);
s = s.substr(0, s.length - 1);
u = a;
} else {
u = u.substr(0, u.length - 1);
}
if (this.options.transformTagName) {
a = this.options.transformTagName(a);
}
const e = new R(a);
if (a !== u && f) {
e[":@"] = this.buildAttributesMap(u, s, a);
}
this.addChild(n, e, s);
s = s.substr(0, s.lastIndexOf("."));
} else {
const e = new R(a);
this.tagsNodeStack.push(n);
if (a !== u && f) {
e[":@"] = this.buildAttributesMap(u, s, a);
}
this.addChild(n, e, s);
n = e;
}
i = "";
r = c;
}
}
} else {
i += e[r];
}
}
return t.child;
};
function ee(e, t, n) {
const i = this.options.updateTag(t.tagname, n, t[":@"]);
if (i === false) ; else if (typeof i === "string") {
t.tagname = i;
e.addChild(t);
} else {
e.addChild(t);
}
}
const te = function(e) {
if (this.options.processEntities) {
for (let t in this.docTypeEntities) {
const n = this.docTypeEntities[t];
e = e.replace(n.regx, n.val);
}
for (let t in this.lastEntities) {
const n = this.lastEntities[t];
e = e.replace(n.regex, n.val);
}
if (this.options.htmlEntities) {
for (let t in this.htmlEntities) {
const n = this.htmlEntities[t];
e = e.replace(n.regex, n.val);
}
}
e = e.replace(this.ampEntity.regex, this.ampEntity.val);
}
return e;
};
function ne(e, t, n, i) {
if (e) {
if (i === undefined) i = t.child.length === 0;
e = this.parseTextData(e, t.tagname, n, false, t[":@"] ? Object.keys(t[":@"]).length !== 0 : false, i);
if (e !== undefined && e !== "") t.add(this.options.textNodeName, e);
e = "";
}
return e;
}
function ie(e, t, n) {
const i = "*." + n;
for (const n in e) {
const s = e[n];
if (i === s || t === s) return true;
}
return false;
}
function se(e, t, n = ">") {
let i;
let s = "";
for (let r = t; r < e.length; r++) {
let t = e[r];
if (i) {
if (t === i) i = "";
} else if (t === '"' || t === "'") {
i = t;
} else if (t === n[0]) {
if (n[1]) {
if (e[r + 1] === n[1]) {
return {
data: s,
index: r
};
}
} else {
return {
data: s,
index: r
};
}
} else if (t === "\t") {
t = " ";
}
s += t;
}
}
function re(e, t, n, i) {
const s = e.indexOf(t, n);
if (s === -1) {
throw new Error(i);
} else {
return s + t.length - 1;
}
}
function oe(e, t, n, i = ">") {
const s = se(e, t + 1, i);
if (!s) return;
let r = s.data;
const o = s.index;
const a = r.search(/\s/);
let l = r;
let u = true;
if (a !== -1) {
l = r.substring(0, a);
r = r.substring(a + 1).trimStart();
}
const f = l;
if (n) {
const e = l.indexOf(":");
if (e !== -1) {
l = l.substr(e + 1);
u = l !== s.data.substr(e + 1);
}
}
return {
tagName: l,
tagExp: r,
closeIndex: o,
attrExpPresent: u,
rawTagName: f
};
}
function ae(e, t, n) {
const i = n;
let s = 1;
for (;n < e.length; n++) {
if (e[n] === "<") {
if (e[n + 1] === "/") {
const r = re(e, ">", n, `${t} is not closed`);
let o = e.substring(n + 2, r).trim();
if (o === t) {
s--;
if (s === 0) {
return {
tagContent: e.substring(i, n),
i: r
};
}
}
n = r;
} else if (e[n + 1] === "?") {
const t = re(e, "?>", n + 1, "StopNode is not closed.");
n = t;
} else if (e.substr(n + 1, 3) === "!--") {
const t = re(e, "--\x3e", n + 3, "StopNode is not closed.");
n = t;
} else if (e.substr(n + 1, 2) === "![") {
const t = re(e, "]]>", n, "StopNode is not closed.") - 2;
n = t;
} else {
const i = oe(e, n, ">");
if (i) {
const e = i && i.tagName;
if (e === t && i.tagExp[i.tagExp.length - 1] !== "/") {
s++;
}
n = i.closeIndex;
}
}
}
}
}
function le(e, t, n) {
if (t && typeof e === "string") {
const t = e.trim();
if (t === "true") return true; else if (t === "false") return false; else return Z(e, n);
} else {
if (G.isExist(e)) {
return e;
} else {
return "";
}
}
}
var ue = q;
var fe = {};
function ce(e, t) {
return he(e, t);
}
function he(e, t, n) {
let i;
const s = {};
for (let r = 0; r < e.length; r++) {
const o = e[r];
const a = de(o);
let l = "";
if (n === undefined) l = a; else l = n + "." + a;
if (a === t.textNodeName) {
if (i === undefined) i = o[a]; else i += "" + o[a];
} else if (a === undefined) {
continue;
} else if (o[a]) {
let e = he(o[a], t, l);
const n = ge(e, t);
if (o[":@"]) {
pe(e, o[":@"], l, t);
} else if (Object.keys(e).length === 1 && e[t.textNodeName] !== undefined && !t.alwaysCreateTextNode) {
e = e[t.textNodeName];
} else if (Object.keys(e).length === 0) {
if (t.alwaysCreateTextNode) e[t.textNodeName] = ""; else e = "";
}
if (s[a] !== undefined && s.hasOwnProperty(a)) {
if (!Array.isArray(s[a])) {
s[a] = [ s[a] ];
}
s[a].push(e);
} else {
if (t.isArray(a, l, n)) {
s[a] = [ e ];
} else {
s[a] = e;
}
}
}
}
if (typeof i === "string") {
if (i.length > 0) s[t.textNodeName] = i;
} else if (i !== undefined) s[t.textNodeName] = i;
return s;
}
function de(e) {
const t = Object.keys(e);
for (let e = 0; e < t.length; e++) {
const n = t[e];
if (n !== ":@") return n;
}
}
function pe(e, t, n, i) {
if (t) {
const s = Object.keys(t);
const r = s.length;
for (let o = 0; o < r; o++) {
const r = s[o];
if (i.isArray(r, n + "." + r, true, true)) {
e[r] = [ t[r] ];
} else {
e[r] = t[r];
}
}
}
}
function ge(e, t) {
const {textNodeName: n} = t;
const i = Object.keys(e).length;
if (i === 0) {
return true;
}
if (i === 1 && (e[n] || typeof e[n] === "boolean" || e[n] === 0)) {
return true;
}
return false;
}
fe.prettify = ce;
const {buildOptions: me} = b;
const xe = ue;
const {prettify: Ne} = fe;
const be = e;
let Ee = class XMLParser {
constructor(e) {
this.externalEntities = {};
this.options = me(e);
}
parse(e, t) {
if (typeof e === "string") ; else if (e.toString) {
e = e.toString();
} else {
throw new Error("XML data is accepted in String or Bytes[] form.");
}
if (t) {
if (t === true) t = {};
const n = be.validate(e, t);
if (n !== true) {
throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`);
}
}
const n = new xe(this.options);
n.addExternalEntities(this.externalEntities);
const i = n.parseXml(e);
if (this.options.preserveOrder || i === undefined) return i; else return Ne(i, this.options);
}
addEntity(e, t) {
if (t.indexOf("&") !== -1) {
throw new Error("Entity value can't have '&'");
} else if (e.indexOf("&") !== -1 || e.indexOf(";") !== -1) {
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
} else if (t === "&") {
throw new Error("An entity with value '&' is not permitted");
} else {
this.externalEntities[e] = t;
}
}
};
var ve = Ee;
const ye = "\n";
function Te(e, t) {
let n = "";
if (t.format && t.indentBy.length > 0) {
n = ye;
}
return Oe(e, t, "", n);
}
function Oe(e, t, n, i) {
let s = "";
let r = false;
for (let o = 0; o < e.length; o++) {
const a = e[o];
const l = we(a);
if (l === undefined) continue;
let u = "";
if (n.length === 0) u = l; else u = `${n}.${l}`;
if (l === t.textNodeName) {
let e = a[l];
if (!Pe(u, t)) {
e = t.tagValueProcessor(l, e);
e = Ie(e, t);
}
if (r) {
s += i;
}
s += e;
r = false;
continue;
} else if (l === t.cdataPropName) {
if (r) {
s += i;
}
s += `<![CDATA[${a[l][0][t.textNodeName]}]]>`;
r = false;
continue;
} else if (l === t.commentPropName) {
s += i + `\x3c!--${a[l][0][t.textNodeName]}--\x3e`;
r = true;
continue;
} else if (l[0] === "?") {
const e = Ae(a[":@"], t);
const n = l === "?xml" ? "" : i;
let o = a[l][0][t.textNodeName];
o = o.length !== 0 ? " " + o : "";
s += n + `<${l}${o}${e}?>`;
r = true;
continue;
}
let f = i;
if (f !== "") {
f += t.indentBy;
}
const c = Ae(a[":@"], t);
const h = i + `<${l}${c}`;
const d = Oe(a[l], t, u, f);
if (t.unpairedTags.indexOf(l) !== -1) {
if (t.suppressUnpairedNode) s += h + ">"; else s += h + "/>";
} else if ((!d || d.length === 0) && t.suppressEmptyNode) {
s += h + "/>";
} else if (d && d.endsWith(">")) {
s += h + `>${d}${i}</${l}>`;
} else {
s += h + ">";
if (d && i !== "" && (d.includes("/>") || d.includes("</"))) {
s += i + t.indentBy + d + i;
} else {
s += d;
}
s += `</${l}>`;
}
r = true;
}
return s;
}
function we(e) {
const t = Object.keys(e);
for (let n = 0; n < t.length; n++) {
const i = t[n];
if (!e.hasOwnProperty(i)) continue;
if (i !== ":@") return i;
}
}
function Ae(e, t) {
let n = "";
if (e && !t.ignoreAttributes) {
for (let i in e) {
if (!e.hasOwnProperty(i)) continue;
let s = t.attributeValueProcessor(i, e[i]);
s = Ie(s, t);
if (s === true && t.suppressBooleanAttributes) {
n += ` ${i.substr(t.attributeNamePrefix.length)}`;
} else {
n += ` ${i.substr(t.attributeNamePrefix.length)}="${s}"`;
}
}
}
return n;
}
function Pe(e, t) {
e = e.substr(0, e.length - t.textNodeName.length - 1);
let n = e.substr(e.lastIndexOf(".") + 1);
for (let i in t.stopNodes) {
if (t.stopNodes[i] === e || t.stopNodes[i] === "*." + n) return true;
}
return false;
}
function Ie(e, t) {
if (e && e.length > 0 && t.processEntities) {
for (let n = 0; n < t.entities.length; n++) {
const i = t.entities[n];
e = e.replace(i.regex, i.val);
}
}
return e;
}
var Ce = Te;
const Se = Ce;
const Ve = X;
const je = {
attributeNamePrefix: "@_",
attributesGroupName: false,
textNodeName: "#text",
ignoreAttributes: true,
cdataPropName: false,
format: false,
indentBy: " ",
suppressEmptyNode: false,
suppressUnpairedNode: true,
suppressBooleanAttributes: true,
tagValueProcessor: function(e, t) {
return t;
},
attributeValueProcessor: function(e, t) {
return t;
},
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
};
function $e(e) {
this.options = Object.assign({}, je, e);
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
this.isAttribute = function() {
return false;
};
} else {
this.ignoreAttributesFn = Ve(this.options.ignoreAttributes);
this.attrPrefixLen = this.options.attributeNamePrefix.length;
this.isAttribute = _e;
}
this.processTextOrObjNode = ke;
if (this.options.format) {
this.indentate = Fe;
this.tagEndChar = ">\n";
this.newLine = "\n";
} else {
this.indentate = function() {
return "";
};
this.tagEndChar = ">";
this.newLine = "";
}
}
$e.prototype.build = function(e) {
if (this.options.preserveOrder) {
return Se(e, this.options);
} else {
if (Array.isArray(e) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
e = {
[this.options.arrayNodeName]: e
};
}
return this.j2x(e, 0, []).val;
}
};
$e.prototype.j2x = function(e, t, n) {
let i = "";
let s = "";
const r = n.join(".");
for (let o in e) {
if (!Object.prototype.hasOwnProperty.call(e, o)) continue;
if (typeof e[o] === "undefined") {
if (this.isAttribute(o)) {
s += "";
}
} else if (e[o] === null) {
if (this.isAttribute(o)) {
s += "";
} else if (o === this.options.cdataPropName) {
s += "";
} else if (o[0] === "?") {
s += this.indentate(t) + "<" + o + "?" + this.tagEndChar;
} else {
s += this.indentate(t) + "<" + o + "/" + this.tagEndChar;
}
} else if (e[o] instanceof Date) {
s += this.buildTextValNode(e[o], o, "", t);
} else if (typeof e[o] !== "object") {
const n = this.isAttribute(o);
if (n && !this.ignoreAttributesFn(n, r)) {
i += this.buildAttrPairStr(n, "" + e[o]);
} else if (!n) {
if (o === this.options.textNodeName) {
let t = this.options.tagValueProcessor(o, "" + e[o]);
s += this.replaceEntitiesValue(t);
} else {
s += this.buildTextValNode(e[o], o, "", t);
}
}
} else if (Array.isArray(e[o])) {
const i = e[o].length;
let r = "";
let a = "";
for (let l = 0; l < i; l++) {
const i = e[o][l];
if (typeof i === "undefined") ; else if (i === null) {
if (o[0] === "?") s += this.indentate(t) + "<" + o + "?" + this.tagEndChar; else s += this.indentate(t) + "<" + o + "/" + this.tagEndChar;
} else if (typeof i === "object") {
if (this.options.oneListGroup) {
const e = this.j2x(i, t + 1, n.concat(o));
r += e.val;
if (this.options.attributesGroupName && i.hasOwnProperty(this.options.attributesGroupName)) {
a += e.attrStr;
}
} else {
r += this.processTextOrObjNode(i, o, t, n);
}
} else {
if (this.options.oneListGroup) {
let e = this.options.tagValueProcessor(o, i);
e = this.replaceEntitiesValue(e);
r += e;
} else {
r += this.buildTextValNode(i, o, "", t);
}
}
}
if (this.options.oneListGroup) {
r = this.buildObjectNode(r, o, a, t);
}
s += r;
} else {
if (this.options.attributesGroupName && o === this.options.attributesGroupName) {
const t = Object.keys(e[o]);
const n = t.length;
for (let s = 0; s < n; s++) {
i += this.buildAttrPairStr(t[s], "" + e[o][t[s]]);
}
} else {
s += this.processTextOrObjNode(e[o], o, t, n);
}
}
}
return {
attrStr: i,
val: s
};
};
$e.prototype.buildAttrPairStr = function(e, t) {
t = this.options.attributeValueProcessor(e, "" + t);
t = this.replaceEntitiesValue(t);
if (this.options.suppressBooleanAttributes && t === "true") {
return " " + e;
} else return " " + e + '="' + t + '"';
};
function ke(e, t, n, i) {
const s = this.j2x(e, n + 1, i.concat(t));
if (e[this.options.textNodeName] !== undefined && Object.keys(e).length === 1) {
return this.buildTextValNode(e[this.options.textNodeName], t, s.attrStr, n);
} else {
return this.buildObjectNode(s.val, t, s.attrStr, n);
}
}
$e.prototype.buildObjectNode = function(e, t, n, i) {
if (e === "") {
if (t[0] === "?") return this.indentate(i) + "<" + t + n + "?" + this.tagEndChar; else {
return this.indentate(i) + "<" + t + n + this.closeTag(t) + this.tagEndChar;
}
} else {
let s = "</" + t + this.tagEndChar;
let r = "";
if (t[0] === "?") {
r = "?";
s = "";
}
if ((n || n === "") && e.indexOf("<") === -1) {
return this.indentate(i) + "<" + t + n + r + ">" + e + s;