UNPKG

js-awe

Version:

Awesome js utils including - plan: An Asynchronous control flow with a functional taste - Chrono: record and visualize timelines in the console

1 lines 158 kB
import t from"node:util";let e=(void 0!==typeof globalThis?globalThis:void 0!==typeof window?window:void 0!==typeof global?global:void 0!==typeof self?self:void 0!==typeof this?this:{}).performance;void 0===e&&(e={});const n={upperLetters:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],lowerLetters:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],numbers:[0,1,2,3,4,5,6,7,8,9]};function r(t){let e=0;const r=t.split("").map((t=>{let r;const o=function(t){const e=t.charCodeAt();return e>47&&e<58?n.numbers:e>64&&e<91?n.upperLetters:e>96&&e<123?n.lowerLetters:void 0}(t);return r=o?o[function(t){return Math.floor(Math.random()*Math.floor(t))}(o.length-1)]:t,r!==t&&e++,r})).join("");return e<t.length/2?Array.from({length:r.length}).fill("*").join(""):r}var o=function t(e){let n=e;var r={}.toString.call(e).slice(8,-1);if("Set"==r)return new Set([...e].map((e=>t(e))));if("Map"==r)return new Map([...e].map((e=>[t(e[0]),t(e[1])])));if("Date"==r)return new Date(e.getTime());if("RegExp"==r)return RegExp(e.source,function(t){if("string"==typeof t.source.flags)return t.source.flags;var e=[];return t.global&&e.push("g"),t.ignoreCase&&e.push("i"),t.multiline&&e.push("m"),t.sticky&&e.push("y"),t.unicode&&e.push("u"),e.join("")}(e));if("Array"==r||"Object"==r)for(var o in n=Array.isArray(e)?[]:{},e)n[o]=t(e[o]);return n};var u,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function s(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)e.push(n);return e}function c(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t)}function l(){try{return Object.defineProperty({},"_",{}),function(t,e,n){Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0,value:n})}}catch(t){return function(t,e,n){t[e]=n}}}var f=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function p(){}function h(t){if(!(this instanceof h))return new h(t);this.code=t}function d(t){if(y(t))return t;var e=new p;return"object"==typeof t&&c(s(t),(function(n){e[n]=t[n]})),e}function y(t){return t instanceof p}p.prototype={},h.prototype.runInContext=function(t){if(!(t instanceof p))throw new TypeError("needs a 'context' argument.");if(a.document){var e=a.document.createElement("iframe");e.style||(e.style={}),e.style.display="none",a.document.body.appendChild(e);var n=e.contentWindow,r=n.eval,o=n.execScript;!r&&o&&(o.call(n,"null"),r=n.eval),c(s(t),(function(e){n[e]=t[e]})),c(f,(function(e){t[e]&&(n[e]=t[e])}));var i=s(n),h=r.call(n,this.code);return c(s(n),(function(e){(e in t||-1===function(t,e){if(v)return t.indexOf(e);for(var n=0;n<t.length;++n)if(t[n]===e)return n;return-1}(i,e))&&(t[e]=n[e])})),c(f,(function(e){e in t||function(t,e,n){"function"!=typeof u&&(u=l),u(t,e,n)}(t,e,n[e])})),a.document.body.removeChild(e),h}return function(t,e){var n=s(a);return n.push("with (this.__ctx__){return eval(this.__code__)}"),Function.apply(null,n).apply({__code__:t,__ctx__:e})}(this.code,t)},h.prototype.runInThisContext=function(){return new Function("code","return eval(code);").call(a,this.code)},h.prototype.runInNewContext=function(t){var e=d(t),n=this.runInContext(e);return t&&c(s(e),(function(n){t[n]=e[n]})),n};var g={runInContext:function(t,e,n){return new h(t).runInContext(e,n)},isContext:y,createContext:d,createScript:function(t){return new h(t)},Script:h,runInThisContext:function(t,e){return new h(t).runInThisContext(e)},runInNewContext:function(t,e,n){return new h(t).runInNewContext(e,n)}},v=[].indexOf;class m{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+m.version}static addUnaryOp(t){return m.max_unop_len=Math.max(t.length,m.max_unop_len),m.unary_ops[t]=1,m}static addBinaryOp(t,e,n){return m.max_binop_len=Math.max(t.length,m.max_binop_len),m.binary_ops[t]=e,n?m.right_associative.add(t):m.right_associative.delete(t),m}static addIdentifierChar(t){return m.additional_identifier_chars.add(t),m}static addLiteral(t,e){return m.literals[t]=e,m}static removeUnaryOp(t){return delete m.unary_ops[t],t.length===m.max_unop_len&&(m.max_unop_len=m.getMaxKeyLen(m.unary_ops)),m}static removeAllUnaryOps(){return m.unary_ops={},m.max_unop_len=0,m}static removeIdentifierChar(t){return m.additional_identifier_chars.delete(t),m}static removeBinaryOp(t){return delete m.binary_ops[t],t.length===m.max_binop_len&&(m.max_binop_len=m.getMaxKeyLen(m.binary_ops)),m.right_associative.delete(t),m}static removeAllBinaryOps(){return m.binary_ops={},m.max_binop_len=0,m}static removeLiteral(t){return delete m.literals[t],m}static removeAllLiterals(){return m.literals={},m}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new m(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map((t=>t.length)))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return m.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!m.binary_ops[String.fromCharCode(t)]||m.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return m.isIdentifierStart(t)||m.isDecimalDigit(t)}throwError(t){const e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(m.hooks[t]){const n={context:this,node:e};return m.hooks.run(t,n),n.node}return e}searchHook(t){if(m.hooks[t]){const e={context:this};return m.hooks[t].find((function(t){return t.call(e.context,e),e.node})),e.node}}gobbleSpaces(){let t=this.code;for(;t===m.SPACE_CODE||t===m.TAB_CODE||t===m.LF_CODE||t===m.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),e=1===t.length?t[0]:{type:m.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e,n,r=[];for(;this.index<this.expr.length;)if(e=this.code,e===m.SEMCOL_CODE||e===m.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())r.push(n);else if(this.index<this.expr.length){if(e===t)break;this.throwError('Unexpected "'+this.char+'"')}return r}gobbleExpression(){const t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,m.max_binop_len),e=t.length;for(;e>0;){if(m.binary_ops.hasOwnProperty(t)&&(!m.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!m.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,n,r,o,i,u,a,s;if(i=this.gobbleToken(),!i)return i;if(e=this.gobbleBinaryOp(),!e)return i;for(o={value:e,prec:m.binaryPrecedence(e),right_a:m.right_associative.has(e)},u=this.gobbleToken(),u||this.throwError("Expected expression after "+e),r=[i,o,u];e=this.gobbleBinaryOp();){if(n=m.binaryPrecedence(e),0===n){this.index-=e.length;break}o={value:e,prec:n,right_a:m.right_associative.has(e)},s=e;const a=t=>o.right_a&&t.right_a?n>t.prec:n<=t.prec;for(;r.length>2&&a(r[r.length-2]);)u=r.pop(),e=r.pop().value,i=r.pop(),t={type:m.BINARY_EXP,operator:e,left:i,right:u},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+s),r.push(o,t)}for(a=r.length-1,t=r[a];a>1;)t={type:m.BINARY_EXP,operator:r[a-1].value,left:r[a-2],right:t},a-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,m.isDecimalDigit(t)||t===m.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===m.SQUOTE_CODE||t===m.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===m.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,m.max_unop_len),n=e.length;n>0;){if(m.unary_ops.hasOwnProperty(e)&&(!m.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!m.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=n;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:m.UNARY_EXP,operator:e,argument:t,prefix:!0})}e=e.substr(0,--n)}m.isIdentifierStart(t)?(r=this.gobbleIdentifier(),m.literals.hasOwnProperty(r.name)?r={type:m.LITERAL,value:m.literals[r.name],raw:r.name}:r.name===m.this_str&&(r={type:m.THIS_EXP})):t===m.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===m.PERIOD_CODE||e===m.OBRACK_CODE||e===m.OPAREN_CODE||e===m.QUMARK_CODE;){let n;if(e===m.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==m.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===m.OBRACK_CODE?((t={type:m.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),e=this.code,e!==m.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===m.OPAREN_CODE?t={type:m.CALL_EXP,arguments:this.gobbleArguments(m.CPAREN_CODE),callee:t}:(e===m.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:m.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t,e,n="";for(;m.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===m.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);m.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(n+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(n+=this.expr.charAt(this.index++));m.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);m.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return e=this.code,m.isIdentifierStart(e)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(e===m.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===m.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:m.LITERAL,value:parseFloat(n),raw:n}}gobbleStringLiteral(){let t="";const e=this.index,n=this.expr.charAt(this.index++);let r=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===n){r=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:m.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(m.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,m.isIdentifierPart(t));)this.index++;return{type:m.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){const e=[];let n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===t){n=!0,this.index++,t===m.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===m.COMMA_CODE){if(this.index++,r++,r!==e.length)if(t===m.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===m.CBRACK_CODE)for(let t=e.length;t<r;t++)e.push(null)}else if(e.length!==r&&0!==r)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==m.COMPOUND||this.throwError("Expected comma"),e.push(t)}}return n||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(m.CPAREN_CODE);if(this.code===m.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:m.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:m.ARRAY_EXP,elements:this.gobbleArguments(m.CBRACK_CODE)}}}const b=new class{add(t,e,n){if("string"!=typeof arguments[0])for(let t in arguments[0])this.add(t,arguments[0][t],arguments[1]);else(Array.isArray(t)?t:[t]).forEach((function(t){this[t]=this[t]||[],e&&this[t][n?"unshift":"push"](e)}),this)}run(t,e){this[t]=this[t]||[],this[t].forEach((function(t){t.call(e&&e.context?e.context:e,e)}))}};Object.assign(m,{hooks:b,plugins:new class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach((t=>{if("object"!=typeof t||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)}))}}(m),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),m.max_unop_len=m.getMaxKeyLen(m.unary_ops),m.max_binop_len=m.getMaxKeyLen(m.binary_ops);const w=t=>new m(t).parse(),E=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(m).filter((t=>!E.includes(t)&&void 0===w[t])).forEach((t=>{w[t]=m[t]})),w.Jsep=m;var _={name:"ternary",init(t){t.hooks.add("after-expression",(function(e){if(e.node&&this.code===t.QUMARK_CODE){this.index++;const n=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===t.COLON_CODE){this.index++;const o=this.gobbleExpression();if(o||this.throwError("Expected expression"),e.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&t.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&t.binary_ops[r.right.operator]<=.9;)r=r.right;e.node.test=r.right,r.right=e.node,e.node=n}}else this.throwError("Expected :")}}))}};w.plugins.register(_);var x={name:"regex",init(t){t.hooks.add("gobble-token",(function(e){if(47===this.code){const n=++this.index;let r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){const r=this.expr.slice(n,this.index);let o,i="";for(;++this.index<this.expr.length;){const t=this.code;if(!(t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57))break;i+=this.char}try{o=new RegExp(r,i)}catch(t){this.throwError(t.message)}return e.node={type:t.LITERAL,value:o,raw:this.expr.slice(n-1,this.index)},e.node=this.gobbleTokenProperty(e.node),e.node}this.code===t.OBRACK_CODE?r=!0:r&&this.code===t.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const A={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const e=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){A.assignmentOperators.has(t.operator)?(t.type="AssignmentExpression",n(t.left),n(t.right)):t.operator||Object.values(t).forEach((t=>{t&&"object"==typeof t&&n(t)}))}A.assignmentOperators.forEach((e=>t.addBinaryOp(e,A.assignmentPrecedence,!0))),t.hooks.add("gobble-token",(function(t){const n=this.code;A.updateOperators.some((t=>t===n&&t===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&e.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;A.updateOperators.some((t=>t===n&&t===this.expr.charCodeAt(this.index+1)))&&(e.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(t){t.node&&n(t.node)}))}};w.plugins.register(x,A),w.addUnaryOp("typeof"),w.addLiteral("null",null),w.addLiteral("undefined",void 0);const O=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),N={evalAst(t,e){switch(t.type){case"BinaryExpression":case"LogicalExpression":return N.evalBinaryExpression(t,e);case"Compound":return N.evalCompound(t,e);case"ConditionalExpression":return N.evalConditionalExpression(t,e);case"Identifier":return N.evalIdentifier(t,e);case"Literal":return N.evalLiteral(t,e);case"MemberExpression":return N.evalMemberExpression(t,e);case"UnaryExpression":return N.evalUnaryExpression(t,e);case"ArrayExpression":return N.evalArrayExpression(t,e);case"CallExpression":return N.evalCallExpression(t,e);case"AssignmentExpression":return N.evalAssignmentExpression(t,e);default:throw SyntaxError("Unexpected expression",t)}},evalBinaryExpression:(t,e)=>({"||":(t,e)=>t||e(),"&&":(t,e)=>t&&e(),"|":(t,e)=>t|e(),"^":(t,e)=>t^e(),"&":(t,e)=>t&e(),"==":(t,e)=>t==e(),"!=":(t,e)=>t!=e(),"===":(t,e)=>t===e(),"!==":(t,e)=>t!==e(),"<":(t,e)=>t<e(),">":(t,e)=>t>e(),"<=":(t,e)=>t<=e(),">=":(t,e)=>t>=e(),"<<":(t,e)=>t<<e(),">>":(t,e)=>t>>e(),">>>":(t,e)=>t>>>e(),"+":(t,e)=>t+e(),"-":(t,e)=>t-e(),"*":(t,e)=>t*e(),"/":(t,e)=>t/e(),"%":(t,e)=>t%e()}[t.operator](N.evalAst(t.left,e),(()=>N.evalAst(t.right,e)))),evalCompound(t,e){let n;for(let r=0;r<t.body.length;r++){"Identifier"===t.body[r].type&&["var","let","const"].includes(t.body[r].name)&&t.body[r+1]&&"AssignmentExpression"===t.body[r+1].type&&(r+=1);const o=t.body[r];n=N.evalAst(o,e)}return n},evalConditionalExpression:(t,e)=>N.evalAst(t.test,e)?N.evalAst(t.consequent,e):N.evalAst(t.alternate,e),evalIdentifier(t,e){if(Object.hasOwn(e,t.name))return e[t.name];throw ReferenceError(`${t.name} is not defined`)},evalLiteral:t=>t.value,evalMemberExpression(t,e){const n=String(t.computed?N.evalAst(t.property):t.property.name),r=N.evalAst(t.object,e);if(null==r)throw TypeError(`Cannot read properties of ${r} (reading '${n}')`);if(!Object.hasOwn(r,n)&&O.has(n))throw TypeError(`Cannot read properties of ${r} (reading '${n}')`);const o=r[n];return"function"==typeof o?o.bind(r):o},evalUnaryExpression:(t,e)=>({"-":t=>-N.evalAst(t,e),"!":t=>!N.evalAst(t,e),"~":t=>~N.evalAst(t,e),"+":t=>+N.evalAst(t,e),typeof:t=>typeof N.evalAst(t,e)}[t.operator](t.argument)),evalArrayExpression:(t,e)=>t.elements.map((t=>N.evalAst(t,e))),evalCallExpression(t,e){const n=t.arguments.map((t=>N.evalAst(t,e)));return N.evalAst(t.callee,e)(...n)},evalAssignmentExpression(t,e){if("Identifier"!==t.left.type)throw SyntaxError("Invalid left-hand side in assignment");const n=t.left.name,r=N.evalAst(t.right,e);return e[n]=r,e[n]}};function j(t,e){return(t=t.slice()).push(e),t}function S(t,e){return(e=e.slice()).unshift(t),e}class C extends Error{constructor(t){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=t,this.name="NewError"}}function T(t,e,n,r,o){if(!(this instanceof T))try{return new T(t,e,n,r,o)}catch(t){if(!t.avoidNew)throw t;return t.value}"string"==typeof t&&(o=r,r=n,n=e,e=t,t=null);const i=t&&"object"==typeof t;if(t=t||{},this.json=t.json||n,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=!Object.hasOwn(t,"wrap")||t.wrap,this.sandbox=t.sandbox||{},this.eval=void 0===t.eval?"safe":t.eval,this.ignoreEvalErrors=void 0!==t.ignoreEvalErrors&&t.ignoreEvalErrors,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||r||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==t.autostart){const r={path:i?t.path:e};i?"json"in t&&(r.json=t.json):r.json=n;const o=this.evaluate(r);if(!o||"object"!=typeof o)throw new C(o);return o}}function I(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(t=r+"/"+t,e="/"===r.charAt(0))}return t=function(t,e){for(var n=0,r=t.length-1;r>=0;r--){var o=t[r];"."===o?t.splice(r,1):".."===o?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}(function(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r<t.length;r++)e(t[r],r,t)&&n.push(t[r]);return n}(t.split("/"),(function(t){return!!t})),!e).join("/"),(e?"/":"")+t||"."}T.prototype.evaluate=function(t,e,n,r){let o=this.parent,i=this.parentProperty,{flatten:u,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,n=n||this.callback,this.currOtherTypeCallback=r||this.otherTypeCallback,e=e||this.json,(t=t||this.path)&&"object"==typeof t&&!Array.isArray(t)){if(!t.path&&""!==t.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),u=Object.hasOwn(t,"flatten")?t.flatten:u,this.currResultType=Object.hasOwn(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=Object.hasOwn(t,"sandbox")?t.sandbox:this.currSandbox,a=Object.hasOwn(t,"wrap")?t.wrap:a,this.currEval=Object.hasOwn(t,"eval")?t.eval:this.currEval,n=Object.hasOwn(t,"callback")?t.callback:n,this.currOtherTypeCallback=Object.hasOwn(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=Object.hasOwn(t,"parent")?t.parent:o,i=Object.hasOwn(t,"parentProperty")?t.parentProperty:i,t=t.path}if(o=o||null,i=i||null,Array.isArray(t)&&(t=T.toPathString(t)),!t&&""!==t||!e)return;const s=T.toPathArray(t);"$"===s[0]&&s.length>1&&s.shift(),this._hasParentSelector=null;const c=this._trace(s,e,["$"],o,i,n).filter((function(t){return t&&!t.isParentSelector}));return c.length?a||1!==c.length||c[0].hasArrExpr?c.reduce(((t,e)=>{const n=this._getPreferredOutput(e);return u&&Array.isArray(n)?t=t.concat(n):t.push(n),t}),[]):this._getPreferredOutput(c[0]):a?[]:void 0},T.prototype._getPreferredOutput=function(t){const e=this.currResultType;switch(e){case"all":{const e=Array.isArray(t.path)?t.path:T.toPathArray(t.path);return t.pointer=T.toPointer(e),t.path="string"==typeof t.path?t.path:T.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return T.toPathString(t[e]);case"pointer":return T.toPointer(t.path);default:throw new TypeError("Unknown result type")}},T.prototype._handleCallback=function(t,e,n){if(e){const r=this._getPreferredOutput(t);t.path="string"==typeof t.path?t.path:T.toPathString(t.path),e(r,n,t)}},T.prototype._trace=function(t,e,n,r,o,i,u,a){let s;if(!t.length)return s={path:n,value:e,parent:r,parentProperty:o,hasArrExpr:u},this._handleCallback(s,i,"value"),s;const c=t[0],l=t.slice(1),f=[];function p(t){Array.isArray(t)?t.forEach((t=>{f.push(t)})):f.push(t)}if(("string"!=typeof c||a)&&e&&Object.hasOwn(e,c))p(this._trace(l,e[c],j(n,c),e,c,i,u));else if("*"===c)this._walk(e,(t=>{p(this._trace(l,e[t],j(n,t),e,t,i,!0,!0))}));else if(".."===c)p(this._trace(l,e,n,r,o,i,u)),this._walk(e,(r=>{"object"==typeof e[r]&&p(this._trace(t.slice(),e[r],j(n,r),e,r,i,!0))}));else{if("^"===c)return this._hasParentSelector=!0,{path:n.slice(0,-1),expr:l,isParentSelector:!0};if("~"===c)return s={path:j(n,c),value:o,parent:r,parentProperty:null},this._handleCallback(s,i,"property"),s;if("$"===c)p(this._trace(l,e,n,null,null,i,u));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(c))p(this._slice(c,l,e,n,r,o,i));else if(0===c.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const t=c.replace(/^\?\((.*?)\)$/u,"$1"),u=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(t);u?this._walk(e,(t=>{const a=[u[2]],s=u[1]?e[t][u[1]]:e[t];this._trace(a,s,n,r,o,i,!0).length>0&&p(this._trace(l,e[t],j(n,t),e,t,i,!0))})):this._walk(e,(u=>{this._eval(t,e[u],u,n,r,o)&&p(this._trace(l,e[u],j(n,u),e,u,i,!0))}))}else if("("===c[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");p(this._trace(S(this._eval(c,e,n.at(-1),n.slice(0,-1),r,o),l),e,n,r,o,i,u))}else if("@"===c[0]){let t=!1;const u=c.slice(1,-2);switch(u){case"scalar":e&&["object","function"].includes(typeof e)||(t=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===u&&(t=!0);break;case"integer":!Number.isFinite(e)||e%1||(t=!0);break;case"number":Number.isFinite(e)&&(t=!0);break;case"nonFinite":"number"!=typeof e||Number.isFinite(e)||(t=!0);break;case"object":e&&typeof e===u&&(t=!0);break;case"array":Array.isArray(e)&&(t=!0);break;case"other":t=this.currOtherTypeCallback(e,n,r,o);break;case"null":null===e&&(t=!0);break;default:throw new TypeError("Unknown value type "+u)}if(t)return s={path:n,value:e,parent:r,parentProperty:o},this._handleCallback(s,i,"value"),s}else if("`"===c[0]&&e&&Object.hasOwn(e,c.slice(1))){const t=c.slice(1);p(this._trace(l,e[t],j(n,t),e,t,i,u,!0))}else if(c.includes(",")){const t=c.split(",");for(const u of t)p(this._trace(S(u,l),e,n,r,o,i,!0))}else!a&&e&&Object.hasOwn(e,c)&&p(this._trace(l,e[c],j(n,c),e,c,i,u,!0))}if(this._hasParentSelector)for(let t=0;t<f.length;t++){const n=f[t];if(n&&n.isParentSelector){const a=this._trace(n.expr,e,n.path,r,o,i,u);if(Array.isArray(a)){f[t]=a[0];const e=a.length;for(let n=1;n<e;n++)t++,f.splice(t,0,a[n])}else f[t]=a}}return f},T.prototype._walk=function(t,e){if(Array.isArray(t)){const n=t.length;for(let t=0;t<n;t++)e(t)}else t&&"object"==typeof t&&Object.keys(t).forEach((t=>{e(t)}))},T.prototype._slice=function(t,e,n,r,o,i,u){if(!Array.isArray(n))return;const a=n.length,s=t.split(":"),c=s[2]&&Number.parseInt(s[2])||1;let l=s[0]&&Number.parseInt(s[0])||0,f=s[1]&&Number.parseInt(s[1])||a;l=l<0?Math.max(0,l+a):Math.min(a,l),f=f<0?Math.max(0,f+a):Math.min(a,f);const p=[];for(let t=l;t<f;t+=c){this._trace(S(t,e),n,r,o,i,u,!0).forEach((t=>{p.push(t)}))}return p},T.prototype._eval=function(t,e,n,r,o,i){this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=o,this.currSandbox._$_property=n,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;const u=t.includes("@path");u&&(this.currSandbox._$_path=T.toPathString(r.concat([n])));const a=this.currEval+"Script:"+t;if(!T.cache[a]){let e=t.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(u&&(e=e.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)T.cache[a]=new this.safeVm.Script(e);else if("native"===this.currEval)T.cache[a]=new this.vm.Script(e);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const t=this.currEval;T.cache[a]=new t(e)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);T.cache[a]={runInNewContext:t=>this.currEval(e,t)}}}try{return T.cache[a].runInNewContext(this.currSandbox)}catch(e){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+e.message+": "+t)}},T.cache={},T.toPathString=function(t){const e=t,n=e.length;let r="$";for(let t=1;t<n;t++)/^(~|\^|@.*?\(\))$/u.test(e[t])||(r+=/^[0-9*]+$/u.test(e[t])?"["+e[t]+"]":"['"+e[t]+"']");return r},T.toPointer=function(t){const e=t,n=e.length;let r="";for(let t=1;t<n;t++)/^(~|\^|@.*?\(\))$/u.test(e[t])||(r+="/"+e[t].toString().replaceAll("~","~0").replaceAll("/","~1"));return r},T.toPathArray=function(t){const{cache:e}=T;if(e[t])return e[t].concat();const n=[],r=t.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(t,e){return"[#"+(n.push(e)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(t,e){return"['"+e.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(t,e){return";"+e.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,""),o=r.split(";").map((function(t){const e=t.match(/#(\d+)/u);return e&&e[1]?n[e[1]]:t}));return e[t]=o,e[t].concat()},T.prototype.safeVm={Script:class{constructor(t){this.code=t,this.ast=w(this.code)}runInNewContext(t){const e=Object.assign(Object.create(null),t);return N.evalAst(this.ast,e)}}},T.prototype.vm=g;const $=(t,e)=>n=>{let r=n;return"function"==typeof e&&(r=e(n)),console.log(`${t}: ${r}`),n};function R(t){const e=process.cwd();let n=t.indexOf("(file://","");if(-1===n&&(n=t.indexOf("file://","")),-1===n&&(n=t.indexOf("(","")),-1===n)return t;const r=t.replace("(file://","").replace("file://","").replace("(","").replace(")",""),o=r.match(/[0-9]+:[0-9]+/);if(null===o)return t;const i=o[0],u=function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=I(t).substr(1),e=I(e).substr(1);for(var r=n(t.split("/")),o=n(e.split("/")),i=Math.min(r.length,o.length),u=i,a=0;a<i;a++)if(r[a]!==o[a]){u=a;break}var s=[];for(a=u;a<r.length;a++)s.push("..");return(s=s.concat(o.slice(u))).join("/")}(e,r.substring(n,o.index-1));return`${t.substring(0,n-1)} ${u}:${i}`}function D(t,e=5){if(t instanceof Error==!1)return"Not an error object";const n=t.stack.split("\n").filter((t=>!t.includes("node_modules")&&!t.includes("node:internal"))).map((t=>t.trim())).filter((t=>t.startsWith("at"))).map(R),r=[],o=n.length;o>e?(r.push(...n.slice(0,e-1)),r.push("...skipped..."),r.push(n[o-1])):r.push(...n);const i=r.join(" -> ");return`${`${t.name}: ${t.message} ${t.cause?.message?`[cause]: ${t.cause.message}`:""}`}\nStack Trace: ${i}`}class P extends Error{constructor(t="GENERIC",e=t,n={status:500}){super(e),super.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,P),this.data=n}map(t){return this}chain(t){return this}summarizeError(t){return D(t)}static of=P}function k(t){return class extends P{constructor(e,n,r){super(e,n,r),this.name=t}}}function M(t){const e=typeof t;return"object"!==e&&"undefined"!==e&&"function"!==e}class U{constructor(t,e){let n,r;if(!1===Array.isArray(t))throw new P("NOT_AN_ARRAY","Only Array composed of non objects are permitted");if(t.filter((t=>"object"===t)).length>0)throw new P("ARRAY_VALUES_MUST_BE_OF_BASIC_TYPE","Only basic types are allowed");const i=t.filter((t=>"get"===t||"set"===t||"getValue"===t));if(i.length>0)throw new P("ENUM_INVALID_ENUM_VALUE",`The following ENUM value/s are not allowed: ${i} as they are reserved words for enum`);const u=B(W(t),(function(){return!1}));return n=t[0],u[n]=!0,void 0!==e&&function(t){if(null===t||"object"!=typeof t||!0===Array.isArray(t))throw new P("ENUM_RULES_BAD_FORMAT",`rules is not an object: ${t}`);for(const e in t){if(void 0===u[e]||!1===Array.isArray(t[e]))throw new P("ENUM_RULES_BAD_FORMAT",`Each attribute of rules must be an element in the ENUM and its value should be an array: ${u[e]}${t[e]}`);const n=t[e].filter((t=>void 0===u[t]));if(n.length>0)throw new P("ENUM_RULES_BAD_FORMAT",`All elements in a rule entry must be one of the list values in the ENUM. The following values dont exist: ${n}`)}r=o(t)}(e),this.get=function(t,e){if("getValue"===e)return a;if(null==u[e])throw new P("ENUM_INVALID_PROPERTY",`.${e} is none of the possible values ${this}`);return u[e]},this.set=function(t,e,o){if(!0!==o)throw new P("ENUM_ACTIVATION_NO_TRUE",`Tryng to set ${e} with ${o} but activation only admits true`);if(void 0===u[e])throw new P("ENUM_INVALID_PROPERTY",`.${e} is none of the possible values ${this}`);if(!function(t,e){return void 0===r||void 0!==r[t]&&-1!==r[t].indexOf(e)}(n,e))throw new P("ENUM_TRANSITION_NOT_ALLOWED",`.From: ${n} --\x3e To: ${e}`);u[n]=!1,u[e]=!0,n=e;return!0},this.getValue=a,new Proxy(u,this);function a(){return n}}}class F{constructor(t){const e=this.#t(o(t));return new Proxy(e,this)}#t(t){if(null==t)throw new Error("Null or undefined is not permitted to construct a EnumMap instance.");const e=Object.getPrototypeOf(t).constructor.name;if("Map"===e)return Object.fromEntries(t);if("Object"===e)return t;let n;const r=[];if("Array"===e){for(let e=0;e<t.length;e++){if(M(t[e])){if(r[t[e]]=e,void 0!==n&&"basicType"!==n)throw new P("ENUMMAP_VALUES_NOT_VALID","EnumMap values should be consistent...");n="basicType"}if(Array.isArray(t[e])&&2===t[e].length){if(r[t[e][0]]=t[e][1],void 0!==n&&"array"!==n)throw new P("ENUMMAP_VALUES_NOT_VALID","EnumMap values should be consistent...");n="array"}if(null!==t[e]&&"object"==typeof t[e]&&1===Object.keys(t[e]).length){const o=Object.keys(t[e])[0];if(r[o]=t[e][o],void 0!==n&&"object"!==n)throw new P("ENUMMAP_VALUES_NOT_VALID","EnumMap values should be consistent...");n="object"}}if(void 0===n)throw new P("ENUM_VALUES_NOT_VALID","Values must be an array of strings, an array of arrays, an array of objects or an array of maps")}return r}get(t,e){if(null==t[e]&&null==this[e])throw new P("ENUM_OUT_OF_RANGE",`.${e} is none of the possible values ${this}`);return null!=this[e]?this[e]:t[e]}set(t,e){throw new P("ENUM_NOT_MODIFIABLE",`Object of .${e} is not modifiable`)}invert(){const t={};for(const e in this)if(this.hasOwnProperty(e)){if(!1===M(this[e]))throw new P("INVERT_VALUES_NOT_BASIC_TYPE","EnumMap values should be basic types");t[this[e]]=e}return new F(o(t))}}function L(t,e,n){t.forEach((function(t){if(t!==t.toUpperCase())throw new P("STATE_MUST_BE_UPPERCASE",`The state: ${t} does not have all characters in uppercase`)})),e.forEach((function(t){if(t!==t.toLowerCase())throw new P("EVENT_MUST_BE_LOWERCASE",`The event: ${t} does not have all characters in lowercase`)}));let r=t[0];const o=Object.entries(n).reduce(((t,[n,r])=>{u(n);let o=r;if("string"==typeof r)u(r),o=e.reduce(((t,e)=>(t[e]=r,t)),{});else for(const[t,e]of Object.entries(o))a(t),u(e);return t[n]={...t[n],...o},t}),t.reduce(((t,n)=>(t[n]=e.reduce(((t,e)=>(t[e]=e.toUpperCase(),t)),{}),t)),{}));function i(t){return a(t),r=o[r][t],r}return i.valueOf=()=>r,i;function u(e){if(!1===t.some((t=>t===e)))throw new P("STATE_NOT_FOUND",`The state: ${e} was not found in the list of states supplied: ${t}`)}function a(t){if(!1===e.some((e=>e===t)))throw new P("EVENT_NOT_FOUND",`The event: ${t} was not found in the list of events supplied: ${e}`)}}function B(t,e){return t.reduce(((t,n,r)=>(t[n]=e(n,r),t)),{})}function Y(t){if("function"==typeof t?.[Symbol.iterator]){const e={};for(const n of t)for(const t in n)e[t]=n[t];return e}return arr.reduce(((t,e,n)=>{for(const n in e)t[n]=e[n];return t}),{})}function W(t){return[...new Set(t)]}function q(t,e,n=!0){const r=["$"],i=n?o(t):t;let u=!1;const a={};a.$=i;const s=c(e,a,"$",r);return i!==a.$||!0===u||!1===s&&function t(n){if(n&&n instanceof Object&&!1===u)for(const o in n)if(n.hasOwnProperty(o)){r.push(o);const i=c(e,n,o,r);if(!0===u)return;!1===i&&t(n[o]),r.pop()}}(a.$),a.$;function c(t,e,n,r){let o=!1;if(t){const i=t(e[n],r,e,n);void 0!==i&&i!==q.stop&&i!==q.skip&&i!==q.delete&&(e[n]=i,o=!0),i===q.stop&&(u=!0),i===q.skip&&(o=!0),i===q.delete&&(e[n]=void 0,o=!0)}return o}}function V(t,e,n){if(!1===Array.isArray(n))return;let r=0,o=0,i=!0;for(let u=0;i||u<o;u++){const a=[];for(let t=0;t<n.length;t++){a[t]={...n[t]};for(const r of e)i&&(o=n[t]?.[r]?.length>o?n[t][r].length:o),a[t][r]=n[t]?.[r]?.[u]}0!==o&&(t(a,r),r++),i=!1}}function z(t,e,n=!0){const r=Symbol();let i;if(null==e)return e;if(Array.isArray(e))i=[];else{if(Object.getPrototypeOf(e)!==Object.prototype){if(!1===Array.isArray(t))throw new Error("paths must be an array");return t.filter((t=>"+$"===t)).length-t.filter((t=>"-$"===t)).length>0?e:void 0}i={}}for(const u of t){if("+"!==u[0]&&"-"!==u[0])throw new Error("ivanlid format");const t="+"===u[0],a=T({resultType:"all",path:u.substring(1),json:e}),s=new Map;for(const{pointer:e,value:u}of a){const a=e.substring(1).split("/");if(1===a.length&&""===a[0])i=t?o(u):void 0;else if(!0===n&&!1===t){const t=a.slice(0,-1),e=Ct(i,t);if(!0===Array.isArray(e))s.set(t.join("/"),e),Tt(i,a,r);else{delete e[a[a.length-1]],Tt(i,t,e)}}else Tt(i,a,t?o(u):void 0)}for(const[t,e]of s){const n=e.filter((t=>t!==r));Tt(i,t.split("/"),n)}}return i}function J(t,e,n=!1){return r=>(e.map((e=>{let o,i;"object"==typeof e?(o=e.from,i=e.to):(o=e,i=e);let u=Ct(r,o);"function"==typeof e.transform&&(u=e.transform(u)),null!=u&&(!0===n&&X(Ct(t,i))&&Tt(t,i,u),!1===n&&Tt(t,i,u))})),t)}function H(t,e=!1){return n=>(q(n,((n,r)=>{if(!1===K(n))return;if(null==n||1===r.length)return;const o=r.slice(1-r.length);if(!0!==e)Tt(t,o,n);else{X(Ct(t,o))&&Tt(t,o,n)}})),t)}function K(t){return!("Object"===t?.constructor.name&&Object.keys(t).length>0||"Array"===t?.constructor.name&&t.length>0)}function X(t){return!!(null==t||""===t||0===t||0n===t||Number.isNaN(t)||Array.isArray(t)&&0===t?.length||"object"==typeof t&&0===Object.keys(t).length)}function G(t){return"string"==typeof t?t[0].toUpperCase()+t.substring(1).toLowerCase():t}function Q(t){return Object.keys(t).reduce(((e,n)=>`${e?`${e}&`:e}${n}=${t[n]}`),"")}function Z(t,e,n){if("string"!=typeof t)return t;return t.replace(/"{{([^=}]+)(?:=([^}]+))?}}"/g,((t,r,o)=>{if(e&&void 0!==e[r]){if("string"==typeof e[r])return`"${e[r]}"`;if("object"==typeof e[r]){if("url"===n&&Array.isArray(e[r]))return tt(e[r]);if("url"===n&&!Array.isArray(e[r]))return et(e[r]);if(!n)return JSON.stringify(e[r])}return e[r]}return void 0===o?null:o.replace(/\\"/g,'"')})).replace(/{{([^=}]+)(?:=([^}]+))?}}/g,((t,r,o)=>e&&void 0!==e[r]?"object"!=typeof e[r]?e[r]:"url"===n&&Array.isArray(e[r])?tt(e[r]):"url"!==n||Array.isArray(e[r])?n?void 0:JSON.stringify(e[r]):et(e[r]):void 0===o?null:o.replace(/\\"/g,"")))}function tt(t){return t.reduce(((t,e)=>`${t},${e}`))}function et(t){return Object.keys(t).reduce(((e,n)=>`${e}${n}=${t[n]}&`),"").slice(0,-1)}function nt(t,e,n){return{gatewayUrl:t,serviceName:e,servicePath:n,url:`${t}${e}${n}`}}function rt(t,e){return e.filter((e=>t.split(e).length>=2)).map((e=>{const[n,...r]=t.split(e);return{gatewayUrl:n,serviceName:e,servicePath:r.join(e)}}))}function ot(t,e,n){if(n>0==!1)return-1;let r=-1;for(let o=0;o<n;o++)r=t.indexOf(e,r+1);return r}function it(t){return t?t instanceof Date?t:new Date(t):new Date}function ut(t){return t instanceof Date&&!Number.isNaN(t)}function at(t){return"string"==typeof t&&ut(new Date(t))}function st(t){return e=>ct(t,e)}function ct(t,e){const n=it(e);if(!1===ut(n))return;const r=new F({January:"01",February:"02",March:"03",April:"04",May:"05",June:"06",July:"07",August:"08",September:"09",October:"10",November:"11",December:"12"}).invert(),o=new F({Sunday:"0",Monday:"1",Tuesday:"2",Wednesday:"3",Thursday:"4",Friday:"5",Saturday:"6"}).invert(),i=n.toISOString(),u=i.substring(0,4),a=i.substring(2,4),s=i.substring(5,7),c=i.substring(8,10),l=Number.parseInt(c,10).toString(),f=i.substring(11,13),p=Number.parseInt(f,10).toString(),h=i.substring(14,16),d=i.substring(17,19),y=i.substring(20,23),g=i.substring(20,22),v=r[s],m=o[n.getUTCDay()];return t.replace(/\$YYYY/g,u).replace(/\$YY/g,a).replace(/\$MM/g,s).replace(/\$DD/g,c).replace(/\$D/g,l).replace(/\$hh/g,f).replace(/\$h/g,p).replace(/\$mm/g,h).replace(/\$ss/g,d).replace(/\$mil/g,y).replace(/\$mi/g,g).replace(/\$month/g,v).replace(/\$dayOfWeek/g,m)}function lt(t){const e=Number.parseInt(t.substring(0,4)),n=Number.parseInt(t.substring(5,7))-1,r=Number.parseInt(t.substring(8,10)),o=Number.parseInt(t.substring(11,13)),i=Number.parseInt(t.substring(14,16)),u=Number.parseInt(t.substring(17,19));return Date.UTC(e,n,r,o,i,u)}q.skip=Symbol(),q.stop=Symbol(),q.delete=Symbol(),q.matchPath=(t,e)=>{const n=t.split(".");return n.length===e.length&&n.every(((t,n)=>"*"===t||t===e[n]))};const ft=new F(["SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"]),pt=new F(["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]);function ht(t){const e=it(t);if(!1===ut(e))return;const n=e.toISOString();return{YYYY:Number.parseInt(n.substring(0,4)),MM:Number.parseInt(n.substring(5,7)),DD:Number.parseInt(n.substring(8,10)),hh:Number.parseInt(n.substring(11,13)),mm:Number.parseInt(n.substring(14,16)),ss:Number.parseInt(n.substring(17,19)),mil:Number.parseInt(n.substring(20,23))}}function dt(t,e){return Math.ceil((new Date(e)-new Date(t))/864e5)}function yt(t,e){const n=it(e);return!1===ut(n)?n:new Date(n.valueOf()+864e5*t)}function gt(t,e){const n=it(e);return!1===ut(n)?n:new Date(n.valueOf()-864e5*t)}function vt(t,e){const n=it(e);if(!1===ut(n))return n;const r=n.getUTCDay()-t;return gt(r>=0?r:7+r,n)}function mt(t,e){const n=it(e);if(!1===ut(n))return n;const r=t-n.getUTCDay();return yt(r>=0?r:7+r,n)}function bt(t,e){const n=it(e);if(!1===ut(n))return n;return yt((0===t?7:t)-(0===n.getUTCDay()?7:n.getUTCDay()),n)}function wt(t){const e=it(t);if(!1===ut(e))return e;const n=e.getUTCDay();return n>0&&n<6?e:gt(0===n?2:1,e)}function Et(t){return"T00:00:00.000Z"===t?.toISOString?.()?.substring(10,24)}function _t(t){if("string"==typeof t&&t.match(/\d{4}\D\d{2}\D\d{2}/))return new Date(`${t.substring(0,10)} UTC`);if("string"==typeof t)return new Date(`${t} UTC`);const e=0===arguments.length?new Date:new Date(t);return Number.isNaN(+e)||Et(e)?e:new Date(`${e.toISOString().substring(0,10)} UTC`)}const{colors:xt,colorMessage:At,colorMessageByStatus:Ot,colorByStatus:Nt}=(()=>{const t={red:"",green:"",yellow:"",cyan:"",blue:"",reset:"",reverse:"",fgBlack:"",fgRed:"",fgGreen:"",fgYellow:"",fgBlue:"",fgMagenta:"",fgCyan:"",fgWhite:"",bgBlack:"",bgRed:"",bgGreen:"",bgYellow:"",bgBlue:"",bgMagenta:"",bgCyan:"",bgWhite:"",bright:"",dim:"",underscore:"",blink:"",hidden:""};return{colors:t,colorMessage:(e,n)=>`${t[n]}${e}${t.reset}`,colorMessageByStatus:(e,n)=>n>=200&n<300?t.green:n>=300&n<400?t.cyan:n>=400&n<500?t.yellow:t.red,colorByStatus:e=>e>=200&e<300?t.green:e>=300&e<400?t.cyan:e>=400&e<500?t.yellow:t.red}})();function jt(t,e){const n=[],r=[];return function t(o){for(const i in o)i===e&&(r.push([...n]),r[r.length-1].push(i),r.push(o[i])),null!==o[i]&&"object"==typeof o[i]&&(n.push(i),t(o[i]),n.pop())}(t),r}function St(t){for(const e of Object.getOwnPropertyNames(t))null===t[e]||"object"!=typeof t[e]&&"function"!=typeof t[e]||St(t[e]);return Object.freeze(t),t}function Ct(t,e){if(null==t||null==e)return;if(""===e)return t;let n=t;const r="string"==typeof e?e.split("."):e;for(const t of r){if(void 0===n)return n;n=n instanceof Object?"$last"===t&&Array.isArray(n)?n[n.length-1]:n[t]:void 0}return n}function Tt(t,e,n){const r="CREATED",o="FAILED";let u,a=t,s=o;if(null==t||null==e)throw{name:"setAtParamsException",msg:`obj: ${t}, valuePath: ${e}, value: ${n}`};try{u="string"==typeof e?e.split("."):e;for(let t=0,e=u.length;t<e;t++){const e=c(a,u[t]);t===u.length-1?(void 0!==a?.[u[t]]?s!==r&&(s="MODIFIED"):s!==r&&(s="ADDED"),a[e]=n):("object"!=typeof a[e]&&(Number.isNaN(Number(u[t+1]))?a[e]={}:a[e]=[],s=r),a=a[e])}if(s===o)throw{name:"setAtException",msg:`obj: ${t}, valuePath: ${e}, value: ${n}`}}catch(r){return console.log(`${r} Warning: There was an exception in setAt(obj, valuePath, value)... obj: ${t} valuePath: ${e} value: ${n}`),s=o,s}return s;function c(t,e){return Array.isArray(t)&&"$last"===e?t.length-1:Array.isArray(t)&&"$push"===e?t.length:Array.isArray(t)&&Number.parseInt(e)<0?t.length+Number.parseInt(u[i]):e}}const It=t=>t.split(".").map((t=>{const e=Number(t);return Number.isNaN(e)?t:"*"})).join("."),$t=t=>"$."===t.substring(0,2)?t.substring(2):t,Rt=(t,e)=>null==t||Number.isNaN(t)?e:t,Dt=(t,e=!0)=>{let n,r=1,o=-1,i=Number.POSITIVE_INFINITY;return!1===e&&(r=-1,o=1,i=Number.NEGATIVE_INFINITY),n="string"==typeof t?[t]:[...t],(t,e)=>{for(const u of n){if(Rt(Ct(t,u),i)>Rt(Ct(e,u),i))return r;if(Rt(Ct(t,u),i)<Rt(Ct(e,u),i))return o}return 0}},Pt=(t,e=!0)=>{let n,r=e;return!1===Array.isArray(e)&&(r=Array(t.length).fill(e)),n="string"==typeof t?[t]:[...t],(t,e)=>{let o,i,u,a;for(let s=0;s<n.length;s++){if(a=n[s],o=1,i=-1,u=Number.POSITIVE_INFINITY,!1===r[s]&&(o=-1,i=1,u=Number.NEGATIVE_INFINITY),Rt(Ct(t,a),u)>Rt(Ct(e,a),u))return o;if(Rt(Ct(t,a),u)<Rt(Ct(e,a),u))return i}return 0}};function kt(t,e){if(void 0===t?.length||0===t?.length)return-1;let n=0,r=t.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t[o];if(i>e)r=o-1;else{if(!(i<e))return o;n=o+1}}return-1}function Mt(t,e){let n=0,r=t.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t[o];if(i<e)n=o+1;else{if(!(i>e))return o;r=o-1}}return r}function Ut(t,e){let n=0,r=t.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t[o];if(i<e)n=o+1;else{if(!(i>e))return o;r=o-1}}return n===t.length?-1:n}function Ft(t,e){const n=[];let r,o=0;for(let i=0,u=e.length;i<u;i++)if(r=t(e[i],i,e),void 0!==r)if(!0===Array.isArray(r))for(let t=0,e=r.length;t<e;t++)void 0!==r[t]&&(n[o++]=r[t]);else n[o++]=r;return n}const Lt=(t=!0)=>(e,n)=>!1===t?e<n?1:e>n?-1:0:e<n?-1:e>n?1:0;function Bt(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function Yt(t){return new Promise((e=>setTimeout(e,t)))}function Wt(t,e){return new Promise((n=>setTimeout((()=>n(e)),t)))}function qt(t,e,...n){return new Promise((r=>setTimeout((()=>r(e(...n))),t)))}async function Vt(t,e,n,r,o,i){let u,a=0;for(let s=0;s<t;s++){s>0&&await Yt(a);try{u=await n(...r)}catch(e){if(s===t-1)throw e;u=e}if(void 0===o&&u instanceof Error==!1)return u;try{if(!0===o?.(u))return u}catch(t){throw console.log(`Called to shouldStopFun failed with params: ${a}, ${s}`),console.log(`Log from caller to retryFunction: ${i}`),console.log("Throwing exception..."),t}const c=u?.message??u?.error??u?.code??u?.status??u?.status??u?.name;console.log(`Iteration: ${s+1} sleepTime: ${a} Error: ${c}`),console.log(`Log from caller to retryFunction: ${i}`);try{a=e(a,s)}catch(t){throw console.log(`Calling updateSleepTimeFun failed with params: ${a}, ${s}`),console.log(`Log from caller to retryFunction: ${i}`),t}}return u}const zt=t=>(...e)=>!t(...e);function Jt(t,e,n=[0]){const r=o(t,n);return void 0===e.find((t=>o(t,n)===r))?(e.push(t),t):void 0;function o(t,e){return"object"!=typeof t?t:e.reduce(((e,n,r)=>`${e}-${r}-${t[n]}`),"")}}function Ht(t,e,n=[0],r){if(void 0===Jt(t,e,n)){const i=o(t,n);return e.map((e=>i===o(e,n)?r(t,e):e))}return e;function o(t,e){return"object"!=typeof t?t:e.reduce(((e,n,r)=>`${e}-${r}-${t[n]}`),"")}}function Kt(t,e,n){if(!1===Array.isArray(n))throw new P("PUSHAT_LAST_PARAMETER_MUST_BE_ARRAY");const r=n.length;return ee(n.length-t).times((t=>{n[r-t]=n[r-t-1]})),n[t]=e,n}function Xt(){const t=new Map;return{memoizeMap:function(e,...n){const r=JSON.stringify(n);let o=t.get(r);return void 0===o&&!1===t.has(r)&&(o=e(...n),t.set(r,o)),o},memoizeWithHashFun:function(e,n,...r){const o=JSON.stringify(n(r));let i=t.get(o);return void 0===i&&!1===t.has(o)&&(i=e(...r),t.set(o,i)),i}}}function Gt(t,e){const n=[],r="function"==typeof e?e:t=>t<e;let o,i=-1;do{i++,n[i]=t(i,n),o=r(i,n),o||n.pop()}while(o);return n}function Qt(t,e,n){return t.toFixed(n).padStart(e+n+1,"0")}function Zt(t,...e){let n=e;return void 0!==e[0][0].from&&(n=e[0]),n.reduce(((t,e)=>t.split(e.from).join(e.to)),t)}function te(t){return t.replace(/([^a-z0-9 .,]+)/gi,"").replace(/ +/g," ").trim()}function ee(t){const e=[];let n=!1;return{times:function(r){for(let o=0;o<t&&!1===n;o++)e[o]=r(o);return e},awaitTimes:async function(r){for(let o=0;o<t&&!1===n;o++)e[o]=await r(o);return e},value:function(e){return Array(t).fill(e)},breakNextIteration:function(){n=!0}}}function ne(t,e=!0){let n=e?0:t-1;return{call:function(e){function r(...r){if(0===n)return n=t-1,e(...r);n--}return r.reset=(e=!0)=>{n=e?0:t-1},r.stop=()=>{n=Number.POSITIVE_INFINITY},r}}}function*re(t,e){let n=0;for(;;)yield t+n%e,n++}function oe(t){console.log(`Shutting down with error: ${t}`);try{process.exit(1)}catch(t){console.log(t)}}const ie={logWithPrefix:$,firstCapital:G,varSubsDoubleBracket:Z,queryObjToStr:Q,summarizeError:D,CustomError:P,createCustomErrorClass:k,isBasicType:M,urlCompose:nt,urlDecompose:rt,indexOfNthMatch:ot,colors:xt,colorMessage:At,colorMessageByStatus:Ot,colorByStatus:Nt,findDeepKey:jt,deepFreeze:St,getAt:Ct,setAt:Tt,pathReplacingArrayIndexWithAsterisk:It,stripDollarRoot:$t,sorterByPaths:Dt,sorterByFields:Pt,findIndexInSortedArray:kt,findIndexOrPreviousInSortedArray:Mt,findIndexOrNextInSortedArray:Ut,defaultValue:Rt,filterFlatMap:Ft,arraySorter:Lt,isPromise:Bt,sleep:Yt,sleepWithValue:Wt,sleepWithFunction:qt,notTo:zt,arrayToObject:B,arrayOfObjectsToObject:Y,removeDuplicates:W,traverse:q,traverseVertically:V,project:z,copyPropsWithValue:H,copyPropsWithValueUsingRules:J,EnumMap:F,Enum:U,transition:L,pushUniqueKey:Jt,pushUniqueKeyOrChange:Ht,pushAt:Kt,memoize:Xt,fillWith:Gt,numberToFixedString:Qt,isDate:ut,isEmpty:X,isALeaf:K,isStringADate:at,formatDate:ct,DAYS:ft,MONTHS:pt,dateFormatter:st,YYYY_MM_DD_hh_mm_ss_ToUtcDate:lt,dateToObj:ht,diffInDaysYYYY_MM_DD:dt,subtractDays:gt,addDays:yt,previousDayOfWeek:vt,nextDayOfWeek:mt,dayOfWeek:bt,getSameDateOrPreviousFridayForWeekends:wt,isDateMidnight:Et,setDateToMidnight:_t,replaceAll:Zt,cleanString:te,repeat:ee,oneIn:ne,loopIndexGenerator:re,retryW