UNPKG

lambda-live-debugger

Version:

Debug Lambda functions locally like it is running in the cloud

2 lines 31.4 kB
!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:()=>ut,XMLParser:()=>et,XMLValidator:()=>pt});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 s=i.length,a=0;a<s;a++)n.push(i[a]);r.push(n),i=e.exec(t)}return r}var s=function(t){return!(null==i.exec(t))},a={allowBooleanAttributes:!1,unpairedTags:[]};function o(t,e){e=Object.assign({},a,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 m("InvalidChar","char '"+t[o]+"' is not expected.",b(t,o))}var h=o;if("!"===t[++o]){o=d(t,o);continue}var f=!1;"/"===t[o]&&(f=!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--),!s(g))return m("InvalidTag",0===g.trim().length?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",b(t,o));var x=p(t,o);if(!1===x)return m("InvalidAttr","Attributes for '"+g+"' have open quote.",b(t,o));var N=x.value;if(o=x.index,"/"===N[N.length-1]){var E=o-N.length,y=c(N=N.substring(0,N.length-1),e);if(!0!==y)return m(y.err.code,y.err.msg,b(t,E+y.err.line));i=!0}else if(f){if(!x.tagClosed)return m("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",b(t,o));if(N.trim().length>0)return m("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",b(t,h));if(0===r.length)return m("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 m("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(N,e);if(!0!==I)return m(I.err.code,I.err.msg,b(t,o-N.length+I.err.line));if(!0===n)return m("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 P=v(t,o);if(-1==P)return m("InvalidChar","char '&' is not expected.",b(t,o));o=P}else if(!0===n&&!l(t[o]))return m("InvalidXml","Extra text at the end",b(t,o));"<"===t[o]&&o--}return i?1==r.length?m("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",b(t,r[0].tagStartPos)):!(r.length>0)||m("InvalidXml","Invalid '"+JSON.stringify(r.map((function(t){return t.tagName})),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):m("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 m("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='"',f="'";function p(t,e){for(var r="",i="",n=!1;e<t.length;e++){if(t[e]===h||t[e]===f)""===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={},s=0;s<r.length;s++){if(0===r[s][1].length)return m("InvalidAttr","Attribute '"+r[s][2]+"' has no space in starting.",N(r[s]));if(void 0!==r[s][3]&&void 0===r[s][4])return m("InvalidAttr","Attribute '"+r[s][2]+"' is without value.",N(r[s]));if(void 0===r[s][3]&&!e.allowBooleanAttributes)return m("InvalidAttr","boolean attribute '"+r[s][2]+"' is not allowed.",N(r[s]));var a=r[s][2];if(!x(a))return m("InvalidAttr","Attribute '"+a+"' is an invalid name.",N(r[s]));if(i.hasOwnProperty(a))return m("InvalidAttr","Attribute '"+a+"' is repeated.",N(r[s]));i[a]=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 m(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function x(t){return s(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 N(t){return t.startIndex+t[1].length}var E,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};E="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var T=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][E]={startIndex:e})},t.getMetaDataSymbol=function(){return E},t}(),w=function(){function t(t){this.suppressValidationErr=!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,s=!1;e<t.length;e++)if("<"!==t[e]||s)if(">"===t[e]){if(s?"-"===t[e-1]&&"-"===t[e-2]&&(s=!1,i--):i--,0===i)break}else"["===t[e]?n=!0:t[e];else{if(n&&P(t,"!ENTITY",e)){e+=7;var a,o=void 0,l=this.readEntityExp(t,e+1,this.suppressValidationErr);a=l[0],o=l[1],e=l[2],-1===o.indexOf("&")&&(r[a]={regx:RegExp("&"+a+";","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");s=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}},e.readEntityExp=function(t,e){e=I(t,e);for(var r="";e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)r+=t[e],e++;if(A(r),e=I(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=this.readIdentifierVal(t,e,"entity");return e=i[0],[r,i[1],--e]},e.readNotationExp=function(t,e){e=I(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;!this.suppressValidationErr&&A(r),e=I(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=I(t,e);var n=null,s=null;if("PUBLIC"===i){var a=this.readIdentifierVal(t,e,"publicIdentifier");if(e=a[0],n=a[1],'"'===t[e=I(t,e)]||"'"===t[e]){var o=this.readIdentifierVal(t,e,"systemIdentifier");e=o[0],s=o[1]}}else if("SYSTEM"===i){var l=this.readIdentifierVal(t,e,"systemIdentifier");if(e=l[0],s=l[1],!this.suppressValidationErr&&!s)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:r,publicIdentifier:n,systemIdentifier:s,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=I(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;if(!this.suppressValidationErr&&!s(r))throw new Error('Invalid element name: "'+r+'"');var i="";if("E"===t[e=I(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=I(t,e);for(var r="";e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;A(r),e=I(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;if(!A(i))throw new Error('Invalid attribute name: "'+i+'"');e=I(t,e);var n="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(n="NOTATION","("!==t[e=I(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var s=[];e<t.length&&")"!==t[e];){for(var a="";e<t.length&&"|"!==t[e]&&")"!==t[e];)a+=t[e],e++;if(!A(a=a.trim()))throw new Error('Invalid notation name: "'+a+'"');s.push(a),"|"===t[e]&&(e++,e=I(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,n+=" ("+s.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=I(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}(),I=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 A(t){if(s(t))return t;throw new Error("Invalid entity name "+t)}const O=/^[-+]?0x[a-fA-F0-9]+$/,S=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,C={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const V=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function D(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 j(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 D(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)?D(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 String.fromCodePoint(Number.parseInt(e,10))}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return String.fromCodePoint(Number.parseInt(e,16))}}},this.addExternalEntities=F,this.parseXml=B,this.parseTextData=_,this.resolveNameSpace=k,this.buildAttributesMap=U,this.isItStopNode=X,this.replaceEntitiesValue=Y,this.readStopNodeData=q,this.saveTextToParentTag=G,this.addChild=R,this.ignoreAttributesFn=j(this.options.ignoreAttributes),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 F(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];this.lastEntities[i]={regex:new RegExp("&"+i+";","g"),val:t[i]}}}function _(t,e,r,i,n,s,a){if(void 0!==t&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));var o=this.options.tagValueProcessor(e,t,r,n,s);return null==o?t:typeof o!=typeof t||o!==t?o:this.options.trimValues||t.trim()===t?Z(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function k(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 L=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function U(t,e){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var r=n(t,L),i=r.length,s={},a=0;a<i;a++){var o=this.resolveNameSpace(r[a][1]);if(!this.ignoreAttributesFn(o,e)){var l=r[a][4],u=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),"__proto__"===u&&(u="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);var d=this.options.attributeValueProcessor(o,l,e);s[u]=null==d?l:typeof d!=typeof l||d!==l?d:Z(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[u]=!0)}}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){var h={};return h[this.options.attributesGroupName]=s,h}return s}}var B=function(t){t=t.replace(/\r\n?/g,"\n");for(var e=new T("!xml"),r=e,i="",n="",s=new w(this.options.processEntities),a=0;a<t.length;a++)if("<"===t[a])if("/"===t[a+1]){var o=$(t,">",a,"Closing Tag is not closed."),l=t.substring(a+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="",a=o}else if("?"===t[a+1]){var f=W(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),this.options.ignoreDeclaration&&"?xml"===f.tagName||this.options.ignorePiTags);else{var p=new T(f.tagName);p.add(this.options.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(p[":@"]=this.buildAttributesMap(f.tagExp,n)),this.addChild(r,p,n,a)}a=f.closeIndex+1}else if("!--"===t.substr(a+1,3)){var g=$(t,"--\x3e",a+4,"Comment is not closed.");if(this.options.commentPropName){var c,v=t.substring(a+4,g-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[(c={},c[this.options.textNodeName]=v,c)])}a=g}else if("!D"===t.substr(a+1,2)){var m=s.readDocType(t,a);this.docTypeEntities=m.entities,a=m.i}else if("!["===t.substr(a+1,2)){var x=$(t,"]]>",a,"CDATA is not closed.")-2,b=t.substring(a+9,x);i=this.saveTextToParentTag(i,r,n);var N,E=this.parseTextData(b,r.tagname,n,!0,!1,!0,!0);null==E&&(E=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[(N={},N[this.options.textNodeName]=b,N)]):r.add(this.options.textNodeName,E),a=x+2}else{var y=W(t,a,this.options.removeNSPrefix),I=y.tagName,P=y.rawTagName,A=y.tagExp,O=y.attrExpPresent,S=y.closeIndex;if(this.options.transformTagName){var C=this.options.transformTagName(I);A===I&&(A=C),I=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("."))),I!==e.tagname&&(n+=n?"."+I:I);var D=a;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,n,I)){var j="";if(A.length>0&&A.lastIndexOf("/")===A.length-1)"/"===I[I.length-1]?(I=I.substr(0,I.length-1),n=n.substr(0,n.length-1),A=I):A=A.substr(0,A.length-1),a=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(I))a=y.closeIndex;else{var M=this.readStopNodeData(t,P,S+1);if(!M)throw new Error("Unexpected end of "+P);a=M.i,j=M.tagContent}var F=new T(I);I!==A&&O&&(F[":@"]=this.buildAttributesMap(A,n)),j&&(j=this.parseTextData(j,I,n,!0,O,!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("/"===I[I.length-1]?(I=I.substr(0,I.length-1),n=n.substr(0,n.length-1),A=I):A=A.substr(0,A.length-1),this.options.transformTagName){var _=this.options.transformTagName(I);A===I&&(A=_),I=_}var k=new T(I);I!==A&&O&&(k[":@"]=this.buildAttributesMap(A,n)),this.addChild(r,k,n,D),n=n.substr(0,n.lastIndexOf("."))}else{var L=new T(I);this.tagsNodeStack.push(r),I!==A&&O&&(L[":@"]=this.buildAttributesMap(A,n)),this.addChild(r,L,n,D),r=L}i="",a=S}}else i+=t[a];return e.child};function R(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 Y=function(t){if(this.options.processEntities){for(var e in this.docTypeEntities){var r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(var i in this.lastEntities){var n=this.lastEntities[i];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(var s in this.htmlEntities){var a=this.htmlEntities[s];t=t.replace(a.regex,a.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function G(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 X(t,e,r,i){return!(!e||!e.has(i))||!(!t||!t.has(r))}function $(t,e,r,i){var n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}function W(t,e,r,i){void 0===i&&(i=">");var n=function(t,e,r){var i;void 0===r&&(r=">");for(var n="",s=e;s<t.length;s++){var a=t[s];if(i)a===i&&(i="");else if('"'===a||"'"===a)i=a;else if(a===r[0]){if(!r[1])return{data:n,index:s};if(t[s+1]===r[1])return{data:n,index:s}}else"\t"===a&&(a=" ");n+=a}}(t,e+1,i);if(n){var s=n.data,a=n.index,o=s.search(/\s/),l=s,u=!0;-1!==o&&(l=s.substring(0,o),s=s.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:s,closeIndex:a,attrExpPresent:u,rawTagName:d}}}function q(t,e,r){for(var i=r,n=1;r<t.length;r++)if("<"===t[r])if("/"===t[r+1]){var s=$(t,">",r,e+" is not closed");if(t.substring(r+2,s).trim()===e&&0==--n)return{tagContent:t.substring(i,r),i:s};r=s}else if("?"===t[r+1])r=$(t,"?>",r+1,"StopNode is not closed.");else if("!--"===t.substr(r+1,3))r=$(t,"--\x3e",r+3,"StopNode is not closed.");else if("!["===t.substr(r+1,2))r=$(t,"]]>",r,"StopNode is not closed.")-2;else{var a=W(t,r,">");a&&((a&&a.tagName)===e&&"/"!==a.tagExp[a.tagExp.length-1]&&n++,r=a.closeIndex)}}function Z(t,e,r){if(e&&"string"==typeof t){var i=t.trim();return"true"===i||"false"!==i&&function(t,e={}){if(e=Object.assign({},C,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&&O.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(V);if(i){let n=i[1]||"";const s=-1===i[3].indexOf("e")?"E":"e",a=i[2],o=n?t[a.length+1]===s:t[a.length]===s;return a.length>1&&o?t:1!==a.length||!i[3].startsWith(`.${s}`)&&i[3][0]!==s?r.leadingZeros&&!o?(e=(i[1]||"")+i[3],Number(e)):t:Number(e)}return t}(t,r,e);{const n=S.exec(r);if(n){const s=n[1]||"",a=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=s?"."===t[a.length+1]:"."===t[a.length];if(!e.leadingZeros&&(a.length>1||1===a.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===`${s}${o}`?i:t;let l=a?o:r;return a?l===n||s+l===n?i:t:l===n||l===s+n?i:t}}return t}var i}(t,r)}return void 0!==t?t:""}var K=T.getMetaDataSymbol();function Q(t,e){return z(t,e)}function z(t,e,r){for(var i,n={},s=0;s<t.length;s++){var a,o=t[s],l=J(o);if(a=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=z(o[l],e,a),d=tt(u,e);void 0!==o[K]&&(u[K]=o[K]),o[":@"]?H(u,o[":@"],a,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,a,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 J(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(":@"!==i)return i}}function H(t,e,r,i){if(e)for(var n=Object.keys(e),s=n.length,a=0;a<s;a++){var o=n[a];i.isArray(o,r+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function tt(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 et=function(){function t(t){this.externalEntities={},this.options=function(t){return Object.assign({},y,t)}(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:Q(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 '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return T.getMetaDataSymbol()},t}();function rt(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),it(t,e,"",r)}function it(t,e,r,i){for(var n="",s=!1,a=0;a<t.length;a++){var o=t[a],l=nt(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+st(o[":@"],e),f=it(o[l],e,u,d);-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?n+=h+">":n+=h+"/>":f&&0!==f.length||!e.suppressEmptyNode?f&&f.endsWith(">")?n+=h+">"+f+i+"</"+l+">":(n+=h+">",f&&""!==i&&(f.includes("/>")||f.includes("</"))?n+=i+e.indentBy+f+i:n+=f,n+="</"+l+">"):n+=h+"/>",s=!0}else{var p=st(o[":@"],e),g="?xml"===l?"":i,c=o[l][0][e.textNodeName];n+=g+"<"+l+(c=0!==c.length?" "+c:"")+p+"?>",s=!0}else n+=i+"\x3c!--"+o[l][0][e.textNodeName]+"--\x3e",s=!0;else s&&(n+=i),n+="<![CDATA["+o[l][0][e.textNodeName]+"]]>",s=!1;else{var v=o[l];at(u,e)||(v=ot(v=e.tagValueProcessor(l,v),e)),s&&(n+=i),n+=v,s=!1}}}return n}function nt(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 st(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=ot(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function at(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 ot(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 lt={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ut(t){this.options=Object.assign({},lt,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=j(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=ft),this.processTextOrObjNode=dt,this.options.format?(this.indentate=ht,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function dt(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 ht(t){return this.options.indentBy.repeat(t)}function ft(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}ut.prototype.build=function(t){return this.options.preserveOrder?rt(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},ut.prototype.j2x=function(t,e,r){var i="",n="",s=r.join(".");for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(void 0===t[a])this.isAttribute(a)&&(n+="");else if(null===t[a])this.isAttribute(a)||a===this.options.cdataPropName?n+="":"?"===a[0]?n+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)n+=this.buildTextValNode(t[a],a,"",e);else if("object"!=typeof t[a]){var o=this.isAttribute(a);if(o&&!this.ignoreAttributesFn(o,s))i+=this.buildAttrPairStr(o,""+t[a]);else if(!o)if(a===this.options.textNodeName){var l=this.options.tagValueProcessor(a,""+t[a]);n+=this.replaceEntitiesValue(l)}else n+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){for(var u=t[a].length,d="",h="",f=0;f<u;f++){var p=t[a][f];if(void 0===p);else if(null===p)"?"===a[0]?n+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if("object"==typeof p)if(this.options.oneListGroup){var g=this.j2x(p,e+1,r.concat(a));d+=g.val,this.options.attributesGroupName&&p.hasOwnProperty(this.options.attributesGroupName)&&(h+=g.attrStr)}else d+=this.processTextOrObjNode(p,a,e,r);else if(this.options.oneListGroup){var c=this.options.tagValueProcessor(a,p);d+=c=this.replaceEntitiesValue(c)}else d+=this.buildTextValNode(p,a,"",e)}this.options.oneListGroup&&(d=this.buildObjectNode(d,a,h,e)),n+=d}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName)for(var v=Object.keys(t[a]),m=v.length,x=0;x<m;x++)i+=this.buildAttrPairStr(v[x],""+t[a][v[x]]);else n+=this.processTextOrObjNode(t[a],a,e,r);return{attrStr:i,val:n}},ut.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},ut.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,s="";return"?"===e[0]&&(s="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+s+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+s+">"+t+n},ut.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},ut.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},ut.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 pt={validate:o};return e})())); //# sourceMappingURL=fxp.min.js.map