lakutata
Version:
An IoC-based universal application framework.
1,656 lines (1,543 loc) • 53 kB
JavaScript
import { g as e } from "../../../vendor/Package.5.mjs";
var t = {};
var n = {};
(function(e) {
"use strict";
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;
})(n);
const i = e(n);
"use strict";
const s = n;
const r = {
allowBooleanAttributes: false,
unpairedTags: []
};
var o = t.validate = function(e, t) {
t = Object.assign({}, r, t);
const n = [];
let i = false;
let s = false;
if (e[0] === "\ufeff") {
e = e.substr(1);
}
for (let r = 0; r < e.length; r++) {
if (e[r] === "<" && e[r + 1] === "?") {
r += 2;
r = l(e, r);
if (r.err) return r;
} else if (e[r] === "<") {
let o = r;
r++;
if (e[r] === "!") {
r = u(e, r);
continue;
} else {
let f = false;
if (e[r] === "/") {
f = true;
r++;
}
let c = "";
for (;r < e.length && e[r] !== ">" && e[r] !== " " && e[r] !== "\t" && e[r] !== "\n" && e[r] !== "\r"; r++) {
c += e[r];
}
c = c.trim();
if (c[c.length - 1] === "/") {
c = c.substring(0, c.length - 1);
r--;
}
if (!b(c)) {
let t;
if (c.trim().length === 0) {
t = "Invalid space after '<'.";
} else {
t = "Tag '" + c + "' is an invalid name.";
}
return x("InvalidTag", t, E(e, r));
}
const d = h(e, r);
if (d === false) {
return x("InvalidAttr", "Attributes for '" + c + "' have open quote.", E(e, r));
}
let g = d.value;
r = d.index;
if (g[g.length - 1] === "/") {
const n = r - g.length;
g = g.substring(0, g.length - 1);
const s = p(g, t);
if (s === true) {
i = true;
} else {
return x(s.err.code, s.err.msg, E(e, n + s.err.line));
}
} else if (f) {
if (!d.tagClosed) {
return x("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", E(e, r));
} else if (g.trim().length > 0) {
return x("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", E(e, o));
} else if (n.length === 0) {
return x("InvalidTag", "Closing tag '" + c + "' has not been opened.", E(e, o));
} else {
const t = n.pop();
if (c !== t.tagName) {
let n = E(e, t.tagStartPos);
return x("InvalidTag", "Expected closing tag '" + t.tagName + "' (opened in line " + n.line + ", col " + n.col + ") instead of closing tag '" + c + "'.", E(e, o));
}
if (n.length == 0) {
s = true;
}
}
} else {
const a = p(g, t);
if (a !== true) {
return x(a.err.code, a.err.msg, E(e, r - g.length + a.err.line));
}
if (s === true) {
return x("InvalidXml", "Multiple possible root nodes found.", E(e, r));
} else if (t.unpairedTags.indexOf(c) !== -1) {} else {
n.push({
tagName: c,
tagStartPos: o
});
}
i = true;
}
for (r++; r < e.length; r++) {
if (e[r] === "<") {
if (e[r + 1] === "!") {
r++;
r = u(e, r);
continue;
} else if (e[r + 1] === "?") {
r = l(e, ++r);
if (r.err) return r;
} else {
break;
}
} else if (e[r] === "&") {
const t = m(e, r);
if (t == -1) return x("InvalidChar", "char '&' is not expected.", E(e, r));
r = t;
} else {
if (s === true && !a(e[r])) {
return x("InvalidXml", "Extra text at the end", E(e, r));
}
}
}
if (e[r] === "<") {
r--;
}
}
} else {
if (a(e[r])) {
continue;
}
return x("InvalidChar", "char '" + e[r] + "' is not expected.", E(e, r));
}
}
if (!i) {
return x("InvalidXml", "Start tag expected.", 1);
} else if (n.length == 1) {
return x("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", E(e, n[0].tagStartPos));
} else if (n.length > 0) {
return x("InvalidXml", "Invalid '" + JSON.stringify(n.map((e => e.tagName)), null, 4).replace(/\r?\n/g, "") + "' found.", {
line: 1,
col: 1
});
}
return true;
};
function a(e) {
return e === " " || e === "\t" || e === "\n" || e === "\r";
}
function l(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 x("InvalidXml", "XML declaration allowed only at the start of the document.", E(e, t));
} else if (e[t] == "?" && e[t + 1] == ">") {
t++;
break;
} else {
continue;
}
}
}
return t;
}
function u(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 f = '"';
const c = "'";
function h(e, t) {
let n = "";
let i = "";
let s = false;
for (;t < e.length; t++) {
if (e[t] === f || e[t] === c) {
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 d = new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g");
function p(e, t) {
const n = s.getAllMatches(e, d);
const i = {};
for (let e = 0; e < n.length; e++) {
if (n[e][1].length === 0) {
return x("InvalidAttr", "Attribute '" + n[e][2] + "' has no space in starting.", v(n[e]));
} else if (n[e][3] !== undefined && n[e][4] === undefined) {
return x("InvalidAttr", "Attribute '" + n[e][2] + "' is without value.", v(n[e]));
} else if (n[e][3] === undefined && !t.allowBooleanAttributes) {
return x("InvalidAttr", "boolean attribute '" + n[e][2] + "' is not allowed.", v(n[e]));
}
const s = n[e][2];
if (!N(s)) {
return x("InvalidAttr", "Attribute '" + s + "' is an invalid name.", v(n[e]));
}
if (!i.hasOwnProperty(s)) {
i[s] = 1;
} else {
return x("InvalidAttr", "Attribute '" + s + "' is repeated.", v(n[e]));
}
}
return true;
}
function g(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 m(e, t) {
t++;
if (e[t] === ";") return -1;
if (e[t] === "#") {
t++;
return g(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 x(e, t, n) {
return {
err: {
code: e,
msg: t,
line: n.line || n,
col: n.col
}
};
}
function N(e) {
return s.isName(e);
}
function b(e) {
return s.isName(e);
}
function E(e, t) {
const n = e.substring(0, t).split(/\r?\n/);
return {
line: n.length,
col: n[n.length - 1].length + 1
};
}
function v(e) {
return e.startIndex + e[1].length;
}
var y = {};
const T = {
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 O = function(e) {
return Object.assign({}, T, e);
};
var w = y.buildOptions = O;
var P = y.defaultOptions = T;
"use strict";
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 A = XmlNode;
const I = e(A);
const C = n;
function S(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 && k(e, t)) {
t += 7;
let i, s;
[i, s, t] = V(e, t + 1);
if (s.indexOf("&") === -1) n[D(i)] = {
regx: RegExp(`&${i};`, "g"),
val: s
};
} else if (s && $(e, t)) t += 8; else if (s && F(e, t)) t += 8; else if (s && _(e, t)) t += 9; else if (j) 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 V(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 j(e, t) {
if (e[t + 1] === "!" && e[t + 2] === "-" && e[t + 3] === "-") return true;
return false;
}
function k(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 $(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 F(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 _(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 D(e) {
if (C.isName(e)) return e; else throw new Error(`Invalid entity name ${e}`);
}
var L = S;
const M = e(L);
const B = /^[-+]?0x[a-fA-F0-9]+$/;
const X = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
const G = {
hex: true,
leadingZeros: true,
decimalPoint: ".",
eNotation: true
};
function R(e, t = {}) {
t = Object.assign({}, G, 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 && B.test(n)) {
return Z(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 = X.exec(n);
if (i) {
const s = i[1];
const r = i[2];
let o = U(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 U(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 Z(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 Y = R;
const q = e(Y);
function W(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 z = W;
const J = e(z);
"use strict";
const H = n;
const K = A;
const Q = L;
const ee = Y;
const te = z;
let ne = 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 = ie;
this.parseXml = le;
this.parseTextData = se;
this.resolveNameSpace = re;
this.buildAttributesMap = ae;
this.isItStopNode = he;
this.replaceEntitiesValue = fe;
this.readStopNodeData = me;
this.saveTextToParentTag = ce;
this.addChild = ue;
this.ignoreAttributesFn = te(this.options.ignoreAttributes);
}
};
function ie(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 se(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 xe(e, this.options.parseTagValue, this.options.numberParseOptions);
} else {
const t = e.trim();
if (t === e) {
return xe(e, this.options.parseTagValue, this.options.numberParseOptions);
} else {
return e;
}
}
}
}
}
function re(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 oe = new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
function ae(e, t, n) {
if (this.options.ignoreAttributes !== true && typeof e === "string") {
const n = H.getAllMatches(e, oe);
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] = xe(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 le = function(e) {
e = e.replace(/\r\n?/g, "\n");
const t = new K("!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 = pe(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 = ge(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 K(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 = pe(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 = Q(e, r);
this.docTypeEntities = t.entities;
r = t.i;
} else if (e.substr(r + 1, 2) === "![") {
const t = pe(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 = ge(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 K(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 K(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 K(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 ue(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 fe = 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 ce(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 he(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 de(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 pe(e, t, n, i) {
const s = e.indexOf(t, n);
if (s === -1) {
throw new Error(i);
} else {
return s + t.length - 1;
}
}
function ge(e, t, n, i = ">") {
const s = de(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 me(e, t, n) {
const i = n;
let s = 1;
for (;n < e.length; n++) {
if (e[n] === "<") {
if (e[n + 1] === "/") {
const r = pe(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 = pe(e, "?>", n + 1, "StopNode is not closed.");
n = t;
} else if (e.substr(n + 1, 3) === "!--") {
const t = pe(e, "--\x3e", n + 3, "StopNode is not closed.");
n = t;
} else if (e.substr(n + 1, 2) === "![") {
const t = pe(e, "]]>", n, "StopNode is not closed.") - 2;
n = t;
} else {
const i = ge(e, n, ">");
if (i) {
const e = i && i.tagName;
if (e === t && i.tagExp[i.tagExp.length - 1] !== "/") {
s++;
}
n = i.closeIndex;
}
}
}
}
}
function xe(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 ee(e, n);
} else {
if (H.isExist(e)) {
return e;
} else {
return "";
}
}
}
var Ne = ne;
const be = e(Ne);
var Ee = {};
"use strict";
function ve(e, t) {
return ye(e, t);
}
function ye(e, t, n) {
let i;
const s = {};
for (let r = 0; r < e.length; r++) {
const o = e[r];
const a = Te(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 = ye(o[a], t, l);
const n = we(e, t);
if (o[":@"]) {
Oe(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 Te(e) {
const t = Object.keys(e);
for (let e = 0; e < t.length; e++) {
const n = t[e];
if (n !== ":@") return n;
}
}
function Oe(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 we(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;
}
var Pe = Ee.prettify = ve;
const {buildOptions: Ae} = y;
const Ie = Ne;
const {prettify: Ce} = Ee;
const Se = t;
let Ve = class XMLParser {
constructor(e) {
this.externalEntities = {};
this.options = Ae(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 = Se.validate(e, t);
if (n !== true) {
throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`);
}
}
const n = new Ie(this.options);
n.addExternalEntities(this.externalEntities);
const i = n.parseXml(e);
if (this.options.preserveOrder || i === undefined) return i; else return Ce(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 je = Ve;
const ke = e(je);
const $e = "\n";
function Fe(e, t) {
let n = "";
if (t.format && t.indentBy.length > 0) {
n = $e;
}
return _e(e, t, "", n);
}
function _e(e, t, n, i) {
let s = "";
let r = false;
for (let o = 0; o < e.length; o++) {
const a = e[o];
const l = De(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 (!Me(u, t)) {
e = t.tagValueProcessor(l, e);
e = Be(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 = Le(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 = Le(a[":@"], t);
const h = i + `<${l}${c}`;
const d = _e(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 De(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 Le(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 = Be(s, t);
if (s === true && t.suppressBooleanAttributes) {
n += ` ${i.substr(t.attributeNamePrefix.length)}`;
} else {
n += ` ${i.substr(t.attributeNamePrefix.length)}="${s}"`;
}
}
}
return n;
}
function Me(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 Be(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 Xe = Fe;
const Ge = e(Xe);
"use strict";
const Re = Xe;
const Ue = z;
const Ze = {
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 Ye(e) {
this.options = Object.assign({}, Ze, e);
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
this.isAttribute = function() {
return false;
};
} else {
this.ignoreAttributesFn = Ue(this.options.ignoreAttributes);
this.attrPrefixLen = this.options.attributeNamePrefix.length;
this.isAttribute = Je;
}
this.processTextOrObjNode = qe;
if (this.options.format) {
this.indentate = ze;
this.tagEndChar = ">\n";
this.newLine = "\n";
} else {
this.indentate = function() {
return "";
};
this.tagEndChar = ">";
this.newLine = "";
}
}
Ye.prototype.build = function(e) {
if (this.options.preserveOrder) {
return Re(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;
}
};
Ye.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
};
};
Ye.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 qe(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);
}
}
Ye.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;
}