Socket
Socket
Sign inDemoInstall

jsonata

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonata - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

4

CHANGELOG.md

@@ -0,1 +1,5 @@

#### 1.2.5 Maintenance Release
- Fix $base64encode and $base64decode functions in the browser
#### 1.2.4 Maintenance Release

@@ -2,0 +6,0 @@

2

jsonata.min.js

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

var jsonata=function(){"use strict";function e(e){for(var r=1,t=[],n={},i=n;r<e.length;){var a=e.charAt(r);if(":"===a)break;var o=function(){t.push(n),i=n,n={}},s=function(e,r,t,n){for(var i=1,o=r;o<e.length;)if(o++,(a=e.charAt(o))===n){if(0===--i)break}else a===t&&i++;return o};switch(a){case"s":case"n":case"b":case"l":case"o":n.regex="["+a+"m]",n.type=a,o();break;case"a":n.regex="[asnblfom]",n.type=a,n.array=!0,o();break;case"f":n.regex="f",n.type=a,o();break;case"j":n.regex="[asnblom]",n.type=a,o();break;case"x":n.regex="[asnblfom]",n.type=a,o();break;case"-":i.context=!0,i.contextRegex=new RegExp(i.regex),i.regex+="?";break;case"?":case"+":i.regex+=a;break;case"(":var u=s(e,r,"(",")"),c=e.substring(r+1,u);if(-1!==c.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:c,offset:r};n.regex="["+c+"m]",n.type="("+c+")",r=u,o();break;case"<":if("a"!==i.type&&"f"!==i.type)throw{code:"S0401",stack:(new Error).stack,value:i.type,offset:r};var f=s(e,r,"<",">");i.subtype=e.substring(r+1,f),r=f}r++}var l="^"+t.map(function(e){return"("+e.regex+")"}).join("")+"$",p=new RegExp(l),d=function(e){var r;if($(e))r="f";else switch(typeof e){case"string":r="s";break;case"number":r="n";break;case"boolean":r="b";break;case"object":r=null===e?"l":Array.isArray(e)?"a":"o";break;case"undefined":r="m"}return r},v=function(e,r){for(var n="^",i=0,a=0;a<t.length;a++){n+=t[a].regex;var o=r.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:e[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:e[i],index:i+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(e){n+=d(e)});var i=p.exec(n);if(i){var a=[],o=0;return t.forEach(function(t,n){var s=e[o],u=i[n+1];if(""===u)if(t.context){var c=d(r);if(!t.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};a.push(r)}else a.push(s),o++;else u.split("").forEach(function(r){if("a"===t.type){if("m"===r)s=void 0;else{s=e[o];var n=!0;if(void 0!==t.subtype)if("a"!==r&&u!==t.subtype)n=!1;else if("a"===r&&s.length>0){var i=d(s[0]);n=i===t.subtype.charAt(0)&&0===s.filter(function(e){return d(e)!==i}).length}if(!n)throw{code:"T0412",stack:(new Error).stack,value:s,index:o+1,type:t.subtype};"a"!==r&&(s=[s])}a.push(s),o++}else a.push(s),o++})}),a}v(e,n)}}}function r(e){var r=!1;if("number"==typeof e){var t=parseFloat(e);if((r=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:e,stack:(new Error).stack}}return r}function t(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return"string"!=typeof e}).length),r}function n(e){var t=!1;return Array.isArray(e)&&(t=0===e.filter(function(e){return!r(e)}).length),t}function*i(e,r,t){var n,i=t.lookup("__evaluate_entry");switch(i&&i(e,r,t),e.type){case"path":n=o(n=yield*a(e.steps,r,t),e.keepSingletonArray);break;case"binary":n=yield*f(e,r,t);break;case"unary":n=yield*l(e,r,t);break;case"name":n=p(e,r,t);break;case"literal":n=d(e);break;case"wildcard":n=v(e,r);break;case"descendant":n=y(e,r);break;case"condition":n=yield*T(e,r,t);break;case"block":n=yield*j(e,r,t);break;case"bind":n=yield*S(e,r,t);break;case"regex":n=_(e);break;case"function":n=yield*P(e,r,t);break;case"variable":n=D(e,r,t);break;case"lambda":n=q(e,r,t);break;case"partial":n=yield*R(e,r,t);break;case"apply":n=yield*N(e,r,t);break;case"sort":n=yield*O(e,r,t)}!t.lookup("__jsonata_async")||void 0!==n&&null!==n&&"function"==typeof n.then||(n=Promise.resolve(n)),n=yield n,e.hasOwnProperty("predicate")&&(n=o(n=yield*u(e.predicate,n,t))),e.hasOwnProperty("group")&&(n=yield*A(e.group,n,t));var s=t.lookup("__evaluate_exit");return s&&s(e,r,t,n),n}function*a(e,r,t){var n;n="variable"===e[0].type?[r]:e[0].consarray?[null]:Array.isArray(r)?r:[r];for(var i,a=0;a<e.length&&(void 0!==(i=yield*s(e[a],n,t))&&0!==i.length);a++)n=i;return i}function o(e,r){var t;return void 0===e?t=void 0:Array.isArray(e)?1===e.length?t=r?e:e[0]:e.length>1&&(t=e):t=e,t}function*s(e,r,t){for(var n=[],a=0;a<r.length;a++){var o=yield*i(e,r[a],t);Array.isArray(o)&&"["!==e.value||e.consarray||(o=[o]),o.forEach(function(e){void 0!==e&&n.push(e)})}return n}function*u(e,t,n){for(var i=t,a=[],o=0;o<e.length;o++){var s=e[o];if(Array.isArray(i)||(i=[i]),a=[],"literal"===s.type&&r(s.value)){var u=s.value;Number.isInteger(u)||(u=Math.floor(u)),u<0&&(u=i.length+u),a=i[u]}else a=yield*c(s,i,n);i=a}return a}function*c(e,t,a){for(var o=[],s=0;s<t.length;s++){var u=t[s],c=yield*i(e,u,a);r(c)&&(c=[c]),n(c)?c.forEach(function(e){Number.isInteger(e)||(e=Math.floor(e)),e<0&&(e=t.length+e),e===s&&o.push(u)}):xe(c)&&o.push(u)}return o}function*f(e,r,t){var n,a=yield*i(e.lhs,r,t),o=yield*i(e.rhs,r,t),s=e.value;try{switch(s){case"+":case"-":case"*":case"/":case"%":n=g(a,o,s);break;case"=":case"!=":case"<":case"<=":case">":case">=":n=k(a,o,s);break;case"&":n=x(a,o);break;case"and":case"or":n=w(a,o,s);break;case"..":n=E(a,o);break;case"in":n=m(a,o)}}catch(r){throw r.position=e.position,r.token=s,r}return n}function*l(e,t,n){var a;switch(e.value){case"-":if(a=yield*i(e.expression,t,n),!r(a))throw{code:"D1002",stack:(new Error).stack,position:e.position,token:e.value,value:a};a=-a;break;case"[":a=[];for(var o=0;o<e.lhs.length;o++){var s=e.lhs[o],u=yield*i(s,t,n);void 0!==u&&("["===s.value?a.push(u):a=Oe(a,u))}break;case"{":a=yield*A(e,t,n)}return a}function p(e,r,t){var n;if(Array.isArray(r)){n=[];for(var i=0;i<r.length;i++){var a=p(e,r[i],t);void 0!==a&&n.push(a)}}else null!==r&&"object"==typeof r&&(n=r[e.value]);return n=o(n)}function d(e){return e.value}function v(e,r){var t=[];return null!==r&&"object"==typeof r&&Object.keys(r).forEach(function(e){var n=r[e];Array.isArray(n)?(n=h(n),t=Oe(t,n)):t.push(n)}),o(t)}function h(e,r){return void 0===r&&(r=[]),Array.isArray(e)?e.forEach(function(e){h(e,r)}):r.push(e),r}function y(e,r){var t,n=[];return void 0!==r&&(b(r,n),t=1===n.length?n[0]:n),t}function b(e,r){Array.isArray(e)||r.push(e),Array.isArray(e)?e.forEach(function(e){b(e,r)}):null!==e&&"object"==typeof e&&Object.keys(e).forEach(function(t){b(e[t],r)})}function g(e,t,n){var i;if(void 0===e||void 0===t)return i;if(!r(e))throw{code:"T2001",stack:(new Error).stack,value:e};if(!r(t))throw{code:"T2002",stack:(new Error).stack,value:t};switch(n){case"+":i=e+t;break;case"-":i=e-t;break;case"*":i=e*t;break;case"/":i=e/t;break;case"%":i=e%t}return i}function k(e,r,t){var n,i=typeof e,a=typeof r;if("undefined"===i||"undefined"===a)return!1;var o=function(){if("string"!==i&&"number"!==i||"string"!==a&&"number"!==a)throw{code:"T2010",stack:(new Error).stack,value:"string"!==i&&"number"!==i?e:r};if(i!==a)throw{code:"T2009",stack:(new Error).stack,value:e,value2:r}};switch(t){case"=":n=e===r;break;case"!=":n=e!==r;break;case"<":o(),n=e<r;break;case"<=":o(),n=e<=r;break;case">":o(),n=e>r;break;case">=":o(),n=e>=r}return n}function m(e,r){var t=!1;if(void 0===e||void 0===r)return!1;Array.isArray(r)||(r=[r]);for(var n=0;n<r.length;n++)if(r[n]===e){t=!0;break}return t}function w(e,r,t){var n;switch(t){case"and":n=xe(e)&&xe(r);break;case"or":n=xe(e)||xe(r)}return n}function x(e,r){var t="",n="";return void 0!==e&&(t=Z(e)),void 0!==r&&(n=Z(r)),t.concat(n)}function*A(e,r,t){var n={},a={};Array.isArray(r)||(r=[r]);for(var o=[],s=0;s<r.length;s++)for(var u=0;u<e.lhs.length;u++)o.push(yield*i(e.lhs[u][0],r[s],t));var c=o.entries();r.forEach(function(r){e.lhs.forEach(function(t){var n=c.next().value[1];if("string"!=typeof n)throw{code:"T1003",stack:(new Error).stack,position:e.position,value:n};var i={data:r,expr:t[1]};a.hasOwnProperty(n)?a[n].data=Oe(a[n].data,r):a[n]=i})}),o=[];var f;for(f in a){var l=a[f];o.push(yield*i(l.expr,l.data,t))}c=o.entries();for(f in a){var p=c.next().value[1];n[f]=p}return n}function E(e,r){var t;if(void 0===e||void 0===r)return t;if(e>r)return t;if(!Number.isInteger(e))throw{code:"T2003",stack:(new Error).stack,value:e};if(!Number.isInteger(r))throw{code:"T2004",stack:(new Error).stack,value:r};t=new Array(r-e+1);for(var n=e,i=0;n<=r;n++,i++)t[i]=n;return t}function*S(e,r,t){var n=yield*i(e.rhs,r,t);if("variable"!==e.lhs.type)throw{code:"D2005",stack:(new Error).stack,position:e.position,token:e.value,value:"path"===e.lhs.type?e.lhs.steps[0].value:e.lhs.value};return t.bind(e.lhs.value,n),n}function*T(e,r,t){var n;return xe(yield*i(e.condition,r,t))?n=yield*i(e.then,r,t):void 0!==e.else&&(n=yield*i(e.else,r,t)),n}function*j(e,r,t){for(var n,a=Ce(t),o=0;o<e.expressions.length;o++)n=yield*i(e.expressions[o],r,a);return n}function _(e){e.value.lastIndex=0;var r=function(t){var n,i=e.value,a=i.exec(t);if(null!==a){if(n={match:a[0],start:a.index,end:a.index+a[0].length,groups:[]},a.length>1)for(var o=1;o<a.length;o++)n.groups.push(a[o]);n.next=function(){if(!(i.lastIndex>=t.length)){var n=r(t);if(n&&""===n.match&&i.lastIndex===e.value.lastIndex)throw{code:"D1004",stack:(new Error).stack,position:e.position,value:e.value.source};return n}}}return n};return r}function D(e,r,t){return""===e.value?r:t.lookup(e.value)}function*O(e,r,t){return Ie(yield*i(e.lhs,r,t),function(r,n){for(var i=0,a=0;0===i&&a<e.rhs.length;a++){var o=e.rhs[a],s=M(o.expression,r,t),u=M(o.expression,n,t),c=typeof s,f=typeof u;if("undefined"!==c)if("undefined"!==f){if("string"!==c&&"number"!==c||"string"!==f&&"number"!==f)throw{code:"T2008",stack:(new Error).stack,position:e.position,value:"string"!==c&&"number"!==c?s:u};if(c!==f)throw{code:"T2007",stack:(new Error).stack,position:e.position,value:s,value2:u};s!==u&&(i=s<u?-1:1,!0===o.descending&&(i=-i))}else i=-1;else i="undefined"===f?0:1}return 1===i})}function M(e,r,t){for(var n=i(e,r,t),a=n.next();!a.done;)a=n.next(a.value);return a.value}function*N(e,r,t){var n,a=yield*i(e.lhs,r,t);if("function"===e.rhs.type)n=yield*P(e.rhs,r,t,{context:a});else{var o=yield*i(e.rhs,r,t);if(!$(o))throw{code:"T2006",stack:(new Error).stack,position:e.position,value:o};n=$(a)?yield*U(Ke,[a,o],t,null):yield*U(o,[a],t,null)}return n}function $(e){return e&&(!0===e._jsonata_function||!0===e._jsonata_lambda)||"function"==typeof e}function F(e){return e&&!0===e._jsonata_lambda}function I(e){return"object"==typeof e&&Symbol.iterator in e&&"function"==typeof e[Symbol.iterator]&&"next"in e&&"function"==typeof e.next}function*P(e,r,t,n){for(var a,o=[],s=0;s<e.arguments.length;s++)o.push(yield*i(e.arguments[s],r,t));n&&o.unshift(n.context);var u=yield*i(e.procedure,r,t);if(void 0===u&&"path"===e.procedure.type&&t.lookup(e.procedure.steps[0].value))throw{code:"T1005",stack:(new Error).stack,position:e.position,token:e.procedure.steps[0].value};try{a=yield*U(u,o,r)}catch(r){throw r.position=e.position,r.token="path"===e.procedure.type?e.procedure.steps[0].value:e.procedure.value,r}return a}function*U(e,r,t){var n;for(n=yield*C(e,r,t);F(n)&&!0===n.thunk;){for(var a=yield*i(n.body.procedure,n.input,n.environment),o=[],s=0;s<n.body.arguments.length;s++)o.push(yield*i(n.body.arguments[s],n.input,n.environment));n=yield*C(a,o,t)}return n}function*C(e,r,t){var n,i=r;if(e&&(i=J(e.signature,r,t)),F(e))n=yield*z(e,i);else if(e&&!0===e._jsonata_function)I(n=e.implementation.apply(t,i))&&(n=yield*n);else{if("function"!=typeof e)throw{code:"T1006",stack:(new Error).stack};n=e.apply(t,i)}return n}function q(e,r,t){var n={_jsonata_lambda:!0,input:r,environment:t,arguments:e.arguments,signature:e.signature,body:e.body};return!0===e.thunk&&(n.thunk=!0),n}function*R(e,r,t){for(var n,a=[],o=0;o<e.arguments.length;o++){var s=e.arguments[o];"operator"===s.type&&"?"===s.value?a.push(s):a.push(yield*i(s,r,t))}var u=yield*i(e.procedure,r,t);if(void 0===u&&"path"===e.procedure.type&&t.lookup(e.procedure.steps[0].value))throw{code:"T1007",stack:(new Error).stack,position:e.position,token:e.procedure.steps[0].value};if(F(u))n=B(u,a);else if(u&&!0===u._jsonata_function)n=L(u.implementation,a);else{if("function"!=typeof u)throw{code:"T1008",stack:(new Error).stack,position:e.position,token:"path"===e.procedure.type?e.procedure.steps[0].value:e.procedure.value};n=L(u,a)}return n}function J(e,r,t){return void 0===e?r:e.validate(r,t)}function*z(e,r){var t=Ce(e.environment);return e.arguments.forEach(function(e,n){t.bind(e.value,r[n])}),"function"==typeof e.body?yield*G(e.body,t):yield*i(e.body,e.input,t)}function B(e,r){var t=Ce(e.environment),n=[];return e.arguments.forEach(function(e,i){var a=r[i];a&&"operator"===a.type&&"?"===a.value?n.push(e):t.bind(e.value,a)}),{_jsonata_lambda:!0,input:e.input,environment:t,arguments:n,body:e.body}}function L(e,r){var t=K(e),n="function("+(t=t.map(function(e){return"$"+e.trim()})).join(", ")+"){ _ }",i=Le(n);return i.body=e,B(i,r)}function*G(e,r){var t=K(e).map(function(e){return r.lookup(e.trim())}),n=e.apply(null,t);return I(n)&&(n=yield*n),n}function K(e){var r=e.toString();return/\(([^\)]*)\)/.exec(r)[1].split(",")}function H(r,t){var n={_jsonata_function:!0,implementation:r};return void 0!==t&&(n.signature=e(t)),n}function Q(e){if(void 0!==e){var r=0;return e.forEach(function(e){r+=e}),r}}function V(e){return void 0===e?0:e.length}function W(e){if(void 0!==e&&0!==e.length)return Math.max.apply(Math,e)}function X(e){if(void 0!==e&&0!==e.length)return Math.min.apply(Math,e)}function Y(e){if(void 0!==e&&0!==e.length){var r=0;return e.forEach(function(e){r+=e}),r/e.length}}function Z(e){if(void 0!==e){var t;if("string"==typeof e)t=e;else if($(e))t="";else{if("number"==typeof e&&!isFinite(e))throw{code:"D3001",value:e,stack:(new Error).stack};t=JSON.stringify(e,function(e,t){return void 0!==t&&null!==t&&t.toPrecision&&r(t)?Number(t.toPrecision(13)):t&&$(t)?"":t})}return t}}function ee(e,r,t){if(void 0!==e)return e.substr(r,t)}function re(e,r){if(void 0!==e){var t=e.indexOf(r);return t>-1?e.substr(0,t):e}}function te(e,r){if(void 0!==e){var t=e.indexOf(r);return t>-1?e.substr(t+r.length):e}}function ne(e){if(void 0!==e)return e.toLowerCase()}function ie(e){if(void 0!==e)return e.toUpperCase()}function ae(e){if(void 0!==e)return e.length}function oe(e){if(void 0!==e){var r=e.replace(/[ \t\n\r]+/gm," ");return" "===r.charAt(0)&&(r=r.substring(1))," "===r.charAt(r.length-1)&&(r=r.substring(0,r.length-1)),r}}function se(e,r){if(void 0!==e){return"string"==typeof r?-1!==e.indexOf(r):void 0!==r(e)}}function ue(e,r,t){if(void 0!==e){if(t<0)throw{stack:(new Error).stack,value:t,code:"D3040",index:3};var n=[];if(void 0===t||t>0){var i=0,a=r(e);if(void 0!==a)for(;void 0!==a&&(void 0===t||i<t);)n.push({match:a.match,index:a.start,groups:a.groups}),a=a.next(),i++}return n}}function*ce(e,r,t,n){if(void 0!==e){if(""===r)throw{code:"D3010",stack:(new Error).stack,value:r,index:2};if(n<0)throw{code:"D3011",stack:(new Error).stack,value:n,index:4};var i;i="string"==typeof t?function(e){for(var r="",n=0,i=t.indexOf("$",n);-1!==i&&n<t.length;){r+=t.substring(n,i),n=i+1;var a=t.charAt(n);if("$"===a)r+="$",n++;else if("0"===a)r+=e.match,n++;else{var o;if(o=0===e.groups.length?1:Math.floor(Math.log(e.groups.length)*Math.LOG10E)+1,i=parseInt(t.substring(n,n+o),10),o>1&&i>e.groups.length&&(i=parseInt(t.substring(n,n+o-1),10)),isNaN(i))r+="$";else{if(e.groups.length>0){var s=e.groups[i-1];void 0!==s&&(r+=s)}n+=i.toString().length}}i=t.indexOf("$",n)}return r+=t.substring(n)}:t;var a="",o=0;if(void 0===n||n>0){var s=0;if("string"==typeof r){for(var u=e.indexOf(r,o);-1!==u&&(void 0===n||s<n);)a+=e.substring(o,u),a+=t,o=u+r.length,s++,u=e.indexOf(r,o);a+=e.substring(o)}else{var c=r(e);if(void 0!==c){for(;void 0!==c&&(void 0===n||s<n);){a+=e.substring(o,c.start);var f=yield*U(i,[c],null);if("string"!=typeof f)throw{code:"D3012",stack:(new Error).stack,value:f};a+=f,o=c.start+c.match.length,s++,c=c.next()}a+=e.substring(o)}else a=e}}else a=e;return a}}function fe(e){if(void 0!==e){var r=r||function(e){return new global.Buffer(e,"binary").toString("base64")};return r(e)}}function le(e){if(void 0!==e){var r=r||function(e){return new global.Buffer(e,"base64").toString("binary")};return r(e)}}function pe(e,r,t){if(void 0!==e){if(t<0)throw{code:"D3020",stack:(new Error).stack,value:t,index:3};var n=[];if(void 0===t||t>0)if("string"==typeof r)n=e.split(r,t);else{var i=0,a=r(e);if(void 0!==a){for(var o=0;void 0!==a&&(void 0===t||i<t);)n.push(e.substring(o,a.start)),o=a.end,a=a.next(),i++;(void 0===t||i<t)&&n.push(e.substring(o))}else n=[e]}return n}}function de(e,r){if(void 0!==e)return void 0===r&&(r=""),e.join(r)}function ve(e){var r;if(void 0!==e){if("number"==typeof e)r=e;else{if("string"!=typeof e||!/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(e)||isNaN(parseFloat(e))||!isFinite(e))throw{code:"D3030",value:e,stack:(new Error).stack,index:1};r=parseFloat(e)}return r}}function he(e){if(void 0!==e)return Math.abs(e)}function ye(e){if(void 0!==e)return Math.floor(e)}function be(e){if(void 0!==e)return Math.ceil(e)}function ge(e,r){var t;if(void 0!==e){if(r){var n=e.toString().split("e");e=+(n[0]+"e"+(n[1]?+n[1]+r:r))}var i=(t=Math.round(e))-e;return.5===Math.abs(i)&&1===Math.abs(t%2)&&(t-=1),r&&(t=+((n=t.toString().split("e"))[0]+"e"+(n[1]?+n[1]-r:-r))),-0===t&&(t=0),t}}function ke(e){if(void 0!==e){if(e<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:e};return Math.sqrt(e)}}function me(e,r){var t;if(void 0!==e){if(t=Math.pow(e,r),!isFinite(t))throw{stack:(new Error).stack,code:"D3061",index:1,value:e,exp:r};return t}}function we(){return Math.random()}function xe(e){if(void 0!==e){var t=!1;return Array.isArray(e)?1===e.length?t=xe(e[0]):e.length>1&&(t=e.filter(function(e){return xe(e)}).length>0):"string"==typeof e?e.length>0&&(t=!0):r(e)?0!==e&&(t=!0):null!==e&&"object"==typeof e?Object.keys(e).length>0&&(F(e)||e._jsonata_function||(t=!0)):"boolean"==typeof e&&!0===e&&(t=!0),t}}function Ae(e){return!xe(e)}function*Ee(e,r){if(void 0!==e){for(var t=[],n=0;n<e.length;n++){var i=[e[n]],a="function"==typeof r?r.length:!0===r._jsonata_function?r.implementation.length:r.arguments.length;a>=2&&i.push(n),a>=3&&i.push(e);var o=yield*U(r,i,null);void 0!==o&&t.push(o)}return t}}function*Se(e,r){if(void 0!==e){for(var t=[],n=0;n<e.length;n++){var i=e[n];xe(function(e,t,n){for(var i=U(r,[e,t,n],null),a=i.next();!a.done;)a=i.next(a.value);return a.value}(i,n,e))&&t.push(i)}return t}}function Te(){for(var e=[],r=Array.prototype.slice.call(arguments),t=Math.min.apply(Math,r.map(function(e){return Array.isArray(e)?e.length:0})),n=0;n<t;n++){var i=r.map(e=>e[n]);e.push(i)}return e}function*je(e,r,t){if(void 0!==e){var n;if(2!==r.length&&(!0!==r._jsonata_function||2!==r.implementation.length)&&2!==r.arguments.length)throw{stack:(new Error).stack,code:"D3050",index:1};var i;for(void 0===t&&e.length>0?(n=e[0],i=1):(n=t,i=0);i<e.length;)n=yield*U(r,[n,e[i]],null),i++;return n}}function _e(e){var r=[];if(Array.isArray(e)){var t={};e.forEach(function(e){var r=_e(e);Array.isArray(r)&&r.forEach(function(e){t[e]=!0})}),r=_e(t)}else null===e||"object"!=typeof e||F(e)?r=void 0:0===(r=Object.keys(e)).length&&(r=void 0);return r}function De(e,r){return p({value:r},e)}function Oe(e,r){return void 0===e?r:void 0===r?e:(Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]),Array.prototype.push.apply(e,r),e)}function Me(e){return void 0!==e}function Ne(e){var r=[];if(Array.isArray(e))e.forEach(function(e){r=Oe(r,Ne(e))});else if(null===e||"object"!=typeof e||F(e))r=e;else for(var t in e){var n={};n[t]=e[t],r.push(n)}return r}function $e(e){if(void 0!==e){if(e.length<=1)return e;for(var r=e.length,t=new Array(r),n=0;n<r;n++)t[r-n-1]=e[n];return t}}function*Fe(e,r){var t=[];for(var n in e){var i=[e[n],n];t.push(yield*U(r,i,null))}return t}function Ie(e,r){if(void 0!==e){if(e.length<=1)return e;var i;if(void 0===r){if(!n(e)&&!t(e))throw{stack:(new Error).stack,code:"D3070",index:1};i=function(e,r){return e>r}}else i="function"==typeof r?r:function(e,t){for(var n=U(r,[e,t],null),i=n.next();!i.done;)i=n.next(i.value);return i.value};var a=function(e,r){var t=function(e,r,n){0===r.length?Array.prototype.push.apply(e,n):0===n.length?Array.prototype.push.apply(e,r):i(r[0],n[0])?(e.push(n[0]),t(e,r,n.slice(1))):(e.push(r[0]),t(e,r.slice(1),n))},n=[];return t(n,e,r),n},o=function(e){if(e.length<=1)return e;var r=Math.floor(e.length/2),t=e.slice(0,r),n=e.slice(r);return t=o(t),n=o(n),a(t,n)};return o(e)}}function Pe(e){if(void 0!==e){if(e.length<=1)return e;for(var r=new Array(e.length),t=0;t<e.length;t++){var n=Math.floor(Math.random()*(t+1));t!==n&&(r[t]=r[n]),r[n]=e[t]}return r}}function Ue(e,r){var t={};for(var n in e){var i=e[n];xe(function(e,t,n){for(var i=U(r,[e,t,n],null),a=i.next();!a.done;)a=i.next(a.value);return a.value}(i,n,e))&&(t[n]=i)}return 0===Object.keys(t).length&&(t=void 0),t}function Ce(e){var r={};return{bind:function(e,t){r[e]=t},lookup:function(t){var n;return r.hasOwnProperty(t)?n=r[t]:e&&(n=e.lookup(t)),n}}}function qe(e){var r="Unknown error";void 0!==e.message&&(r=e.message);var t=He[e.code];return void 0!==t&&(r=(r=t.replace(/\{\{\{([^}]+)}}}/g,function(){return e[arguments[1]]})).replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(e[arguments[1]])})),r}function Re(e){var r;try{r=Le(e)}catch(e){throw e.message=qe(e),e}var t=Ce(Ge);return{evaluate:function(e,n,a){if(void 0!==n){var o;o=Ce(t);for(var s in n)o.bind(s,n[s])}else o=t;o.bind("$",e);var u=(new Date).toJSON();o.bind("now",H(function(){return u},"<:s>"));var c,f;if("function"==typeof a){o.bind("__jsonata_async",!0);var l=function(e){(c=f.next(e)).done?a(null,c.value):c.value.then(l).catch(function(e){e.message=qe(e),a(e,null)})};f=i(r,e,o),(c=f.next()).value.then(l)}else try{for(f=i(r,e,o),c=f.next();!c.done;)c=f.next(c.value);return c.value}catch(e){throw e.message=qe(e),e}},assign:function(e,r){t.bind(e,r)},registerFunction:function(e,r,n){var i=H(r,n);t.bind(e,i)}}}var Je={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":75,"#":70,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"`":80,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},ze={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},Be=function(e){var r=0,t=e.length,n=function(e,t){return{type:e,value:t,position:r}},i=function(){for(var n,i,a=r,o=0;r<t;){var s=e.charAt(r);if("/"===s&&"\\"!==e.charAt(r-1)&&0===o){if(""===(n=e.substring(a,r)))throw{code:"S0301",stack:(new Error).stack,position:r};for(r++,s=e.charAt(r),a=r;"i"===s||"m"===s;)r++,s=e.charAt(r);return i=e.substring(a,r)+"g",new RegExp(n,i)}"("!==s&&"["!==s&&"{"!==s||"\\"===e.charAt(r-1)||o++,")"!==s&&"]"!==s&&"}"!==s||"\\"===e.charAt(r-1)||o--,r++}throw{code:"S0302",stack:(new Error).stack,position:r}};return function(a){if(r>=t)return null;for(var o=e.charAt(r);r<t&&" \t\n\r\v".indexOf(o)>-1;)r++,o=e.charAt(r);if(!0!==a&&"/"===o)return r++,n("regex",i());if("."===o&&"."===e.charAt(r+1))return r+=2,n("operator","..");if(":"===o&&"="===e.charAt(r+1))return r+=2,n("operator",":=");if("!"===o&&"="===e.charAt(r+1))return r+=2,n("operator","!=");if(">"===o&&"="===e.charAt(r+1))return r+=2,n("operator",">=");if("<"===o&&"="===e.charAt(r+1))return r+=2,n("operator","<=");if("*"===o&&"*"===e.charAt(r+1))return r+=2,n("operator","**");if("~"===o&&">"===e.charAt(r+1))return r+=2,n("operator","~>");if(Je.hasOwnProperty(o))return r++,n("operator",o);if('"'===o||"'"===o){var s=o;r++;for(var u="";r<t;){if("\\"===(o=e.charAt(r)))if(r++,o=e.charAt(r),ze.hasOwnProperty(o))u+=ze[o];else{if("u"!==o)throw{code:"S0103",stack:(new Error).stack,position:r,token:o};var c=e.substr(r+1,4);if(!/^[0-9a-fA-F]+$/.test(c))throw{code:"S0104",stack:(new Error).stack,position:r};var f=parseInt(c,16);u+=String.fromCharCode(f),r+=4}else{if(o===s)return r++,n("string",u);u+=o}r++}throw{code:"S0101",stack:(new Error).stack,position:r}}var l=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(e.substring(r));if(null!==l){var p=parseFloat(l[0]);if(!isNaN(p)&&isFinite(p))return r+=l[0].length,n("number",p);throw{code:"S0102",stack:(new Error).stack,position:r,token:l[0]}}for(var d,v,h=r;;)if(d=e.charAt(h),h===t||" \t\n\r\v".indexOf(d)>-1||Je.hasOwnProperty(d)){if("$"===e.charAt(r))return v=e.substring(r+1,h),r=h,n("variable",v);switch(v=e.substring(r,h),r=h,v){case"or":case"in":case"and":return n("operator",v);case"true":return n("value",!0);case"false":return n("value",!1);case"null":return n("value",null);default:return r===t&&""===v?null:n("name",v)}}else h++}},Le=function(t){var n,i,a={},o={nud:function(){return this}},s=function(e,r){var t=a[e];return r=r||0,t?r>=t.lbp&&(t.lbp=r):((t=Object.create(o)).id=t.value=e,t.lbp=r,a[e]=t),t},u=function(e,r){if(e&&n.id!==e){var o;throw o="(end)"===n.id?"S0203":"S0202",{code:o,stack:(new Error).stack,position:n.position,token:n.id,value:e}}var s=i(r);if(null===s)return n=a["(end)"],n.position=t.length,n;var u,c=s.value,f=s.type;switch(f){case"name":case"variable":u=a["(name)"];break;case"operator":if(!(u=a[c]))throw{code:"S0204",stack:(new Error).stack,position:s.position,token:c};break;case"string":case"number":case"value":f="literal",u=a["(literal)"];break;case"regex":f="regex",u=a["(regex)"];break;default:throw{code:"S0205",stack:(new Error).stack,position:s.position,token:c}}return n=Object.create(u),n.value=c,n.type=f,n.position=s.position,n},c=function(e){var r,t=n;for(u(null,!0),r=t.nud();e<n.lbp;)t=n,u(),r=t.led(r);return r},f=function(e,r,t){var n=r||Je[e],i=s(e,n);return i.led=t||function(e){return this.lhs=e,this.rhs=c(n),this.type="binary",this},i},l=function(e,r){var t=s(e);return t.nud=r||function(){return this.expression=c(70),this.type="unary",this},t};s("(end)"),s("(name)"),s("(literal)"),s("(regex)"),s(":"),s(";"),s(","),s(")"),s("]"),s("}"),s(".."),f("."),f("+"),f("-"),f("*"),f("/"),f("%"),f("="),f("<"),f(">"),f("!="),f("<="),f(">="),f("&"),f("and"),f("or"),f("in"),function(e,r,t){var n=r||Je[e],i=s(e,n);i.led=t||function(e){return this.lhs=e,this.rhs=c(n-1),this.type="binary",this}}(":="),l("-"),f("~>"),l("*",function(){return this.type="wildcard",this}),l("**",function(){return this.type="descendant",this}),f("(",Je["("],function(r){if(this.procedure=r,this.type="function",this.arguments=[],")"!==n.id)for(;"operator"===n.type&&"?"===n.id?(this.type="partial",this.arguments.push(n),u("?")):this.arguments.push(c(0)),","===n.id;)u(",");if(u(")",!0),"name"===r.type&&("function"===r.value||"λ"===r.value)){if(this.arguments.forEach(function(e,r){if("variable"!==e.type)throw{code:"S0208",stack:(new Error).stack,position:e.position,token:e.value,value:r+1}}),this.type="lambda","<"===n.id){for(var t=n.position,i=1,a="<";i>0&&"{"!==n.id&&"(end)"!==n.id;){var o=u();">"===o.id?i--:"<"===o.id&&i++,a+=o.value}u(">");try{this.signature=e(a)}catch(e){throw e.position=t+e.offset,e}}u("{"),this.body=c(0),u("}")}return this}),l("(",function(){for(var e=[];")"!==n.id&&(e.push(c(0)),";"===n.id);)u(";");return u(")",!0),this.type="block",this.expressions=e,this}),l("[",function(){var e=[];if("]"!==n.id)for(;;){var r=c(0);if(".."===n.id){var t={type:"binary",value:"..",position:n.position,lhs:r};u(".."),t.rhs=c(0),r=t}if(e.push(r),","!==n.id)break;u(",")}return u("]",!0),this.lhs=e,this.type="unary",this}),f("[",Je["["],function(e){if("]"===n.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,u("]"),e}return this.lhs=e,this.rhs=c(Je["]"]),this.type="binary",u("]",!0),this}),f("^",Je["^"],function(e){u("(");for(var r=[];;){var t={descending:!1};if("<"===n.id?u("<"):">"===n.id&&(t.descending=!0,u(">")),t.expression=c(0),r.push(t),","!==n.id)break;u(",")}return u(")"),this.lhs=e,this.rhs=r,this.type="binary",this});var p=function(e){var r=[];if("}"!==n.id)for(;;){var t=c(0);u(":");var i=c(0);if(r.push([t,i]),","!==n.id)break;u(",")}return u("}",!0),void 0===e?(this.lhs=r,this.type="unary"):(this.lhs=e,this.rhs=r,this.type="binary"),this};l("{",p),f("{",Je["{"],p),f("?",Je["?"],function(e){return this.type="condition",this.condition=e,this.then=c(0),":"===n.id&&(u(":"),this.else=c(0)),this});var d=function(e){var r;if("function"===e.type){var t={type:"lambda",thunk:!0,arguments:[],position:e.position};t.body=e,r=t}else if("condition"===e.type)e.then=d(e.then),void 0!==e.else&&(e.else=d(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=d(e.expressions[n-1])),r=e}else r=e;return r},v=function(e){var t;switch(e.type){case"binary":switch(e.value){case".":var n=v(e.lhs);t={type:"path",steps:[]},"path"===n.type?Array.prototype.push.apply(t.steps,n.steps):t.steps=[n];var i=v(e.rhs);"path"!==i.type&&(i={type:"path",steps:[i]}),Array.prototype.push.apply(t.steps,i.steps),t.steps.filter(function(e){return"literal"===e.type}).forEach(function(e){e.type="name"}),t.steps.filter(function(e){return!0===e.keepArray}).length>0&&(t.keepSingletonArray=!0),"unary"===t.steps[0].type&&"["===t.steps[0].value&&(t.steps[0].consarray=!0);break;case"[":var a=t=v(e.lhs);if("path"===t.type&&(a=t.steps[t.steps.length-1]),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===a.predicate&&(a.predicate=[]),a.predicate.push(v(e.rhs));break;case"{":if(void 0!==(t=v(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};t.group={lhs:e.rhs.map(function(e){return[v(e[0]),v(e[1])]}),position:e.position};break;case"^":(t={type:"sort",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=e.rhs.map(function(e){return{descending:e.descending,expression:v(e.expression)}});break;case":=":(t={type:"bind",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs);break;case"~>":(t={type:"apply",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs);break;default:(t={type:e.type,value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs)}break;case"unary":t={type:e.type,value:e.value,position:e.position},"["===e.value?t.lhs=e.lhs.map(function(e){return v(e)}):"{"===e.value?t.lhs=e.lhs.map(function(e){return[v(e[0]),v(e[1])]}):(t.expression=v(e.expression),"-"===e.value&&"literal"===t.expression.type&&r(t.expression.value)&&((t=t.expression).value=-t.value));break;case"function":case"partial":(t={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){return v(e)}),t.procedure=v(e.procedure);break;case"lambda":t={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var o=v(e.body);t.body=d(o);break;case"condition":(t={type:e.type,position:e.position}).condition=v(e.condition),t.then=v(e.then),void 0!==e.else&&(t.else=v(e.else));break;case"block":(t={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){return v(e)});break;case"name":t={type:"path",steps:[e]},e.keepArray&&(t.keepSingletonArray=!0);break;case"literal":case"wildcard":case"descendant":case"variable":case"regex":t=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",t=v(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};t=e}break;default:var s="S0206";throw"(end)"===e.id&&(s="S0207"),{code:s,stack:(new Error).stack,position:e.position,token:e.value}}return t};i=Be(t),u();var h=c(0);if("(end)"!==n.id)throw{code:"S0201",stack:(new Error).stack,position:n.position,token:n.value};return h=v(h)},Ge=Ce(null);Number.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};var Ke=M(Le("function($f, $g) { function($x){ $g($f($x)) } }"),null,Ge);Ge.bind("sum",H(Q,"<a<n>:n>")),Ge.bind("count",H(V,"<a:n>")),Ge.bind("max",H(W,"<a<n>:n>")),Ge.bind("min",H(X,"<a<n>:n>")),Ge.bind("average",H(Y,"<a<n>:n>")),Ge.bind("string",H(Z,"<x-:s>")),Ge.bind("substring",H(ee,"<s-nn?:s>")),Ge.bind("substringBefore",H(re,"<s-s:s>")),Ge.bind("substringAfter",H(te,"<s-s:s>")),Ge.bind("lowercase",H(ne,"<s-:s>")),Ge.bind("uppercase",H(ie,"<s-:s>")),Ge.bind("length",H(ae,"<s-:n>")),Ge.bind("trim",H(oe,"<s-:s>")),Ge.bind("match",H(ue,"<s-f<s:o>n?:a<o>>")),Ge.bind("contains",H(se,"<s-(sf):b>")),Ge.bind("replace",H(ce,"<s-(sf)(sf)n?:s>")),Ge.bind("split",H(pe,"<s-(sf)n?:a<s>>")),Ge.bind("join",H(de,"<a<s>s?:s>")),Ge.bind("number",H(ve,"<(ns)-:n>")),Ge.bind("floor",H(ye,"<n-:n>")),Ge.bind("ceil",H(be,"<n-:n>")),Ge.bind("round",H(ge,"<n-n?:n>")),Ge.bind("abs",H(he,"<n-:n>")),Ge.bind("sqrt",H(ke,"<n-:n>")),Ge.bind("power",H(me,"<n-n:n>")),Ge.bind("random",H(we,"<:n>")),Ge.bind("boolean",H(xe,"<x-:b>")),Ge.bind("not",H(Ae,"<x-:b>")),Ge.bind("map",H(Ee,"<af>")),Ge.bind("zip",H(Te,"<a+>")),Ge.bind("filter",H(Se,"<af>")),Ge.bind("reduce",H(je,"<afj?:j>")),Ge.bind("sift",H(Ue,"<o-f?:o>")),Ge.bind("keys",H(_e,"<x-:a<s>>")),Ge.bind("lookup",H(De,"<x-s:x>")),Ge.bind("append",H(Oe,"<xx:a>")),Ge.bind("exists",H(Me,"<x:b>")),Ge.bind("spread",H(Ne,"<x-:a<o>>")),Ge.bind("reverse",H($e,"<a:a>")),Ge.bind("each",H(Fe,"<o-f:a>")),Ge.bind("sort",H(Ie,"<af?:a>")),Ge.bind("shuffle",H(Pe,"<a:a>")),Ge.bind("base64encode",H(fe,"<s-:s>")),Ge.bind("base64decode",H(le,"<s-:s>"));var He={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0203:"Expected {{value}} before end of expression",S0202:"Expected {{value}}, got {{token}}",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0201:"Syntax error: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T1003:"Key in object structure must evaluate to a string; got: {{value}}",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",D1004:"Regular expression matches zero length string",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"First argument of reduce function must be a function with two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function"};return Re.parser=Le,Re}();"undefined"!=typeof module&&(module.exports=jsonata);
var jsonata=function(){"use strict";function e(e){for(var r=1,t=[],n={},i=n;r<e.length;){var a=e.charAt(r);if(":"===a)break;var o=function(){t.push(n),i=n,n={}},s=function(e,r,t,n){for(var i=1,o=r;o<e.length;)if(o++,(a=e.charAt(o))===n){if(0==--i)break}else a===t&&i++;return o};switch(a){case"s":case"n":case"b":case"l":case"o":n.regex="["+a+"m]",n.type=a,o();break;case"a":n.regex="[asnblfom]",n.type=a,n.array=!0,o();break;case"f":n.regex="f",n.type=a,o();break;case"j":n.regex="[asnblom]",n.type=a,o();break;case"x":n.regex="[asnblfom]",n.type=a,o();break;case"-":i.context=!0,i.contextRegex=new RegExp(i.regex),i.regex+="?";break;case"?":case"+":i.regex+=a;break;case"(":var u=s(e,r,"(",")"),c=e.substring(r+1,u);if(-1!==c.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:c,offset:r};n.regex="["+c+"m]",n.type="("+c+")",r=u,o();break;case"<":if("a"!==i.type&&"f"!==i.type)throw{code:"S0401",stack:(new Error).stack,value:i.type,offset:r};var f=s(e,r,"<",">");i.subtype=e.substring(r+1,f),r=f}r++}var l="^"+t.map(function(e){return"("+e.regex+")"}).join("")+"$",p=new RegExp(l),d=function(e){var r;if($(e))r="f";else switch(typeof e){case"string":r="s";break;case"number":r="n";break;case"boolean":r="b";break;case"object":r=null===e?"l":Array.isArray(e)?"a":"o";break;case"undefined":r="m"}return r},v=function(e,r){for(var n="^",i=0,a=0;a<t.length;a++){n+=t[a].regex;var o=r.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:e[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:e[i],index:i+1}};return{definition:e,validate:function(e,r){var n="";e.forEach(function(e){n+=d(e)});var i=p.exec(n);if(i){var a=[],o=0;return t.forEach(function(t,n){var s=e[o],u=i[n+1];if(""===u)if(t.context){var c=d(r);if(!t.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};a.push(r)}else a.push(s),o++;else u.split("").forEach(function(r){if("a"===t.type){if("m"===r)s=void 0;else{s=e[o];var n=!0;if(void 0!==t.subtype)if("a"!==r&&u!==t.subtype)n=!1;else if("a"===r&&s.length>0){var i=d(s[0]);n=i===t.subtype.charAt(0)&&0===s.filter(function(e){return d(e)!==i}).length}if(!n)throw{code:"T0412",stack:(new Error).stack,value:s,index:o+1,type:t.subtype};"a"!==r&&(s=[s])}a.push(s),o++}else a.push(s),o++})}),a}v(e,n)}}}function r(e){var r=!1;if("number"==typeof e){var t=parseFloat(e);if((r=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:e,stack:(new Error).stack}}return r}function t(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter(function(e){return"string"!=typeof e}).length),r}function n(e){var t=!1;return Array.isArray(e)&&(t=0===e.filter(function(e){return!r(e)}).length),t}function*i(e,r,t){var n,i=t.lookup("__evaluate_entry");switch(i&&i(e,r,t),e.type){case"path":n=o(n=yield*a(e.steps,r,t),e.keepSingletonArray);break;case"binary":n=yield*f(e,r,t);break;case"unary":n=yield*l(e,r,t);break;case"name":n=p(e,r,t);break;case"literal":n=d(e);break;case"wildcard":n=v(e,r);break;case"descendant":n=y(e,r);break;case"condition":n=yield*T(e,r,t);break;case"block":n=yield*j(e,r,t);break;case"bind":n=yield*S(e,r,t);break;case"regex":n=_(e);break;case"function":n=yield*P(e,r,t);break;case"variable":n=D(e,r,t);break;case"lambda":n=q(e,r,t);break;case"partial":n=yield*R(e,r,t);break;case"apply":n=yield*N(e,r,t);break;case"sort":n=yield*O(e,r,t)}!t.lookup("__jsonata_async")||void 0!==n&&null!==n&&"function"==typeof n.then||(n=Promise.resolve(n)),n=yield n,e.hasOwnProperty("predicate")&&(n=o(n=yield*u(e.predicate,n,t))),e.hasOwnProperty("group")&&(n=yield*A(e.group,n,t));var s=t.lookup("__evaluate_exit");return s&&s(e,r,t,n),n}function*a(e,r,t){var n;n="variable"===e[0].type?[r]:e[0].consarray?[null]:Array.isArray(r)?r:[r];for(var i,a=0;a<e.length&&(void 0!==(i=yield*s(e[a],n,t))&&0!==i.length);a++)n=i;return i}function o(e,r){var t;return void 0===e?t=void 0:Array.isArray(e)?1===e.length?t=r?e:e[0]:e.length>1&&(t=e):t=e,t}function*s(e,r,t){for(var n=[],a=0;a<r.length;a++){var o=yield*i(e,r[a],t);Array.isArray(o)&&"["!==e.value||e.consarray||(o=[o]),o.forEach(function(e){void 0!==e&&n.push(e)})}return n}function*u(e,t,n){for(var i=t,a=[],o=0;o<e.length;o++){var s=e[o];if(Array.isArray(i)||(i=[i]),a=[],"literal"===s.type&&r(s.value)){var u=s.value;Number.isInteger(u)||(u=Math.floor(u)),u<0&&(u=i.length+u),a=i[u]}else a=yield*c(s,i,n);i=a}return a}function*c(e,t,a){for(var o=[],s=0;s<t.length;s++){var u=t[s],c=yield*i(e,u,a);r(c)&&(c=[c]),n(c)?c.forEach(function(e){Number.isInteger(e)||(e=Math.floor(e)),e<0&&(e=t.length+e),e===s&&o.push(u)}):V(c)&&o.push(u)}return o}function*f(e,r,t){var n,a=yield*i(e.lhs,r,t),o=yield*i(e.rhs,r,t),s=e.value;try{switch(s){case"+":case"-":case"*":case"/":case"%":n=g(a,o,s);break;case"=":case"!=":case"<":case"<=":case">":case">=":n=k(a,o,s);break;case"&":n=x(a,o);break;case"and":case"or":n=w(a,o,s);break;case"..":n=E(a,o);break;case"in":n=m(a,o)}}catch(r){throw r.position=e.position,r.token=s,r}return n}function*l(e,t,n){var a;switch(e.value){case"-":if(a=yield*i(e.expression,t,n),!r(a))throw{code:"D1002",stack:(new Error).stack,position:e.position,token:e.value,value:a};a=-a;break;case"[":a=[];for(var o=0;o<e.lhs.length;o++){var s=e.lhs[o],u=yield*i(s,t,n);void 0!==u&&("["===s.value?a.push(u):a=X(a,u))}break;case"{":a=yield*A(e,t,n)}return a}function p(e,r,t){var n;if(Array.isArray(r)){n=[];for(var i=0;i<r.length;i++){var a=p(e,r[i],t);void 0!==a&&n.push(a)}}else null!==r&&"object"==typeof r&&(n=r[e.value]);return n=o(n)}function d(e){return e.value}function v(e,r){var t=[];return null!==r&&"object"==typeof r&&Object.keys(r).forEach(function(e){var n=r[e];Array.isArray(n)?(n=h(n),t=X(t,n)):t.push(n)}),o(t)}function h(e,r){return void 0===r&&(r=[]),Array.isArray(e)?e.forEach(function(e){h(e,r)}):r.push(e),r}function y(e,r){var t,n=[];return void 0!==r&&(b(r,n),t=1===n.length?n[0]:n),t}function b(e,r){Array.isArray(e)||r.push(e),Array.isArray(e)?e.forEach(function(e){b(e,r)}):null!==e&&"object"==typeof e&&Object.keys(e).forEach(function(t){b(e[t],r)})}function g(e,t,n){var i;if(void 0===e||void 0===t)return i;if(!r(e))throw{code:"T2001",stack:(new Error).stack,value:e};if(!r(t))throw{code:"T2002",stack:(new Error).stack,value:t};switch(n){case"+":i=e+t;break;case"-":i=e-t;break;case"*":i=e*t;break;case"/":i=e/t;break;case"%":i=e%t}return i}function k(e,r,t){var n,i=typeof e,a=typeof r;if("undefined"===i||"undefined"===a)return!1;var o=function(){if("string"!==i&&"number"!==i||"string"!==a&&"number"!==a)throw{code:"T2010",stack:(new Error).stack,value:"string"!==i&&"number"!==i?e:r};if(i!==a)throw{code:"T2009",stack:(new Error).stack,value:e,value2:r}};switch(t){case"=":n=e===r;break;case"!=":n=e!==r;break;case"<":o(),n=e<r;break;case"<=":o(),n=e<=r;break;case">":o(),n=e>r;break;case">=":o(),n=e>=r}return n}function m(e,r){var t=!1;if(void 0===e||void 0===r)return!1;Array.isArray(r)||(r=[r]);for(var n=0;n<r.length;n++)if(r[n]===e){t=!0;break}return t}function w(e,r,t){var n;switch(t){case"and":n=V(e)&&V(r);break;case"or":n=V(e)||V(r)}return n}function x(e,r){var t="",n="";return void 0!==e&&(t=Q(e)),void 0!==r&&(n=Q(r)),t.concat(n)}function*A(e,r,t){var n={},a={};Array.isArray(r)||(r=[r]);for(var o=[],s=0;s<r.length;s++)for(var u=0;u<e.lhs.length;u++)o.push(yield*i(e.lhs[u][0],r[s],t));var c=o.entries();r.forEach(function(r){e.lhs.forEach(function(t){var n=c.next().value[1];if("string"!=typeof n)throw{code:"T1003",stack:(new Error).stack,position:e.position,value:n};var i={data:r,expr:t[1]};a.hasOwnProperty(n)?a[n].data=X(a[n].data,r):a[n]=i})}),o=[];var f;for(f in a){var l=a[f];o.push(yield*i(l.expr,l.data,t))}c=o.entries();for(f in a){var p=c.next().value[1];n[f]=p}return n}function E(e,r){var t;if(void 0===e||void 0===r)return t;if(e>r)return t;if(!Number.isInteger(e))throw{code:"T2003",stack:(new Error).stack,value:e};if(!Number.isInteger(r))throw{code:"T2004",stack:(new Error).stack,value:r};t=new Array(r-e+1);for(var n=e,i=0;n<=r;n++,i++)t[i]=n;return t}function*S(e,r,t){var n=yield*i(e.rhs,r,t);if("variable"!==e.lhs.type)throw{code:"D2005",stack:(new Error).stack,position:e.position,token:e.value,value:"path"===e.lhs.type?e.lhs.steps[0].value:e.lhs.value};return t.bind(e.lhs.value,n),n}function*T(e,r,t){var n;return V(yield*i(e.condition,r,t))?n=yield*i(e.then,r,t):void 0!==e.else&&(n=yield*i(e.else,r,t)),n}function*j(e,r,t){for(var n,a=ee(t),o=0;o<e.expressions.length;o++)n=yield*i(e.expressions[o],r,a);return n}function _(e){e.value.lastIndex=0;var r=function(t){var n,i=e.value,a=i.exec(t);if(null!==a){if(n={match:a[0],start:a.index,end:a.index+a[0].length,groups:[]},a.length>1)for(var o=1;o<a.length;o++)n.groups.push(a[o]);n.next=function(){if(!(i.lastIndex>=t.length)){var n=r(t);if(n&&""===n.match&&i.lastIndex===e.value.lastIndex)throw{code:"D1004",stack:(new Error).stack,position:e.position,value:e.value.source};return n}}}return n};return r}function D(e,r,t){return""===e.value?r:t.lookup(e.value)}function*O(e,r,t){return Z(yield*i(e.lhs,r,t),function(r,n){for(var i=0,a=0;0===i&&a<e.rhs.length;a++){var o=e.rhs[a],s=M(o.expression,r,t),u=M(o.expression,n,t),c=typeof s,f=typeof u;if("undefined"!==c)if("undefined"!==f){if("string"!==c&&"number"!==c||"string"!==f&&"number"!==f)throw{code:"T2008",stack:(new Error).stack,position:e.position,value:"string"!==c&&"number"!==c?s:u};if(c!==f)throw{code:"T2007",stack:(new Error).stack,position:e.position,value:s,value2:u};s!==u&&(i=s<u?-1:1,!0===o.descending&&(i=-i))}else i=-1;else i="undefined"===f?0:1}return 1===i})}function M(e,r,t){for(var n=i(e,r,t),a=n.next();!a.done;)a=n.next(a.value);return a.value}function*N(e,r,t){var n,a=yield*i(e.lhs,r,t);if("function"===e.rhs.type)n=yield*P(e.rhs,r,t,{context:a});else{var o=yield*i(e.rhs,r,t);if(!$(o))throw{code:"T2006",stack:(new Error).stack,position:e.position,value:o};n=$(a)?yield*U(ue,[a,o],t,null):yield*U(o,[a],t,null)}return n}function $(e){return e&&(!0===e._jsonata_function||!0===e._jsonata_lambda)||"function"==typeof e}function F(e){return e&&!0===e._jsonata_lambda}function I(e){return"object"==typeof e&&Symbol.iterator in e&&"function"==typeof e[Symbol.iterator]&&"next"in e&&"function"==typeof e.next}function*P(e,r,t,n){for(var a,o=[],s=0;s<e.arguments.length;s++)o.push(yield*i(e.arguments[s],r,t));n&&o.unshift(n.context);var u=yield*i(e.procedure,r,t);if(void 0===u&&"path"===e.procedure.type&&t.lookup(e.procedure.steps[0].value))throw{code:"T1005",stack:(new Error).stack,position:e.position,token:e.procedure.steps[0].value};try{a=yield*U(u,o,r)}catch(r){throw r.position=e.position,r.token="path"===e.procedure.type?e.procedure.steps[0].value:e.procedure.value,r}return a}function*U(e,r,t){var n;for(n=yield*C(e,r,t);F(n)&&!0===n.thunk;){for(var a=yield*i(n.body.procedure,n.input,n.environment),o=[],s=0;s<n.body.arguments.length;s++)o.push(yield*i(n.body.arguments[s],n.input,n.environment));n=yield*C(a,o,t)}return n}function*C(e,r,t){var n,i=r;if(e&&(i=J(e.signature,r,t)),F(e))n=yield*z(e,i);else if(e&&!0===e._jsonata_function)I(n=e.implementation.apply(t,i))&&(n=yield*n);else{if("function"!=typeof e)throw{code:"T1006",stack:(new Error).stack};n=e.apply(t,i)}return n}function q(e,r,t){var n={_jsonata_lambda:!0,input:r,environment:t,arguments:e.arguments,signature:e.signature,body:e.body};return!0===e.thunk&&(n.thunk=!0),n}function*R(e,r,t){for(var n,a=[],o=0;o<e.arguments.length;o++){var s=e.arguments[o];"operator"===s.type&&"?"===s.value?a.push(s):a.push(yield*i(s,r,t))}var u=yield*i(e.procedure,r,t);if(void 0===u&&"path"===e.procedure.type&&t.lookup(e.procedure.steps[0].value))throw{code:"T1007",stack:(new Error).stack,position:e.position,token:e.procedure.steps[0].value};if(F(u))n=B(u,a);else if(u&&!0===u._jsonata_function)n=L(u.implementation,a);else{if("function"!=typeof u)throw{code:"T1008",stack:(new Error).stack,position:e.position,token:"path"===e.procedure.type?e.procedure.steps[0].value:e.procedure.value};n=L(u,a)}return n}function J(e,r,t){return void 0===e?r:e.validate(r,t)}function*z(e,r){var t=ee(e.environment);return e.arguments.forEach(function(e,n){t.bind(e.value,r[n])}),"function"==typeof e.body?yield*G(e.body,t):yield*i(e.body,e.input,t)}function B(e,r){var t=ee(e.environment),n=[];return e.arguments.forEach(function(e,i){var a=r[i];a&&"operator"===a.type&&"?"===a.value?n.push(e):t.bind(e.value,a)}),{_jsonata_lambda:!0,input:e.input,environment:t,arguments:n,body:e.body}}function L(e,r){var t=K(e),n="function("+(t=t.map(function(e){return"$"+e.trim()})).join(", ")+"){ _ }",i=oe(n);return i.body=e,B(i,r)}function*G(e,r){var t=K(e).map(function(e){return r.lookup(e.trim())}),n=e.apply(null,t);return I(n)&&(n=yield*n),n}function K(e){var r=e.toString();return/\(([^)]*)\)/.exec(r)[1].split(",")}function H(r,t){var n={_jsonata_function:!0,implementation:r};return void 0!==t&&(n.signature=e(t)),n}function Q(e){if(void 0!==e){var t;if("string"==typeof e)t=e;else if($(e))t="";else{if("number"==typeof e&&!isFinite(e))throw{code:"D3001",value:e,stack:(new Error).stack};t=JSON.stringify(e,function(e,t){return void 0!==t&&null!==t&&t.toPrecision&&r(t)?Number(t.toPrecision(13)):t&&$(t)?"":t})}return t}}function V(e){if(void 0!==e){var t=!1;return Array.isArray(e)?1===e.length?t=V(e[0]):e.length>1&&(t=e.filter(function(e){return V(e)}).length>0):"string"==typeof e?e.length>0&&(t=!0):r(e)?0!==e&&(t=!0):null!==e&&"object"==typeof e?Object.keys(e).length>0&&(F(e)||e._jsonata_function||(t=!0)):"boolean"==typeof e&&!0===e&&(t=!0),t}}function W(e){var r=[];if(Array.isArray(e)){var t={};e.forEach(function(e){var r=W(e);Array.isArray(r)&&r.forEach(function(e){t[e]=!0})}),r=W(t)}else null===e||"object"!=typeof e||F(e)?r=void 0:0===(r=Object.keys(e)).length&&(r=void 0);return r}function X(e,r){return void 0===e?r:void 0===r?e:(Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]),Array.prototype.push.apply(e,r),e)}function Y(e){var r=[];if(Array.isArray(e))e.forEach(function(e){r=X(r,Y(e))});else if(null===e||"object"!=typeof e||F(e))r=e;else for(var t in e){var n={};n[t]=e[t],r.push(n)}return r}function Z(e,r){if(void 0!==e){if(e.length<=1)return e;var i;if(void 0===r){if(!n(e)&&!t(e))throw{stack:(new Error).stack,code:"D3070",index:1};i=function(e,r){return e>r}}else i="function"==typeof r?r:function(e,t){for(var n=U(r,[e,t],null),i=n.next();!i.done;)i=n.next(i.value);return i.value};var a=function(e,r){var t=function(e,r,n){0===r.length?Array.prototype.push.apply(e,n):0===n.length?Array.prototype.push.apply(e,r):i(r[0],n[0])?(e.push(n[0]),t(e,r,n.slice(1))):(e.push(r[0]),t(e,r.slice(1),n))},n=[];return t(n,e,r),n},o=function(e){if(e.length<=1)return e;var r=Math.floor(e.length/2),t=e.slice(0,r),n=e.slice(r);return t=o(t),n=o(n),a(t,n)};return o(e)}}function ee(e){var r={};return{bind:function(e,t){r[e]=t},lookup:function(t){var n;return r.hasOwnProperty(t)?n=r[t]:e&&(n=e.lookup(t)),n}}}function re(e){var r="Unknown error";void 0!==e.message&&(r=e.message);var t=ce[e.code];return void 0!==t&&(r=(r=t.replace(/\{\{\{([^}]+)}}}/g,function(){return e[arguments[1]]})).replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(e[arguments[1]])})),r}function te(e){var r;try{r=oe(e)}catch(e){throw e.message=re(e),e}var t=ee(se);return{evaluate:function(e,n,a){if(void 0!==n){var o;o=ee(t);for(var s in n)o.bind(s,n[s])}else o=t;o.bind("$",e);var u=(new Date).toJSON();o.bind("now",H(function(){return u},"<:s>"));var c,f;if("function"==typeof a){o.bind("__jsonata_async",!0);var l=function(e){(c=f.next(e)).done?a(null,c.value):c.value.then(l).catch(function(e){e.message=re(e),a(e,null)})};f=i(r,e,o),(c=f.next()).value.then(l)}else try{for(f=i(r,e,o),c=f.next();!c.done;)c=f.next(c.value);return c.value}catch(e){throw e.message=re(e),e}},assign:function(e,r){t.bind(e,r)},registerFunction:function(e,r,n){var i=H(r,n);t.bind(e,i)}}}var ne={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":75,"#":70,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"`":80,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},ie={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},ae=function(e){var r=0,t=e.length,n=function(e,t){return{type:e,value:t,position:r}},i=function(){for(var n,i,a=r,o=0;r<t;){var s=e.charAt(r);if("/"===s&&"\\"!==e.charAt(r-1)&&0===o){if(""===(n=e.substring(a,r)))throw{code:"S0301",stack:(new Error).stack,position:r};for(r++,s=e.charAt(r),a=r;"i"===s||"m"===s;)r++,s=e.charAt(r);return i=e.substring(a,r)+"g",new RegExp(n,i)}"("!==s&&"["!==s&&"{"!==s||"\\"===e.charAt(r-1)||o++,")"!==s&&"]"!==s&&"}"!==s||"\\"===e.charAt(r-1)||o--,r++}throw{code:"S0302",stack:(new Error).stack,position:r}};return function(a){if(r>=t)return null;for(var o=e.charAt(r);r<t&&" \t\n\r\v".indexOf(o)>-1;)r++,o=e.charAt(r);if(!0!==a&&"/"===o)return r++,n("regex",i());if("."===o&&"."===e.charAt(r+1))return r+=2,n("operator","..");if(":"===o&&"="===e.charAt(r+1))return r+=2,n("operator",":=");if("!"===o&&"="===e.charAt(r+1))return r+=2,n("operator","!=");if(">"===o&&"="===e.charAt(r+1))return r+=2,n("operator",">=");if("<"===o&&"="===e.charAt(r+1))return r+=2,n("operator","<=");if("*"===o&&"*"===e.charAt(r+1))return r+=2,n("operator","**");if("~"===o&&">"===e.charAt(r+1))return r+=2,n("operator","~>");if(ne.hasOwnProperty(o))return r++,n("operator",o);if('"'===o||"'"===o){var s=o;r++;for(var u="";r<t;){if("\\"===(o=e.charAt(r)))if(r++,o=e.charAt(r),ie.hasOwnProperty(o))u+=ie[o];else{if("u"!==o)throw{code:"S0103",stack:(new Error).stack,position:r,token:o};var c=e.substr(r+1,4);if(!/^[0-9a-fA-F]+$/.test(c))throw{code:"S0104",stack:(new Error).stack,position:r};var f=parseInt(c,16);u+=String.fromCharCode(f),r+=4}else{if(o===s)return r++,n("string",u);u+=o}r++}throw{code:"S0101",stack:(new Error).stack,position:r}}var l=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(e.substring(r));if(null!==l){var p=parseFloat(l[0]);if(!isNaN(p)&&isFinite(p))return r+=l[0].length,n("number",p);throw{code:"S0102",stack:(new Error).stack,position:r,token:l[0]}}for(var d,v,h=r;;)if(d=e.charAt(h),h===t||" \t\n\r\v".indexOf(d)>-1||ne.hasOwnProperty(d)){if("$"===e.charAt(r))return v=e.substring(r+1,h),r=h,n("variable",v);switch(v=e.substring(r,h),r=h,v){case"or":case"in":case"and":return n("operator",v);case"true":return n("value",!0);case"false":return n("value",!1);case"null":return n("value",null);default:return r===t&&""===v?null:n("name",v)}}else h++}},oe=function(t){var n,i,a={},o={nud:function(){return this}},s=function(e,r){var t=a[e];return r=r||0,t?r>=t.lbp&&(t.lbp=r):((t=Object.create(o)).id=t.value=e,t.lbp=r,a[e]=t),t},u=function(e,r){if(e&&n.id!==e){var o;throw o="(end)"===n.id?"S0203":"S0202",{code:o,stack:(new Error).stack,position:n.position,token:n.id,value:e}}var s=i(r);if(null===s)return n=a["(end)"],n.position=t.length,n;var u,c=s.value,f=s.type;switch(f){case"name":case"variable":u=a["(name)"];break;case"operator":if(!(u=a[c]))throw{code:"S0204",stack:(new Error).stack,position:s.position,token:c};break;case"string":case"number":case"value":f="literal",u=a["(literal)"];break;case"regex":f="regex",u=a["(regex)"];break;default:throw{code:"S0205",stack:(new Error).stack,position:s.position,token:c}}return n=Object.create(u),n.value=c,n.type=f,n.position=s.position,n},c=function(e){var r,t=n;for(u(null,!0),r=t.nud();e<n.lbp;)t=n,u(),r=t.led(r);return r},f=function(e,r,t){var n=r||ne[e],i=s(e,n);return i.led=t||function(e){return this.lhs=e,this.rhs=c(n),this.type="binary",this},i},l=function(e,r){var t=s(e);return t.nud=r||function(){return this.expression=c(70),this.type="unary",this},t};s("(end)"),s("(name)"),s("(literal)"),s("(regex)"),s(":"),s(";"),s(","),s(")"),s("]"),s("}"),s(".."),f("."),f("+"),f("-"),f("*"),f("/"),f("%"),f("="),f("<"),f(">"),f("!="),f("<="),f(">="),f("&"),f("and"),f("or"),f("in"),function(e,r,t){var n=r||ne[e],i=s(e,n);i.led=t||function(e){return this.lhs=e,this.rhs=c(n-1),this.type="binary",this}}(":="),l("-"),f("~>"),l("*",function(){return this.type="wildcard",this}),l("**",function(){return this.type="descendant",this}),f("(",ne["("],function(r){if(this.procedure=r,this.type="function",this.arguments=[],")"!==n.id)for(;"operator"===n.type&&"?"===n.id?(this.type="partial",this.arguments.push(n),u("?")):this.arguments.push(c(0)),","===n.id;)u(",");if(u(")",!0),"name"===r.type&&("function"===r.value||"λ"===r.value)){if(this.arguments.forEach(function(e,r){if("variable"!==e.type)throw{code:"S0208",stack:(new Error).stack,position:e.position,token:e.value,value:r+1}}),this.type="lambda","<"===n.id){for(var t=n.position,i=1,a="<";i>0&&"{"!==n.id&&"(end)"!==n.id;){var o=u();">"===o.id?i--:"<"===o.id&&i++,a+=o.value}u(">");try{this.signature=e(a)}catch(e){throw e.position=t+e.offset,e}}u("{"),this.body=c(0),u("}")}return this}),l("(",function(){for(var e=[];")"!==n.id&&(e.push(c(0)),";"===n.id);)u(";");return u(")",!0),this.type="block",this.expressions=e,this}),l("[",function(){var e=[];if("]"!==n.id)for(;;){var r=c(0);if(".."===n.id){var t={type:"binary",value:"..",position:n.position,lhs:r};u(".."),t.rhs=c(0),r=t}if(e.push(r),","!==n.id)break;u(",")}return u("]",!0),this.lhs=e,this.type="unary",this}),f("[",ne["["],function(e){if("]"===n.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,u("]"),e}return this.lhs=e,this.rhs=c(ne["]"]),this.type="binary",u("]",!0),this}),f("^",ne["^"],function(e){u("(");for(var r=[];;){var t={descending:!1};if("<"===n.id?u("<"):">"===n.id&&(t.descending=!0,u(">")),t.expression=c(0),r.push(t),","!==n.id)break;u(",")}return u(")"),this.lhs=e,this.rhs=r,this.type="binary",this});var p=function(e){var r=[];if("}"!==n.id)for(;;){var t=c(0);u(":");var i=c(0);if(r.push([t,i]),","!==n.id)break;u(",")}return u("}",!0),void 0===e?(this.lhs=r,this.type="unary"):(this.lhs=e,this.rhs=r,this.type="binary"),this};l("{",p),f("{",ne["{"],p),f("?",ne["?"],function(e){return this.type="condition",this.condition=e,this.then=c(0),":"===n.id&&(u(":"),this.else=c(0)),this});var d=function(e){var r;if("function"===e.type){var t={type:"lambda",thunk:!0,arguments:[],position:e.position};t.body=e,r=t}else if("condition"===e.type)e.then=d(e.then),void 0!==e.else&&(e.else=d(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=d(e.expressions[n-1])),r=e}else r=e;return r},v=function(e){var t;switch(e.type){case"binary":switch(e.value){case".":var n=v(e.lhs);t={type:"path",steps:[]},"path"===n.type?Array.prototype.push.apply(t.steps,n.steps):t.steps=[n];var i=v(e.rhs);"path"!==i.type&&(i={type:"path",steps:[i]}),Array.prototype.push.apply(t.steps,i.steps),t.steps.filter(function(e){return"literal"===e.type}).forEach(function(e){e.type="name"}),t.steps.filter(function(e){return!0===e.keepArray}).length>0&&(t.keepSingletonArray=!0),"unary"===t.steps[0].type&&"["===t.steps[0].value&&(t.steps[0].consarray=!0);break;case"[":var a=t=v(e.lhs);if("path"===t.type&&(a=t.steps[t.steps.length-1]),void 0!==a.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===a.predicate&&(a.predicate=[]),a.predicate.push(v(e.rhs));break;case"{":if(void 0!==(t=v(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};t.group={lhs:e.rhs.map(function(e){return[v(e[0]),v(e[1])]}),position:e.position};break;case"^":(t={type:"sort",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=e.rhs.map(function(e){return{descending:e.descending,expression:v(e.expression)}});break;case":=":(t={type:"bind",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs);break;case"~>":(t={type:"apply",value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs);break;default:(t={type:e.type,value:e.value,position:e.position}).lhs=v(e.lhs),t.rhs=v(e.rhs)}break;case"unary":t={type:e.type,value:e.value,position:e.position},"["===e.value?t.lhs=e.lhs.map(function(e){return v(e)}):"{"===e.value?t.lhs=e.lhs.map(function(e){return[v(e[0]),v(e[1])]}):(t.expression=v(e.expression),"-"===e.value&&"literal"===t.expression.type&&r(t.expression.value)&&((t=t.expression).value=-t.value));break;case"function":case"partial":(t={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){return v(e)}),t.procedure=v(e.procedure);break;case"lambda":t={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var o=v(e.body);t.body=d(o);break;case"condition":(t={type:e.type,position:e.position}).condition=v(e.condition),t.then=v(e.then),void 0!==e.else&&(t.else=v(e.else));break;case"block":(t={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){return v(e)});break;case"name":t={type:"path",steps:[e]},e.keepArray&&(t.keepSingletonArray=!0);break;case"literal":case"wildcard":case"descendant":case"variable":case"regex":t=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",t=v(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};t=e}break;default:var s="S0206";throw"(end)"===e.id&&(s="S0207"),{code:s,stack:(new Error).stack,position:e.position,token:e.value}}return t};i=ae(t),u();var h=c(0);if("(end)"!==n.id)throw{code:"S0201",stack:(new Error).stack,position:n.position,token:n.value};return h=v(h)},se=ee(null);Number.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};var ue=M(oe("function($f, $g) { function($x){ $g($f($x)) } }"),null,se);se.bind("sum",H(function(e){if(void 0!==e){var r=0;return e.forEach(function(e){r+=e}),r}},"<a<n>:n>")),se.bind("count",H(function(e){return void 0===e?0:e.length},"<a:n>")),se.bind("max",H(function(e){if(void 0!==e&&0!==e.length)return Math.max.apply(Math,e)},"<a<n>:n>")),se.bind("min",H(function(e){if(void 0!==e&&0!==e.length)return Math.min.apply(Math,e)},"<a<n>:n>")),se.bind("average",H(function(e){if(void 0!==e&&0!==e.length){var r=0;return e.forEach(function(e){r+=e}),r/e.length}},"<a<n>:n>")),se.bind("string",H(Q,"<x-:s>")),se.bind("substring",H(function(e,r,t){if(void 0!==e)return e.substr(r,t)},"<s-nn?:s>")),se.bind("substringBefore",H(function(e,r){if(void 0!==e){var t=e.indexOf(r);return t>-1?e.substr(0,t):e}},"<s-s:s>")),se.bind("substringAfter",H(function(e,r){if(void 0!==e){var t=e.indexOf(r);return t>-1?e.substr(t+r.length):e}},"<s-s:s>")),se.bind("lowercase",H(function(e){if(void 0!==e)return e.toLowerCase()},"<s-:s>")),se.bind("uppercase",H(function(e){if(void 0!==e)return e.toUpperCase()},"<s-:s>")),se.bind("length",H(function(e){if(void 0!==e)return e.length},"<s-:n>")),se.bind("trim",H(function(e){if(void 0!==e){var r=e.replace(/[ \t\n\r]+/gm," ");return" "===r.charAt(0)&&(r=r.substring(1))," "===r.charAt(r.length-1)&&(r=r.substring(0,r.length-1)),r}},"<s-:s>")),se.bind("match",H(function(e,r,t){if(void 0!==e){if(t<0)throw{stack:(new Error).stack,value:t,code:"D3040",index:3};var n=[];if(void 0===t||t>0){var i=0,a=r(e);if(void 0!==a)for(;void 0!==a&&(void 0===t||i<t);)n.push({match:a.match,index:a.start,groups:a.groups}),a=a.next(),i++}return n}},"<s-f<s:o>n?:a<o>>")),se.bind("contains",H(function(e,r){if(void 0!==e)return"string"==typeof r?-1!==e.indexOf(r):void 0!==r(e)},"<s-(sf):b>")),se.bind("replace",H(function*(e,r,t,n){if(void 0!==e){if(""===r)throw{code:"D3010",stack:(new Error).stack,value:r,index:2};if(n<0)throw{code:"D3011",stack:(new Error).stack,value:n,index:4};var i;i="string"==typeof t?function(e){for(var r="",n=0,i=t.indexOf("$",n);-1!==i&&n<t.length;){r+=t.substring(n,i),n=i+1;var a=t.charAt(n);if("$"===a)r+="$",n++;else if("0"===a)r+=e.match,n++;else{var o;if(o=0===e.groups.length?1:Math.floor(Math.log(e.groups.length)*Math.LOG10E)+1,i=parseInt(t.substring(n,n+o),10),o>1&&i>e.groups.length&&(i=parseInt(t.substring(n,n+o-1),10)),isNaN(i))r+="$";else{if(e.groups.length>0){var s=e.groups[i-1];void 0!==s&&(r+=s)}n+=i.toString().length}}i=t.indexOf("$",n)}return r+=t.substring(n)}:t;var a="",o=0;if(void 0===n||n>0){var s=0;if("string"==typeof r){for(var u=e.indexOf(r,o);-1!==u&&(void 0===n||s<n);)a+=e.substring(o,u),a+=t,o=u+r.length,s++,u=e.indexOf(r,o);a+=e.substring(o)}else{var c=r(e);if(void 0!==c){for(;void 0!==c&&(void 0===n||s<n);){a+=e.substring(o,c.start);var f=yield*U(i,[c],null);if("string"!=typeof f)throw{code:"D3012",stack:(new Error).stack,value:f};a+=f,o=c.start+c.match.length,s++,c=c.next()}a+=e.substring(o)}else a=e}}else a=e;return a}},"<s-(sf)(sf)n?:s>")),se.bind("split",H(function(e,r,t){if(void 0!==e){if(t<0)throw{code:"D3020",stack:(new Error).stack,value:t,index:3};var n=[];if(void 0===t||t>0)if("string"==typeof r)n=e.split(r,t);else{var i=0,a=r(e);if(void 0!==a){for(var o=0;void 0!==a&&(void 0===t||i<t);)n.push(e.substring(o,a.start)),o=a.end,a=a.next(),i++;(void 0===t||i<t)&&n.push(e.substring(o))}else n=[e]}return n}},"<s-(sf)n?:a<s>>")),se.bind("join",H(function(e,r){if(void 0!==e)return void 0===r&&(r=""),e.join(r)},"<a<s>s?:s>")),se.bind("number",H(function(e){var r;if(void 0!==e){if("number"==typeof e)r=e;else{if("string"!=typeof e||!/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(e)||isNaN(parseFloat(e))||!isFinite(e))throw{code:"D3030",value:e,stack:(new Error).stack,index:1};r=parseFloat(e)}return r}},"<(ns)-:n>")),se.bind("floor",H(function(e){if(void 0!==e)return Math.floor(e)},"<n-:n>")),se.bind("ceil",H(function(e){if(void 0!==e)return Math.ceil(e)},"<n-:n>")),se.bind("round",H(function(e,r){var t;if(void 0!==e){if(r){var n=e.toString().split("e");e=+(n[0]+"e"+(n[1]?+n[1]+r:r))}var i=(t=Math.round(e))-e;return.5===Math.abs(i)&&1===Math.abs(t%2)&&(t-=1),r&&(t=+((n=t.toString().split("e"))[0]+"e"+(n[1]?+n[1]-r:-r))),Object.is(t,-0)&&(t=0),t}},"<n-n?:n>")),se.bind("abs",H(function(e){if(void 0!==e)return Math.abs(e)},"<n-:n>")),se.bind("sqrt",H(function(e){if(void 0!==e){if(e<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:e};return Math.sqrt(e)}},"<n-:n>")),se.bind("power",H(function(e,r){var t;if(void 0!==e){if(t=Math.pow(e,r),!isFinite(t))throw{stack:(new Error).stack,code:"D3061",index:1,value:e,exp:r};return t}},"<n-n:n>")),se.bind("random",H(function(){return Math.random()},"<:n>")),se.bind("boolean",H(V,"<x-:b>")),se.bind("not",H(function(e){return!V(e)},"<x-:b>")),se.bind("map",H(function*(e,r){if(void 0!==e){for(var t=[],n=0;n<e.length;n++){var i=[e[n]],a="function"==typeof r?r.length:!0===r._jsonata_function?r.implementation.length:r.arguments.length;a>=2&&i.push(n),a>=3&&i.push(e);var o=yield*U(r,i,null);void 0!==o&&t.push(o)}return t}},"<af>")),se.bind("zip",H(function(){for(var e=[],r=Array.prototype.slice.call(arguments),t=Math.min.apply(Math,r.map(function(e){return Array.isArray(e)?e.length:0})),n=0;n<t;n++){var i=r.map(e=>e[n]);e.push(i)}return e},"<a+>")),se.bind("filter",H(function*(e,r){if(void 0!==e){for(var t=[],n=0;n<e.length;n++){var i=e[n];V(function(e,t,n){for(var i=U(r,[e,t,n],null),a=i.next();!a.done;)a=i.next(a.value);return a.value}(i,n,e))&&t.push(i)}return t}},"<af>")),se.bind("reduce",H(function*(e,r,t){if(void 0!==e){var n;if(2!==r.length&&(!0!==r._jsonata_function||2!==r.implementation.length)&&2!==r.arguments.length)throw{stack:(new Error).stack,code:"D3050",index:1};var i;for(void 0===t&&e.length>0?(n=e[0],i=1):(n=t,i=0);i<e.length;)n=yield*U(r,[n,e[i]],null),i++;return n}},"<afj?:j>")),se.bind("sift",H(function(e,r){var t={};for(var n in e){var i=e[n];V(function(e,t,n){for(var i=U(r,[e,t,n],null),a=i.next();!a.done;)a=i.next(a.value);return a.value}(i,n,e))&&(t[n]=i)}return 0===Object.keys(t).length&&(t=void 0),t},"<o-f?:o>")),se.bind("keys",H(W,"<x-:a<s>>")),se.bind("lookup",H(function(e,r){return p({value:r},e)},"<x-s:x>")),se.bind("append",H(X,"<xx:a>")),se.bind("exists",H(function(e){return void 0!==e},"<x:b>")),se.bind("spread",H(Y,"<x-:a<o>>")),se.bind("reverse",H(function(e){if(void 0!==e){if(e.length<=1)return e;for(var r=e.length,t=new Array(r),n=0;n<r;n++)t[r-n-1]=e[n];return t}},"<a:a>")),se.bind("each",H(function*(e,r){var t=[];for(var n in e){var i=[e[n],n];t.push(yield*U(r,i,null))}return t},"<o-f:a>")),se.bind("sort",H(Z,"<af?:a>")),se.bind("shuffle",H(function(e){if(void 0!==e){if(e.length<=1)return e;for(var r=new Array(e.length),t=0;t<e.length;t++){var n=Math.floor(Math.random()*(t+1));t!==n&&(r[t]=r[n]),r[n]=e[t]}return r}},"<a:a>")),se.bind("base64encode",H(function(e){if(void 0!==e)return("undefined"!=typeof window?window.btoa:function(e){return new global.Buffer(e,"binary").toString("base64")})(e)},"<s-:s>")),se.bind("base64decode",H(function(e){if(void 0!==e)return("undefined"!=typeof window?window.atob:function(e){return new global.Buffer(e,"base64").toString("binary")})(e)},"<s-:s>"));var ce={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0203:"Expected {{value}} before end of expression",S0202:"Expected {{value}}, got {{token}}",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0201:"Syntax error: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T1003:"Key in object structure must evaluate to a string; got: {{value}}",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",D1004:"Regular expression matches zero length string",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"First argument of reduce function must be a function with two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function"};return te.parser=oe,te}();"undefined"!=typeof module&&(module.exports=jsonata);
{
"name": "jsonata",
"version": "1.2.4",
"version": "1.2.5",
"description": "JSON query and transformation language",

@@ -38,16 +38,16 @@ "main": "jsonata.js",

"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.4.0",
"babel-preset-env": "^1.5.2",
"babel-runtime": "^6.23.0",
"browserify": "^14.3.0",
"browserify": "^14.4.0",
"chai": "^3.4.1",
"chai-as-promised": "^6.0.0",
"coveralls": "^2.11.14",
"eslint": "^2.0.0",
"eslint": "^4.0.0",
"eslint-plugin-ideal": "^0.1.3",
"istanbul": "^0.4.5",
"jsdoc": "^3.4.0",
"mocha": "^3.0.2",
"mocha": "^3.4.2",
"mocha-lcov-reporter": "^1.2.0",
"request": "^2.81.0",
"uglify-es": "^3.0.4"
"uglify-es": "^3.0.20"
},

@@ -54,0 +54,0 @@ "engines": {

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

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

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

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