fast-xml-parser 5.3.6 → 5.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/fxbuilder.min.js +1 -1
- package/lib/fxbuilder.min.js.map +1 -1
- package/lib/fxp.cjs +1 -1
- package/lib/fxp.d.cts +1 -1
- package/lib/fxp.min.js +1 -1
- package/lib/fxp.min.js.map +1 -1
- package/lib/fxparser.min.js +1 -1
- package/lib/fxparser.min.js.map +1 -1
- package/lib/fxvalidator.min.js +1 -1
- package/lib/fxvalidator.min.js.map +1 -1
- package/package.json +2 -2
- package/src/util.js +1 -26
package/lib/fxp.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>pt,XMLParser:()=>nt,XMLValidator:()=>vt});var r=":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("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function n(t,e){for(var r=[],i=e.exec(t);i;){var n=[];n.startIndex=e.lastIndex-i[0].length;for(var a=i.length,s=0;s<a;s++)n.push(i[s]);r.push(n),i=e.exec(t)}return r}var a=function(t){return!(null==i.exec(t))},s={allowBooleanAttributes:!1,unpairedTags:[]};function o(t,e){e=Object.assign({},s,e);var r=[],i=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if((o=u(t,o+=2)).err)return o}else{if("<"!==t[o]){if(l(t[o]))continue;return x("InvalidChar","char '"+t[o]+"' is not expected.",b(t,o))}var h=o;if("!"===t[++o]){o=d(t,o);continue}var p=!1;"/"===t[o]&&(p=!0,o++);for(var g="";o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)g+=t[o];if("/"===(g=g.trim())[g.length-1]&&(g=g.substring(0,g.length-1),o--),!a(g))return x("InvalidTag",0===g.trim().length?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",b(t,o));var m=f(t,o);if(!1===m)return x("InvalidAttr","Attributes for '"+g+"' have open quote.",b(t,o));var E=m.value;if(o=m.index,"/"===E[E.length-1]){var N=o-E.length,y=c(E=E.substring(0,E.length-1),e);if(!0!==y)return x(y.err.code,y.err.msg,b(t,N+y.err.line));i=!0}else if(p){if(!m.tagClosed)return x("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",b(t,o));if(E.trim().length>0)return x("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",b(t,h));if(0===r.length)return x("InvalidTag","Closing tag '"+g+"' has not been opened.",b(t,h));var T=r.pop();if(g!==T.tagName){var w=b(t,T.tagStartPos);return x("InvalidTag","Expected closing tag '"+T.tagName+"' (opened in line "+w.line+", col "+w.col+") instead of closing tag '"+g+"'.",b(t,h))}0==r.length&&(n=!0)}else{var I=c(E,e);if(!0!==I)return x(I.err.code,I.err.msg,b(t,o-E.length+I.err.line));if(!0===n)return x("InvalidXml","Multiple possible root nodes found.",b(t,o));-1!==e.unpairedTags.indexOf(g)||r.push({tagName:g,tagStartPos:h}),i=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o=d(t,++o);continue}if("?"!==t[o+1])break;if((o=u(t,++o)).err)return o}else if("&"===t[o]){var O=v(t,o);if(-1==O)return x("InvalidChar","char '&' is not expected.",b(t,o));o=O}else if(!0===n&&!l(t[o]))return x("InvalidXml","Extra text at the end",b(t,o));"<"===t[o]&&o--}return i?1==r.length?x("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",b(t,r[0].tagStartPos)):!(r.length>0)||x("InvalidXml","Invalid '"+JSON.stringify(r.map((function(t){return t.tagName})),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):x("InvalidXml","Start tag expected.",1)}function l(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function u(t,e){for(var r=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var i=t.substr(r,e-r);if(e>5&&"xml"===i)return x("InvalidXml","XML declaration allowed only at the start of the document.",b(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var r=1;for(e+=8;e<t.length;e++)if("<"===t[e])r++;else if(">"===t[e]&&0==--r)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var h='"',p="'";function f(t,e){for(var r="",i="",n=!1;e<t.length;e++){if(t[e]===h||t[e]===p)""===i?i=t[e]:i!==t[e]||(i="");else if(">"===t[e]&&""===i){n=!0;break}r+=t[e]}return""===i&&{value:r,index:e,tagClosed:n}}var g=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function c(t,e){for(var r=n(t,g),i={},a=0;a<r.length;a++){if(0===r[a][1].length)return x("InvalidAttr","Attribute '"+r[a][2]+"' has no space in starting.",E(r[a]));if(void 0!==r[a][3]&&void 0===r[a][4])return x("InvalidAttr","Attribute '"+r[a][2]+"' is without value.",E(r[a]));if(void 0===r[a][3]&&!e.allowBooleanAttributes)return x("InvalidAttr","boolean attribute '"+r[a][2]+"' is not allowed.",E(r[a]));var s=r[a][2];if(!m(s))return x("InvalidAttr","Attribute '"+s+"' is an invalid name.",E(r[a]));if(i.hasOwnProperty(s))return x("InvalidAttr","Attribute '"+s+"' is repeated.",E(r[a]));i[s]=1}return!0}function v(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var r=/\d/;for("x"===t[e]&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(r))break}return-1}(t,++e);for(var r=0;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(";"===t[e])break;return-1}return e}function x(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function m(t){return a(t)}function b(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function E(t){return t.startIndex+t[1].length}var N={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1};function y(t){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:null!=(e=t.maxEntitySize)?e:1e4,maxExpansionDepth:null!=(r=t.maxExpansionDepth)?r:10,maxTotalExpansions:null!=(i=t.maxTotalExpansions)?i:1e3,maxExpandedLength:null!=(n=t.maxExpandedLength)?n:1e5,allowedTags:null!=(a=t.allowedTags)?a:null,tagFilter:null!=(s=t.tagFilter)?s:null}:y(!0);var e,r,i,n,a,s}var T,w=function(t){var e=Object.assign({},N,t);return e.processEntities=y(e.processEntities),e};T="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var I=function(){function t(t){this.tagname=t,this.child=[],this[":@"]={}}var e=t.prototype;return e.add=function(t,e){var r;"__proto__"===t&&(t="#__proto__"),this.child.push(((r={})[t]=e,r))},e.addChild=function(t,e){var r,i;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((r={})[t.tagname]=t.child,r[":@"]=t[":@"],r)):this.child.push(((i={})[t.tagname]=t.child,i)),void 0!==e&&(this.child[this.child.length-1][T]={startIndex:e})},t.getMetaDataSymbol=function(){return T},t}(),O=function(){function t(t){this.suppressValidationErr=!t,this.options=t}var e=t.prototype;return e.readDocType=function(t,e){var r={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var i=1,n=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,i--):i--,0===i)break}else"["===t[e]?n=!0:t[e];else{if(n&&P(t,"!ENTITY",e)){e+=7;var s=void 0,o=void 0,l=this.readEntityExp(t,e+1,this.suppressValidationErr);if(s=l[0],o=l[1],e=l[2],-1===o.indexOf("&")){var u=s.replace(/[.\-+*:]/g,"\\.");r[s]={regx:RegExp("&"+u+";","g"),val:o}}}else if(n&&P(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(n&&P(t,"!ATTLIST",e))e+=8;else if(n&&P(t,"!NOTATION",e))e+=9,e=this.readNotationExp(t,e+1,this.suppressValidationErr).index;else{if(!P(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}},e.readEntityExp=function(t,e){e=A(t,e);for(var r="";e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)r+=t[e],e++;if(S(r),e=A(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}var i,n=this.readIdentifierVal(t,e,"entity");if(e=n[0],i=n[1],!1!==this.options.enabled&&this.options.maxEntitySize&&i.length>this.options.maxEntitySize)throw new Error('Entity "'+r+'" size ('+i.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[r,i,--e]},e.readNotationExp=function(t,e){e=A(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;!this.suppressValidationErr&&S(r),e=A(t,e);var i=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==i&&"PUBLIC"!==i)throw new Error('Expected SYSTEM or PUBLIC, found "'+i+'"');e+=i.length,e=A(t,e);var n=null,a=null;if("PUBLIC"===i){var s=this.readIdentifierVal(t,e,"publicIdentifier");if(e=s[0],n=s[1],'"'===t[e=A(t,e)]||"'"===t[e]){var o=this.readIdentifierVal(t,e,"systemIdentifier");e=o[0],a=o[1]}}else if("SYSTEM"===i){var l=this.readIdentifierVal(t,e,"systemIdentifier");if(e=l[0],a=l[1],!this.suppressValidationErr&&!a)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:r,publicIdentifier:n,systemIdentifier:a,index:--e}},e.readIdentifierVal=function(t,e,r){var i="",n=t[e];if('"'!==n&&"'"!==n)throw new Error('Expected quoted string, found "'+n+'"');for(e++;e<t.length&&t[e]!==n;)i+=t[e],e++;if(t[e]!==n)throw new Error("Unterminated "+r+" value");return[++e,i]},e.readElementExp=function(t,e){e=A(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;if(!this.suppressValidationErr&&!a(r))throw new Error('Invalid element name: "'+r+'"');var i="";if("E"===t[e=A(t,e)]&&P(t,"MPTY",e))e+=4;else if("A"===t[e]&&P(t,"NY",e))e+=2;else if("("===t[e]){for(e++;e<t.length&&")"!==t[e];)i+=t[e],e++;if(")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error('Invalid Element Expression, found "'+t[e]+'"');return{elementName:r,contentModel:i.trim(),index:e}},e.readAttlistExp=function(t,e){e=A(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;S(r),e=A(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;if(!S(i))throw new Error('Invalid attribute name: "'+i+'"');e=A(t,e);var n="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(n="NOTATION","("!==t[e=A(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var a=[];e<t.length&&")"!==t[e];){for(var s="";e<t.length&&"|"!==t[e]&&")"!==t[e];)s+=t[e],e++;if(!S(s=s.trim()))throw new Error('Invalid notation name: "'+s+'"');a.push(s),"|"===t[e]&&(e++,e=A(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,n+=" ("+a.join("|")+")"}else{for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(n.toUpperCase()))throw new Error('Invalid attribute type: "'+n+'"')}e=A(t,e);var o="";if("#REQUIRED"===t.substring(e,e+8).toUpperCase())o="#REQUIRED",e+=8;else if("#IMPLIED"===t.substring(e,e+7).toUpperCase())o="#IMPLIED",e+=7;else{var l=this.readIdentifierVal(t,e,"ATTLIST");e=l[0],o=l[1]}return{elementName:r,attributeName:i,attributeType:n,defaultValue:o,index:e}},t}(),A=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function P(t,e,r){for(var i=0;i<e.length;i++)if(e[i]!==t[r+i+1])return!1;return!0}function S(t){if(a(t))return t;throw new Error("Invalid entity name "+t)}const C=/^[-+]?0x[a-fA-F0-9]+$/,V=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,D={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const j=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function F(t){return"function"==typeof t?t:Array.isArray(t)?function(e){for(var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(r=i()).done;){var n=r.value;if("string"==typeof n&&e===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}}:function(){return!1}}var M=function(t){if(this.options=t,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:function(t,e){return Q(e,10,"&#")}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return Q(e,16,"&#x")}}},this.addExternalEntities=_,this.parseXml=Y,this.parseTextData=k,this.resolveNameSpace=U,this.buildAttributesMap=R,this.isItStopNode=$,this.replaceEntitiesValue=X,this.readStopNodeData=Z,this.saveTextToParentTag=z,this.addChild=G,this.ignoreAttributesFn=F(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(var e=0;e<this.options.stopNodes.length;e++){var r=this.options.stopNodes[e];"string"==typeof r&&(r.startsWith("*.")?this.stopNodesWildcard.add(r.substring(2)):this.stopNodesExact.add(r))}}};function _(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r],n=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+n+";","g"),val:t[i]}}}function k(t,e,r,i,n,a,s){if(void 0!==t&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t,e,r));var o=this.options.tagValueProcessor(e,t,r,n,a);return null==o?t:typeof o!=typeof t||o!==t?o:this.options.trimValues||t.trim()===t?K(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function U(t){if(this.options.removeNSPrefix){var e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}var B=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function R(t,e,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var i=n(t,B),a=i.length,s={},o=0;o<a;o++){var l=this.resolveNameSpace(i[o][1]);if(!this.ignoreAttributesFn(l,e)){var u=i[o][4],d=this.options.attributeNamePrefix+l;if(l.length)if(this.options.transformAttributeName&&(d=this.options.transformAttributeName(d)),"__proto__"===d&&(d="#__proto__"),void 0!==u){this.options.trimValues&&(u=u.trim()),u=this.replaceEntitiesValue(u,r,e);var h=this.options.attributeValueProcessor(l,u,e);s[d]=null==h?u:typeof h!=typeof u||h!==u?h:K(u,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[d]=!0)}}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){var p={};return p[this.options.attributesGroupName]=s,p}return s}}var Y=function(t){t=t.replace(/\r\n?/g,"\n");var e=new I("!xml"),r=e,i="",n="";this.entityExpansionCount=0,this.currentExpandedLength=0;for(var a=new O(this.options.processEntities),s=0;s<t.length;s++)if("<"===t[s])if("/"===t[s+1]){var o=W(t,">",s,"Closing Tag is not closed."),l=t.substring(s+2,o).trim();if(this.options.removeNSPrefix){var u=l.indexOf(":");-1!==u&&(l=l.substr(u+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),r&&(i=this.saveTextToParentTag(i,r,n));var d=n.substring(n.lastIndexOf(".")+1);if(l&&-1!==this.options.unpairedTags.indexOf(l))throw new Error("Unpaired tag can not be used as closing tag: </"+l+">");var h=0;d&&-1!==this.options.unpairedTags.indexOf(d)?(h=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=n.lastIndexOf("."),n=n.substring(0,h),r=this.tagsNodeStack.pop(),i="",s=o}else if("?"===t[s+1]){var p=q(t,s,!1,"?>");if(!p)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),this.options.ignoreDeclaration&&"?xml"===p.tagName||this.options.ignorePiTags);else{var f=new I(p.tagName);f.add(this.options.textNodeName,""),p.tagName!==p.tagExp&&p.attrExpPresent&&(f[":@"]=this.buildAttributesMap(p.tagExp,n,p.tagName)),this.addChild(r,f,n,s)}s=p.closeIndex+1}else if("!--"===t.substr(s+1,3)){var g=W(t,"--\x3e",s+4,"Comment is not closed.");if(this.options.commentPropName){var c,v=t.substring(s+4,g-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[(c={},c[this.options.textNodeName]=v,c)])}s=g}else if("!D"===t.substr(s+1,2)){var x=a.readDocType(t,s);this.docTypeEntities=x.entities,s=x.i}else if("!["===t.substr(s+1,2)){var m=W(t,"]]>",s,"CDATA is not closed.")-2,b=t.substring(s+9,m);i=this.saveTextToParentTag(i,r,n);var E,N=this.parseTextData(b,r.tagname,n,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[(E={},E[this.options.textNodeName]=b,E)]):r.add(this.options.textNodeName,N),s=m+2}else{var y=q(t,s,this.options.removeNSPrefix),T=y.tagName,w=y.rawTagName,A=y.tagExp,P=y.attrExpPresent,S=y.closeIndex;if(this.options.transformTagName){var C=this.options.transformTagName(T);A===T&&(A=C),T=C}r&&i&&"!xml"!==r.tagname&&(i=this.saveTextToParentTag(i,r,n,!1));var V=r;V&&-1!==this.options.unpairedTags.indexOf(V.tagname)&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),T!==e.tagname&&(n+=n?"."+T:T);var D=s;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,n,T)){var j="";if(A.length>0&&A.lastIndexOf("/")===A.length-1)"/"===T[T.length-1]?(T=T.substr(0,T.length-1),n=n.substr(0,n.length-1),A=T):A=A.substr(0,A.length-1),s=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(T))s=y.closeIndex;else{var L=this.readStopNodeData(t,w,S+1);if(!L)throw new Error("Unexpected end of "+w);s=L.i,j=L.tagContent}var F=new I(T);T!==A&&P&&(F[":@"]=this.buildAttributesMap(A,n,T)),j&&(j=this.parseTextData(j,T,n,!0,P,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),F.add(this.options.textNodeName,j),this.addChild(r,F,n,D)}else{if(A.length>0&&A.lastIndexOf("/")===A.length-1){if("/"===T[T.length-1]?(T=T.substr(0,T.length-1),n=n.substr(0,n.length-1),A=T):A=A.substr(0,A.length-1),this.options.transformTagName){var M=this.options.transformTagName(T);A===T&&(A=M),T=M}var _=new I(T);T!==A&&P&&(_[":@"]=this.buildAttributesMap(A,n,T)),this.addChild(r,_,n,D),n=n.substr(0,n.lastIndexOf("."))}else{var k=new I(T);this.tagsNodeStack.push(r),T!==A&&P&&(k[":@"]=this.buildAttributesMap(A,n,T)),this.addChild(r,k,n,D),r=k}i="",s=S}}else i+=t[s];return e.child};function G(t,e,r,i){this.options.captureMetaData||(i=void 0);var n=this.options.updateTag(e.tagname,r,e[":@"]);!1===n||("string"==typeof n?(e.tagname=n,t.addChild(e,i)):t.addChild(e,i))}var X=function(t,e,r){if(-1===t.indexOf("&"))return t;var i=this.options.processEntities;if(!i.enabled)return t;if(i.allowedTags&&!i.allowedTags.includes(e))return t;if(i.tagFilter&&!i.tagFilter(e,r))return t;for(var n in this.docTypeEntities){var a=this.docTypeEntities[n],s=t.match(a.regx);if(s){if(this.entityExpansionCount+=s.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+i.maxTotalExpansions);var o=t.length;if(t=t.replace(a.regx,a.val),i.maxExpandedLength&&(this.currentExpandedLength+=t.length-o,this.currentExpandedLength>i.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+i.maxExpandedLength)}}if(-1===t.indexOf("&"))return t;for(var l in this.lastEntities){var u=this.lastEntities[l];t=t.replace(u.regex,u.val)}if(-1===t.indexOf("&"))return t;if(this.options.htmlEntities)for(var d in this.htmlEntities){var h=this.htmlEntities[d];t=t.replace(h.regex,h.val)}return t.replace(this.ampEntity.regex,this.ampEntity.val)};function z(t,e,r,i){return t&&(void 0===i&&(i=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function $(t,e,r,i){return!(!e||!e.has(i))||!(!t||!t.has(r))}function W(t,e,r,i){var n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}function q(t,e,r,i){void 0===i&&(i=">");var n=function(t,e,r){var i;void 0===r&&(r=">");for(var n="",a=e;a<t.length;a++){var s=t[a];if(i)s===i&&(i="");else if('"'===s||"'"===s)i=s;else if(s===r[0]){if(!r[1])return{data:n,index:a};if(t[a+1]===r[1])return{data:n,index:a}}else"\t"===s&&(s=" ");n+=s}}(t,e+1,i);if(n){var a=n.data,s=n.index,o=a.search(/\s/),l=a,u=!0;-1!==o&&(l=a.substring(0,o),a=a.substring(o+1).trimStart());var d=l;if(r){var h=l.indexOf(":");-1!==h&&(u=(l=l.substr(h+1))!==n.data.substr(h+1))}return{tagName:l,tagExp:a,closeIndex:s,attrExpPresent:u,rawTagName:d}}}function Z(t,e,r){for(var i=r,n=1;r<t.length;r++)if("<"===t[r])if("/"===t[r+1]){var a=W(t,">",r,e+" is not closed");if(t.substring(r+2,a).trim()===e&&0==--n)return{tagContent:t.substring(i,r),i:a};r=a}else if("?"===t[r+1])r=W(t,"?>",r+1,"StopNode is not closed.");else if("!--"===t.substr(r+1,3))r=W(t,"--\x3e",r+3,"StopNode is not closed.");else if("!["===t.substr(r+1,2))r=W(t,"]]>",r,"StopNode is not closed.")-2;else{var s=q(t,r,">");s&&((s&&s.tagName)===e&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,r=s.closeIndex)}}function K(t,e,r){if(e&&"string"==typeof t){var i=t.trim();return"true"===i||"false"!==i&&function(t,e={}){if(e=Object.assign({},D,e),!t||"string"!=typeof t)return t;let r=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(r))return t;if("0"===t)return 0;if(e.hex&&C.test(r))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(-1!==r.search(/.+[eE].+/))return function(t,e,r){if(!r.eNotation)return t;const i=e.match(j);if(i){let n=i[1]||"";const a=-1===i[3].indexOf("e")?"E":"e",s=i[2],o=n?t[s.length+1]===a:t[s.length]===a;return s.length>1&&o?t:1!==s.length||!i[3].startsWith(`.${a}`)&&i[3][0]!==a?r.leadingZeros&&!o?(e=(i[1]||"")+i[3],Number(e)):t:Number(e)}return t}(t,r,e);{const n=V.exec(r);if(n){const a=n[1]||"",s=n[2];let o=(i=n[3])&&-1!==i.indexOf(".")?("."===(i=i.replace(/0+$/,""))?i="0":"."===i[0]?i="0"+i:"."===i[i.length-1]&&(i=i.substring(0,i.length-1)),i):i;const l=a?"."===t[s.length+1]:"."===t[s.length];if(!e.leadingZeros&&(s.length>1||1===s.length&&!l))return t;{const i=Number(r),n=String(i);if(0===i||-0===i)return i;if(-1!==n.search(/[eE]/))return e.eNotation?i:t;if(-1!==r.indexOf("."))return"0"===n||n===o||n===`${a}${o}`?i:t;let l=s?o:r;return s?l===n||a+l===n?i:t:l===n||l===a+n?i:t}}return t}var i}(t,r)}return void 0!==t?t:""}function Q(t,e,r){var i=Number.parseInt(t,e);return i>=0&&i<=1114111?String.fromCodePoint(i):r+t+";"}var J=I.getMetaDataSymbol();function H(t,e){return tt(t,e)}function tt(t,e,r){for(var i,n={},a=0;a<t.length;a++){var s,o=t[a],l=et(o);if(s=void 0===r?l:r+"."+l,l===e.textNodeName)void 0===i?i=o[l]:i+=""+o[l];else{if(void 0===l)continue;if(o[l]){var u=tt(o[l],e,s),d=it(u,e);void 0!==o[J]&&(u[J]=o[J]),o[":@"]?rt(u,o[":@"],s,e):1!==Object.keys(u).length||void 0===u[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(u).length&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""):u=u[e.textNodeName],void 0!==n[l]&&n.hasOwnProperty(l)?(Array.isArray(n[l])||(n[l]=[n[l]]),n[l].push(u)):e.isArray(l,s,d)?n[l]=[u]:n[l]=u}}}return"string"==typeof i?i.length>0&&(n[e.textNodeName]=i):void 0!==i&&(n[e.textNodeName]=i),n}function et(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(":@"!==i)return i}}function rt(t,e,r,i){if(e)for(var n=Object.keys(e),a=n.length,s=0;s<a;s++){var o=n[s];i.isArray(o,r+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function it(t,e){var r=e.textNodeName,i=Object.keys(t).length;return 0===i||!(1!==i||!t[r]&&"boolean"!=typeof t[r]&&0!==t[r])}var nt=function(){function t(t){this.externalEntities={},this.options=w(t)}var e=t.prototype;return e.parse=function(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});var r=o(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var i=new M(this.options);i.addExternalEntities(this.externalEntities);var n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:H(n,this.options)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return I.getMetaDataSymbol()},t}();function at(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),st(t,e,"",r)}function st(t,e,r,i){for(var n="",a=!1,s=0;s<t.length;s++){var o=t[s],l=ot(o);if(void 0!==l){var u;if(u=0===r.length?l:r+"."+l,l!==e.textNodeName)if(l!==e.cdataPropName)if(l!==e.commentPropName)if("?"!==l[0]){var d=i;""!==d&&(d+=e.indentBy);var h=i+"<"+l+lt(o[":@"],e),p=st(o[l],e,u,d);-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?n+=h+">":n+=h+"/>":p&&0!==p.length||!e.suppressEmptyNode?p&&p.endsWith(">")?n+=h+">"+p+i+"</"+l+">":(n+=h+">",p&&""!==i&&(p.includes("/>")||p.includes("</"))?n+=i+e.indentBy+p+i:n+=p,n+="</"+l+">"):n+=h+"/>",a=!0}else{var f=lt(o[":@"],e),g="?xml"===l?"":i,c=o[l][0][e.textNodeName];n+=g+"<"+l+(c=0!==c.length?" "+c:"")+f+"?>",a=!0}else n+=i+"\x3c!--"+o[l][0][e.textNodeName]+"--\x3e",a=!0;else a&&(n+=i),n+="<![CDATA["+o[l][0][e.textNodeName]+"]]>",a=!1;else{var v=o[l];ut(u,e)||(v=dt(v=e.tagValueProcessor(l,v),e)),a&&(n+=i),n+=v,a=!1}}}return n}function ot(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(t.hasOwnProperty(i)&&":@"!==i)return i}}function lt(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(t.hasOwnProperty(i)){var n=e.attributeValueProcessor(i,t[i]);!0===(n=dt(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function ut(t,e){var r=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(var i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+r)return!0;return!1}function dt(t,e){if(t&&t.length>0&&e.processEntities)for(var r=0;r<e.entities.length;r++){var i=e.entities[r];t=t.replace(i.regex,i.val)}return t}var ht={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function pt(t){this.options=Object.assign({},ht,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=F(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=ct),this.processTextOrObjNode=ft,this.options.format?(this.indentate=gt,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ft(t,e,r,i){var n=this.j2x(t,r+1,i.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function gt(t){return this.options.indentBy.repeat(t)}function ct(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}pt.prototype.build=function(t){return this.options.preserveOrder?at(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e),this.j2x(t,0,[]).val);var e},pt.prototype.j2x=function(t,e,r){var i="",n="",a=r.join(".");for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))if(void 0===t[s])this.isAttribute(s)&&(n+="");else if(null===t[s])this.isAttribute(s)||s===this.options.cdataPropName?n+="":"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if(t[s]instanceof Date)n+=this.buildTextValNode(t[s],s,"",e);else if("object"!=typeof t[s]){var o=this.isAttribute(s);if(o&&!this.ignoreAttributesFn(o,a))i+=this.buildAttrPairStr(o,""+t[s]);else if(!o)if(s===this.options.textNodeName){var l=this.options.tagValueProcessor(s,""+t[s]);n+=this.replaceEntitiesValue(l)}else n+=this.buildTextValNode(t[s],s,"",e)}else if(Array.isArray(t[s])){for(var u=t[s].length,d="",h="",p=0;p<u;p++){var f=t[s][p];if(void 0===f);else if(null===f)"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if("object"==typeof f)if(this.options.oneListGroup){var g=this.j2x(f,e+1,r.concat(s));d+=g.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(h+=g.attrStr)}else d+=this.processTextOrObjNode(f,s,e,r);else if(this.options.oneListGroup){var c=this.options.tagValueProcessor(s,f);d+=c=this.replaceEntitiesValue(c)}else d+=this.buildTextValNode(f,s,"",e)}this.options.oneListGroup&&(d=this.buildObjectNode(d,s,h,e)),n+=d}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName)for(var v=Object.keys(t[s]),x=v.length,m=0;m<x;m++)i+=this.buildAttrPairStr(v[m],""+t[s][v[m]]);else n+=this.processTextOrObjNode(t[s],s,e,r);return{attrStr:i,val:n}},pt.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},pt.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;var n="</"+e+this.tagEndChar,a="";return"?"===e[0]&&(a="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===a.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+a+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+a+">"+t+n},pt.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},pt.prototype.buildTextValNode=function(t,e,r,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"</"+e+this.tagEndChar},pt.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t};var vt={validate:o};return e})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>ft,XMLParser:()=>at,XMLValidator:()=>xt});var r=":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("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function n(t,e){for(var r=[],i=e.exec(t);i;){var n=[];n.startIndex=e.lastIndex-i[0].length;for(var a=i.length,s=0;s<a;s++)n.push(i[s]);r.push(n),i=e.exec(t)}return r}var a=function(t){return!(null==i.exec(t))},s={allowBooleanAttributes:!1,unpairedTags:[]};function o(t,e){e=Object.assign({},s,e);var r=[],i=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var a=0;a<t.length;a++)if("<"===t[a]&&"?"===t[a+1]){if((a=u(t,a+=2)).err)return a}else{if("<"!==t[a]){if(l(t[a]))continue;return x("InvalidChar","char '"+t[a]+"' is not expected.",E(t,a))}var o=a;if("!"===t[++a]){a=d(t,a);continue}var h=!1;"/"===t[a]&&(h=!0,a++);for(var p="";a<t.length&&">"!==t[a]&&" "!==t[a]&&"\t"!==t[a]&&"\n"!==t[a]&&"\r"!==t[a];a++)p+=t[a];if("/"===(p=p.trim())[p.length-1]&&(p=p.substring(0,p.length-1),a--),!b(p))return x("InvalidTag",0===p.trim().length?"Invalid space after '<'.":"Tag '"+p+"' is an invalid name.",E(t,a));var g=f(t,a);if(!1===g)return x("InvalidAttr","Attributes for '"+p+"' have open quote.",E(t,a));var m=g.value;if(a=g.index,"/"===m[m.length-1]){var N=a-m.length,y=c(m=m.substring(0,m.length-1),e);if(!0!==y)return x(y.err.code,y.err.msg,E(t,N+y.err.line));i=!0}else if(h){if(!g.tagClosed)return x("InvalidTag","Closing tag '"+p+"' doesn't have proper closing.",E(t,a));if(m.trim().length>0)return x("InvalidTag","Closing tag '"+p+"' can't have attributes or invalid starting.",E(t,o));if(0===r.length)return x("InvalidTag","Closing tag '"+p+"' has not been opened.",E(t,o));var T=r.pop();if(p!==T.tagName){var w=E(t,T.tagStartPos);return x("InvalidTag","Expected closing tag '"+T.tagName+"' (opened in line "+w.line+", col "+w.col+") instead of closing tag '"+p+"'.",E(t,o))}0==r.length&&(n=!0)}else{var I=c(m,e);if(!0!==I)return x(I.err.code,I.err.msg,E(t,a-m.length+I.err.line));if(!0===n)return x("InvalidXml","Multiple possible root nodes found.",E(t,a));-1!==e.unpairedTags.indexOf(p)||r.push({tagName:p,tagStartPos:o}),i=!0}for(a++;a<t.length;a++)if("<"===t[a]){if("!"===t[a+1]){a=d(t,++a);continue}if("?"!==t[a+1])break;if((a=u(t,++a)).err)return a}else if("&"===t[a]){var O=v(t,a);if(-1==O)return x("InvalidChar","char '&' is not expected.",E(t,a));a=O}else if(!0===n&&!l(t[a]))return x("InvalidXml","Extra text at the end",E(t,a));"<"===t[a]&&a--}return i?1==r.length?x("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",E(t,r[0].tagStartPos)):!(r.length>0)||x("InvalidXml","Invalid '"+JSON.stringify(r.map(function(t){return t.tagName}),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):x("InvalidXml","Start tag expected.",1)}function l(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function u(t,e){for(var r=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var i=t.substr(r,e-r);if(e>5&&"xml"===i)return x("InvalidXml","XML declaration allowed only at the start of the document.",E(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var r=1;for(e+=8;e<t.length;e++)if("<"===t[e])r++;else if(">"===t[e]&&0===--r)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var h='"',p="'";function f(t,e){for(var r="",i="",n=!1;e<t.length;e++){if(t[e]===h||t[e]===p)""===i?i=t[e]:i!==t[e]||(i="");else if(">"===t[e]&&""===i){n=!0;break}r+=t[e]}return""===i&&{value:r,index:e,tagClosed:n}}var g=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function c(t,e){for(var r=n(t,g),i={},a=0;a<r.length;a++){if(0===r[a][1].length)return x("InvalidAttr","Attribute '"+r[a][2]+"' has no space in starting.",N(r[a]));if(void 0!==r[a][3]&&void 0===r[a][4])return x("InvalidAttr","Attribute '"+r[a][2]+"' is without value.",N(r[a]));if(void 0===r[a][3]&&!e.allowBooleanAttributes)return x("InvalidAttr","boolean attribute '"+r[a][2]+"' is not allowed.",N(r[a]));var s=r[a][2];if(!m(s))return x("InvalidAttr","Attribute '"+s+"' is an invalid name.",N(r[a]));if(i.hasOwnProperty(s))return x("InvalidAttr","Attribute '"+s+"' is repeated.",N(r[a]));i[s]=1}return!0}function v(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var r=/\d/;for("x"===t[e]&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(r))break}return-1}(t,++e);for(var r=0;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(";"===t[e])break;return-1}return e}function x(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function m(t){return a(t)}function b(t){return a(t)}function E(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function N(t){return t.startIndex+t[1].length}var y={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1};function T(t){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:null!=(e=t.maxEntitySize)?e:1e4,maxExpansionDepth:null!=(r=t.maxExpansionDepth)?r:10,maxTotalExpansions:null!=(i=t.maxTotalExpansions)?i:1e3,maxExpandedLength:null!=(n=t.maxExpandedLength)?n:1e5,allowedTags:null!=(a=t.allowedTags)?a:null,tagFilter:null!=(s=t.tagFilter)?s:null}:T(!0);var e,r,i,n,a,s}var w,I=function(t){var e=Object.assign({},y,t);return e.processEntities=T(e.processEntities),e};w="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var O=function(){function t(t){this.tagname=t,this.child=[],this[":@"]={}}var e=t.prototype;return e.add=function(t,e){var r;"__proto__"===t&&(t="#__proto__"),this.child.push(((r={})[t]=e,r))},e.addChild=function(t,e){var r,i;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((r={})[t.tagname]=t.child,r[":@"]=t[":@"],r)):this.child.push(((i={})[t.tagname]=t.child,i)),void 0!==e&&(this.child[this.child.length-1][w]={startIndex:e})},t.getMetaDataSymbol=function(){return w},t}(),A=function(){function t(t){this.suppressValidationErr=!t,this.options=t}var e=t.prototype;return e.readDocType=function(t,e){var r={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var i=1,n=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,i--):i--,0===i)break}else"["===t[e]?n=!0:t[e];else{if(n&&S(t,"!ENTITY",e)){e+=7;var s=void 0,o=void 0,l=this.readEntityExp(t,e+1,this.suppressValidationErr);if(s=l[0],o=l[1],e=l[2],-1===o.indexOf("&")){var u=s.replace(/[.\-+*:]/g,"\\.");r[s]={regx:RegExp("&"+u+";","g"),val:o}}}else if(n&&S(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(n&&S(t,"!ATTLIST",e))e+=8;else if(n&&S(t,"!NOTATION",e))e+=9,e=this.readNotationExp(t,e+1,this.suppressValidationErr).index;else{if(!S(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}},e.readEntityExp=function(t,e){e=P(t,e);for(var r="";e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)r+=t[e],e++;if(C(r),e=P(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}var i,n=this.readIdentifierVal(t,e,"entity");if(e=n[0],i=n[1],!1!==this.options.enabled&&this.options.maxEntitySize&&i.length>this.options.maxEntitySize)throw new Error('Entity "'+r+'" size ('+i.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[r,i,--e]},e.readNotationExp=function(t,e){e=P(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;!this.suppressValidationErr&&C(r),e=P(t,e);var i=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==i&&"PUBLIC"!==i)throw new Error('Expected SYSTEM or PUBLIC, found "'+i+'"');e+=i.length,e=P(t,e);var n=null,a=null;if("PUBLIC"===i){var s=this.readIdentifierVal(t,e,"publicIdentifier");if(e=s[0],n=s[1],'"'===t[e=P(t,e)]||"'"===t[e]){var o=this.readIdentifierVal(t,e,"systemIdentifier");e=o[0],a=o[1]}}else if("SYSTEM"===i){var l=this.readIdentifierVal(t,e,"systemIdentifier");if(e=l[0],a=l[1],!this.suppressValidationErr&&!a)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:r,publicIdentifier:n,systemIdentifier:a,index:--e}},e.readIdentifierVal=function(t,e,r){var i="",n=t[e];if('"'!==n&&"'"!==n)throw new Error('Expected quoted string, found "'+n+'"');for(e++;e<t.length&&t[e]!==n;)i+=t[e],e++;if(t[e]!==n)throw new Error("Unterminated "+r+" value");return[++e,i]},e.readElementExp=function(t,e){e=P(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;if(!this.suppressValidationErr&&!a(r))throw new Error('Invalid element name: "'+r+'"');var i="";if("E"===t[e=P(t,e)]&&S(t,"MPTY",e))e+=4;else if("A"===t[e]&&S(t,"NY",e))e+=2;else if("("===t[e]){for(e++;e<t.length&&")"!==t[e];)i+=t[e],e++;if(")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error('Invalid Element Expression, found "'+t[e]+'"');return{elementName:r,contentModel:i.trim(),index:e}},e.readAttlistExp=function(t,e){e=P(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;C(r),e=P(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;if(!C(i))throw new Error('Invalid attribute name: "'+i+'"');e=P(t,e);var n="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(n="NOTATION","("!==t[e=P(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var a=[];e<t.length&&")"!==t[e];){for(var s="";e<t.length&&"|"!==t[e]&&")"!==t[e];)s+=t[e],e++;if(!C(s=s.trim()))throw new Error('Invalid notation name: "'+s+'"');a.push(s),"|"===t[e]&&(e++,e=P(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,n+=" ("+a.join("|")+")"}else{for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(n.toUpperCase()))throw new Error('Invalid attribute type: "'+n+'"')}e=P(t,e);var o="";if("#REQUIRED"===t.substring(e,e+8).toUpperCase())o="#REQUIRED",e+=8;else if("#IMPLIED"===t.substring(e,e+7).toUpperCase())o="#IMPLIED",e+=7;else{var l=this.readIdentifierVal(t,e,"ATTLIST");e=l[0],o=l[1]}return{elementName:r,attributeName:i,attributeType:n,defaultValue:o,index:e}},t}(),P=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function S(t,e,r){for(var i=0;i<e.length;i++)if(e[i]!==t[r+i+1])return!1;return!0}function C(t){if(a(t))return t;throw new Error("Invalid entity name "+t)}const V=/^[-+]?0x[a-fA-F0-9]+$/,D=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,j={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const L=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function M(t){return"function"==typeof t?t:Array.isArray(t)?function(e){for(var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return F(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?F(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(r=i()).done;){var n=r.value;if("string"==typeof n&&e===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}}:function(){return!1}}var _=function(t){if(this.options=t,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:function(t,e){return J(e,10,"&#")}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return J(e,16,"&#x")}}},this.addExternalEntities=k,this.parseXml=G,this.parseTextData=U,this.resolveNameSpace=B,this.buildAttributesMap=Y,this.isItStopNode=W,this.replaceEntitiesValue=z,this.readStopNodeData=K,this.saveTextToParentTag=$,this.addChild=X,this.ignoreAttributesFn=M(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(var e=0;e<this.options.stopNodes.length;e++){var r=this.options.stopNodes[e];"string"==typeof r&&(r.startsWith("*.")?this.stopNodesWildcard.add(r.substring(2)):this.stopNodesExact.add(r))}}};function k(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r],n=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+n+";","g"),val:t[i]}}}function U(t,e,r,i,n,a,s){if(void 0!==t&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t,e,r));var o=this.options.tagValueProcessor(e,t,r,n,a);return null==o?t:typeof o!=typeof t||o!==t?o:this.options.trimValues||t.trim()===t?Q(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function B(t){if(this.options.removeNSPrefix){var e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}var R=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Y(t,e,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var i=n(t,R),a=i.length,s={},o=0;o<a;o++){var l=this.resolveNameSpace(i[o][1]);if(!this.ignoreAttributesFn(l,e)){var u=i[o][4],d=this.options.attributeNamePrefix+l;if(l.length)if(this.options.transformAttributeName&&(d=this.options.transformAttributeName(d)),"__proto__"===d&&(d="#__proto__"),void 0!==u){this.options.trimValues&&(u=u.trim()),u=this.replaceEntitiesValue(u,r,e);var h=this.options.attributeValueProcessor(l,u,e);s[d]=null==h?u:typeof h!=typeof u||h!==u?h:Q(u,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[d]=!0)}}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){var p={};return p[this.options.attributesGroupName]=s,p}return s}}var G=function(t){t=t.replace(/\r\n?/g,"\n");var e=new O("!xml"),r=e,i="",n="";this.entityExpansionCount=0,this.currentExpandedLength=0;for(var a=new A(this.options.processEntities),s=0;s<t.length;s++)if("<"===t[s])if("/"===t[s+1]){var o=q(t,">",s,"Closing Tag is not closed."),l=t.substring(s+2,o).trim();if(this.options.removeNSPrefix){var u=l.indexOf(":");-1!==u&&(l=l.substr(u+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),r&&(i=this.saveTextToParentTag(i,r,n));var d=n.substring(n.lastIndexOf(".")+1);if(l&&-1!==this.options.unpairedTags.indexOf(l))throw new Error("Unpaired tag can not be used as closing tag: </"+l+">");var h=0;d&&-1!==this.options.unpairedTags.indexOf(d)?(h=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=n.lastIndexOf("."),n=n.substring(0,h),r=this.tagsNodeStack.pop(),i="",s=o}else if("?"===t[s+1]){var p=Z(t,s,!1,"?>");if(!p)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),this.options.ignoreDeclaration&&"?xml"===p.tagName||this.options.ignorePiTags);else{var f=new O(p.tagName);f.add(this.options.textNodeName,""),p.tagName!==p.tagExp&&p.attrExpPresent&&(f[":@"]=this.buildAttributesMap(p.tagExp,n,p.tagName)),this.addChild(r,f,n,s)}s=p.closeIndex+1}else if("!--"===t.substr(s+1,3)){var g=q(t,"--\x3e",s+4,"Comment is not closed.");if(this.options.commentPropName){var c,v=t.substring(s+4,g-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[(c={},c[this.options.textNodeName]=v,c)])}s=g}else if("!D"===t.substr(s+1,2)){var x=a.readDocType(t,s);this.docTypeEntities=x.entities,s=x.i}else if("!["===t.substr(s+1,2)){var m=q(t,"]]>",s,"CDATA is not closed.")-2,b=t.substring(s+9,m);i=this.saveTextToParentTag(i,r,n);var E,N=this.parseTextData(b,r.tagname,n,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[(E={},E[this.options.textNodeName]=b,E)]):r.add(this.options.textNodeName,N),s=m+2}else{var y=Z(t,s,this.options.removeNSPrefix),T=y.tagName,w=y.rawTagName,I=y.tagExp,P=y.attrExpPresent,S=y.closeIndex;if(this.options.transformTagName){var C=this.options.transformTagName(T);I===T&&(I=C),T=C}r&&i&&"!xml"!==r.tagname&&(i=this.saveTextToParentTag(i,r,n,!1));var V=r;V&&-1!==this.options.unpairedTags.indexOf(V.tagname)&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),T!==e.tagname&&(n+=n?"."+T:T);var D=s;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,n,T)){var j="";if(I.length>0&&I.lastIndexOf("/")===I.length-1)"/"===T[T.length-1]?(T=T.substr(0,T.length-1),n=n.substr(0,n.length-1),I=T):I=I.substr(0,I.length-1),s=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(T))s=y.closeIndex;else{var L=this.readStopNodeData(t,w,S+1);if(!L)throw new Error("Unexpected end of "+w);s=L.i,j=L.tagContent}var F=new O(T);T!==I&&P&&(F[":@"]=this.buildAttributesMap(I,n,T)),j&&(j=this.parseTextData(j,T,n,!0,P,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),F.add(this.options.textNodeName,j),this.addChild(r,F,n,D)}else{if(I.length>0&&I.lastIndexOf("/")===I.length-1){if("/"===T[T.length-1]?(T=T.substr(0,T.length-1),n=n.substr(0,n.length-1),I=T):I=I.substr(0,I.length-1),this.options.transformTagName){var M=this.options.transformTagName(T);I===T&&(I=M),T=M}var _=new O(T);T!==I&&P&&(_[":@"]=this.buildAttributesMap(I,n,T)),this.addChild(r,_,n,D),n=n.substr(0,n.lastIndexOf("."))}else{var k=new O(T);this.tagsNodeStack.push(r),T!==I&&P&&(k[":@"]=this.buildAttributesMap(I,n,T)),this.addChild(r,k,n,D),r=k}i="",s=S}}else i+=t[s];return e.child};function X(t,e,r,i){this.options.captureMetaData||(i=void 0);var n=this.options.updateTag(e.tagname,r,e[":@"]);!1===n||("string"==typeof n?(e.tagname=n,t.addChild(e,i)):t.addChild(e,i))}var z=function(t,e,r){if(-1===t.indexOf("&"))return t;var i=this.options.processEntities;if(!i.enabled)return t;if(i.allowedTags&&!i.allowedTags.includes(e))return t;if(i.tagFilter&&!i.tagFilter(e,r))return t;for(var n in this.docTypeEntities){var a=this.docTypeEntities[n],s=t.match(a.regx);if(s){if(this.entityExpansionCount+=s.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+i.maxTotalExpansions);var o=t.length;if(t=t.replace(a.regx,a.val),i.maxExpandedLength&&(this.currentExpandedLength+=t.length-o,this.currentExpandedLength>i.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+i.maxExpandedLength)}}if(-1===t.indexOf("&"))return t;for(var l in this.lastEntities){var u=this.lastEntities[l];t=t.replace(u.regex,u.val)}if(-1===t.indexOf("&"))return t;if(this.options.htmlEntities)for(var d in this.htmlEntities){var h=this.htmlEntities[d];t=t.replace(h.regex,h.val)}return t.replace(this.ampEntity.regex,this.ampEntity.val)};function $(t,e,r,i){return t&&(void 0===i&&(i=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function W(t,e,r,i){return!(!e||!e.has(i))||!(!t||!t.has(r))}function q(t,e,r,i){var n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}function Z(t,e,r,i){void 0===i&&(i=">");var n=function(t,e,r){var i;void 0===r&&(r=">");for(var n="",a=e;a<t.length;a++){var s=t[a];if(i)s===i&&(i="");else if('"'===s||"'"===s)i=s;else if(s===r[0]){if(!r[1])return{data:n,index:a};if(t[a+1]===r[1])return{data:n,index:a}}else"\t"===s&&(s=" ");n+=s}}(t,e+1,i);if(n){var a=n.data,s=n.index,o=a.search(/\s/),l=a,u=!0;-1!==o&&(l=a.substring(0,o),a=a.substring(o+1).trimStart());var d=l;if(r){var h=l.indexOf(":");-1!==h&&(u=(l=l.substr(h+1))!==n.data.substr(h+1))}return{tagName:l,tagExp:a,closeIndex:s,attrExpPresent:u,rawTagName:d}}}function K(t,e,r){for(var i=r,n=1;r<t.length;r++)if("<"===t[r])if("/"===t[r+1]){var a=q(t,">",r,e+" is not closed");if(t.substring(r+2,a).trim()===e&&0===--n)return{tagContent:t.substring(i,r),i:a};r=a}else if("?"===t[r+1])r=q(t,"?>",r+1,"StopNode is not closed.");else if("!--"===t.substr(r+1,3))r=q(t,"--\x3e",r+3,"StopNode is not closed.");else if("!["===t.substr(r+1,2))r=q(t,"]]>",r,"StopNode is not closed.")-2;else{var s=Z(t,r,">");s&&((s&&s.tagName)===e&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,r=s.closeIndex)}}function Q(t,e,r){if(e&&"string"==typeof t){var i=t.trim();return"true"===i||"false"!==i&&function(t,e={}){if(e=Object.assign({},j,e),!t||"string"!=typeof t)return t;let r=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(r))return t;if("0"===t)return 0;if(e.hex&&V.test(r))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(r.includes("e")||r.includes("E"))return function(t,e,r){if(!r.eNotation)return t;const i=e.match(L);if(i){let n=i[1]||"";const a=-1===i[3].indexOf("e")?"E":"e",s=i[2],o=n?t[s.length+1]===a:t[s.length]===a;return s.length>1&&o?t:1!==s.length||!i[3].startsWith(`.${a}`)&&i[3][0]!==a?r.leadingZeros&&!o?(e=(i[1]||"")+i[3],Number(e)):t:Number(e)}return t}(t,r,e);{const n=D.exec(r);if(n){const a=n[1]||"",s=n[2];let o=(i=n[3])&&-1!==i.indexOf(".")?("."===(i=i.replace(/0+$/,""))?i="0":"."===i[0]?i="0"+i:"."===i[i.length-1]&&(i=i.substring(0,i.length-1)),i):i;const l=a?"."===t[s.length+1]:"."===t[s.length];if(!e.leadingZeros&&(s.length>1||1===s.length&&!l))return t;{const i=Number(r),n=String(i);if(0===i)return i;if(-1!==n.search(/[eE]/))return e.eNotation?i:t;if(-1!==r.indexOf("."))return"0"===n||n===o||n===`${a}${o}`?i:t;let l=s?o:r;return s?l===n||a+l===n?i:t:l===n||l===a+n?i:t}}return t}var i}(t,r)}return void 0!==t?t:""}function J(t,e,r){var i=Number.parseInt(t,e);return i>=0&&i<=1114111?String.fromCodePoint(i):r+t+";"}var H=O.getMetaDataSymbol();function tt(t,e){return et(t,e)}function et(t,e,r){for(var i,n={},a=0;a<t.length;a++){var s,o=t[a],l=rt(o);if(s=void 0===r?l:r+"."+l,l===e.textNodeName)void 0===i?i=o[l]:i+=""+o[l];else{if(void 0===l)continue;if(o[l]){var u=et(o[l],e,s),d=nt(u,e);void 0!==o[H]&&(u[H]=o[H]),o[":@"]?it(u,o[":@"],s,e):1!==Object.keys(u).length||void 0===u[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(u).length&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""):u=u[e.textNodeName],void 0!==n[l]&&n.hasOwnProperty(l)?(Array.isArray(n[l])||(n[l]=[n[l]]),n[l].push(u)):e.isArray(l,s,d)?n[l]=[u]:n[l]=u}}}return"string"==typeof i?i.length>0&&(n[e.textNodeName]=i):void 0!==i&&(n[e.textNodeName]=i),n}function rt(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(":@"!==i)return i}}function it(t,e,r,i){if(e)for(var n=Object.keys(e),a=n.length,s=0;s<a;s++){var o=n[s];i.isArray(o,r+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function nt(t,e){var r=e.textNodeName,i=Object.keys(t).length;return 0===i||!(1!==i||!t[r]&&"boolean"!=typeof t[r]&&0!==t[r])}var at=function(){function t(t){this.externalEntities={},this.options=I(t)}var e=t.prototype;return e.parse=function(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});var r=o(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var i=new _(this.options);i.addExternalEntities(this.externalEntities);var n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:tt(n,this.options)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return O.getMetaDataSymbol()},t}();function st(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),ot(t,e,"",r)}function ot(t,e,r,i){for(var n="",a=!1,s=0;s<t.length;s++){var o=t[s],l=lt(o);if(void 0!==l){var u;if(u=0===r.length?l:r+"."+l,l!==e.textNodeName)if(l!==e.cdataPropName)if(l!==e.commentPropName)if("?"!==l[0]){var d=i;""!==d&&(d+=e.indentBy);var h=i+"<"+l+ut(o[":@"],e),p=ot(o[l],e,u,d);-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?n+=h+">":n+=h+"/>":p&&0!==p.length||!e.suppressEmptyNode?p&&p.endsWith(">")?n+=h+">"+p+i+"</"+l+">":(n+=h+">",p&&""!==i&&(p.includes("/>")||p.includes("</"))?n+=i+e.indentBy+p+i:n+=p,n+="</"+l+">"):n+=h+"/>",a=!0}else{var f=ut(o[":@"],e),g="?xml"===l?"":i,c=o[l][0][e.textNodeName];n+=g+"<"+l+(c=0!==c.length?" "+c:"")+f+"?>",a=!0}else n+=i+"\x3c!--"+o[l][0][e.textNodeName]+"--\x3e",a=!0;else a&&(n+=i),n+="<![CDATA["+o[l][0][e.textNodeName]+"]]>",a=!1;else{var v=o[l];dt(u,e)||(v=ht(v=e.tagValueProcessor(l,v),e)),a&&(n+=i),n+=v,a=!1}}}return n}function lt(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(t.hasOwnProperty(i)&&":@"!==i)return i}}function ut(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(t.hasOwnProperty(i)){var n=e.attributeValueProcessor(i,t[i]);!0===(n=ht(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function dt(t,e){var r=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(var i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+r)return!0;return!1}function ht(t,e){if(t&&t.length>0&&e.processEntities)for(var r=0;r<e.entities.length;r++){var i=e.entities[r];t=t.replace(i.regex,i.val)}return t}var pt={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ft(t){this.options=Object.assign({},pt,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=M(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=vt),this.processTextOrObjNode=gt,this.options.format?(this.indentate=ct,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function gt(t,e,r,i){var n=this.j2x(t,r+1,i.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function ct(t){return this.options.indentBy.repeat(t)}function vt(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}ft.prototype.build=function(t){return this.options.preserveOrder?st(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e),this.j2x(t,0,[]).val);var e},ft.prototype.j2x=function(t,e,r){var i="",n="",a=r.join(".");for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))if(void 0===t[s])this.isAttribute(s)&&(n+="");else if(null===t[s])this.isAttribute(s)||s===this.options.cdataPropName?n+="":"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if(t[s]instanceof Date)n+=this.buildTextValNode(t[s],s,"",e);else if("object"!=typeof t[s]){var o=this.isAttribute(s);if(o&&!this.ignoreAttributesFn(o,a))i+=this.buildAttrPairStr(o,""+t[s]);else if(!o)if(s===this.options.textNodeName){var l=this.options.tagValueProcessor(s,""+t[s]);n+=this.replaceEntitiesValue(l)}else n+=this.buildTextValNode(t[s],s,"",e)}else if(Array.isArray(t[s])){for(var u=t[s].length,d="",h="",p=0;p<u;p++){var f=t[s][p];if(void 0===f);else if(null===f)"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if("object"==typeof f)if(this.options.oneListGroup){var g=this.j2x(f,e+1,r.concat(s));d+=g.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(h+=g.attrStr)}else d+=this.processTextOrObjNode(f,s,e,r);else if(this.options.oneListGroup){var c=this.options.tagValueProcessor(s,f);d+=c=this.replaceEntitiesValue(c)}else d+=this.buildTextValNode(f,s,"",e)}this.options.oneListGroup&&(d=this.buildObjectNode(d,s,h,e)),n+=d}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName)for(var v=Object.keys(t[s]),x=v.length,m=0;m<x;m++)i+=this.buildAttrPairStr(v[m],""+t[s][v[m]]);else n+=this.processTextOrObjNode(t[s],s,e,r);return{attrStr:i,val:n}},ft.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},ft.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;var n="</"+e+this.tagEndChar,a="";return"?"===e[0]&&(a="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===a.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+a+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+a+">"+t+n},ft.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},ft.prototype.buildTextValNode=function(t,e,r,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"</"+e+this.tagEndChar},ft.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t};var xt={validate:o};return e})());
|
|
2
2
|
//# sourceMappingURL=fxp.min.js.map
|