Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonpath-plus

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonpath-plus - npm Package Compare versions

Comparing version 10.0.0 to 10.0.1

4

CHANGES.md
# CHANGES for jsonpath-plus
## 10.0.1
- fix(security): prohibit `Function` in "safe" vm
## 10.0.0

@@ -4,0 +8,0 @@

2

dist/index-browser-esm.min.js

@@ -1,2 +0,2 @@

function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r){return t=s(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,r||[],s(e).constructor):t.apply(e,r))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t,r){if(u())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&h(i,r.prototype),i}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function o(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,r){return(t=p(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function l(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function d(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function y(e){var t="function"==typeof Map?new Map:void 0;return y=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},y(e)}var b=function(){return o((function e(){r(this,e)}),[{key:"add",value:function(e,t,r){if("string"!=typeof arguments[0])for(var n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}},{key:"run",value:function(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}}])}(),v=function(){return o((function e(t){r(this,e),this.jsep=t,this.registered={}}),[{key:"register",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){if("object"!==f(t)||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");e.registered[t.name]||(t.init(e.jsep),e.registered[t.name]=t)}))}}])}(),E=function(){function e(t){r(this,e),this.expr=t,this.index=0}return o(e,[{key:"char",get:function(){return this.expr.charAt(this.index)}},{key:"code",get:function(){return this.expr.charCodeAt(this.index)}},{key:"throwError",value:function(e){var t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}},{key:"runHook",value:function(t,r){if(e.hooks[t]){var n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}},{key:"searchHook",value:function(t){if(e.hooks[t]){var r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}},{key:"gobbleSpaces",value:function(){for(var t=this.code;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}},{key:"parse",value:function(){this.runHook("before-all");var t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}},{key:"gobbleExpressions",value:function(t){for(var r,n,i=[];this.index<this.expr.length;)if((r=this.code)===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())i.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}},{key:"gobbleExpression",value:function(){var e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}},{key:"gobbleBinaryOp",value:function(){this.gobbleSpaces();for(var t=this.expr.substr(this.index,e.max_binop_len),r=t.length;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}},{key:"gobbleBinaryExpression",value:function(){var t,r,n,i,o,a,s,u,c,h;if(!(a=this.gobbleToken()))return a;if(!(r=this.gobbleBinaryOp()))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},(s=this.gobbleToken())||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(0===(n=e.binaryPrecedence(r))){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;for(;i.length>2&&(h=i[i.length-2],o.right_a&&h.right_a?n>h.prec:n<=h.prec);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);(t=this.gobbleToken())||this.throwError("Expected expression after "+c),i.push(o,t)}for(t=i[u=i.length-1];u>1;)t={type:e.BINARY_EXP,operator:i[u-1].value,left:i[u-2],right:t},u-=2;return t}},{key:"gobbleToken",value:function(){var t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(n=(r=this.expr.substr(this.index,e.max_unop_len)).length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;var o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}},{key:"gobbleTokenProperty",value:function(t){this.gobbleSpaces();for(var r=this.code;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){var n=void 0;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(r=this.code)!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}},{key:"gobbleNumericLiteral",value:function(){for(var t,r,n="";e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(n+=this.expr.charAt(this.index++),"+"!==(t=this.char)&&"-"!==t||(n+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(r===e.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(n),raw:n}}},{key:"gobbleStringLiteral",value:function(){for(var t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;this.index<this.expr.length;){var o=this.expr.charAt(this.index++);if(o===n){i=!0;break}if("\\"===o)switch(o=this.expr.charAt(this.index++)){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+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}},{key:"gobbleIdentifier",value:function(){var t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}},{key:"gobbleArguments",value:function(t){for(var r=[],n=!1,i=0;this.index<this.expr.length;){this.gobbleSpaces();var o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(o===e.COMMA_CODE){if(this.index++,++i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(var a=r.length;a<i;a++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{var s=this.gobbleExpression();s&&s.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(s)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}},{key:"gobbleGroup",value:function(){this.index++;var t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}},{key:"gobbleArray",value:function(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}],[{key:"version",get:function(){return"1.3.9"}},{key:"toString",value:function(){return"JavaScript Expression Parser (JSEP) v"+e.version}},{key:"addUnaryOp",value:function(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}},{key:"addBinaryOp",value:function(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}},{key:"addIdentifierChar",value:function(t){return e.additional_identifier_chars.add(t),e}},{key:"addLiteral",value:function(t,r){return e.literals[t]=r,e}},{key:"removeUnaryOp",value:function(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}},{key:"removeAllUnaryOps",value:function(){return e.unary_ops={},e.max_unop_len=0,e}},{key:"removeIdentifierChar",value:function(t){return e.additional_identifier_chars.delete(t),e}},{key:"removeBinaryOp",value:function(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}},{key:"removeAllBinaryOps",value:function(){return e.binary_ops={},e.max_binop_len=0,e}},{key:"removeLiteral",value:function(t){return delete e.literals[t],e}},{key:"removeAllLiterals",value:function(){return e.literals={},e}},{key:"parse",value:function(t){return new e(t).parse()}},{key:"getMaxKeyLen",value:function(e){return Math.max.apply(Math,[0].concat(l(Object.keys(e).map((function(e){return e.length})))))}},{key:"isDecimalDigit",value:function(e){return e>=48&&e<=57}},{key:"binaryPrecedence",value:function(t){return e.binary_ops[t]||0}},{key:"isIdentifierStart",value:function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}},{key:"isIdentifierPart",value:function(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}}])}(),g=new b;Object.assign(E,{hooks:g,plugins:new v(E),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,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),E.max_unop_len=E.getMaxKeyLen(E.unary_ops),E.max_binop_len=E.getMaxKeyLen(E.binary_ops);var x=function(e){return new E(e).parse()},F=Object.getOwnPropertyNames(o((function e(){r(this,e)})));Object.getOwnPropertyNames(E).filter((function(e){return!F.includes(e)&&void 0===x[e]})).forEach((function(e){x[e]=E[e]})),x.Jsep=E;var D={name:"ternary",init:function(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;var r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;var i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){for(var o=r;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;t.node.test=o.right,o.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};x.plugins.register(D);var _={name:"regex",init:function(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){for(var r=++this.index,n=!1;this.index<this.expr.length;){if(47===this.code&&!n){for(var i=this.expr.slice(r,this.index),o="";++this.index<this.expr.length;){var a=this.code;if(!(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57))break;o+=this.char}var s=void 0;try{s=new RegExp(i,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}},O={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(e){var t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){O.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((function(e){e&&"object"===f(e)&&r(e)}))}O.assignmentOperators.forEach((function(t){return e.addBinaryOp(t,O.assignmentPrecedence,!0)})),e.hooks.add("gobble-token",(function(e){var r=this,n=this.code;O.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))})),e.hooks.add("after-token",(function(e){var r=this;if(e.node){var n=this.code;O.updateOperators.some((function(e){return e===n&&e===r.expr.charCodeAt(r.index+1)}))&&(t.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};x.plugins.register(_,O);var m={evalAst:function(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return m.evalBinaryExpression(e,t);case"Compound":return m.evalCompound(e,t);case"ConditionalExpression":return m.evalConditionalExpression(e,t);case"Identifier":return m.evalIdentifier(e,t);case"Literal":return m.evalLiteral(e,t);case"MemberExpression":return m.evalMemberExpression(e,t);case"UnaryExpression":return m.evalUnaryExpression(e,t);case"ArrayExpression":return m.evalArrayExpression(e,t);case"CallExpression":return m.evalCallExpression(e,t);case"AssignmentExpression":return m.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:function(e,t){return{"||":function(e,t){return e||t()},"&&":function(e,t){return e&&t()},"|":function(e,t){return e|t()},"^":function(e,t){return e^t()},"&":function(e,t){return e&t()},"==":function(e,t){return e==t()},"!=":function(e,t){return e!=t()},"===":function(e,t){return e===t()},"!==":function(e,t){return e!==t()},"<":function(e,t){return e<t()},">":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<<t()},">>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](m.evalAst(e.left,t),(function(){return m.evalAst(e.right,t)}))},evalCompound:function(e,t){for(var r,n=0;n<e.body.length;n++){"Identifier"===e.body[n].type&&["var","let","const"].includes(e.body[n].name)&&e.body[n+1]&&"AssignmentExpression"===e.body[n+1].type&&(n+=1);var i=e.body[n];r=m.evalAst(i,t)}return r},evalConditionalExpression:function(e,t){return m.evalAst(e.test,t)?m.evalAst(e.consequent,t):m.evalAst(e.alternate,t)},evalIdentifier:function(e,t){if(e.name in t)return t[e.name];throw ReferenceError("".concat(e.name," is not defined"))},evalLiteral:function(e){return e.value},evalMemberExpression:function(e,t){var r=e.computed?m.evalAst(e.property):e.property.name,n=m.evalAst(e.object,t),i=n[r];return"function"==typeof i?i.bind(n):i},evalUnaryExpression:function(e,t){return{"-":function(e){return-m.evalAst(e,t)},"!":function(e){return!m.evalAst(e,t)},"~":function(e){return~m.evalAst(e,t)},"+":function(e){return+m.evalAst(e,t)}}[e.operator](e.argument)},evalArrayExpression:function(e,t){return e.elements.map((function(e){return m.evalAst(e,t)}))},evalCallExpression:function(e,t){var r=e.arguments.map((function(e){return m.evalAst(e,t)}));return m.evalAst(e.callee,t).apply(void 0,l(r))},evalAssignmentExpression:function(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");var r=e.left.name,n=m.evalAst(e.right,t);return t[r]=n,t[r]}},C=function(){return o((function e(t){r(this,e),this.code=t,this.ast=x(this.code)}),[{key:"runInNewContext",value:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);return m.evalAst(this.ast,t)}}])}();function w(e,t){return(e=e.slice()).push(t),e}function A(e,t){return(t=t.slice()).unshift(e),t}var k=function(){function e(n){var i;return r(this,e),(i=t(this,e,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,i.value=n,i.name="NewError",i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(e,y(Error)),o(e)}();function P(e,t,r,n,i){if(!(this instanceof P))try{return new P(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===f(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;var s=this.evaluate(a);if(!s||"object"!==f(s))throw new k(s);return s}}P.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===f(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=Object.hasOwn(e,"flatten")?e.flatten:s,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,u=Object.hasOwn(e,"wrap")?e.wrap:u,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=Object.hasOwn(e,"parent")?e.parent:o,a=Object.hasOwn(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=P.toPathString(e)),(e||""===e)&&t){var c=P.toPathArray(e);"$"===c[0]&&c.length>1&&c.shift(),this._hasParentSelector=null;var h=this._trace(c,t,["$"],o,a,r).filter((function(e){return e&&!e.isParentSelector}));return h.length?u||1!==h.length||h[0].hasArrExpr?h.reduce((function(e,t){var r=i._getPreferredOutput(t);return s&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(h[0]):u?[]:void 0}},P.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){case"all":var r=Array.isArray(e.path)?e.path:P.toPathArray(e.path);return e.pointer=P.toPointer(r),e.path="string"==typeof e.path?e.path:P.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return P.toPathString(e[t]);case"pointer":return P.toPointer(e.path);default:throw new TypeError("Unknown result type")}},P.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:P.toPathString(e.path),t(n,r,e)}},P.prototype._trace=function(e,t,r,n,i,o,a,s){var u,c=this;if(!e.length)return u={path:r,value:t,parent:n,parentProperty:i,hasArrExpr:a},this._handleCallback(u,o,"value"),u;var h=e[0],l=e.slice(1),p=[];function y(e){Array.isArray(e)?e.forEach((function(e){p.push(e)})):p.push(e)}if(("string"!=typeof h||s)&&t&&Object.hasOwn(t,h))y(this._trace(l,t[h],w(r,h),t,h,o,a));else if("*"===h)this._walk(t,(function(e){y(c._trace(l,t[e],w(r,e),t,e,o,!0,!0))}));else if(".."===h)y(this._trace(l,t,r,n,i,o,a)),this._walk(t,(function(n){"object"===f(t[n])&&y(c._trace(e.slice(),t[n],w(r,n),t,n,o,!0))}));else{if("^"===h)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:l,isParentSelector:!0};if("~"===h)return u={path:w(r,h),value:i,parent:n,parentProperty:null},this._handleCallback(u,o,"property"),u;if("$"===h)y(this._trace(l,t,r,null,null,o,a));else if(/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(h))y(this._slice(h,l,t,r,n,i,o));else if(0===h.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");var b=h.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),v=/@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(b);v?this._walk(t,(function(e){var a=[v[2]],s=v[1]?t[e][v[1]]:t[e];c._trace(a,s,r,n,i,o,!0).length>0&&y(c._trace(l,t[e],w(r,e),t,e,o,!0))})):this._walk(t,(function(e){c._eval(b,t[e],e,r,n,i)&&y(c._trace(l,t[e],w(r,e),t,e,o,!0))}))}else if("("===h[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");y(this._trace(A(this._eval(h,t,r[r.length-1],r.slice(0,-1),n,i),l),t,r,n,i,o,a))}else if("@"===h[0]){var E=!1,g=h.slice(1,-2);switch(g){case"scalar":t&&["object","function"].includes(f(t))||(E=!0);break;case"boolean":case"string":case"undefined":case"function":f(t)===g&&(E=!0);break;case"integer":!Number.isFinite(t)||t%1||(E=!0);break;case"number":Number.isFinite(t)&&(E=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(E=!0);break;case"object":t&&f(t)===g&&(E=!0);break;case"array":Array.isArray(t)&&(E=!0);break;case"other":E=this.currOtherTypeCallback(t,r,n,i);break;case"null":null===t&&(E=!0);break;default:throw new TypeError("Unknown value type "+g)}if(E)return u={path:r,value:t,parent:n,parentProperty:i},this._handleCallback(u,o,"value"),u}else if("`"===h[0]&&t&&Object.hasOwn(t,h.slice(1))){var x=h.slice(1);y(this._trace(l,t[x],w(r,x),t,x,o,a,!0))}else if(h.includes(",")){var F,D=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=d(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f: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.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(h.split(","));try{for(D.s();!(F=D.n()).done;){var _=F.value;y(this._trace(A(_,l),t,r,n,i,o,!0))}}catch(e){D.e(e)}finally{D.f()}}else!s&&t&&Object.hasOwn(t,h)&&y(this._trace(l,t[h],w(r,h),t,h,o,a,!0))}if(this._hasParentSelector)for(var O=0;O<p.length;O++){var m=p[O];if(m&&m.isParentSelector){var C=this._trace(m.expr,t,m.path,n,i,o,a);if(Array.isArray(C)){p[O]=C[0];for(var k=C.length,P=1;P<k;P++)O++,p.splice(O,0,C[P])}else p[O]=C}}return p},P.prototype._walk=function(e,t){if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)t(n);else e&&"object"===f(e)&&Object.keys(e).forEach((function(e){t(e)}))},P.prototype._slice=function(e,t,r,n,i,o,a){if(Array.isArray(r)){var s=r.length,u=e.split(":"),c=u[2]&&Number.parseInt(u[2])||1,h=u[0]&&Number.parseInt(u[0])||0,l=u[1]&&Number.parseInt(u[1])||s;h=h<0?Math.max(0,h+s):Math.min(s,h),l=l<0?Math.max(0,l+s):Math.min(s,l);for(var p=[],f=h;f<l;f+=c){this._trace(A(f,t),r,n,i,o,a,!0).forEach((function(e){p.push(e)}))}return p}},P.prototype._eval=function(e,t,r,n,i,o){var a=this;this.currSandbox._$_parentProperty=o,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;var s=e.includes("@path");s&&(this.currSandbox._$_path=P.toPathString(n.concat([r])));var u=this.currEval+"Script:"+e;if(!P.cache[u]){var c=e.replace(/@parentProperty/g,"_$_parentProperty").replace(/@parent/g,"_$_parent").replace(/@property/g,"_$_property").replace(/@root/g,"_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g,"_$_v$1");if(s&&(c=c.replace(/@path/g,"_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)P.cache[u]=new this.safeVm.Script(c);else if("native"===this.currEval)P.cache[u]=new this.vm.Script(c);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){var h=this.currEval;P.cache[u]=new h(c)}else{if("function"!=typeof this.currEval)throw new TypeError('Unknown "eval" property "'.concat(this.currEval,'"'));P.cache[u]={runInNewContext:function(e){return a.currEval(c,e)}}}}try{return P.cache[u].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},P.cache={},P.toPathString=function(e){for(var t=e,r=t.length,n="$",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+=/^[\*0-9]+$/.test(t[i])?"["+t[i]+"]":"['"+t[i]+"']");return n},P.toPointer=function(e){for(var t=e,r=t.length,n="",i=1;i<r;i++)/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i])||(n+="/"+t[i].toString().replace(/~/g,"~0").replace(/\//g,"~1"));return n},P.toPathArray=function(e){var t=P.cache;if(t[e])return t[e].concat();var r=[],n=e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g,";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g,(function(e,t){return"['"+t.replace(/\./g,"%@%").replace(/~/g,"%%@@%%")+"']"})).replace(/~/g,";~;").replace(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g,";").replace(/%@%/g,".").replace(/%%@@%%/g,"~").replace(/(?:;)?(\^+)(?:;)?/g,(function(e,t){return";"+t.split("").join(";")+";"})).replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").split(";").map((function(e){var t=e.match(/#([0-9]+)/);return t&&t[1]?r[t[1]]:e}));return t[e]=n,t[e].concat()},P.prototype.safeVm={Script:C};var S=function(){return o((function e(t){r(this,e),this.code=t}),[{key:"runInNewContext",value:function(e){var t=this.code,r=Object.keys(e),i=[];!function(e,t,r){for(var n=e.length,i=0;i<n;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,i,(function(t){return"function"==typeof e[t]}));var o=r.map((function(t){return e[t]})),a=i.reduce((function(t,r){var n=e[r].toString();return/function/.test(n)||(n="function "+n),"var "+r+"="+n+";"+t}),"");/(["'])use strict\1/.test(t=a+t)||r.includes("arguments")||(t="var arguments = undefined;"+t);var s=(t=t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/,"")).lastIndexOf(";"),u=s>-1?t.slice(0,s+1)+" return "+t.slice(s+1):" return "+t;return n(Function,r.concat([u])).apply(void 0,l(o))}}])}();P.prototype.vm={Script:S};export{P as JSONPath};
class e{static get version(){return"1.3.9"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,s){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,s?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map((e=>e.length)))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const s={context:this,node:r};return e.hooks.run(t,s),s.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find((function(e){return e.call(r.context,r),r.node})),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,s,i=[];for(;this.index<this.expr.length;)if(r=this.code,r===e.SEMCOL_CODE||r===e.COMMA_CODE)this.index++;else if(s=this.gobbleExpression())i.push(s);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return i}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,s,i,n,o,a,h,l;if(o=this.gobbleToken(),!o)return o;if(r=this.gobbleBinaryOp(),!r)return o;for(n={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+r),i=[o,n,a];r=this.gobbleBinaryOp();){if(s=e.binaryPrecedence(r),0===s){this.index-=r.length;break}n={value:r,prec:s,right_a:e.right_associative.has(r)},l=r;const h=e=>n.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;i.length>2&&h(i[i.length-2]);)a=i.pop(),r=i.pop().value,o=i.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),i.push(n,t)}for(h=i.length-1,t=i[h];h>1;)t={type:e.BINARY_EXP,operator:i[h-1].value,left:i[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,s,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),s=r.length;s>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=s;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:t,prefix:!0})}r=r.substr(0,--s)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let s;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;s=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?((t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||s)&&(s&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),s&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t,r,s="";for(;e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(s+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(s+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)s+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+s+this.char+")")}return r=this.code,e.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+s+this.char+")"):(r===e.PERIOD_CODE||1===s.length&&s.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(s),raw:s}}gobbleStringLiteral(){let t="";const r=this.index,s=this.expr.charAt(this.index++);let i=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===s){i=!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 i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){const r=[];let s=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let n=this.code;if(n===t){s=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(n===e.COMMA_CODE){if(this.index++,i++,i!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e<i;e++)r.push(null)}else if(r.length!==i&&0!==i)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==e.COMPOUND||this.throwError("Expected comma"),r.push(t)}}return s||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:e.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}}const t=new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this)}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};Object.assign(e,{hooks:t,plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.forEach((e=>{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)}))}}(e),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,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter((e=>!s.includes(e)&&void 0===r[e])).forEach((t=>{r[t]=e[t]})),r.Jsep=e;var i={name:"ternary",init(e){e.hooks.add("after-expression",(function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:i},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}}))}};r.plugins.register(i);var n={name:"regex",init(e){e.hooks.add("gobble-token",(function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index<this.expr.length;){if(47===this.code&&!s){const s=this.expr.slice(r,this.index);let i,n="";for(;++this.index<this.expr.length;){const e=this.code;if(!(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;n+=this.char}try{i=new RegExp(s,n)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:i,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}}))}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach((e=>{e&&"object"==typeof e&&r(e)}))}o.assignmentOperators.forEach((t=>e.addBinaryOp(t,o.assignmentPrecedence,!0))),e.hooks.add("gobble-token",(function(e){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const r=this.code;o.updateOperators.some((e=>e===r&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&r(e.node)}))}};r.plugins.register(n,o);const a={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return a.evalBinaryExpression(e,t);case"Compound":return a.evalCompound(e,t);case"ConditionalExpression":return a.evalConditionalExpression(e,t);case"Identifier":return a.evalIdentifier(e,t);case"Literal":return a.evalLiteral(e,t);case"MemberExpression":return a.evalMemberExpression(e,t);case"UnaryExpression":return a.evalUnaryExpression(e,t);case"ArrayExpression":return a.evalArrayExpression(e,t);case"CallExpression":return a.evalCallExpression(e,t);case"AssignmentExpression":return a.evalAssignmentExpression(e,t);default:throw SyntaxError("Unexpected expression",e)}},evalBinaryExpression:(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()}[e.operator](a.evalAst(e.left,t),(()=>a.evalAst(e.right,t)))),evalCompound(e,t){let r;for(let s=0;s<e.body.length;s++){"Identifier"===e.body[s].type&&["var","let","const"].includes(e.body[s].name)&&e.body[s+1]&&"AssignmentExpression"===e.body[s+1].type&&(s+=1);const i=e.body[s];r=a.evalAst(i,t)}return r},evalConditionalExpression:(e,t)=>a.evalAst(e.test,t)?a.evalAst(e.consequent,t):a.evalAst(e.alternate,t),evalIdentifier(e,t){if(e.name in t)return t[e.name];throw ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=e.computed?a.evalAst(e.property):e.property.name,s=a.evalAst(e.object,t),i=s[r];if("function"==typeof i){if(i===Function)throw new Error("Function constructor is disabled");return i.bind(s)}return i},evalUnaryExpression:(e,t)=>({"-":e=>-a.evalAst(e,t),"!":e=>!a.evalAst(e,t),"~":e=>~a.evalAst(e,t),"+":e=>+a.evalAst(e,t)}[e.operator](e.argument)),evalArrayExpression:(e,t)=>e.elements.map((e=>a.evalAst(e,t))),evalCallExpression(e,t){const r=e.arguments.map((e=>a.evalAst(e,t)));return a.evalAst(e.callee,t)(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=a.evalAst(e.right,t);return t[r]=s,t[r]}};function h(e,t){return(e=e.slice()).push(t),e}function l(e,t){return(t=t.slice()).unshift(e),t}class c extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function p(e,t,r,s,i){if(!(this instanceof p))try{return new p(e,t,r,s,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=s,s=r,r=t,t=e,e=null);const n=e&&"object"==typeof e;if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const s={path:n?e.path:t};n?"json"in e&&(s.json=e.json):s.json=r;const i=this.evaluate(s);if(!i||"object"!=typeof i)throw new c(i);return i}}p.prototype.evaluate=function(e,t,r,s){let i=this.parent,n=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"==typeof e&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=e),o=Object.hasOwn(e,"flatten")?e.flatten:o,this.currResultType=Object.hasOwn(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=Object.hasOwn(e,"sandbox")?e.sandbox:this.currSandbox,a=Object.hasOwn(e,"wrap")?e.wrap:a,this.currEval=Object.hasOwn(e,"eval")?e.eval:this.currEval,r=Object.hasOwn(e,"callback")?e.callback:r,this.currOtherTypeCallback=Object.hasOwn(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=Object.hasOwn(e,"parent")?e.parent:i,n=Object.hasOwn(e,"parentProperty")?e.parentProperty:n,e=e.path}if(i=i||null,n=n||null,Array.isArray(e)&&(e=p.toPathString(e)),!e&&""!==e||!t)return;const h=p.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=null;const l=this._trace(h,t,["$"],i,n,r).filter((function(e){return e&&!e.isParentSelector}));return l.length?a||1!==l.length||l[0].hasArrExpr?l.reduce(((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(l[0]):a?[]:void 0},p.prototype._getPreferredOutput=function(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:p.toPathArray(e.path);return e.pointer=p.toPointer(t),e.path="string"==typeof e.path?e.path:p.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return p.toPathString(e[t]);case"pointer":return p.toPointer(e.path);default:throw new TypeError("Unknown result type")}},p.prototype._handleCallback=function(e,t,r){if(t){const s=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:p.toPathString(e.path),t(s,r,e)}},p.prototype._trace=function(e,t,r,s,i,n,o,a){let c;if(!e.length)return c={path:r,value:t,parent:s,parentProperty:i,hasArrExpr:o},this._handleCallback(c,n,"value"),c;const p=e[0],u=e.slice(1),d=[];function f(e){Array.isArray(e)?e.forEach((e=>{d.push(e)})):d.push(e)}if(("string"!=typeof p||a)&&t&&Object.hasOwn(t,p))f(this._trace(u,t[p],h(r,p),t,p,n,o));else if("*"===p)this._walk(t,(e=>{f(this._trace(u,t[e],h(r,e),t,e,n,!0,!0))}));else if(".."===p)f(this._trace(u,t,r,s,i,n,o)),this._walk(t,(s=>{"object"==typeof t[s]&&f(this._trace(e.slice(),t[s],h(r,s),t,s,n,!0))}));else{if("^"===p)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:u,isParentSelector:!0};if("~"===p)return c={path:h(r,p),value:i,parent:s,parentProperty:null},this._handleCallback(c,n,"property"),c;if("$"===p)f(this._trace(u,t,r,null,null,n,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(p))f(this._slice(p,u,t,r,s,i,n));else if(0===p.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=p.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);o?this._walk(t,(e=>{const a=[o[2]],l=o[1]?t[e][o[1]]:t[e];this._trace(a,l,r,s,i,n,!0).length>0&&f(this._trace(u,t[e],h(r,e),t,e,n,!0))})):this._walk(t,(o=>{this._eval(e,t[o],o,r,s,i)&&f(this._trace(u,t[o],h(r,o),t,o,n,!0))}))}else if("("===p[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(l(this._eval(p,t,r.at(-1),r.slice(0,-1),s,i),u),t,r,s,i,n,o))}else if("@"===p[0]){let e=!1;const o=p.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,i);break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return c={path:r,value:t,parent:s,parentProperty:i},this._handleCallback(c,n,"value"),c}else if("`"===p[0]&&t&&Object.hasOwn(t,p.slice(1))){const e=p.slice(1);f(this._trace(u,t[e],h(r,e),t,e,n,o,!0))}else if(p.includes(",")){const e=p.split(",");for(const o of e)f(this._trace(l(o,u),t,r,s,i,n,!0))}else!a&&t&&Object.hasOwn(t,p)&&f(this._trace(u,t[p],h(r,p),t,p,n,o,!0))}if(this._hasParentSelector)for(let e=0;e<d.length;e++){const r=d[e];if(r&&r.isParentSelector){const a=this._trace(r.expr,t,r.path,s,i,n,o);if(Array.isArray(a)){d[e]=a[0];const t=a.length;for(let r=1;r<t;r++)e++,d.splice(e,0,a[r])}else d[e]=a}}return d},p.prototype._walk=function(e,t){if(Array.isArray(e)){const r=e.length;for(let e=0;e<r;e++)t(e)}else e&&"object"==typeof e&&Object.keys(e).forEach((e=>{t(e)}))},p.prototype._slice=function(e,t,r,s,i,n,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number.parseInt(h[2])||1;let p=h[0]&&Number.parseInt(h[0])||0,u=h[1]&&Number.parseInt(h[1])||a;p=p<0?Math.max(0,p+a):Math.min(a,p),u=u<0?Math.max(0,u+a):Math.min(a,u);const d=[];for(let e=p;e<u;e+=c){this._trace(l(e,t),r,s,i,n,o,!0).forEach((e=>{d.push(e)}))}return d},p.prototype._eval=function(e,t,r,s,i,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t;const o=e.includes("@path");o&&(this.currSandbox._$_path=p.toPathString(s.concat([r])));const a=this.currEval+"Script:"+e;if(!p.cache[a]){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(o&&(t=t.replaceAll("@path","_$_path")),"safe"===this.currEval||!0===this.currEval||void 0===this.currEval)p.cache[a]=new this.safeVm.Script(t);else if("native"===this.currEval)p.cache[a]=new this.vm.Script(t);else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;p.cache[a]=new e(t)}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);p.cache[a]={runInNewContext:e=>this.currEval(t,e)}}}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e)}},p.cache={},p.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+=/^[0-9*]+$/u.test(t[e])?"["+t[e]+"]":"['"+t[e]+"']");return s},p.toPointer=function(e){const t=e,r=t.length;let s="";for(let e=1;e<r;e++)/^(~|\^|@.*?\(\))$/u.test(t[e])||(s+="/"+t[e].toString().replaceAll("~","~0").replaceAll("/","~1"));return s},p.toPathArray=function(e){const{cache:t}=p;if(t[e])return t[e].concat();const r=[],s=e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,(function(e,t){return"[#"+(r.push(t)-1)+"]"})).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,(function(e,t){return"['"+t.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"})).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,(function(e,t){return";"+t.split("").join(";")+";"})).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map((function(e){const t=e.match(/#(\d+)/u);return t&&t[1]?r[t[1]]:e}));return t[e]=s,t[e].concat()},p.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t={...e};return a.evalAst(this.ast,t)}}};p.prototype.vm={Script:class{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const r=Object.keys(e),s=[];!function(e,t,r){const s=e.length;for(let i=0;i<s;i++)r(e[i])&&t.push(e.splice(i--,1)[0])}(r,s,(t=>"function"==typeof e[t]));const i=r.map((t=>e[t]));t=s.reduce(((t,r)=>{let s=e[r].toString();return/function/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t}),"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const n=t.lastIndexOf(";"),o=n>-1?t.slice(0,n+1)+" return "+t.slice(n+1):" return "+t;return new Function(...r,o)(...i)}}};export{p as JSONPath};
//# sourceMappingURL=index-browser-esm.min.js.map

@@ -1198,3 +1198,3 @@ import vm from 'vm';

/* eslint-disable no-bitwise */
/* eslint-disable no-bitwise -- Convenient */

@@ -1242,5 +1242,5 @@ // register plugins

'&': (a, b) => a & b(),
// eslint-disable-next-line eqeqeq
// eslint-disable-next-line eqeqeq -- API
'==': (a, b) => a == b(),
// eslint-disable-next-line eqeqeq
// eslint-disable-next-line eqeqeq -- API
'!=': (a, b) => a != b(),

@@ -1300,2 +1300,5 @@ '===': (a, b) => a === b(),

if (typeof result === 'function') {
if (result === Function) {
throw new Error('Function constructor is disabled');
}
return result.bind(obj); // arrow functions aren't affected by bind.

@@ -1310,3 +1313,3 @@ }

'~': a => ~SafeEval.evalAst(a, subs),
// eslint-disable-next-line no-implicit-coercion
// eslint-disable-next-line no-implicit-coercion -- API
'+': a => +SafeEval.evalAst(a, subs)

@@ -1360,4 +1363,3 @@ }[ast.operator](ast.argument);

/* eslint-disable camelcase, unicorn/prefer-string-replace-all,
unicorn/prefer-at */
/* eslint-disable camelcase -- Convenient for escaping */

@@ -1495,3 +1497,3 @@

function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax -- Allow for pseudo-class
if (!(this instanceof JSONPath)) {

@@ -1644,3 +1646,3 @@ try {

fullRetObj.path = typeof fullRetObj.path === 'string' ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
// eslint-disable-next-line n/callback-return
// eslint-disable-next-line n/callback-return -- No need to return
callback(preferredOutput, type, fullRetObj);

@@ -1782,3 +1784,3 @@ }

// parent of the property to which this expression will resolve
addRet(this._trace(unshift(this._eval(loc, val, path[path.length - 1], path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
addRet(this._trace(unshift(this._eval(loc, val, path.at(-1), path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
} else if (loc[0] === '@') {

@@ -1938,5 +1940,5 @@ // value type: @boolean(), etc.

if (!JSONPath.cache[scriptCacheKey]) {
let script = code.replace(/@parentProperty/gu, '_$_parentProperty').replace(/@parent/gu, '_$_parent').replace(/@property/gu, '_$_property').replace(/@root/gu, '_$_root').replace(/@([.\s)[])/gu, '_$_v$1');
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s)[])/gu, '_$_v$1');
if (containsPath) {
script = script.replace(/@path/gu, '_$_path');
script = script.replaceAll('@path', '_$_path');
}

@@ -1999,3 +2001,3 @@ if (this.currEval === 'safe' || this.currEval === true || this.currEval === undefined) {

if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
p += '/' + x[i].toString().replace(/~/gu, '~0').replace(/\//gu, '~1');
p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');
}

@@ -2020,28 +2022,28 @@ }

// Properties
.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;')
.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;')
// Parenthetical evaluations (filtering and otherwise), directly
// within brackets or single quotes
.replace(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
return '[#' + (subx.push($1) - 1) + ']';
})
// Escape periods and tildes within properties
.replace(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
return "['" + prop.replace(/\./gu, '%@%').replace(/~/gu, '%%@@%%') + "']";
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
return "['" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + "']";
})
// Properties operator
.replace(/~/gu, ';~;')
.replaceAll('~', ';~;')
// Split by property boundaries
.replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
// Reinsert periods within properties
.replace(/%@%/gu, '.')
.replaceAll('%@%', '.')
// Reinsert tildes within properties
.replace(/%%@@%%/gu, '~')
.replaceAll('%%@@%%', '~')
// Parent
.replace(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
return ';' + ups.split('').join(';') + ';';
})
// Descendents
.replace(/;;;|;;/gu, ';..;')
.replaceAll(/;;;|;;/gu, ';..;')
// Remove trailing
.replace(/;$|'?\]|'$/gu, '');
.replaceAll(/;$|'?\]|'$/gu, '');
const exprList = normalized.split(';').map(function (exp) {

@@ -2048,0 +2050,0 @@ const match = exp.match(/#(\d+)/u);

{
"author": "Stefan Goessner",
"name": "jsonpath-plus",
"version": "10.0.0",
"version": "10.0.1",
"type": "module",

@@ -96,3 +96,3 @@ "bin": {

"browserslist": [
"cover 100%"
"defaults, not op_mini all"
],

@@ -99,0 +99,0 @@ "c8": {

@@ -93,3 +93,3 @@ import {JSONPath} from './jsonpath.js';

// eslint-disable-next-line no-new-func
// eslint-disable-next-line no-new-func -- User's choice
return new Function(...keys, code)(...values);

@@ -96,0 +96,0 @@ }

@@ -1,3 +0,2 @@

/* eslint-disable camelcase, unicorn/prefer-string-replace-all,
unicorn/prefer-at */
/* eslint-disable camelcase -- Convenient for escaping */

@@ -139,3 +138,3 @@ import {SafeScript} from './Safe-Script.js';

function JSONPath (opts, expr, obj, callback, otherTypeCallback) {
// eslint-disable-next-line no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax -- Allow for pseudo-class
if (!(this instanceof JSONPath)) {

@@ -322,3 +321,3 @@ try {

: JSONPath.toPathString(fullRetObj.path);
// eslint-disable-next-line n/callback-return
// eslint-disable-next-line n/callback-return -- No need to return
callback(preferredOutput, type, fullRetObj);

@@ -475,3 +474,3 @@ }

this._eval(
loc, val, path[path.length - 1],
loc, val, path.at(-1),
path.slice(0, -1), parent, parentPropName

@@ -652,9 +651,9 @@ ),

let script = code
.replace(/@parentProperty/gu, '_$_parentProperty')
.replace(/@parent/gu, '_$_parent')
.replace(/@property/gu, '_$_property')
.replace(/@root/gu, '_$_root')
.replace(/@([.\s)[])/gu, '_$_v$1');
.replaceAll('@parentProperty', '_$_parentProperty')
.replaceAll('@parent', '_$_parent')
.replaceAll('@property', '_$_property')
.replaceAll('@root', '_$_root')
.replaceAll(/@([.\s)[])/gu, '_$_v$1');
if (containsPath) {
script = script.replace(/@path/gu, '_$_path');
script = script.replaceAll('@path', '_$_path');
}

@@ -725,4 +724,4 @@ if (

p += '/' + x[i].toString()
.replace(/~/gu, '~0')
.replace(/\//gu, '~1');
.replaceAll('~', '~0')
.replaceAll('/', '~1');
}

@@ -745,3 +744,3 @@ }

// Properties
.replace(
.replaceAll(
/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,

@@ -752,28 +751,28 @@ ';$&;'

// within brackets or single quotes
.replace(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
return '[#' + (subx.push($1) - 1) + ']';
})
// Escape periods and tildes within properties
.replace(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
return "['" + prop
.replace(/\./gu, '%@%')
.replace(/~/gu, '%%@@%%') +
.replaceAll('.', '%@%')
.replaceAll('~', '%%@@%%') +
"']";
})
// Properties operator
.replace(/~/gu, ';~;')
.replaceAll('~', ';~;')
// Split by property boundaries
.replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
// Reinsert periods within properties
.replace(/%@%/gu, '.')
.replaceAll('%@%', '.')
// Reinsert tildes within properties
.replace(/%%@@%%/gu, '~')
.replaceAll('%%@@%%', '~')
// Parent
.replace(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
return ';' + ups.split('').join(';') + ';';
})
// Descendents
.replace(/;;;|;;/gu, ';..;')
.replaceAll(/;;;|;;/gu, ';..;')
// Remove trailing
.replace(/;$|'?\]|'$/gu, '');
.replaceAll(/;$|'?\]|'$/gu, '');

@@ -780,0 +779,0 @@ const exprList = normalized.split(';').map(function (exp) {

@@ -1,2 +0,2 @@

/* eslint-disable no-bitwise */
/* eslint-disable no-bitwise -- Convenient */
import jsep from 'jsep';

@@ -48,5 +48,5 @@ import jsepRegex from '@jsep-plugin/regex';

'&': (a, b) => a & b(),
// eslint-disable-next-line eqeqeq
// eslint-disable-next-line eqeqeq -- API
'==': (a, b) => a == b(),
// eslint-disable-next-line eqeqeq
// eslint-disable-next-line eqeqeq -- API
'!=': (a, b) => a != b(),

@@ -115,2 +115,5 @@ '===': (a, b) => a === b(),

if (typeof result === 'function') {
if (result === Function) {
throw new Error('Function constructor is disabled');
}
return result.bind(obj); // arrow functions aren't affected by bind.

@@ -125,3 +128,3 @@ }

'~': (a) => ~SafeEval.evalAst(a, subs),
// eslint-disable-next-line no-implicit-coercion
// eslint-disable-next-line no-implicit-coercion -- API
'+': (a) => +SafeEval.evalAst(a, subs)

@@ -128,0 +131,0 @@ }[ast.operator](ast.argument);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc