lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
2 lines • 34.4 kB
JavaScript
!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,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},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:()=>mt,XMLParser:()=>rt,XMLValidator:()=>xt});var i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=new RegExp("^["+i+"]["+i+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function r(t,e){for(var i=[],n=e.exec(t);n;){var r=[];r.startIndex=e.lastIndex-n[0].length;for(var s=n.length,o=0;o<s;o++)r.push(n[o]);i.push(r),n=e.exec(t)}return i}var s=function(t){return!(null==n.exec(t))},o={allowBooleanAttributes:!1,unpairedTags:[]};function a(t,e){e=Object.assign({},o,e);var i=[],n=!1,r=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var s=0;s<t.length;s++)if("<"===t[s]&&"?"===t[s+1]){if((s=u(t,s+=2)).err)return s}else{if("<"!==t[s]){if(l(t[s]))continue;return x("InvalidChar","char '"+t[s]+"' is not expected.",E(t,s))}var a=s;if("!"===t[++s]){s=d(t,s);continue}var h=!1;"/"===t[s]&&(h=!0,s++);for(var p="";s<t.length&&">"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)p+=t[s];if("/"===(p=p.trim())[p.length-1]&&(p=p.substring(0,p.length-1),s--),!b(p))return x("InvalidTag",0===p.trim().length?"Invalid space after '<'.":"Tag '"+p+"' is an invalid name.",E(t,s));var g=f(t,s);if(!1===g)return x("InvalidAttr","Attributes for '"+p+"' have open quote.",E(t,s));var v=g.value;if(s=g.index,"/"===v[v.length-1]){var N=s-v.length,y=c(v=v.substring(0,v.length-1),e);if(!0!==y)return x(y.err.code,y.err.msg,E(t,N+y.err.line));n=!0}else if(h){if(!g.tagClosed)return x("InvalidTag","Closing tag '"+p+"' doesn't have proper closing.",E(t,s));if(v.trim().length>0)return x("InvalidTag","Closing tag '"+p+"' can't have attributes or invalid starting.",E(t,a));if(0===i.length)return x("InvalidTag","Closing tag '"+p+"' has not been opened.",E(t,a));var T=i.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,a))}0==i.length&&(r=!0)}else{var I=c(v,e);if(!0!==I)return x(I.err.code,I.err.msg,E(t,s-v.length+I.err.line));if(!0===r)return x("InvalidXml","Multiple possible root nodes found.",E(t,s));-1!==e.unpairedTags.indexOf(p)||i.push({tagName:p,tagStartPos:a}),n=!0}for(s++;s<t.length;s++)if("<"===t[s]){if("!"===t[s+1]){s=d(t,++s);continue}if("?"!==t[s+1])break;if((s=u(t,++s)).err)return s}else if("&"===t[s]){var O=m(t,s);if(-1==O)return x("InvalidChar","char '&' is not expected.",E(t,s));s=O}else if(!0===r&&!l(t[s]))return x("InvalidXml","Extra text at the end",E(t,s));"<"===t[s]&&s--}return n?1==i.length?x("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",E(t,i[0].tagStartPos)):!(i.length>0)||x("InvalidXml","Invalid '"+JSON.stringify(i.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 i=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var n=t.substr(i,e-i);if(e>5&&"xml"===n)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 i=1;for(e+=8;e<t.length;e++)if("<"===t[e])i++;else if(">"===t[e]&&0===--i)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 i="",n="",r=!1;e<t.length;e++){if(t[e]===h||t[e]===p)""===n?n=t[e]:n!==t[e]||(n="");else if(">"===t[e]&&""===n){r=!0;break}i+=t[e]}return""===n&&{value:i,index:e,tagClosed:r}}var g=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function c(t,e){for(var i=r(t,g),n={},s=0;s<i.length;s++){if(0===i[s][1].length)return x("InvalidAttr","Attribute '"+i[s][2]+"' has no space in starting.",N(i[s]));if(void 0!==i[s][3]&&void 0===i[s][4])return x("InvalidAttr","Attribute '"+i[s][2]+"' is without value.",N(i[s]));if(void 0===i[s][3]&&!e.allowBooleanAttributes)return x("InvalidAttr","boolean attribute '"+i[s][2]+"' is not allowed.",N(i[s]));var o=i[s][2];if(!v(o))return x("InvalidAttr","Attribute '"+o+"' is an invalid name.",N(i[s]));if(Object.prototype.hasOwnProperty.call(n,o))return x("InvalidAttr","Attribute '"+o+"' is repeated.",N(i[s]));n[o]=1}return!0}function m(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var i=/\d/;for("x"===t[e]&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(i))break}return-1}(t,++e);for(var i=0;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(";"===t[e])break;return-1}return e}function x(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function v(t){return s(t)}function b(t){return s(t)}function E(t,e){var i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.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,i){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0};function T(t){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:null!=(e=t.maxEntitySize)?e:1e4,maxExpansionDepth:null!=(i=t.maxExpansionDepth)?i:10,maxTotalExpansions:null!=(n=t.maxTotalExpansions)?n:1e3,maxExpandedLength:null!=(r=t.maxExpandedLength)?r:1e5,maxEntityCount:null!=(s=t.maxEntityCount)?s:100,allowedTags:null!=(o=t.allowedTags)?o:null,tagFilter:null!=(a=t.tagFilter)?a:null}:T(!0);var e,i,n,r,s,o,a}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[":@"]=Object.create(null)}var e=t.prototype;return e.add=function(t,e){var i;"__proto__"===t&&(t="#__proto__"),this.child.push(((i={})[t]=e,i))},e.addChild=function(t,e){var i,n;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((i={})[t.tagname]=t.child,i[":@"]=t[":@"],i)):this.child.push(((n={})[t.tagname]=t.child,n)),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 i=Object.create(null),n=0;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 r=1,s=!1,o=!1;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?s=!0:t[e];else{if(s&&S(t,"!ENTITY",e)){e+=7;var a=void 0,l=void 0,u=this.readEntityExp(t,e+1,this.suppressValidationErr);if(a=u[0],l=u[1],e=u[2],-1===l.indexOf("&")){if(!1!==this.options.enabled&&this.options.maxEntityCount&&n>=this.options.maxEntityCount)throw new Error("Entity count ("+(n+1)+") exceeds maximum allowed ("+this.options.maxEntityCount+")");var d=a.replace(/[.\-+*:]/g,"\\.");i[a]={regx:RegExp("&"+d+";","g"),val:l},n++}}else if(s&&S(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(s&&S(t,"!ATTLIST",e))e+=8;else if(s&&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");o=!0}r++}if(0!==r)throw new Error("Unclosed DOCTYPE");return{entities:i,i:e}},e.readEntityExp=function(t,e){e=P(t,e);for(var i="";e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)i+=t[e],e++;if(C(i),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 n,r=this.readIdentifierVal(t,e,"entity");if(e=r[0],n=r[1],!1!==this.options.enabled&&this.options.maxEntitySize&&n.length>this.options.maxEntitySize)throw new Error('Entity "'+i+'" size ('+n.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[i,n,--e]},e.readNotationExp=function(t,e){e=P(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;!this.suppressValidationErr&&C(i),e=P(t,e);var n=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==n&&"PUBLIC"!==n)throw new Error('Expected SYSTEM or PUBLIC, found "'+n+'"');e+=n.length,e=P(t,e);var r=null,s=null;if("PUBLIC"===n){var o=this.readIdentifierVal(t,e,"publicIdentifier");if(e=o[0],r=o[1],'"'===t[e=P(t,e)]||"'"===t[e]){var a=this.readIdentifierVal(t,e,"systemIdentifier");e=a[0],s=a[1]}}else if("SYSTEM"===n){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:i,publicIdentifier:r,systemIdentifier:s,index:--e}},e.readIdentifierVal=function(t,e,i){var n="",r=t[e];if('"'!==r&&"'"!==r)throw new Error('Expected quoted string, found "'+r+'"');for(e++;e<t.length&&t[e]!==r;)n+=t[e],e++;if(t[e]!==r)throw new Error("Unterminated "+i+" value");return[++e,n]},e.readElementExp=function(t,e){e=P(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;if(!this.suppressValidationErr&&!s(i))throw new Error('Invalid element name: "'+i+'"');var n="";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];)n+=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:i,contentModel:n.trim(),index:e}},e.readAttlistExp=function(t,e){e=P(t,e);for(var i="";e<t.length&&!/\s/.test(t[e]);)i+=t[e],e++;C(i),e=P(t,e);for(var n="";e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!C(n))throw new Error('Invalid attribute name: "'+n+'"');e=P(t,e);var r="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(r="NOTATION","("!==t[e=P(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var s=[];e<t.length&&")"!==t[e];){for(var o="";e<t.length&&"|"!==t[e]&&")"!==t[e];)o+=t[e],e++;if(!C(o=o.trim()))throw new Error('Invalid notation name: "'+o+'"');s.push(o),"|"===t[e]&&(e++,e=P(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,r+=" ("+s.join("|")+")"}else{for(;e<t.length&&!/\s/.test(t[e]);)r+=t[e],e++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(r.toUpperCase()))throw new Error('Invalid attribute type: "'+r+'"')}e=P(t,e);var a="";if("#REQUIRED"===t.substring(e,e+8).toUpperCase())a="#REQUIRED",e+=8;else if("#IMPLIED"===t.substring(e,e+7).toUpperCase())a="#IMPLIED",e+=7;else{var l=this.readIdentifierVal(t,e,"ATTLIST");e=l[0],a=l[1]}return{elementName:i,attributeName:n,attributeType:r,defaultValue:a,index:e}},t}(),P=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function S(t,e,i){for(var n=0;n<e.length;n++)if(e[n]!==t[i+n+1])return!1;return!0}function C(t){if(s(t))return t;throw new Error("Invalid entity name "+t)}const V=/^[-+]?0x[a-fA-F0-9]+$/,j=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,D={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const L=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}var F=function(t){var e;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=k,this.parseXml=B,this.parseTextData=_,this.resolveNameSpace=$,this.buildAttributesMap=R,this.isItStopNode=z,this.replaceEntitiesValue=G,this.readStopNodeData=Z,this.saveTextToParentTag=X,this.addChild=Y,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?function(t){for(var i,n=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return M(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?M(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(i=n()).done;){var r=i.value;if("string"==typeof r&&t===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}}:function(){return!1},this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(var i=0;i<this.options.stopNodes.length;i++){var n=this.options.stopNodes[i];"string"==typeof n&&(n.startsWith("*.")?this.stopNodesWildcard.add(n.substring(2)):this.stopNodesExact.add(n))}}};function k(t){for(var e=Object.keys(t),i=0;i<e.length;i++){var n=e[i],r=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+r+";","g"),val:t[n]}}}function _(t,e,i,n,r,s,o){if(void 0!==t&&(this.options.trimValues&&!n&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t,e,i));var a=this.options.tagValueProcessor(e,t,i,r,s);return null==a?t:typeof a!=typeof t||a!==t?a:this.options.trimValues||t.trim()===t?K(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function $(t){if(this.options.removeNSPrefix){var e=t.split(":"),i="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=i+e[1])}return t}var U=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function R(t,e,i){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var n=r(t,U),s=n.length,o={},a=0;a<s;a++){var l=this.resolveNameSpace(n[a][1]);if(!this.ignoreAttributesFn(l,e)){var u=n[a][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,i,e);var h=this.options.attributeValueProcessor(l,u,e);o[d]=null==h?u:typeof h!=typeof u||h!==u?h:K(u,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[d]=!0)}}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){var p={};return p[this.options.attributesGroupName]=o,p}return o}}var B=function(t){t=t.replace(/\r\n?/g,"\n");var e=new O("!xml"),i=e,n="",r="";this.entityExpansionCount=0,this.currentExpandedLength=0;for(var s=new A(this.options.processEntities),o=0;o<t.length;o++)if("<"===t[o])if("/"===t[o+1]){var a=W(t,">",o,"Closing Tag is not closed."),l=t.substring(o+2,a).trim();if(this.options.removeNSPrefix){var u=l.indexOf(":");-1!==u&&(l=l.substr(u+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),i&&(n=this.saveTextToParentTag(n,i,r));var d=r.substring(r.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=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=r.lastIndexOf("."),r=r.substring(0,h),i=this.tagsNodeStack.pop(),n="",o=a}else if("?"===t[o+1]){var p=q(t,o,!1,"?>");if(!p)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,i,r),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,r,p.tagName)),this.addChild(i,f,r,o)}o=p.closeIndex+1}else if("!--"===t.substr(o+1,3)){var g=W(t,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){var c,m=t.substring(o+4,g-2);n=this.saveTextToParentTag(n,i,r),i.add(this.options.commentPropName,[(c={},c[this.options.textNodeName]=m,c)])}o=g}else if("!D"===t.substr(o+1,2)){var x=s.readDocType(t,o);this.docTypeEntities=x.entities,o=x.i}else if("!["===t.substr(o+1,2)){var v=W(t,"]]>",o,"CDATA is not closed.")-2,b=t.substring(o+9,v);n=this.saveTextToParentTag(n,i,r);var E,N=this.parseTextData(b,i.tagname,r,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[(E={},E[this.options.textNodeName]=b,E)]):i.add(this.options.textNodeName,N),o=v+2}else{var y=q(t,o,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}if(this.options.strictReservedNames&&(T===this.options.commentPropName||T===this.options.cdataPropName))throw new Error("Invalid tag name: "+T);i&&n&&"!xml"!==i.tagname&&(n=this.saveTextToParentTag(n,i,r,!1));var V=i;V&&-1!==this.options.unpairedTags.indexOf(V.tagname)&&(i=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),T!==e.tagname&&(r+=r?"."+T:T);var j=o;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,r,T)){var D="";if(I.length>0&&I.lastIndexOf("/")===I.length-1)"/"===T[T.length-1]?(T=T.substr(0,T.length-1),r=r.substr(0,r.length-1),I=T):I=I.substr(0,I.length-1),o=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(T))o=y.closeIndex;else{var L=this.readStopNodeData(t,w,S+1);if(!L)throw new Error("Unexpected end of "+w);o=L.i,D=L.tagContent}var M=new O(T);T!==I&&P&&(M[":@"]=this.buildAttributesMap(I,r,T)),D&&(D=this.parseTextData(D,T,r,!0,P,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),M.add(this.options.textNodeName,D),this.addChild(i,M,r,j)}else{if(I.length>0&&I.lastIndexOf("/")===I.length-1){if("/"===T[T.length-1]?(T=T.substr(0,T.length-1),r=r.substr(0,r.length-1),I=T):I=I.substr(0,I.length-1),this.options.transformTagName){var F=this.options.transformTagName(T);I===T&&(I=F),T=F}var k=new O(T);T!==I&&P&&(k[":@"]=this.buildAttributesMap(I,r,T)),this.addChild(i,k,r,j),r=r.substr(0,r.lastIndexOf("."))}else{if(-1!==this.options.unpairedTags.indexOf(T)){var _=new O(T);T!==I&&P&&(_[":@"]=this.buildAttributesMap(I,r)),this.addChild(i,_,r,j),r=r.substr(0,r.lastIndexOf(".")),o=y.closeIndex;continue}var $=new O(T);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),T!==I&&P&&($[":@"]=this.buildAttributesMap(I,r,T)),this.addChild(i,$,r,j),i=$}n="",o=S}}else n+=t[o];return e.child};function Y(t,e,i,n){this.options.captureMetaData||(n=void 0);var r=this.options.updateTag(e.tagname,i,e[":@"]);!1===r||("string"==typeof r?(e.tagname=r,t.addChild(e,n)):t.addChild(e,n))}var G=function(t,e,i){if(-1===t.indexOf("&"))return t;var n=this.options.processEntities;if(!n.enabled)return t;if(n.allowedTags&&!n.allowedTags.includes(e))return t;if(n.tagFilter&&!n.tagFilter(e,i))return t;for(var r in this.docTypeEntities){var s=this.docTypeEntities[r],o=t.match(s.regx);if(o){if(this.entityExpansionCount+=o.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+n.maxTotalExpansions);var a=t.length;if(t=t.replace(s.regx,s.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>n.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+n.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 X(t,e,i,n){return t&&(void 0===n&&(n=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,i,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,n))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function z(t,e,i,n){return!(!e||!e.has(n))||!(!t||!t.has(i))}function W(t,e,i,n){var r=t.indexOf(e,i);if(-1===r)throw new Error(n);return r+e.length-1}function q(t,e,i,n){void 0===n&&(n=">");var r=function(t,e,i){var n;void 0===i&&(i=">");for(var r="",s=e;s<t.length;s++){var o=t[s];if(n)o===n&&(n="");else if('"'===o||"'"===o)n=o;else if(o===i[0]){if(!i[1])return{data:r,index:s};if(t[s+1]===i[1])return{data:r,index:s}}else"\t"===o&&(o=" ");r+=o}}(t,e+1,n);if(r){var s=r.data,o=r.index,a=s.search(/\s/),l=s,u=!0;-1!==a&&(l=s.substring(0,a),s=s.substring(a+1).trimStart());var d=l;if(i){var h=l.indexOf(":");-1!==h&&(u=(l=l.substr(h+1))!==r.data.substr(h+1))}return{tagName:l,tagExp:s,closeIndex:o,attrExpPresent:u,rawTagName:d}}}function Z(t,e,i){for(var n=i,r=1;i<t.length;i++)if("<"===t[i])if("/"===t[i+1]){var s=W(t,">",i,e+" is not closed");if(t.substring(i+2,s).trim()===e&&0===--r)return{tagContent:t.substring(n,i),i:s};i=s}else if("?"===t[i+1])i=W(t,"?>",i+1,"StopNode is not closed.");else if("!--"===t.substr(i+1,3))i=W(t,"--\x3e",i+3,"StopNode is not closed.");else if("!["===t.substr(i+1,2))i=W(t,"]]>",i,"StopNode is not closed.")-2;else{var o=q(t,i,">");o&&((o&&o.tagName)===e&&"/"!==o.tagExp[o.tagExp.length-1]&&r++,i=o.closeIndex)}}function K(t,e,i){if(e&&"string"==typeof t){var n=t.trim();return"true"===n||"false"!==n&&function(t,e={}){if(e=Object.assign({},D,e),!t||"string"!=typeof t)return t;let i=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===t)return 0;if(e.hex&&V.test(i))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")}(i);if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const n=e.match(L);if(n){let r=n[1]||"";const s=-1===n[3].indexOf("e")?"E":"e",o=n[2],a=r?t[o.length+1]===s:t[o.length]===s;return o.length>1&&a?t:1!==o.length||!n[3].startsWith(`.${s}`)&&n[3][0]!==s?i.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,i,e);{const r=j.exec(i);if(r){const s=r[1]||"",o=r[2];let a=(n=r[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const l=s?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!l))return t;{const n=Number(i),r=String(n);if(0===n)return n;if(-1!==r.search(/[eE]/))return e.eNotation?n:t;if(-1!==i.indexOf("."))return"0"===r||r===a||r===`${s}${a}`?n:t;let l=o?a:i;return o?l===r||s+l===r?n:t:l===r||l===s+r?n:t}}return t}var n}(t,i)}return void 0!==t?t:""}function Q(t,e,i){var n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):i+t+";"}var J=O.getMetaDataSymbol();function H(t,e){return tt(t,e)}function tt(t,e,i){for(var n,r={},s=0;s<t.length;s++){var o,a=t[s],l=et(a);if(o=void 0===i?l:i+"."+l,l===e.textNodeName)void 0===n?n=a[l]:n+=""+a[l];else{if(void 0===l)continue;if(a[l]){var u=tt(a[l],e,o),d=nt(u,e);a[":@"]?it(u,a[":@"],o,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!==a[J]&&"object"==typeof u&&null!==u&&(u[J]=a[J]),void 0!==r[l]&&Object.prototype.hasOwnProperty.call(r,l)?(Array.isArray(r[l])||(r[l]=[r[l]]),r[l].push(u)):e.isArray(l,o,d)?r[l]=[u]:r[l]=u}}}return"string"==typeof n?n.length>0&&(r[e.textNodeName]=n):void 0!==n&&(r[e.textNodeName]=n),r}function et(t){for(var e=Object.keys(t),i=0;i<e.length;i++){var n=e[i];if(":@"!==n)return n}}function it(t,e,i,n){if(e)for(var r=Object.keys(e),s=r.length,o=0;o<s;o++){var a=r[o];n.isArray(a,i+"."+a,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}function nt(t,e){var i=e.textNodeName,n=Object.keys(t).length;return 0===n||!(1!==n||!t[i]&&"boolean"!=typeof t[i]&&0!==t[i])}var rt=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 i=a(t,e);if(!0!==i)throw Error(i.err.msg+":"+i.err.line+":"+i.err.col)}var n=new F(this.options);n.addExternalEntities(this.externalEntities);var r=n.parseXml(t);return this.options.preserveOrder||void 0===r?r:H(r,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){let i="";return e.format&&e.indentBy.length>0&&(i="\n"),ot(t,e,"",i)}function ot(t,e,i,n){let r="",s=!1;if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=dt(i,e),i}return""}for(let o=0;o<t.length;o++){const a=t[o],l=at(a);if(void 0===l)continue;let u="";if(u=0===i.length?l:`${i}.${l}`,l===e.textNodeName){let t=a[l];ut(u,e)||(t=e.tagValueProcessor(l,t),t=dt(t,e)),s&&(r+=n),r+=t,s=!1;continue}if(l===e.cdataPropName){s&&(r+=n),r+=`<![CDATA[${a[l][0][e.textNodeName]}]]>`,s=!1;continue}if(l===e.commentPropName){r+=n+`\x3c!--${a[l][0][e.textNodeName]}--\x3e`,s=!0;continue}if("?"===l[0]){const t=lt(a[":@"],e),i="?xml"===l?"":n;let o=a[l][0][e.textNodeName];o=0!==o.length?" "+o:"",r+=i+`<${l}${o}${t}?>`,s=!0;continue}let d=n;""!==d&&(d+=e.indentBy);const h=n+`<${l}${lt(a[":@"],e)}`,p=ot(a[l],e,u,d);-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?r+=h+">":r+=h+"/>":p&&0!==p.length||!e.suppressEmptyNode?p&&p.endsWith(">")?r+=h+`>${p}${n}</${l}>`:(r+=h+">",p&&""!==n&&(p.includes("/>")||p.includes("</"))?r+=n+e.indentBy+p+n:r+=p,r+=`</${l}>`):r+=h+"/>",s=!0}return r}function at(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const n=e[i];if(Object.prototype.hasOwnProperty.call(t,n)&&":@"!==n)return n}}function lt(t,e){let i="";if(t&&!e.ignoreAttributes)for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let r=e.attributeValueProcessor(n,t[n]);r=dt(r,e),!0===r&&e.suppressBooleanAttributes?i+=` ${n.substr(e.attributeNamePrefix.length)}`:i+=` ${n.substr(e.attributeNamePrefix.length)}="${r}"`}return i}function ut(t,e){let i=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(let n in e.stopNodes)if(e.stopNodes[n]===t||e.stopNodes[n]==="*."+i)return!0;return!1}function dt(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const n=e.entities[i];t=t.replace(n.regex,n.val)}return t}const 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){var e;this.options=Object.assign({},ht,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,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,i,n){const r=this.j2x(t,i+1,n.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,r.attrStr,i):this.buildObjectNode(r.val,e,r.attrStr,i)}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?st(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)},pt.prototype.j2x=function(t,e,i){let n="",r="";const s=i.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(void 0===t[o])this.isAttribute(o)&&(r+="");else if(null===t[o])this.isAttribute(o)||o===this.options.cdataPropName?r+="":"?"===o[0]?r+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)r+=this.buildTextValNode(t[o],o,"",e);else if("object"!=typeof t[o]){const i=this.isAttribute(o);if(i&&!this.ignoreAttributesFn(i,s))n+=this.buildAttrPairStr(i,""+t[o]);else if(!i)if(o===this.options.textNodeName){let e=this.options.tagValueProcessor(o,""+t[o]);r+=this.replaceEntitiesValue(e)}else r+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const n=t[o].length;let s="",a="";for(let l=0;l<n;l++){const n=t[o][l];if(void 0===n);else if(null===n)"?"===o[0]?r+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if("object"==typeof n)if(this.options.oneListGroup){const t=this.j2x(n,e+1,i.concat(o));s+=t.val,this.options.attributesGroupName&&n.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else s+=this.processTextOrObjNode(n,o,e,i);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(o,n);t=this.replaceEntitiesValue(t),s+=t}else s+=this.buildTextValNode(n,o,"",e)}this.options.oneListGroup&&(s=this.buildObjectNode(s,o,a,e)),r+=s}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const e=Object.keys(t[o]),i=e.length;for(let r=0;r<i;r++)n+=this.buildAttrPairStr(e[r],""+t[o][e[r]])}else r+=this.processTextOrObjNode(t[o],o,e,i);return{attrStr:n,val:r}},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,i,n){if(""===t)return"?"===e[0]?this.indentate(n)+"<"+e+i+"?"+this.tagEndChar:this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar;{let r="</"+e+this.tagEndChar,s="";return"?"===e[0]&&(s="?",r=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(n)+"<"+e+i+s+this.tagEndChar+t+this.indentate(n)+r:this.indentate(n)+"<"+e+i+s+">"+t+r}},pt.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},pt.prototype.buildTextValNode=function(t,e,i,n){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(n)+`<![CDATA[${t}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(n)+"<"+e+i+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),""===r?this.indentate(n)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(n)+"<"+e+i+">"+r+"</"+e+this.tagEndChar}},pt.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};const mt=pt;var xt={validate:a};return e})());
//# sourceMappingURL=fxp.min.js.map