yaml-flow 5.4.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/board-live-cards-cli.js +2 -2
- package/board-livecards-server-runtime.js +488 -551
- package/browser/asset-integrity.json +10 -0
- package/browser/board-livecards-runtime-client.js +0 -6
- package/browser/board-livegraph-engine.js +2 -1676
- package/browser/board-livegraph-engine.js.map +1 -1
- package/browser/live-cards.js +347 -26
- package/browser/live-cards.schema.json +418 -132
- package/card-store.js +37 -0
- package/dist/batch/index.cjs +1 -108
- package/dist/batch/index.cjs.map +1 -1
- package/dist/batch/index.js +1 -106
- package/dist/batch/index.js.map +1 -1
- package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
- package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
- package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
- package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
- package/dist/board-livegraph-runtime/index.cjs +2 -1671
- package/dist/board-livegraph-runtime/index.cjs.map +1 -1
- package/dist/board-livegraph-runtime/index.d.cts +1 -2
- package/dist/board-livegraph-runtime/index.d.ts +1 -2
- package/dist/board-livegraph-runtime/index.js +2 -1662
- package/dist/board-livegraph-runtime/index.js.map +1 -1
- package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
- package/dist/card-compute/index.cjs +9 -7159
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +22 -0
- package/dist/card-compute/index.d.ts +22 -0
- package/dist/card-compute/index.js +9 -7145
- package/dist/card-compute/index.js.map +1 -1
- package/dist/card-compute/jsonata-sync.cjs +7587 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.js +2 -0
- package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
- package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
- package/dist/cli/node/artifacts-store-cli.cjs +11 -0
- package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
- package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
- package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
- package/dist/cli/node/artifacts-store-cli.js +11 -0
- package/dist/cli/node/artifacts-store-cli.js.map +1 -0
- package/dist/cli/node/board-live-cards-cli.cjs +15 -0
- package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
- package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
- package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
- package/dist/cli/node/board-live-cards-cli.js +15 -0
- package/dist/cli/node/board-live-cards-cli.js.map +1 -0
- package/dist/cli/node/card-store-cli.cjs +8 -0
- package/dist/cli/node/card-store-cli.cjs.map +1 -0
- package/dist/cli/node/card-store-cli.d.cts +15 -0
- package/dist/cli/node/card-store-cli.d.ts +15 -0
- package/dist/cli/node/card-store-cli.js +8 -0
- package/dist/cli/node/card-store-cli.js.map +1 -0
- package/dist/cli/node/fs-board-adapter.cjs +14 -0
- package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
- package/dist/cli/node/fs-board-adapter.d.cts +204 -0
- package/dist/cli/node/fs-board-adapter.d.ts +204 -0
- package/dist/cli/node/fs-board-adapter.js +14 -0
- package/dist/cli/node/fs-board-adapter.js.map +1 -0
- package/dist/cli/node/jsonata-sync.cjs +7587 -0
- package/dist/cli/node/source-cli-task-executor.cjs +11 -0
- package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
- package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
- package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
- package/dist/cli/node/source-cli-task-executor.js +11 -0
- package/dist/cli/node/source-cli-task-executor.js.map +1 -0
- package/dist/config/index.cjs +1 -79
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.js +1 -76
- package/dist/config/index.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +2 -2129
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +81 -5
- package/dist/continuous-event-graph/index.d.ts +81 -5
- package/dist/continuous-event-graph/index.js +2 -2088
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
- package/dist/event-graph/index.cjs +22 -8292
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.js +22 -8237
- package/dist/event-graph/index.js.map +1 -1
- package/dist/execution-refs.cjs +2 -0
- package/dist/execution-refs.cjs.map +1 -0
- package/dist/execution-refs.d.cts +222 -0
- package/dist/execution-refs.d.ts +222 -0
- package/dist/execution-refs.js +2 -0
- package/dist/execution-refs.js.map +1 -0
- package/dist/index.cjs +29 -13221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +29 -13112
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +5 -617
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.js +5 -610
- package/dist/inference/index.js.map +1 -1
- package/dist/jsonata-sync.cjs +7587 -0
- package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
- package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
- package/dist/pycli/quickjs-board-runtime.global.js +9 -0
- package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
- package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
- package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
- package/dist/step-machine/index.cjs +11 -7129
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.js +11 -7113
- package/dist/step-machine/index.js.map +1 -1
- package/dist/storage-refs.cjs +10 -0
- package/dist/storage-refs.cjs.map +1 -0
- package/dist/storage-refs.d.cts +92 -0
- package/dist/storage-refs.d.ts +92 -0
- package/dist/storage-refs.js +10 -0
- package/dist/storage-refs.js.map +1 -0
- package/dist/stores/file.cjs +1 -114
- package/dist/stores/file.cjs.map +1 -1
- package/dist/stores/file.js +1 -112
- package/dist/stores/file.js.map +1 -1
- package/dist/stores/index.cjs +1 -231
- package/dist/stores/index.cjs.map +1 -1
- package/dist/stores/index.js +1 -227
- package/dist/stores/index.js.map +1 -1
- package/dist/stores/localStorage.cjs +1 -76
- package/dist/stores/localStorage.cjs.map +1 -1
- package/dist/stores/localStorage.js +1 -74
- package/dist/stores/localStorage.js.map +1 -1
- package/dist/stores/memory.cjs +1 -47
- package/dist/stores/memory.cjs.map +1 -1
- package/dist/stores/memory.js +1 -45
- package/dist/stores/memory.js.map +1 -1
- package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
- package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/examples/example-board/agent-instructions.md +11 -5
- package/examples/example-board/demo-chat-handler.js +14 -4
- package/examples/example-board/demo-server-config.json +1 -0
- package/examples/example-board/demo-server.js +19 -34
- package/examples/example-board/demo-shell-browser.html +5 -4
- package/examples/example-board/demo-shell-with-server.html +10 -6
- package/examples/example-board/demo-task-executor.js +81 -35
- package/examples/index.html +0 -14
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/package.json +39 -3
- package/schema/live-cards.schema.json +418 -132
- package/dist/cli/board-live-cards-cli.cjs +0 -10644
- package/dist/cli/board-live-cards-cli.cjs.map +0 -1
- package/dist/cli/board-live-cards-cli.d.cts +0 -179
- package/dist/cli/board-live-cards-cli.d.ts +0 -179
- package/dist/cli/board-live-cards-cli.js +0 -10592
- package/dist/cli/board-live-cards-cli.js.map +0 -1
- package/dist/journal-9HEgs7dU.d.ts +0 -28
- package/dist/journal-B-JCfQnh.d.cts +0 -28
- package/dist/schedule-Cszq9LYY.d.ts +0 -21
- package/dist/schedule-qWNL0RQh.d.cts +0 -21
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
- package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(function(){'use strict';var Kn=Object.create;var Jt=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var Qn=(c,d,h)=>d in c?Jt(c,d,{enumerable:true,configurable:true,writable:true,value:h}):c[d]=h;var bt=(c=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(c,{get:(d,h)=>(typeof require<"u"?require:d)[h]}):c)(function(c){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+c+'" is not supported')});var an=(c,d)=>()=>(d||c((d={exports:{}}).exports,d),d.exports);var er=(c,d,h,b)=>{if(d&&typeof d=="object"||typeof d=="function")for(let C of Wn(d))!Zn.call(c,C)&&C!==h&&Jt(c,C,{get:()=>d[C],enumerable:!(b=Yn(d,C))||b.enumerable});return c};var Kt=(c,d,h)=>(h=c!=null?Kn(Xn(c)):{},er(Jt(h,"default",{value:c,enumerable:true}),c));var sn=(c,d,h)=>Qn(c,d+"",h);var tn=an((Cn,en)=>{(function(c){if(typeof Cn=="object"&&typeof en<"u")en.exports=c();else if(typeof define=="function"&&define.amd)define([],c);else {var d;typeof window<"u"?d=window:typeof global<"u"?d=global:typeof self<"u"?d=self:d=this,d.jsonata=c();}})(function(){return (function(){function b(C,x,F){function m(ee,ie){if(!x[ee]){if(!C[ee]){var _=typeof bt=="function"&&bt;if(!ie&&_)return _(ee,true);if(L)return L(ee,true);var k=new Error("Cannot find module '"+ee+"'");throw k.code="MODULE_NOT_FOUND",k}var w=x[ee]={exports:{}};C[ee][0].call(w.exports,function(T){var re=C[ee][1][T];return m(re||T)},w,w.exports,b,C,x,F);}return x[ee].exports}for(var L=typeof bt=="function"&&bt,ne=0;ne<F.length;ne++)m(F[ne]);return m}return b})()({1:[function(b,C,x){let F=b("./utils"),m=(function(){let L=F.stringToArray,ne=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],ee=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],ie=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],_=["Thousand","Million","Billion","Trillion"];function k(l,v){var g=function(M,P,S){var j="";if(M<=19)j=(P?" and ":"")+(S?ee[M]:ne[M]);else if(M<100){let me=Math.floor(M/10),be=M%10;j=(P?" and ":"")+ie[me-2],be>0?j+="-"+g(be,false,S):S&&(j=j.substring(0,j.length-1)+"ieth");}else if(M<1e3){let me=Math.floor(M/100),be=M%100;j=(P?", ":"")+ne[me]+" Hundred",be>0?j+=g(be,true,S):S&&(j+="th");}else {var Y=Math.floor(Math.log10(M)/3);Y>_.length&&(Y=_.length);let me=Math.pow(10,Y*3),be=Math.floor(M/me),K=M-be*me;j=(P?", ":"")+g(be,false,false)+" "+_[Y-1],K>0?j+=g(K,true,S):S&&(j+="th");}return j},E=g(l,false,v);return E}let w={};ne.forEach(function(l,v){w[l.toLowerCase()]=v;}),ee.forEach(function(l,v){w[l.toLowerCase()]=v;}),ie.forEach(function(l,v){let g=l.toLowerCase();w[g]=(v+2)*10,w[g.substring(0,l.length-1)+"ieth"]=w[g];}),w.hundredth=100,_.forEach(function(l,v){let g=l.toLowerCase(),E=Math.pow(10,(v+1)*3);w[g]=E,w[g+"th"]=E;});function T(l){let g=l.split(/,\s|\sand\s|[\s\\-]/).map(P=>w[P]),E=[0];return g.forEach(P=>{if(P<100){let S=E.pop();S>=1e3&&(E.push(S),S=0),E.push(S+P);}else E.push(E.pop()*P);}),E.reduce((P,S)=>P+S,0)}let re=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],ce={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function z(l){for(var v=0;v<re.length;v++){let g=re[v];if(l>=g[0])return g[1]+z(l-g[0])}return ""}function q(l){for(var v=0,g=1,E=l.length-1;E>=0;E--){let M=l[E],P=ce[M];P<g?v-=P:(g=P,v+=P);}return v}function A(l,v){for(var g=[],E=v.charCodeAt(0);l>0;)g.unshift(String.fromCharCode((l-1)%26+E)),l=Math.floor((l-1)/26);return g.join("")}function J(l,v){for(var g=v.charCodeAt(0),E=0,M=0;M<l.length;M++)E+=(l.charCodeAt(l.length-M-1)-g+1)*Math.pow(26,M);return E}function I(l,v){if(typeof l>"u")return;l=Math.floor(l);let g=ue(v);return $(l,g)}let p={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},R={UPPER:"upper",LOWER:"lower",TITLE:"title"};function $(l,v){let g,E=l<0;switch(l=Math.abs(l),v.primary){case p.LETTERS:g=A(l,v.case===R.UPPER?"A":"a");break;case p.ROMAN:g=z(l),v.case===R.UPPER&&(g=g.toUpperCase());break;case p.WORDS:g=k(l,v.ordinal),v.case===R.UPPER?g=g.toUpperCase():v.case===R.LOWER&&(g=g.toLowerCase());break;case p.DECIMAL:g=""+l;var M=v.mandatoryDigits-g.length;if(M>0){var P=new Array(M+1).join("0");g=P+g;}if(v.zeroCode!==48&&(g=L(g).map(me=>String.fromCodePoint(me.codePointAt(0)+v.zeroCode-48)).join("")),v.regular){let me=Math.floor((g.length-1)/v.groupingSeparators.position);for(let be=me;be>0;be--){let K=g.length-be*v.groupingSeparators.position;g=g.substr(0,K)+v.groupingSeparators.character+g.substr(K);}}else v.groupingSeparators.reverse().forEach(me=>{let be=g.length-me.position;g=g.substr(0,be)+me.character+g.substr(be);});if(v.ordinal){var S={1:"st",2:"nd",3:"rd"},j=g[g.length-1],Y=S[j];(!Y||g.length>1&&g[g.length-2]==="1")&&(Y="th"),g=g+Y;}break;case p.SEQUENCE:throw {code:"D3130",value:v.token}}return E&&(g="-"+g),g}let Z=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function ue(l){let v={type:"integer",primary:p.DECIMAL,case:R.LOWER,ordinal:false},g,E,M=l.lastIndexOf(";");switch(M===-1?g=l:(g=l.substring(0,M),E=l.substring(M+1),E[0]==="o"&&(v.ordinal=true)),g){case "A":v.case=R.UPPER;case "a":v.primary=p.LETTERS;break;case "I":v.case=R.UPPER;case "i":v.primary=p.ROMAN;break;case "W":v.case=R.UPPER,v.primary=p.WORDS;break;case "Ww":v.case=R.TITLE,v.primary=p.WORDS;break;case "w":v.primary=p.WORDS;break;default:{let P=null,S=0,j=0,Y=[],me=0;if(L(g).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let X=false;for(let de=0;de<Z.length;de++){let H=Z[de];if(K>=H&&K<=H+9){if(X=true,S++,me++,P===null)P=H;else if(H!==P)throw {code:"D3131"};break}}X||(K===35?(me++,j++):Y.push({position:me,character:String.fromCodePoint(K)}));}),S>0){v.primary=p.DECIMAL,v.zeroCode=P,v.mandatoryDigits=S,v.optionalDigits=j;let X=function(de){if(de.length===0)return 0;let H=de[0].character;for(let te=1;te<de.length;te++)if(de[te].character!==H)return 0;let Ie=de.map(te=>te.position),Ge=function(te,ge){return ge===0?te:Ge(ge,te%ge)},Ne=Ie.reduce(Ge);for(let te=1;te<=Ie.length;te++)if(Ie.indexOf(te*Ne)===-1)return 0;return Ne}(Y);X>0?(v.regular=true,v.groupingSeparators={position:X,character:Y[0].character}):(v.regular=false,v.groupingSeparators=Y);}else v.primary=p.SEQUENCE,v.token=g;}}return v}let fe={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function le(l){var v=[];let g={type:"datetime",parts:v},E=function(X,de){if(de>X){let H=l.substring(X,de);H=H.split("]]").join("]"),v.push({type:"literal",value:H});}};for(var M=0,P=0;P<l.length;){if(l.charAt(P)==="["){if(l.charAt(P+1)==="["){E(M,P),v.push({type:"literal",value:"["}),P+=2,M=P;continue}if(E(M,P),M=P,P=l.indexOf("]",M),P===-1)throw {code:"D3135"};let X=l.substring(M+1,P);X=X.split(/\s+/).join("");var S={type:"marker",component:X.charAt(0)},j=X.lastIndexOf(","),Y;if(j!==-1){let de=X.substring(j+1),H=de.indexOf("-"),Ie,Ge,Ne=function(ge){if(!(typeof ge>"u"||ge==="*"))return parseInt(ge)};H===-1?Ie=de:(Ie=de.substring(0,H),Ge=de.substring(H+1));let te={min:Ne(Ie),max:Ne(Ge)};S.width=te,Y=X.substring(1,j);}else Y=X.substring(1);if(Y.length===1)S.presentation1=Y;else if(Y.length>1){var me=Y.charAt(Y.length-1);"atco".indexOf(me)!==-1?(S.presentation2=me,me==="o"&&(S.ordinal=true),S.presentation1=Y.substring(0,Y.length-1)):S.presentation1=Y;}else S.presentation1=fe[S.component];if(typeof S.presentation1>"u")throw {code:"D3132",value:S.component};if(S.presentation1[0]==="n")S.names=R.LOWER;else if(S.presentation1[0]==="N")S.presentation1[1]==="n"?S.names=R.TITLE:S.names=R.UPPER;else if("YMDdFWwXxHhmsf".indexOf(S.component)!==-1){var be=S.presentation1;if(S.presentation2&&(be+=";"+S.presentation2),S.integerFormat=ue(be),S.width&&S.width.min!==void 0&&S.integerFormat.mandatoryDigits<S.width.min&&(S.integerFormat.mandatoryDigits=S.width.min),S.component==="Y")if(S.n=-1,S.width&&S.width.max!==void 0)S.n=S.width.max,S.integerFormat.mandatoryDigits=S.n;else {var K=S.integerFormat.mandatoryDigits+S.integerFormat.optionalDigits;K>=2&&(S.n=K);}let de=v[v.length-1];de&&de.integerFormat&&(de.integerFormat.parseWidth=de.integerFormat.mandatoryDigits);}(S.component==="Z"||S.component==="z")&&(S.integerFormat=ue(S.presentation1)),v.push(S),M=P+1;}P++;}return E(M,P),g}let pe=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],xe=["January","February","March","April","May","June","July","August","September","October","November","December"],qe=1e3*60*60*24,ve=function(l){let v=Date.UTC(l.year,l.month);var g=new Date(v).getUTCDay();return g===0&&(g=7),g>4?v+(8-g)*qe:v-(g-1)*qe},D=function(l,v){return {year:l,month:v,nextMonth:function(){return v===11?D(l+1,0):D(l,v+1)},previousMonth:function(){return v===0?D(l-1,11):D(l,v-1)},nextYear:function(){return D(l+1,v)},previousYear:function(){return D(l-1,v)}}},N=function(l,v){return (v-l)/(qe*7)+1},U=(l,v)=>{let g;switch(v){case "Y":g=l.getUTCFullYear();break;case "M":g=l.getUTCMonth()+1;break;case "D":g=l.getUTCDate();break;case "d":{let E=Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),M=Date.UTC(l.getUTCFullYear(),0);g=(E-M)/qe+1;break}case "F":g=l.getUTCDay(),g===0&&(g=7);break;case "W":{let E=D(l.getUTCFullYear(),0),M=ve(E),P=Date.UTC(E.year,l.getUTCMonth(),l.getUTCDate()),S=N(M,P);if(S>52){let j=ve(E.nextYear());P>=j&&(S=1);}else if(S<1){let j=ve(E.previousYear());S=N(j,P);}g=Math.floor(S);break}case "w":{let E=D(l.getUTCFullYear(),l.getUTCMonth()),M=ve(E),P=Date.UTC(E.year,E.month,l.getUTCDate()),S=N(M,P);if(S>4){let j=ve(E.nextMonth());P>=j&&(S=1);}else if(S<1){let j=ve(E.previousMonth());S=N(j,P);}g=Math.floor(S);break}case "X":{let E=D(l.getUTCFullYear(),0),M=ve(E),P=ve(E.nextYear()),S=l.getTime();S<M?g=E.year-1:S>=P?g=E.year+1:g=E.year;break}case "x":{let E=D(l.getUTCFullYear(),l.getUTCMonth()),M=ve(E),P=E.nextMonth(),S=ve(P),j=l.getTime();j<M?g=E.previousMonth().month+1:j>=S?g=P.month+1:g=E.month+1;break}case "H":g=l.getUTCHours();break;case "h":g=l.getUTCHours(),g=g%12,g===0&&(g=12);break;case "P":g=l.getUTCHours()>=12?"pm":"am";break;case "m":g=l.getUTCMinutes();break;case "s":g=l.getUTCSeconds();break;case "f":g=l.getUTCMilliseconds();break;case "Z":case "z":break;case "C":g="ISO";break;case "E":g="ISO";break}return g},oe=null;function Ce(l,v,g){var E=0,M=0;if(typeof g<"u"){let be=parseInt(g);E=Math.floor(be/100),M=be%100;}var P=function(be,K){var X=U(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(X=X%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")X=xe[X-1];else if(K.component==="F")X=pe[X];else throw {code:"D3133",value:K.component};K.names===R.UPPER?X=X.toUpperCase():K.names===R.LOWER&&(X=X.toLowerCase()),K.width&&X.length>K.width.max&&(X=X.substring(0,K.width.max));}else X=$(X,K.integerFormat);else if(K.component==="f")X=$(X,K.integerFormat);else if(K.component==="Z"||K.component==="z"){let de=E*100+M;if(K.integerFormat.regular)X=$(de,K.integerFormat);else {let H=K.integerFormat.mandatoryDigits;if(H===1||H===2)X=$(E,K.integerFormat),M!==0&&(X+=":"+I(M,"00"));else if(H===3||H===4)X=$(de,K.integerFormat);else throw {code:"D3134",value:H}}de>=0&&(X="+"+X),K.component==="z"&&(X="GMT"+X),de===0&&K.presentation2==="t"&&(X="Z");}else K.component==="P"&&K.names===R.UPPER&&(X=X.toUpperCase());return X};let S;typeof v>"u"?(oe===null&&(oe=le("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),S=oe):S=le(v);let j=(60*E+M)*60*1e3,Y=new Date(l+j),me="";return S.parts.forEach(function(be){be.type==="literal"?me+=be.value:me+=P(Y,be);}),me}function o(l){var v={};if(l.type==="datetime")v.type="datetime",v.parts=l.parts.map(function(g){var E={};if(g.type==="literal")E.regex=g.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(g.component==="Z"||g.component==="z"){let P;Array.isArray(g.integerFormat.groupingSeparators)||(P=g.integerFormat.groupingSeparators),E.regex="",g.component==="z"&&(E.regex="GMT"),E.regex+="[-+][0-9]+",P&&(E.regex+=P.character+"[0-9]+"),E.parse=function(S){g.component==="z"&&(S=S.substring(3));let j=0,Y=0;return P?(j=Number.parseInt(S.substring(0,S.indexOf(P.character))),Y=Number.parseInt(S.substring(S.indexOf(P.character)+1))):S.length-1<=2?j=Number.parseInt(S):(j=Number.parseInt(S.substring(0,3)),Y=Number.parseInt(S.substring(3))),j*60+Y};}else if(g.integerFormat)E=o(g.integerFormat);else {E.regex="[a-zA-Z]+";var M={};if(g.component==="M"||g.component==="x")xe.forEach(function(P,S){g.width&&g.width.max?M[P.substring(0,g.width.max)]=S+1:M[P]=S+1;});else if(g.component==="F")pe.forEach(function(P,S){S>0&&(g.width&&g.width.max?M[P.substring(0,g.width.max)]=S:M[P]=S);});else if(g.component==="P")M={am:0,AM:0,pm:1,PM:1};else throw {code:"D3133",value:g.component};E.parse=function(P){return M[P]};}return E.component=g.component,E});else {v.type="integer";let g=l.case===R.UPPER;switch(l.primary){case p.LETTERS:v.regex=g?"[A-Z]+":"[a-z]+",v.parse=function(E){return J(E,g?"A":"a")};break;case p.ROMAN:v.regex=g?"[MDCLXVI]+":"[mdclxvi]+",v.parse=function(E){return q(g?E:E.toUpperCase())};break;case p.WORDS:v.regex="(?:"+Object.keys(w).concat("and","[\\-, ]").join("|")+")+",v.parse=function(E){return T(E.toLowerCase())};break;case p.DECIMAL:v.regex="[0-9]",l.parseWidth?v.regex+=`{${l.parseWidth}}`:v.regex+="+",l.ordinal&&(v.regex+="(?:th|st|nd|rd)"),v.parse=function(E){let M=E;return l.ordinal&&(M=E.substring(0,E.length-2)),l.regular?M=M.split(",").join(""):l.groupingSeparators.forEach(P=>{M=M.split(P.character).join("");}),l.zeroCode!==48&&(M=M.split("").map(P=>String.fromCodePoint(P.codePointAt(0)-l.zeroCode+48)).join("")),parseInt(M)};break;case p.SEQUENCE:throw {code:"D3130",value:l.token}}}return v}function u(l,v){if(typeof l>"u")return;let g=ue(v);return o(g).parse(l)}function B(l,v){let g=le(v),E=o(g),M="^"+E.parts.map(Y=>"("+Y.regex+")").join("")+"$";var S=new RegExp(M,"i").exec(l);if(S!==null){let H={};for(let Ae=1;Ae<S.length;Ae++){let n=E.parts[Ae-1];n.parse&&(H[n.component]=n.parse(S[Ae]));}if(Object.getOwnPropertyNames(H).length===0)return;let Ie=0,Ge=Ae=>{Ie<<=1,Ie+=Ae?1:0;},Ne=Ae=>!(~Ae&Ie)&&!!(Ae&Ie);"YXMxWwdD".split("").forEach(Ae=>Ge(H[Ae]));let ge=!Ne(161)&&Ne(130),Fe=Ne(84),Ke=!Fe&&Ne(72);Ie=0,"PHhmsf".split("").forEach(Ae=>Ge(H[Ae]));let Xe=!Ne(23)&&Ne(47),ht=(ge?"YD":Fe?"XxwF":Ke?"XWF":"YMD")+(Xe?"Phmsf":"Hmsf"),Ye=this.environment.timestamp,ut=false,Ze=false;if(ht.split("").forEach(Ae=>{if(typeof H[Ae]>"u")ut?(H[Ae]="MDd".indexOf(Ae)!==-1?1:0,Ze=true):H[Ae]=U(Ye,Ae);else if(ut=true,Ze)throw {code:"D3136"}}),H.M>0?H.M-=1:H.M=0,ge){let Ae=Date.UTC(H.Y,0),n=(H.d-1)*1e3*60*60*24,a=new Date(Ae+n);H.M=a.getUTCMonth(),H.D=a.getUTCDate();}if(Fe)throw {code:"D3136"};if(Ke)throw {code:"D3136"};Xe&&(H.H=H.h===12?0:H.h,H.P===1&&(H.H+=12));var j=Date.UTC(H.Y,H.M,H.D,H.H,H.m,H.s,H.f);return (H.Z||H.z)&&(j-=(H.Z||H.z)*60*1e3),j}}var ae=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function we(l,v){if(!(typeof l>"u"))if(typeof v>"u"){if(!ae.test(l))throw {stack:new Error().stack,code:"D3110",value:l};return Date.parse(l)}else return B.call(this,l,v)}function ye(l,v,g){if(!(typeof l>"u"))return Ce.call(this,l,v,g)}return {formatInteger:I,parseInteger:u,fromMillis:ye,toMillis:we}})();C.exports=m;},{"./utils":6}],2:[function(b,C,x){(function(F){(function(){var m=b("./utils");let L=(()=>{var ne=m.isNumeric,ee=m.isArrayOfStrings,ie=m.isArrayOfNumbers,_=m.createSequence,k=m.isSequence,w=m.isFunction,T=m.isLambda,re=m.isPromise,ce=m.getFunctionArity,z=m.isDeepEqual,q=m.stringToArray;function A(e){if(!(typeof e>"u")){var t=0;return e.forEach(function(r){t+=r;}),t}}function J(e){return typeof e>"u"?0:e.length}function I(e){if(!(typeof e>"u"||e.length===0))return Math.max.apply(Math,e)}function p(e){if(!(typeof e>"u"||e.length===0))return Math.min.apply(Math,e)}function R(e){if(!(typeof e>"u"||e.length===0)){var t=0;return e.forEach(function(r){t+=r;}),t/e.length}}function $(e,t=false){if(!(typeof e>"u")){var r;if(typeof e=="string")r=e;else if(w(e))r="";else {if(typeof e=="number"&&!isFinite(e))throw {code:"D3001",value:e,stack:new Error().stack};var f=t?2:0;Array.isArray(e)&&e.outerWrapper&&(e=e[0]),r=JSON.stringify(e,function(s,y){return typeof y<"u"&&y!==null&&y.toPrecision&&ne(y)?Number(y.toPrecision(15)):y&&w(y)?"":y},f);}return r}}function Z(e,t,r){if(!(typeof e>"u")){var f=q(e),s=f.length;if(s+t<0&&(t=0),typeof r<"u"){if(r<=0)return "";var y=t>=0?t+r:s+t+r;return f.slice(t,y).join("")}return f.slice(t).join("")}}function ue(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(0,r):e}}function fe(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(r+t.length):e}}function le(e){if(!(typeof e>"u"))return e.toLowerCase()}function pe(e){if(!(typeof e>"u"))return e.toUpperCase()}function xe(e){if(!(typeof e>"u"))return q(e).length}function qe(e){if(!(typeof e>"u")){var t=e.replace(/[ \t\n\r]+/gm," ");return t.charAt(0)===" "&&(t=t.substring(1)),t.charAt(t.length-1)===" "&&(t=t.substring(0,t.length-1)),t}}function ve(e,t,r){if(!(typeof e>"u")){(typeof r>"u"||r.length===0)&&(r=" ");var f;t=Math.trunc(t);var s=Math.abs(t)-xe(e);if(s>0){var y=new Array(s+1).join(r);r.length>1&&(y=Z(y,0,s)),t>0?f=e+y:f=y+e;}else f=e;return f}}async function D(e,t){var r=e.apply(this,[t]);if(re(r)&&(r=await r),r&&!(typeof r.start=="number"||r.end==="number"||Array.isArray(r.groups)||w(r.next)))throw {code:"T1010",stack:new Error().stack};return r}async function N(e,t){if(!(typeof e>"u")){var r;if(typeof t=="string")r=e.indexOf(t)!==-1;else {var f=await D(t,e);r=typeof f<"u";}return r}}async function U(e,t,r){if(!(typeof e>"u")){if(r<0)throw {stack:new Error().stack,value:r,code:"D3040",index:3};var f=_();if(typeof r>"u"||r>0){var s=0,y=await D(t,e);if(typeof y<"u")for(;typeof y<"u"&&(typeof r>"u"||s<r);)f.push({match:y.match,index:y.start,groups:y.groups}),y=await D(y.next),s++;}return f}}async function oe(e,t,r,f){if(!(typeof e>"u")){var s=this;if(t==="")throw {code:"D3010",stack:new Error().stack,value:t,index:2};if(f<0)throw {code:"D3011",stack:new Error().stack,value:f,index:4};var y;typeof r=="string"?y=function(Se){for(var je="",ke=0,De=r.indexOf("$",ke);De!==-1&&ke<r.length;){je+=r.substring(ke,De),ke=De+1;var Je=r.charAt(ke);if(Je==="$")je+="$",ke++;else if(Je==="0")je+=Se.match,ke++;else {var Me;if(Se.groups.length===0?Me=1:Me=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,De=parseInt(r.substring(ke,ke+Me),10),Me>1&&De>Se.groups.length&&(De=parseInt(r.substring(ke,ke+Me-1),10)),isNaN(De))je+="$";else {if(Se.groups.length>0){var ct=Se.groups[De-1];typeof ct<"u"&&(je+=ct);}ke+=De.toString().length;}}De=r.indexOf("$",ke);}return je+=r.substring(ke),je}:y=r;var O="",V=0;if(typeof f>"u"||f>0){var W=0;if(typeof t=="string"){for(var Ee=e.indexOf(t,V);Ee!==-1&&(typeof f>"u"||W<f);)O+=e.substring(V,Ee),O+=r,V=Ee+t.length,W++,Ee=e.indexOf(t,V);O+=e.substring(V);}else {var he=await D(t,e);if(typeof he<"u"){for(;typeof he<"u"&&(typeof f>"u"||W<f);){O+=e.substring(V,he.start);var Te=y.apply(s,[he]);if(re(Te)&&(Te=await Te),typeof Te=="string")O+=Te;else throw {code:"D3012",stack:new Error().stack,value:Te};V=he.start+he.match.length,W++,he=await D(he.next);}O+=e.substring(V);}else O=e;}}else O=e;return O}}function Ce(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.btoa:function(r){return new F.Buffer.from(r,"binary").toString("base64")};return t(e)}}function o(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.atob:function(r){return new F.Buffer.from(r,"base64").toString("binary")};return t(e)}}function u(e){if(!(typeof e>"u")){var t;try{t=encodeURIComponent(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrlComponent"}}return t}}function B(e){if(!(typeof e>"u")){var t;try{t=encodeURI(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrl"}}return t}}function ae(e){if(!(typeof e>"u")){var t;try{t=decodeURIComponent(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrlComponent"}}return t}}function we(e){if(!(typeof e>"u")){var t;try{t=decodeURI(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrl"}}return t}}async function ye(e,t,r){if(!(typeof e>"u")){if(r<0)throw {code:"D3020",stack:new Error().stack,value:r,index:3};var f=[];if(typeof r>"u"||r>0)if(typeof t=="string")f=e.split(t,r);else {var s=0,y=await D(t,e);if(typeof y<"u"){for(var O=0;typeof y<"u"&&(typeof r>"u"||s<r);)f.push(e.substring(O,y.start)),O=y.end,y=await D(y.next),s++;(typeof r>"u"||s<r)&&f.push(e.substring(O));}else f.push(e);}return f}}function l(e,t){if(!(typeof e>"u"))return typeof t>"u"&&(t=""),e.join(t)}function v(e,t,r){if(!(typeof e>"u")){var f={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"\u2030","zero-digit":"0",digit:"#","pattern-separator":";"},s=f;typeof r<"u"&&Object.keys(r).forEach(function(Q){s[Q]=r[Q];});for(var y=[],O=s["zero-digit"].charCodeAt(0),V=O;V<O+10;V++)y.push(String.fromCharCode(V));var W=y.concat([s["decimal-separator"],s["exponent-separator"],s["grouping-separator"],s.digit,s["pattern-separator"]]),Ee=t.split(s["pattern-separator"]);if(Ee.length>2)throw {code:"D3080",stack:new Error().stack};var he=function(Q){var Oe=(function(){for(var _e,ze=0;ze<Q.length;ze++)if(_e=Q.charAt(ze),W.indexOf(_e)!==-1&&_e!==s["exponent-separator"])return Q.substring(0,ze)})(),$e=(function(){for(var _e,ze=Q.length-1;ze>=0;ze--)if(_e=Q.charAt(ze),W.indexOf(_e)!==-1&&_e!==s["exponent-separator"])return Q.substring(ze+1)})(),Re=Q.substring(Oe.length,Q.length-$e.length),Be,rt,Ve,st,He=Q.indexOf(s["exponent-separator"],Oe.length);He===-1||He>Q.length-$e.length?(Be=Re,rt=void 0):(Be=Re.substring(0,He),rt=Re.substring(He+1));var We=Be.indexOf(s["decimal-separator"]);return We===-1?(Ve=Be,st=$e):(Ve=Be.substring(0,We),st=Be.substring(We+1)),{prefix:Oe,suffix:$e,activePart:Re,mantissaPart:Be,exponentPart:rt,integerPart:Ve,fractionalPart:st,subpicture:Q}},Te=function(Q){var Oe,$e,Re=Q.subpicture,Be=Re.indexOf(s["decimal-separator"]);Be!==Re.lastIndexOf(s["decimal-separator"])&&(Oe="D3081"),Re.indexOf(s.percent)!==Re.lastIndexOf(s.percent)&&(Oe="D3082"),Re.indexOf(s["per-mille"])!==Re.lastIndexOf(s["per-mille"])&&(Oe="D3083"),Re.indexOf(s.percent)!==-1&&Re.indexOf(s["per-mille"])!==-1&&(Oe="D3084");var rt=false;for($e=0;$e<Q.mantissaPart.length;$e++){var Ve=Q.mantissaPart.charAt($e);if(y.indexOf(Ve)!==-1||Ve===s.digit){rt=true;break}}rt||(Oe="D3085");var st=Q.activePart.split("").map(function(_e){return W.indexOf(_e)===-1?"p":"a"}).join("");st.indexOf("p")!==-1&&(Oe="D3086"),Be!==-1?(Re.charAt(Be-1)===s["grouping-separator"]||Re.charAt(Be+1)===s["grouping-separator"])&&(Oe="D3087"):Q.integerPart.charAt(Q.integerPart.length-1)===s["grouping-separator"]&&(Oe="D3088"),Re.indexOf(s["grouping-separator"]+s["grouping-separator"])!==-1&&(Oe="D3089");var He=Q.integerPart.indexOf(s.digit);He!==-1&&Q.integerPart.substring(0,He).split("").filter(function(_e){return y.indexOf(_e)>-1}).length>0&&(Oe="D3090"),He=Q.fractionalPart.lastIndexOf(s.digit),He!==-1&&Q.fractionalPart.substring(He).split("").filter(function(_e){return y.indexOf(_e)>-1}).length>0&&(Oe="D3091");var We=typeof Q.exponentPart=="string";if(We&&Q.exponentPart.length>0&&(Re.indexOf(s.percent)!==-1||Re.indexOf(s["per-mille"])!==-1)&&(Oe="D3092"),We&&(Q.exponentPart.length===0||Q.exponentPart.split("").filter(function(_e){return y.indexOf(_e)===-1}).length>0)&&(Oe="D3093"),Oe)throw {code:Oe,stack:new Error().stack}},Se=function(Q){var Oe=function(Ue,St){for(var vt=[],tt=Ue.indexOf(s["grouping-separator"]);tt!==-1;){var Ct=(St?Ue.substring(0,tt):Ue.substring(tt)).split("").filter(function(dt){return y.indexOf(dt)!==-1||dt===s.digit}).length;vt.push(Ct),tt=Q.integerPart.indexOf(s["grouping-separator"],tt+1);}return vt},$e=Oe(Q.integerPart),Re=function(Ue){if(Ue.length===0)return 0;for(var St=function(Ct,dt){return dt===0?Ct:St(dt,Ct%dt)},vt=Ue.reduce(St),tt=1;tt<=Ue.length;tt++)if(Ue.indexOf(tt*vt)===-1)return 0;return vt},Be=Re($e),rt=Oe(Q.fractionalPart,true),Ve=Q.integerPart.split("").filter(function(Ue){return y.indexOf(Ue)!==-1}).length,st=Ve,He=Q.fractionalPart.split(""),We=He.filter(function(Ue){return y.indexOf(Ue)!==-1}).length,_e=He.filter(function(Ue){return y.indexOf(Ue)!==-1||Ue===s.digit}).length,ze=typeof Q.exponentPart=="string";Ve===0&&_e===0&&(ze?(We=1,_e=1):Ve=1),ze&&Ve===0&&Q.integerPart.indexOf(s.digit)!==-1&&(Ve=1),Ve===0&&We===0&&(We=1);var Dt=0;return ze&&(Dt=Q.exponentPart.split("").filter(function(Ue){return y.indexOf(Ue)!==-1}).length),{integerPartGroupingPositions:$e,regularGrouping:Be,minimumIntegerPartSize:Ve,scalingFactor:st,prefix:Q.prefix,fractionalPartGroupingPositions:rt,minimumFactionalPartSize:We,maximumFactionalPartSize:_e,minimumExponentSize:Dt,suffix:Q.suffix,picture:Q.subpicture}},je=Ee.map(he);je.forEach(Te);var ke=je.map(Se),De=s["minus-sign"],Je=s["zero-digit"],Me=s["decimal-separator"],ct=s["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=De+ke[1].prefix);var Pe;e>=0?Pe=ke[0]:Pe=ke[1];var mt;Pe.picture.indexOf(s.percent)!==-1?mt=e*100:Pe.picture.indexOf(s["per-mille"])!==-1?mt=e*1e3:mt=e;var it,ft;if(Pe.minimumExponentSize===0)it=mt;else {var Bt=Math.pow(10,Pe.scalingFactor),Vt=Math.pow(10,Pe.scalingFactor-1);for(it=mt,ft=0;it<Vt;)it*=10,ft-=1;for(;it>Bt;)it/=10,ft+=1;}var Ht=j(it,Pe.maximumFactionalPartSize),Rt=function(Q,Oe){var $e=Math.abs(Q).toFixed(Oe);return Je!=="0"&&($e=$e.split("").map(function(Re){return Re>="0"&&Re<="9"?y[Re.charCodeAt(0)-48]:Re}).join("")),$e},se=Rt(Ht,Pe.maximumFactionalPartSize),Le=se.indexOf(".");for(Le===-1?se=se+Me:se=se.replace(".",Me);se.charAt(0)===Je;)se=se.substring(1);for(;se.charAt(se.length-1)===Je;)se=se.substring(0,se.length-1);Le=se.indexOf(Me);var yt=Pe.minimumIntegerPartSize-Le,Ot=Pe.minimumFactionalPartSize-(se.length-Le-1);if(se=(yt>0?new Array(yt+1).join(Je):"")+se,se=se+(Ot>0?new Array(Ot+1).join(Je):""),Le=se.indexOf(Me),Pe.regularGrouping>0)for(var zt=Math.floor((Le-1)/Pe.regularGrouping),kt=1;kt<=zt;kt++)se=[se.slice(0,Le-kt*Pe.regularGrouping),ct,se.slice(Le-kt*Pe.regularGrouping)].join("");else Pe.integerPartGroupingPositions.forEach(function(Q){se=[se.slice(0,Le-Q),ct,se.slice(Le-Q)].join(""),Le++;});if(Le=se.indexOf(Me),Pe.fractionalPartGroupingPositions.forEach(function(Q){se=[se.slice(0,Q+Le+1),ct,se.slice(Q+Le+1)].join("");}),Le=se.indexOf(Me),(Pe.picture.indexOf(Me)===-1||Le===se.length-1)&&(se=se.substring(0,se.length-1)),typeof ft<"u"){var wt=Rt(ft,0);yt=Pe.minimumExponentSize-wt.length,yt>0&&(wt=new Array(yt+1).join(Je)+wt),se=se+s["exponent-separator"]+(ft<0?De:"")+wt;}return se=Pe.prefix+se+Pe.suffix,se}}function g(e,t){if(!(typeof e>"u")){if(e=j(e),typeof t>"u"?t=10:t=j(t),t<2||t>36)throw {code:"D3100",stack:new Error().stack,value:t};var r=e.toString(t);return r}}function E(e){var t;if(!(typeof e>"u")){if(typeof e=="number")t=e;else if(typeof e=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(e)&&!isNaN(parseFloat(e))&&isFinite(e))t=parseFloat(e);else if(typeof e=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(e))t=Number(e);else if(e===true)t=1;else if(e===false)t=0;else throw {code:"D3030",value:e,stack:new Error().stack,index:1};return t}}function M(e){var t;if(!(typeof e>"u"))return t=Math.abs(e),t}function P(e){var t;if(!(typeof e>"u"))return t=Math.floor(e),t}function S(e){var t;if(!(typeof e>"u"))return t=Math.ceil(e),t}function j(e,t){var r;if(!(typeof e>"u")){if(t){var f=e.toString().split("e");e=+(f[0]+"e"+(f[1]?+f[1]+t:t));}r=Math.round(e);var s=r-e;return Math.abs(s)===.5&&Math.abs(r%2)===1&&(r=r-1),t&&(f=r.toString().split("e"),r=+(f[0]+"e"+(f[1]?+f[1]-t:-t))),Object.is(r,-0)&&(r=0),r}}function Y(e){var t;if(!(typeof e>"u")){if(e<0)throw {stack:new Error().stack,code:"D3060",index:1,value:e};return t=Math.sqrt(e),t}}function me(e,t){var r;if(!(typeof e>"u")){if(r=Math.pow(e,t),!isFinite(r))throw {stack:new Error().stack,code:"D3061",index:1,value:e,exp:t};return r}}function be(){return Math.random()}function K(e){if(!(typeof e>"u")){var t=false;if(Array.isArray(e)){if(e.length===1)t=K(e[0]);else if(e.length>1){var r=e.filter(function(f){return K(f)});t=r.length>0;}}else typeof e=="string"?e.length>0&&(t=true):ne(e)?e!==0&&(t=true):e!==null&&typeof e=="object"&&!w(e)?Object.keys(e).length>0&&(t=true):typeof e=="boolean"&&e===true&&(t=true);return t}}function X(e){if(!(typeof e>"u"))return !K(e)}function de(e,t,r,f){var s=[t],y=ce(e);return y>=2&&s.push(r),y>=3&&s.push(f),s}async function H(e,t){if(!(typeof e>"u")){for(var r=_(),f=0;f<e.length;f++){var s=de(t,e[f],f,e),y=await t.apply(this,s);typeof y<"u"&&r.push(y);}return r}}async function Ie(e,t){if(!(typeof e>"u")){for(var r=_(),f=0;f<e.length;f++){var s=e[f],y=de(t,s,f,e),O=await t.apply(this,y);K(O)&&r.push(s);}return r}}async function Ge(e,t){if(!(typeof e>"u")){for(var r=false,f,s=0;s<e.length;s++){var y=e[s],O=true;if(typeof t<"u"){var V=de(t,y,s,e),W=await t.apply(this,V);O=K(W);}if(O)if(!r)f=y,r=true;else throw {stack:new Error().stack,code:"D3138",index:s}}if(!r)throw {stack:new Error().stack,code:"D3139"};return f}}function Ne(){for(var e=[],t=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,t.map(function(y){return Array.isArray(y)?y.length:0})),f=0;f<r;f++){var s=t.map(y=>y[f]);e.push(s);}return e}async function te(e,t,r){if(!(typeof e>"u")){var f,s=ce(t);if(s<2)throw {stack:new Error().stack,code:"D3050",index:1};var y;for(typeof r>"u"&&e.length>0?(f=e[0],y=1):(f=r,y=0);y<e.length;){var O=[f,e[y]];s>=3&&O.push(y),s>=4&&O.push(e),f=await t.apply(this,O),y++;}return f}}function ge(e){var t=_();if(Array.isArray(e)){var r={};e.forEach(function(f){var s=ge(f);s.forEach(function(y){r[y]=true;});}),t=ge(r);}else e!==null&&typeof e=="object"&&!w(e)&&Object.keys(e).forEach(f=>t.push(f));return t}function Fe(e,t){var r;if(Array.isArray(e)){r=_();for(var f=0;f<e.length;f++){var s=Fe(e[f],t);typeof s<"u"&&(Array.isArray(s)?s.forEach(y=>r.push(y)):r.push(s));}}else e!==null&&typeof e=="object"&&!w(e)&&(r=e[t]);return r}function Ke(e,t){return typeof e>"u"?t:typeof t>"u"?e:(Array.isArray(e)||(e=_(e)),Array.isArray(t)||(t=[t]),e.concat(t))}function nt(e){return !(typeof e>"u")}function Xe(e){var t=_();if(Array.isArray(e))e.forEach(function(s){t=Ke(t,Xe(s));});else if(e!==null&&typeof e=="object"&&!T(e))for(var r in e){var f={};f[r]=e[r],t.push(f);}else t=e;return t}function G(e){if(!(typeof e>"u")){var t={};return e.forEach(function(r){for(var f in r)t[f]=r[f];}),t}}function gt(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=e.length,r=new Array(t),f=0;f<t;f++)r[t-f-1]=e[f];return r}}async function ht(e,t){var r=_();for(var f in e){var s=de(t,e[f],f,e),y=await t.apply(this,s);typeof y<"u"&&r.push(y);}return r}function Ye(e){throw {code:"D3137",stack:new Error().stack,message:e||"$error() function evaluated"}}function ut(e,t){if(!e)throw {code:"D3141",stack:new Error().stack,message:t||"$assert() statement failed"}}function Ze(e){if(e!==void 0)return e===null?"null":ne(e)?"number":typeof e=="string"?"string":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":w(e)?"function":"object"}async function Ae(e,t){if(!(typeof e>"u")){if(e.length<=1)return e;var r;if(typeof t>"u"){if(!ie(e)&&!ee(e))throw {stack:new Error().stack,code:"D3070",index:1};r=async function(O,V){return O>V};}else r=t;var f=async function(O,V){var W=async function(he,Te,Se){Te.length===0?Array.prototype.push.apply(he,Se):Se.length===0?Array.prototype.push.apply(he,Te):await r(Te[0],Se[0])?(he.push(Se[0]),await W(he,Te,Se.slice(1))):(he.push(Te[0]),await W(he,Te.slice(1),Se));},Ee=[];return await W(Ee,O,V),Ee},s=async function(O){if(!Array.isArray(O)||O.length<=1)return O;var V=Math.floor(O.length/2),W=O.slice(0,V),Ee=O.slice(V);return W=await s(W),Ee=await s(Ee),await f(W,Ee)},y=await s(e);return y}}function n(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=new Array(e.length),r=0;r<e.length;r++){var f=Math.floor(Math.random()*(r+1));r!==f&&(t[r]=t[f]),t[f]=e[r];}return t}}function a(e){if(!(typeof e>"u")){if(!Array.isArray(e)||e.length<=1)return e;for(var t=k(e)?_():[],r=0;r<e.length;r++){for(var f=e[r],s=false,y=0;y<t.length;y++)if(z(f,t[y])){s=true;break}s||t.push(f);}return t}}async function i(e,t){var r={};for(var f in e){var s=e[f],y=de(t,s,f,e),O=await t.apply(this,y);K(O)&&(r[f]=s);}return Object.keys(r).length===0&&(r=void 0),r}return {sum:A,count:J,max:I,min:p,average:R,string:$,substring:Z,substringBefore:ue,substringAfter:fe,lowercase:le,uppercase:pe,length:xe,trim:qe,pad:ve,match:U,contains:N,replace:oe,split:ye,join:l,formatNumber:v,formatBase:g,number:E,floor:P,ceil:S,round:j,abs:M,sqrt:Y,power:me,random:be,boolean:K,not:X,map:H,zip:Ne,filter:Ie,single:Ge,foldLeft:te,sift:i,keys:ge,lookup:Fe,append:Ke,exists:nt,spread:Xe,merge:G,reverse:gt,each:ht,error:Ye,assert:ut,type:Ze,sort:Ae,shuffle:n,distinct:a,base64encode:Ce,base64decode:o,encodeUrlComponent:u,encodeUrl:B,decodeUrlComponent:ae,decodeUrl:we}})();C.exports=L;}).call(this);}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{});},{"./utils":6}],3:[function(b,C,x){var F=b("./datetime"),m=b("./functions"),L=b("./utils"),ne=b("./parser"),ee=b("./signature"),ie=(function(){var _=L.isNumeric,k=L.isArrayOfStrings,w=L.isArrayOfNumbers,T=L.createSequence,re=L.isSequence,ce=L.isFunction,z=L.isLambda,q=L.isIterable,A=L.isPromise,J=L.getFunctionArity,I=L.isDeepEqual,p=Ye(null);async function R(n,a,i){var e,t=i.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(t&&await t(n,a,i),n.type){case "path":e=await $(n,a,i);break;case "binary":e=await xe(n,a,i);break;case "unary":e=await qe(n,a,i);break;case "name":e=ve(n,a);break;case "string":case "number":case "value":e=D(n);break;case "wildcard":e=N(n,a);break;case "descendant":e=oe(n,a);break;case "parent":e=i.lookup(n.slot.label);break;case "condition":e=await P(n,a,i);break;case "block":e=await S(n,a,i);break;case "bind":e=await M(n,a,i);break;case "regex":e=j(n);break;case "function":e=await de(n,a,i);break;case "variable":e=Y(n,a,i);break;case "lambda":e=Ge(n,a,i);break;case "partial":e=await Ne(n,a,i);break;case "apply":e=await X(n,a,i);break;case "transform":e=be(n,a,i);break}if(Object.prototype.hasOwnProperty.call(n,"predicate"))for(var r=0;r<n.predicate.length;r++)e=await pe(n.predicate[r].expr,e,i);n.type!=="path"&&Object.prototype.hasOwnProperty.call(n,"group")&&(e=await v(n.group,e,i));var f=i.lookup(Symbol.for("jsonata.__evaluate_exit"));return f&&await f(n,a,i,e),e&&re(e)&&!e.tupleStream&&(n.keepArray&&(e.keepSingleton=true),e.length===0?e=void 0:e.length===1&&(e=e.keepSingleton?e:e[0])),e}async function $(n,a,i){var e;Array.isArray(a)&&n.steps[0].type!=="variable"?e=a:e=T(a);for(var t,r=false,f=void 0,s=0;s<n.steps.length;s++){var y=n.steps[s];if(y.tuple&&(r=true),s===0&&y.consarray?t=await R(y,e,i):r?f=await le(y,e,f,i):t=await ue(y,e,i,s===n.steps.length-1),!r&&(typeof t>"u"||t.length===0))break;typeof y.focus>"u"&&(e=t);}if(r)if(n.tuple)t=f;else for(t=T(),s=0;s<f.length;s++)t.push(f[s]["@"]);return n.keepSingletonArray&&(Array.isArray(t)&&t.cons&&!t.sequence&&(t=T(t)),t.keepSingleton=true),n.hasOwnProperty("group")&&(t=await v(n.group,r?f:t,i)),t}function Z(n,a){var i=Ye(n);for(let e in a)i.bind(e,a[e]);return i}async function ue(n,a,i,e){var t;if(n.type==="sort")return t=await me(n,a,i),n.stages&&(t=await fe(n.stages,t,i)),t;t=T();for(var r=0;r<a.length;r++){var f=await R(n,a[r],i);if(n.stages)for(var s=0;s<n.stages.length;s++)f=await pe(n.stages[s].expr,f,i);typeof f<"u"&&t.push(f);}var y=T();return e&&t.length===1&&Array.isArray(t[0])&&!re(t[0])?y=t[0]:t.forEach(function(O){!Array.isArray(O)||O.cons?y.push(O):O.forEach(V=>y.push(V));}),y}async function fe(n,a,i){for(var e=a,t=0;t<n.length;t++){var r=n[t];switch(r.type){case "filter":e=await pe(r.expr,e,i);break;case "index":for(var f=0;f<e.length;f++){var s=e[f];s[r.value]=f;}break}}return e}async function le(n,a,i,e){var t;if(n.type==="sort"){if(i)t=await me(n,i,e);else {var r=await me(n,a,e);t=T(),t.tupleStream=true;for(var f=0;f<r.length;f++){var s={"@":r[f]};s[n.index]=f,t.push(s);}}return n.stages&&(t=await fe(n.stages,t,e)),t}t=T(),t.tupleStream=true;var y=e;i===void 0&&(i=a.map(Ee=>({"@":Ee})));for(var O=0;O<i.length;O++){y=Z(e,i[O]);var V=await R(n,i[O]["@"],y);if(typeof V<"u"){Array.isArray(V)||(V=[V]);for(var W=0;W<V.length;W++)s={},Object.assign(s,i[O]),V.tupleStream?Object.assign(s,V[W]):(n.focus?(s[n.focus]=V[W],s["@"]=i[O]["@"]):s["@"]=V[W],n.index&&(s[n.index]=W),n.ancestor&&(s[n.ancestor.label]=i[O]["@"])),t.push(s);}}return n.stages&&(t=await fe(n.stages,t,e)),t}async function pe(n,a,i){var e=T();if(a&&a.tupleStream&&(e.tupleStream=true),Array.isArray(a)||(a=T(a)),n.type==="number"){var t=Math.floor(n.value);t<0&&(t=a.length+t);var r=await a[t];typeof r<"u"&&(Array.isArray(r)?e=r:e.push(r));}else for(t=0;t<a.length;t++){var r=a[t],f=r,s=i;a.tupleStream&&(f=r["@"],s=Z(i,r));var y=await R(n,f,s);_(y)&&(y=[y]),w(y)?y.forEach(function(V){var W=Math.floor(V);W<0&&(W=a.length+W),W===t&&e.push(r);}):m.boolean(y)&&e.push(r);}return e}async function xe(n,a,i){var e,t=await R(n.lhs,a,i),r=n.value,f=async()=>await R(n.rhs,a,i);if(r==="and"||r==="or")try{return await we(t,f,r)}catch(y){throw y.position=n.position,y.token=r,y}var s=await f();try{switch(r){case "+":case "-":case "*":case "/":case "%":e=o(t,s,r);break;case "=":case "!=":e=u(t,s,r);break;case "<":case "<=":case ">":case ">=":e=B(t,s,r);break;case "&":e=l(t,s);break;case "..":e=E(t,s);break;case "in":e=ae(t,s);break}}catch(y){throw y.position=n.position,y.token=r,y}return e}async function qe(n,a,i){var e;switch(n.value){case "-":if(e=await R(n.expression,a,i),typeof e>"u")e=void 0;else if(_(e))e=-e;else throw {code:"D1002",stack:new Error().stack,position:n.position,token:n.value,value:e};break;case "[":e=[];let f=await Promise.all(n.expressions.map(async(s,y)=>(i.isParallelCall=y>0,[s,await R(s,a,i)])));for(let s of f){var[t,r]=s;typeof r<"u"&&(t.value==="["?e.push(r):e=m.append(e,r));}n.consarray&&Object.defineProperty(e,"cons",{enumerable:false,configurable:false,value:true});break;case "{":e=await v(n,a,i);break}return e}function ve(n,a,i){return m.lookup(a,n.value)}function D(n){return n.value}function N(n,a){var i=T();return Array.isArray(a)&&a.outerWrapper&&a.length>0&&(a=a[0]),a!==null&&typeof a=="object"&&Object.keys(a).forEach(function(e){var t=a[e];Array.isArray(t)?(t=U(t),i=m.append(i,t)):i.push(t);}),i}function U(n,a){return typeof a>"u"&&(a=[]),Array.isArray(n)?n.forEach(function(i){U(i,a);}):a.push(n),a}function oe(n,a){var i,e=T();return typeof a<"u"&&(Ce(a,e),e.length===1?i=e[0]:i=e),i}function Ce(n,a){Array.isArray(n)||a.push(n),Array.isArray(n)?n.forEach(function(i){Ce(i,a);}):n!==null&&typeof n=="object"&&Object.keys(n).forEach(function(i){Ce(n[i],a);});}function o(n,a,i){var e;if(typeof n<"u"&&!_(n))throw {code:"T2001",stack:new Error().stack,value:n};if(typeof a<"u"&&!_(a))throw {code:"T2002",stack:new Error().stack,value:a};if(typeof n>"u"||typeof a>"u")return e;switch(i){case "+":e=n+a;break;case "-":e=n-a;break;case "*":e=n*a;break;case "/":e=n/a;break;case "%":e=n%a;break}return e}function u(n,a,i){var e,t=typeof n,r=typeof a;if(t==="undefined"||r==="undefined")return false;switch(i){case "=":e=I(n,a);break;case "!=":e=!I(n,a);break}return e}function B(n,a,i){var e,t=typeof n,r=typeof a,f=t==="undefined"||t==="string"||t==="number",s=r==="undefined"||r==="string"||r==="number";if(!f||!s)throw {code:"T2010",stack:new Error().stack,value:t==="string"||t==="number"?a:n};if(!(t==="undefined"||r==="undefined")){if(t!==r)throw {code:"T2009",stack:new Error().stack,value:n,value2:a};switch(i){case "<":e=n<a;break;case "<=":e=n<=a;break;case ">":e=n>a;break;case ">=":e=n>=a;break}return e}}function ae(n,a){var i=false;if(typeof n>"u"||typeof a>"u")return false;Array.isArray(a)||(a=[a]);for(var e=0;e<a.length;e++)if(a[e]===n){i=true;break}return i}async function we(n,a,i){var e,t=ye(n);switch(i){case "and":e=t&&ye(await a());break;case "or":e=t||ye(await a());break}return e}function ye(n){var a=m.boolean(n);return typeof a>"u"?false:a}function l(n,a){var i,e="",t="";return typeof n<"u"&&(e=m.string(n)),typeof a<"u"&&(t=m.string(a)),i=e.concat(t),i}async function v(n,a,i){var e={},t={},r=!!(a&&a.tupleStream);Array.isArray(a)||(a=T(a)),a.length===0&&a.push(void 0);for(var f=0;f<a.length;f++)for(var s=a[f],y=r?Z(i,s):i,O=0;O<n.lhs.length;O++){var V=n.lhs[O],W=await R(V[0],r?s["@"]:s,y);if(typeof W!="string"&&W!==void 0)throw {code:"T1003",stack:new Error().stack,position:n.position,value:W};if(W!==void 0){var Ee={data:s,exprIndex:O};if(t.hasOwnProperty(W)){if(t[W].exprIndex!==O)throw {code:"D1009",stack:new Error().stack,position:n.position,value:W};t[W].data=m.append(t[W].data,s);}else t[W]=Ee;}}let he=await Promise.all(Object.keys(t).map(async(Se,je)=>{let ke=t[Se];var De=ke.data,Je=i;if(r){var Me=g(ke.data);De=Me["@"],delete Me["@"],Je=Z(i,Me);}return i.isParallelCall=je>0,[Se,await R(n.lhs[ke.exprIndex][1],De,Je)]}));for(let Se of he){var[W,Te]=await Se;typeof Te<"u"&&(e[W]=Te);}return e}function g(n){if(!Array.isArray(n))return n;var a={};Object.assign(a,n[0]);for(var i=1;i<n.length;i++)for(let e in n[i])a[e]=m.append(a[e],n[i][e]);return a}function E(n,a){var i;if(typeof n<"u"&&!Number.isInteger(n))throw {code:"T2003",stack:new Error().stack,value:n};if(typeof a<"u"&&!Number.isInteger(a))throw {code:"T2004",stack:new Error().stack,value:a};if(typeof n>"u"||typeof a>"u"||n>a)return i;var e=a-n+1;if(e>1e7)throw {code:"D2014",stack:new Error().stack,value:e};i=new Array(e);for(var t=n,r=0;t<=a;t++,r++)i[r]=t;return i.sequence=true,i}async function M(n,a,i){var e=await R(n.rhs,a,i);return i.bind(n.lhs.value,e),e}async function P(n,a,i){var e,t=await R(n.condition,a,i);return m.boolean(t)?e=await R(n.then,a,i):typeof n.else<"u"&&(e=await R(n.else,a,i)),e}async function S(n,a,i){for(var e,t=Ye(i),r=0;r<n.expressions.length;r++)e=await R(n.expressions[r],a,t);return e}function j(n){var a=new Ae.RegexEngine(n.value),i=function(e,t){var r;a.lastIndex=t||0;var f=a.exec(e);if(f!==null){if(r={match:f[0],start:f.index,end:f.index+f[0].length,groups:[]},f.length>1)for(var s=1;s<f.length;s++)r.groups.push(f[s]);r.next=function(){if(!(a.lastIndex>=e.length)){var y=i(e,a.lastIndex);if(y&&y.match==="")throw {code:"D1004",stack:new Error().stack,position:n.position,value:n.value.source};return y}};}return r};return i}function Y(n,a,i){var e;return n.value===""?e=a&&a.outerWrapper?a[0]:a:e=i.lookup(n.value),e}async function me(n,a,i){var e,t=a,r=!!a.tupleStream,f=async function(y,O){for(var V=0,W=0;V===0&&W<n.terms.length;W++){var Ee=n.terms[W],he=y,Te=i;r&&(he=y["@"],Te=Z(i,y));var Se=await R(Ee.expression,he,Te);he=O,Te=i,r&&(he=O["@"],Te=Z(i,O));var je=await R(Ee.expression,he,Te),ke=typeof Se,De=typeof je;if(ke==="undefined"){V=De==="undefined"?0:1;continue}if(De==="undefined"){V=-1;continue}if(!(ke==="string"||ke==="number")||!(De==="string"||De==="number"))throw {code:"T2008",stack:new Error().stack,position:n.position,value:ke==="string"||ke==="number"?je:Se};if(ke!==De)throw {code:"T2007",stack:new Error().stack,position:n.position,value:Se,value2:je};Se!==je&&(Se<je?V=-1:V=1,Ee.descending===true&&(V=-V));}return V===1},s={environment:i,input:a};return e=await m.sort.apply(s,[t,f]),e}function be(n,a,i){var e=async function(t){if(!(typeof t>"u")){var r=i.lookup("clone");if(!ce(r))throw {code:"T2013",stack:new Error().stack,position:n.position};var f=await H(r,[t],null,i),s=await R(n.pattern,f,i);if(typeof s<"u"){Array.isArray(s)||(s=[s]);for(var y=0;y<s.length;y++){var O=s[y];if(O&&(O.isPrototypeOf(f)||O instanceof Object.constructor))throw {code:"D1010",stack:new Error().stack,position:n.position};var V=await R(n.update,O,i),W=typeof V;if(W!=="undefined"){if(W!=="object"||V===null||Array.isArray(V))throw {code:"T2011",stack:new Error().stack,position:n.update.position,value:V};for(var Ee in V)O[Ee]=V[Ee];}if(typeof n.delete<"u"){var he=await R(n.delete,O,i);if(typeof he<"u"){var Te=he;if(Array.isArray(he)||(he=[he]),!k(he))throw {code:"T2012",stack:new Error().stack,position:n.delete.position,value:Te};for(var Se=0;Se<he.length;Se++)typeof O=="object"&&O!==null&&delete O[he[Se]];}}}}return f}};return G(e,"<(oa):o>")}var K=ne("function($f, $g) { function($x){ $g($f($x)) } }");async function X(n,a,i){var e,t=await R(n.lhs,a,i);if(n.rhs.type==="function")e=await de(n.rhs,a,i,{context:t});else {var r=await R(n.rhs,a,i);if(!ce(r))throw {code:"T2006",stack:new Error().stack,position:n.position,value:r};if(ce(t)){var f=await R(K,null,i);e=await H(f,[t,r],null,i);}else e=await H(r,[t],null,i);}return e}async function de(n,a,i,e){var t,r=await R(n.procedure,a,i);if(typeof r>"u"&&n.procedure.type==="path"&&i.lookup(n.procedure.steps[0].value))throw {code:"T1005",stack:new Error().stack,position:n.position,token:n.procedure.steps[0].value};var f=[];typeof e<"u"&&f.push(e.context);for(var s=0;s<n.arguments.length;s++){let O=await R(n.arguments[s],a,i);if(ce(O)){let V=async function(...W){return await H(O,W,null,i)};V.arity=J(O),f.push(V);}else f.push(O);}var y=n.procedure.type==="path"?n.procedure.steps[0].value:n.procedure.value;try{typeof r=="object"&&(r.token=y,r.position=n.position),t=await H(r,f,a,i);}catch(O){throw O.position||(O.position=n.position),O.token||(O.token=y),O}return t}async function H(n,a,i,e){var t;for(t=await Ie(n,a,i,e);z(t)&&t.thunk===true;){var r=await R(t.body.procedure,t.input,t.environment);t.body.procedure.type==="variable"&&(r.token=t.body.procedure.value),r.position=t.body.procedure.position;for(var f=[],s=0;s<t.body.arguments.length;s++)f.push(await R(t.body.arguments[s],t.input,t.environment));t=await Ie(r,f,i,e);}return t}async function Ie(n,a,i,e){var t;try{var r=a;if(n&&(r=te(n.signature,a,i)),z(n))t=await ge(n,r);else if(n&&n._jsonata_function===!0){var f={environment:e,input:i};t=n.implementation.apply(f,r),q(t)&&(t=t.next().value),A(t)&&(t=await t);}else if(typeof n=="function")t=n.apply(i,r),A(t)&&(t=await t);else throw {code:"T1006",stack:new Error().stack}}catch(s){throw n&&(typeof s.token>"u"&&typeof n.token<"u"&&(s.token=n.token),s.position=n.position||s.position),s}return t}function Ge(n,a,i){var e={_jsonata_lambda:true,input:a,environment:i,arguments:n.arguments,signature:n.signature,body:n.body};return n.thunk===true&&(e.thunk=true),e.apply=async function(t,r){return await H(e,r,a,t?t.environment:i)},e}async function Ne(n,a,i){for(var e,t=[],r=0;r<n.arguments.length;r++){var f=n.arguments[r];f.type==="operator"&&f.value==="?"?t.push(f):t.push(await R(f,a,i));}var s=await R(n.procedure,a,i);if(typeof s>"u"&&n.procedure.type==="path"&&i.lookup(n.procedure.steps[0].value))throw {code:"T1007",stack:new Error().stack,position:n.position,token:n.procedure.steps[0].value};if(z(s))e=Fe(s,t);else if(s&&s._jsonata_function===true)e=Ke(s.implementation,t);else if(typeof s=="function")e=Ke(s,t);else throw {code:"T1008",stack:new Error().stack,position:n.position,token:n.procedure.type==="path"?n.procedure.steps[0].value:n.procedure.value};return e}function te(n,a,i){if(typeof n>"u")return a;var e=n.validate(a,i);return e}async function ge(n,a){var i,e=Ye(n.environment);return n.arguments.forEach(function(t,r){e.bind(t.value,a[r]);}),typeof n.body=="function"?i=await nt(n.body,e):i=await R(n.body,n.input,e),i}function Fe(n,a){var i=Ye(n.environment),e=[];n.arguments.forEach(function(r,f){var s=a[f];s&&s.type==="operator"&&s.value==="?"?e.push(r):i.bind(r.value,s);});var t={_jsonata_lambda:true,input:n.input,environment:i,arguments:e,body:n.body};return t}function Ke(n,a){var i=Xe(n);i=i.map(function(f){return "$"+f.trim()});var e="function("+i.join(", ")+"){ _ }",t=ne(e);t.body=n;var r=Fe(t,a);return r}async function nt(n,a){var i=Xe(n),e=i.map(function(f){return a.lookup(f.trim())}),t={environment:a},r=n.apply(t,e);return A(r)&&(r=await r),r}function Xe(n){var a=n.toString(),i=/\(([^)]*)\)/.exec(a)[1],e=i.split(",");return e}function G(n,a){var i={_jsonata_function:true,implementation:n};return typeof a<"u"&&(i.signature=ee(a)),i}async function gt(n,a){if(!(typeof n>"u")){var i=this.input;typeof a<"u"&&(i=a,Array.isArray(i)&&!re(i)&&(i=T(i),i.outerWrapper=true));try{var e=ne(n,!1);}catch(r){throw Ze(r),{stack:new Error().stack,code:"D3120",value:r.message,error:r}}try{var t=await R(e,i,this.environment);}catch(r){throw Ze(r),{stack:new Error().stack,code:"D3121",value:r.message,error:r}}return t}}function ht(n){if(!(typeof n>"u"))return JSON.parse(m.string(n))}function Ye(n){var a={};let i={bind:function(t,r){a[t]=r;},lookup:function(t){var r;return a.hasOwnProperty(t)?r=a[t]:n&&(r=n.lookup(t)),r},timestamp:n?n.timestamp:null,async:n?n.async:false,isParallelCall:n?n.isParallelCall:false,global:n?n.global:{ancestry:[null]}};if(n){var e=n.lookup(Symbol.for("jsonata.__createFrame_push"));e&&e(n,i);}return i}p.bind("sum",G(m.sum,"<a<n>:n>")),p.bind("count",G(m.count,"<a:n>")),p.bind("max",G(m.max,"<a<n>:n>")),p.bind("min",G(m.min,"<a<n>:n>")),p.bind("average",G(m.average,"<a<n>:n>")),p.bind("string",G(m.string,"<x-b?:s>")),p.bind("substring",G(m.substring,"<s-nn?:s>")),p.bind("substringBefore",G(m.substringBefore,"<s-s:s>")),p.bind("substringAfter",G(m.substringAfter,"<s-s:s>")),p.bind("lowercase",G(m.lowercase,"<s-:s>")),p.bind("uppercase",G(m.uppercase,"<s-:s>")),p.bind("length",G(m.length,"<s-:n>")),p.bind("trim",G(m.trim,"<s-:s>")),p.bind("pad",G(m.pad,"<s-ns?:s>")),p.bind("match",G(m.match,"<s-f<s:o>n?:a<o>>")),p.bind("contains",G(m.contains,"<s-(sf):b>")),p.bind("replace",G(m.replace,"<s-(sf)(sf)n?:s>")),p.bind("split",G(m.split,"<s-(sf)n?:a<s>>")),p.bind("join",G(m.join,"<a<s>s?:s>")),p.bind("formatNumber",G(m.formatNumber,"<n-so?:s>")),p.bind("formatBase",G(m.formatBase,"<n-n?:s>")),p.bind("formatInteger",G(F.formatInteger,"<n-s:s>")),p.bind("parseInteger",G(F.parseInteger,"<s-s:n>")),p.bind("number",G(m.number,"<(nsb)-:n>")),p.bind("floor",G(m.floor,"<n-:n>")),p.bind("ceil",G(m.ceil,"<n-:n>")),p.bind("round",G(m.round,"<n-n?:n>")),p.bind("abs",G(m.abs,"<n-:n>")),p.bind("sqrt",G(m.sqrt,"<n-:n>")),p.bind("power",G(m.power,"<n-n:n>")),p.bind("random",G(m.random,"<:n>")),p.bind("boolean",G(m.boolean,"<x-:b>")),p.bind("not",G(m.not,"<x-:b>")),p.bind("map",G(m.map,"<af>")),p.bind("zip",G(m.zip,"<a+>")),p.bind("filter",G(m.filter,"<af>")),p.bind("single",G(m.single,"<af?>")),p.bind("reduce",G(m.foldLeft,"<afj?:j>")),p.bind("sift",G(m.sift,"<o-f?:o>")),p.bind("keys",G(m.keys,"<x-:a<s>>")),p.bind("lookup",G(m.lookup,"<x-s:x>")),p.bind("append",G(m.append,"<xx:a>")),p.bind("exists",G(m.exists,"<x:b>")),p.bind("spread",G(m.spread,"<x-:a<o>>")),p.bind("merge",G(m.merge,"<a<o>:o>")),p.bind("reverse",G(m.reverse,"<a:a>")),p.bind("each",G(m.each,"<o-f:a>")),p.bind("error",G(m.error,"<s?:x>")),p.bind("assert",G(m.assert,"<bs?:x>")),p.bind("type",G(m.type,"<x:s>")),p.bind("sort",G(m.sort,"<af?:a>")),p.bind("shuffle",G(m.shuffle,"<a:a>")),p.bind("distinct",G(m.distinct,"<x:x>")),p.bind("base64encode",G(m.base64encode,"<s-:s>")),p.bind("base64decode",G(m.base64decode,"<s-:s>")),p.bind("encodeUrlComponent",G(m.encodeUrlComponent,"<s-:s>")),p.bind("encodeUrl",G(m.encodeUrl,"<s-:s>")),p.bind("decodeUrlComponent",G(m.decodeUrlComponent,"<s-:s>")),p.bind("decodeUrl",G(m.decodeUrl,"<s-:s>")),p.bind("eval",G(gt,"<sx?:x>")),p.bind("toMillis",G(F.toMillis,"<s-s?:n>")),p.bind("fromMillis",G(F.fromMillis,"<n-s?s?:s>")),p.bind("clone",G(ht,"<(oa)-:o>"));var ut={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",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",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",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this 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",S0500:"Attempted to evaluate an expression containing syntax error(s)",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}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",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",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",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",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 $)",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",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",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:"The second argument of reduce function must be a function with at least 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",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Ze(n){var a=ut[n.code];if(typeof a<"u"){var i=a.replace(/\{\{\{([^}]+)}}}/g,function(){return n[arguments[1]]});i=i.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(n[arguments[1]])}),n.message=i;}}function Ae(n,a){var i,e;try{i=ne(n,a&&a.recover),e=i.errors,delete i.errors;}catch(f){throw Ze(f),f}var t=Ye(p),r=new Date;return t.bind("now",G(function(f,s){return F.fromMillis(r.getTime(),f,s)},"<s?s?:s>")),t.bind("millis",G(function(){return r.getTime()},"<:n>")),a&&a.RegexEngine?Ae.RegexEngine=a.RegexEngine:Ae.RegexEngine=RegExp,{evaluate:async function(f,s,y){if(typeof e<"u"){var O={code:"S0500",position:0};throw Ze(O),O}if(typeof s<"u"){var V;V=Ye(t);for(var W in s)V.bind(W,s[W]);}else V=t;V.bind("$",f),r=new Date,V.timestamp=r,Array.isArray(f)&&!re(f)&&(f=T(f),f.outerWrapper=true);var Ee;try{return Ee=await R(i,f,V),typeof y=="function"&&y(null,Ee),Ee}catch(he){throw Ze(he),he}},assign:function(f,s){t.bind(f,s);},registerFunction:function(f,s,y){var O=G(s,y);t.bind(f,O);},ast:function(){return i},errors:function(){return e}}}return Ae.parser=ne,Ae})();C.exports=ie;},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(b,C,x){var F=b("./signature");let m=(()=>{var L={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},ne={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},ee=function(_){var k=0,w=_.length,T=function(z,q){var A={type:z,value:q,position:k};return A},re=function(){for(var z=k,q=0,A,J,I=function(R){if(_.charAt(R)==="/"&&q===0){for(var $=0;_.charAt(R-($+1))==="\\";)$++;if($%2===0)return true}return false};k<w;){var p=_.charAt(k);if(I(k)){if(A=_.substring(z,k),A==="")throw {code:"S0301",stack:new Error().stack,position:k};for(k++,p=_.charAt(k),z=k;p==="i"||p==="m";)k++,p=_.charAt(k);return J=_.substring(z,k)+"g",new RegExp(A,J)}(p==="("||p==="["||p==="{")&&_.charAt(k-1)!=="\\"&&q++,(p===")"||p==="]"||p==="}")&&_.charAt(k-1)!=="\\"&&q--,k++;}throw {code:"S0302",stack:new Error().stack,position:k}},ce=function(z){if(k>=w)return null;for(var q=_.charAt(k);k<w&&`
|
|
3
|
+
\r\v`.indexOf(q)>-1;)k++,q=_.charAt(k);if(q==="/"&&_.charAt(k+1)==="*"){var A=k;for(k+=2,q=_.charAt(k);!(q==="*"&&_.charAt(k+1)==="/");)if(q=_.charAt(++k),k>=w)throw {code:"S0106",stack:new Error().stack,position:A};return k+=2,q=_.charAt(k),ce(z)}if(z!==true&&q==="/")return k++,T("regex",re());if(q==="."&&_.charAt(k+1)===".")return k+=2,T("operator","..");if(q===":"&&_.charAt(k+1)==="=")return k+=2,T("operator",":=");if(q==="!"&&_.charAt(k+1)==="=")return k+=2,T("operator","!=");if(q===">"&&_.charAt(k+1)==="=")return k+=2,T("operator",">=");if(q==="<"&&_.charAt(k+1)==="=")return k+=2,T("operator","<=");if(q==="*"&&_.charAt(k+1)==="*")return k+=2,T("operator","**");if(q==="~"&&_.charAt(k+1)===">")return k+=2,T("operator","~>");if(q==="?"&&_.charAt(k+1)===":")return k+=2,T("operator","?:");if(q==="?"&&_.charAt(k+1)==="?")return k+=2,T("operator","??");if(Object.prototype.hasOwnProperty.call(L,q))return k++,T("operator",q);if(q==='"'||q==="'"){var J=q;k++;for(var I="";k<w;){if(q=_.charAt(k),q==="\\")if(k++,q=_.charAt(k),Object.prototype.hasOwnProperty.call(ne,q))I+=ne[q];else if(q==="u"){var p=_.substr(k+1,4);if(/^[0-9a-fA-F]+$/.test(p)){var R=parseInt(p,16);I+=String.fromCharCode(R),k+=4;}else throw {code:"S0104",stack:new Error().stack,position:k}}else throw {code:"S0103",stack:new Error().stack,position:k,token:q};else {if(q===J)return k++,T("string",I);I+=q;}k++;}throw {code:"S0101",stack:new Error().stack,position:k}}var $=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,Z=$.exec(_.substring(k));if(Z!==null){var ue=parseFloat(Z[0]);if(!isNaN(ue)&&isFinite(ue))return k+=Z[0].length,T("number",ue);throw {code:"S0102",stack:new Error().stack,position:k,token:Z[0]}}var fe;if(q==="`"){k++;var le=_.indexOf("`",k);if(le!==-1)return fe=_.substring(k,le),k=le+1,T("name",fe);throw k=w,{code:"S0105",stack:new Error().stack,position:k}}for(var pe=k,xe;;)if(xe=_.charAt(pe),pe===w||`
|
|
4
|
+
\r\v`.indexOf(xe)>-1||Object.prototype.hasOwnProperty.call(L,xe)){if(_.charAt(k)==="$")return fe=_.substring(k+1,pe),k=pe,T("variable",fe);switch(fe=_.substring(k,pe),k=pe,fe){case "or":case "in":case "and":return T("operator",fe);case "true":return T("value",true);case "false":return T("value",false);case "null":return T("value",null);default:return k===w&&fe===""?null:T("name",fe)}}else pe++;};return ce},ie=function(_,k){var w,T,re={},ce=[],z=function(){var o=[];w.id!=="(end)"&&o.push({type:w.type,value:w.value,position:w.position});for(var u=T();u!==null;)o.push(u),u=T();return o},q={nud:function(){var o={code:"S0211",token:this.value,position:this.position};if(k)return o.remaining=z(),o.type="error",ce.push(o),o;throw o.stack=new Error().stack,o}},A=function(o,u){var B=re[o];return u=u||0,B?u>=B.lbp&&(B.lbp=u):(B=Object.create(q),B.id=B.value=o,B.lbp=u,re[o]=B),B},J=function(o){if(k){o.remaining=z(),ce.push(o);var u=re["(error)"];return w=Object.create(u),w.error=o,w.type="(error)",w}else throw o.stack=new Error().stack,o},I=function(o,u){if(o&&w.id!==o){var B;w.id==="(end)"?B="S0203":B="S0202";var ae={code:B,position:w.position,token:w.value,value:o};return J(ae)}var we=T(u);if(we===null)return w=re["(end)"],w.position=_.length,w;var ye=we.value,l=we.type,v;switch(l){case "name":case "variable":v=re["(name)"];break;case "operator":if(v=re[ye],!v)return J({code:"S0204",stack:new Error().stack,position:we.position,token:ye});break;case "string":case "number":case "value":v=re["(literal)"];break;case "regex":l="regex",v=re["(regex)"];break;default:return J({code:"S0205",stack:new Error().stack,position:we.position,token:ye})}return w=Object.create(v),w.value=ye,w.type=l,w.position=we.position,w},p=function(o){var u,B=w;for(I(null,true),u=B.nud();o<w.lbp;)B=w,I(),u=B.led(u);return u},R=function(o){var u=A(o,0);u.nud=function(){return this};},$=function(o,u,B){var ae=u||L[o],we=A(o,ae);return we.led=B||function(ye){return this.lhs=ye,this.rhs=p(ae),this.type="binary",this},we},Z=function(o,u,B){var ae=A(o,u);return ae.led=B,ae},ue=function(o,u){var B=A(o);return B.nud=u||function(){return this.expression=p(70),this.type="unary",this},B};R("(end)"),R("(name)"),R("(literal)"),R("(regex)"),A(":"),A(";"),A(","),A(")"),A("]"),A("}"),A(".."),$("."),$("+"),$("-"),$("*"),$("/"),$("%"),$("="),$("<"),$(">"),$("!="),$("<="),$(">="),$("&"),$("and"),$("or"),$("in"),R("and"),R("or"),R("in"),ue("-"),$("~>"),$("??",L["??"],function(o){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[o]},this.then=o,this.else=p(0),this}),Z("(error)",10,function(o){return this.lhs=o,this.error=w.error,this.remaining=z(),this.type="error",this}),ue("*",function(){return this.type="wildcard",this}),ue("**",function(){return this.type="descendant",this}),ue("%",function(){return this.type="parent",this}),$("(",L["("],function(o){if(this.procedure=o,this.type="function",this.arguments=[],w.id!==")")for(;w.type==="operator"&&w.id==="?"?(this.type="partial",this.arguments.push(w),I("?")):this.arguments.push(p(0)),w.id===",";)I(",");if(I(")",true),o.type==="name"&&(o.value==="function"||o.value==="\u03BB")){if(this.arguments.forEach(function(ye,l){if(ye.type!=="variable")return J({code:"S0208",stack:new Error().stack,position:ye.position,token:ye.value,value:l+1})}),this.type="lambda",w.id==="<"){for(var u=w.position,B=1,ae="<";B>0&&w.id!=="{"&&w.id!=="(end)";){var we=I();we.id===">"?B--:we.id==="<"&&B++,ae+=we.value;}I(">");try{this.signature=F(ae);}catch(ye){return ye.position=u+ye.offset,J(ye)}}I("{"),this.body=p(0),I("}");}return this}),ue("(",function(){for(var o=[];w.id!==")"&&(o.push(p(0)),w.id===";");)I(";");return I(")",true),this.type="block",this.expressions=o,this}),ue("[",function(){var o=[];if(w.id!=="]")for(;;){var u=p(0);if(w.id===".."){var B={type:"binary",value:"..",position:w.position,lhs:u};I(".."),B.rhs=p(0),u=B;}if(o.push(u),w.id!==",")break;I(",");}return I("]",true),this.expressions=o,this.type="unary",this}),$("[",L["["],function(o){if(w.id==="]"){for(var u=o;u&&u.type==="binary"&&u.value==="[";)u=u.lhs;return u.keepArray=true,I("]"),o}else return this.lhs=o,this.rhs=p(L["]"]),this.type="binary",I("]",true),this}),$("^",L["^"],function(o){I("(");for(var u=[];;){var B={descending:false};if(w.id==="<"?I("<"):w.id===">"&&(B.descending=true,I(">")),B.expression=p(0),u.push(B),w.id!==",")break;I(",");}return I(")"),this.lhs=o,this.rhs=u,this.type="binary",this});var fe=function(o){var u=[];if(w.id!=="}")for(;;){var B=p(0);I(":");var ae=p(0);if(u.push([B,ae]),w.id!==",")break;I(",");}return I("}",true),typeof o>"u"?(this.lhs=u,this.type="unary"):(this.lhs=o,this.rhs=u,this.type="binary"),this};ue("{",fe),$("{",L["{"],fe),Z(":=",L[":="],function(o){return o.type!=="variable"?J({code:"S0212",stack:new Error().stack,position:o.position,token:o.value}):(this.lhs=o,this.rhs=p(L[":="]-1),this.type="binary",this)}),$("@",L["@"],function(o){return this.lhs=o,this.rhs=p(L["@"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),$("#",L["#"],function(o){return this.lhs=o,this.rhs=p(L["#"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),$("?",L["?"],function(o){return this.type="condition",this.condition=o,this.then=p(0),w.id===":"&&(I(":"),this.else=p(0)),this}),$("?:",L["?:"],function(o){return this.type="condition",this.condition=o,this.then=o,this.else=p(0),this}),ue("|",function(){return this.type="transform",this.pattern=p(0),I("|"),this.update=p(0),w.id===","&&(I(","),this.delete=p(0)),I("|"),this});var le=function(o){var u;if(o.type==="function"&&!o.predicate){var B={type:"lambda",thunk:true,arguments:[],position:o.position};B.body=o,u=B;}else if(o.type==="condition")o.then=le(o.then),typeof o.else<"u"&&(o.else=le(o.else)),u=o;else if(o.type==="block"){var ae=o.expressions.length;ae>0&&(o.expressions[ae-1]=le(o.expressions[ae-1])),u=o;}else u=o;return u},pe=0,xe=0,qe=[],ve=function(o,u){switch(o.type){case "name":case "wildcard":u.level--,u.level===0&&(typeof o.ancestor>"u"||(qe[u.index].slot.label=o.ancestor.label),o.ancestor=u,o.tuple=true);break;case "parent":u.level++;break;case "block":o.expressions.length>0&&(o.tuple=true,u=ve(o.expressions[o.expressions.length-1],u));break;case "path":o.tuple=true;var B=o.steps.length-1;for(u=ve(o.steps[B--],u);u.level>0&&B>=0;)u=ve(o.steps[B--],u);break;default:throw {code:"S0217",token:o.type,position:o.position}}return u},D=function(o,u){if(typeof u.seekingParent<"u"||u.type==="parent"){var B=typeof u.seekingParent<"u"?u.seekingParent:[];u.type==="parent"&&B.push(u.slot),typeof o.seekingParent>"u"?o.seekingParent=B:Array.prototype.push.apply(o.seekingParent,B);}},N=function(o){var u=o.steps.length-1,B=o.steps[u],ae=typeof B.seekingParent<"u"?B.seekingParent:[];B.type==="parent"&&ae.push(B.slot);for(var we=0;we<ae.length;we++){var ye=ae[we];for(u=o.steps.length-2;ye.level>0;){if(u<0){typeof o.seekingParent>"u"?o.seekingParent=[ye]:o.seekingParent.push(ye);break}for(var l=o.steps[u--];u>=0&&l.focus&&o.steps[u].focus;)l=o.steps[u--];ye=ve(l,ye);}}},U=function(o){var u;switch(o.type){case "binary":switch(o.value){case ".":var B=U(o.lhs);B.type==="path"?u=B:u={type:"path",steps:[B]},B.type==="parent"&&(u.seekingParent=[B.slot]);var ae=U(o.rhs);ae.type==="function"&&ae.procedure.type==="path"&&ae.procedure.steps.length===1&&ae.procedure.steps[0].type==="name"&&u.steps[u.steps.length-1].type==="function"&&(u.steps[u.steps.length-1].nextFunction=ae.procedure.steps[0].value),ae.type==="path"?Array.prototype.push.apply(u.steps,ae.steps):(typeof ae.predicate<"u"&&(ae.stages=ae.predicate,delete ae.predicate),u.steps.push(ae)),u.steps.filter(function(j){if(j.type==="number"||j.type==="value")throw {code:"S0213",stack:new Error().stack,position:j.position,value:j.value};return j.type==="string"}).forEach(function(j){j.type="name";}),u.steps.filter(function(j){return j.keepArray===true}).length>0&&(u.keepSingletonArray=true);var we=u.steps[0];we.type==="unary"&&we.value==="["&&(we.consarray=true);var ye=u.steps[u.steps.length-1];ye.type==="unary"&&ye.value==="["&&(ye.consarray=true),N(u);break;case "[":u=U(o.lhs);var l=u,v="predicate";if(u.type==="path"&&(l=u.steps[u.steps.length-1],v="stages"),typeof l.group<"u")throw {code:"S0209",stack:new Error().stack,position:o.position};typeof l[v]>"u"&&(l[v]=[]);var g=U(o.rhs);typeof g.seekingParent<"u"&&(g.seekingParent.forEach(j=>{j.level===1?ve(l,j):j.level--;}),D(l,g)),l[v].push({type:"filter",expr:g,position:o.position});break;case "{":if(u=U(o.lhs),typeof u.group<"u")throw {code:"S0210",stack:new Error().stack,position:o.position};u.group={lhs:o.rhs.map(function(j){return [U(j[0]),U(j[1])]}),position:o.position};break;case "^":u=U(o.lhs),u.type!=="path"&&(u={type:"path",steps:[u]});var E={type:"sort",position:o.position};E.terms=o.rhs.map(function(j){var Y=U(j.expression);return D(E,Y),{descending:j.descending,expression:Y}}),u.steps.push(E),N(u);break;case ":=":u={type:"bind",value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),D(u,u.rhs);break;case "@":if(u=U(o.lhs),l=u,u.type==="path"&&(l=u.steps[u.steps.length-1]),typeof l.stages<"u"||typeof l.predicate<"u")throw {code:"S0215",stack:new Error().stack,position:o.position};if(l.type==="sort")throw {code:"S0216",stack:new Error().stack,position:o.position};o.keepArray&&(l.keepArray=true),l.focus=o.rhs.value,l.tuple=true;break;case "#":u=U(o.lhs),l=u,u.type==="path"?l=u.steps[u.steps.length-1]:(u={type:"path",steps:[u]},typeof l.predicate<"u"&&(l.stages=l.predicate,delete l.predicate)),typeof l.stages>"u"?l.index=o.rhs.value:l.stages.push({type:"index",value:o.rhs.value,position:o.position}),l.tuple=true;break;case "~>":u={type:"apply",value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),u.keepArray=u.lhs.keepArray||u.rhs.keepArray;break;default:u={type:o.type,value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),D(u,u.lhs),D(u,u.rhs);}break;case "unary":u={type:o.type,value:o.value,position:o.position},o.value==="["?u.expressions=o.expressions.map(function(j){var Y=U(j);return D(u,Y),Y}):o.value==="{"?u.lhs=o.lhs.map(function(j){var Y=U(j[0]);D(u,Y);var me=U(j[1]);return D(u,me),[Y,me]}):(u.expression=U(o.expression),o.value==="-"&&u.expression.type==="number"?(u=u.expression,u.value=-u.value):D(u,u.expression));break;case "function":case "partial":u={type:o.type,name:o.name,value:o.value,position:o.position},u.arguments=o.arguments.map(function(j){var Y=U(j);return D(u,Y),Y}),u.procedure=U(o.procedure);break;case "lambda":u={type:o.type,arguments:o.arguments,signature:o.signature,position:o.position};var M=U(o.body);u.body=le(M);break;case "condition":u={type:o.type,position:o.position},u.condition=U(o.condition),D(u,u.condition),u.then=U(o.then),D(u,u.then),typeof o.else<"u"&&(u.else=U(o.else),D(u,u.else));break;case "transform":u={type:o.type,position:o.position},u.pattern=U(o.pattern),u.update=U(o.update),typeof o.delete<"u"&&(u.delete=U(o.delete));break;case "block":u={type:o.type,position:o.position},u.expressions=o.expressions.map(function(j){var Y=U(j);return D(u,Y),(Y.consarray||Y.type==="path"&&Y.steps[0].consarray)&&(u.consarray=true),Y});break;case "name":u={type:"path",steps:[o]},o.keepArray&&(u.keepSingletonArray=true);break;case "parent":u={type:"parent",slot:{label:"!"+pe++,level:1,index:xe++}},qe.push(u);break;case "string":case "number":case "value":case "wildcard":case "descendant":case "variable":case "regex":u=o;break;case "operator":if(o.value==="and"||o.value==="or"||o.value==="in")o.type="name",u=U(o);else if(o.value==="?")u=o;else throw {code:"S0201",stack:new Error().stack,position:o.position,token:o.value};break;case "error":u=o,o.lhs&&(u=U(o.lhs));break;default:var P="S0206";o.id==="(end)"&&(P="S0207");var S={code:P,position:o.position,token:o.value};if(k)return ce.push(S),{type:"error",error:S};throw S.stack=new Error().stack,S}return o.keepArray&&(u.keepArray=true),u};T=ee(_),I();var oe=p(0);if(w.id!=="(end)"){var Ce={code:"S0201",position:w.position,token:w.value};J(Ce);}if(oe=U(oe),oe.type==="parent"||typeof oe.seekingParent<"u")throw {code:"S0217",token:oe.type,position:oe.position};return ce.length>0&&(oe.errors=ce),oe};return ie})();C.exports=m;},{"./signature":5}],5:[function(b,C,x){var F=b("./utils");let m=(()=>{var L={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function ne(ee){for(var ie=1,_=[],k={},w=k;ie<ee.length;){var T=ee.charAt(ie);if(T===":")break;var re=function(){_.push(k),w=k,k={};},ce=function($,Z,ue,fe){for(var le=1,pe=Z;pe<$.length;)if(pe++,T=$.charAt(pe),T===fe){if(le--,le===0)break}else T===ue&&le++;return pe};switch(T){case "s":case "n":case "b":case "l":case "o":k.regex="["+T+"m]",k.type=T,re();break;case "a":k.regex="[asnblfom]",k.type=T,k.array=true,re();break;case "f":k.regex="f",k.type=T,re();break;case "j":k.regex="[asnblom]",k.type=T,re();break;case "x":k.regex="[asnblfom]",k.type=T,re();break;case "-":w.context=true,w.contextRegex=new RegExp(w.regex),w.regex+="?";break;case "?":case "+":w.regex+=T;break;case "(":var z=ce(ee,ie,"(",")"),q=ee.substring(ie+1,z);if(q.indexOf("<")===-1)k.regex="["+q+"m]";else throw {code:"S0402",stack:new Error().stack,value:q,offset:ie};k.type="("+q+")",ie=z,re();break;case "<":if(w.type==="a"||w.type==="f"){var A=ce(ee,ie,"<",">");w.subtype=ee.substring(ie+1,A),ie=A;}else throw {code:"S0401",stack:new Error().stack,value:w.type,offset:ie};break}ie++;}var J="^"+_.map(function($){return "("+$.regex+")"}).join("")+"$",I=new RegExp(J),p=function($){var Z;if(F.isFunction($))Z="f";else {var ue=typeof $;switch(ue){case "string":Z="s";break;case "number":Z="n";break;case "boolean":Z="b";break;case "object":$===null?Z="l":Array.isArray($)?Z="a":Z="o";break;default:Z="m";}}return Z},R=function($,Z){for(var ue="^",fe=0,le=0;le<_.length;le++){ue+=_[le].regex;var pe=Z.match(ue);if(pe===null)throw {code:"T0410",stack:new Error().stack,value:$[fe],index:fe+1};fe=pe[0].length;}throw {code:"T0410",stack:new Error().stack,value:$[fe],index:fe+1}};return {definition:ee,validate:function($,Z){var ue="";$.forEach(function(xe){ue+=p(xe);});var fe=I.exec(ue);if(fe){var le=[],pe=0;return _.forEach(function(xe,qe){var ve=$[pe],D=fe[qe+1];if(D==="")if(xe.context&&xe.contextRegex){var N=p(Z);if(xe.contextRegex.test(N))le.push(Z);else throw {code:"T0411",stack:new Error().stack,value:Z,index:pe+1}}else le.push(ve),pe++;else D.split("").forEach(function(U){if(xe.type==="a"){if(U==="m")ve=void 0;else {ve=$[pe];var oe=true;if(typeof xe.subtype<"u"){if(U!=="a"&&D!==xe.subtype)oe=false;else if(U==="a"&&ve.length>0){var Ce=p(ve[0]);if(Ce!==xe.subtype.charAt(0))oe=false;else {var o=ve.filter(function(u){return p(u)!==Ce});oe=o.length===0;}}}if(!oe)throw {code:"T0412",stack:new Error().stack,value:ve,index:pe+1,type:L[xe.subtype]};U!=="a"&&(ve=[ve]);}le.push(ve),pe++;}else le.push(ve),pe++;});}),le}R($,ue);}}}return ne})();C.exports=m;},{"./utils":6}],6:[function(b,C,x){let F=(()=>{function m(A){var J=false;if(typeof A=="number"&&(J=!isNaN(A),J&&!isFinite(A)))throw {code:"D1001",value:A,stack:new Error().stack};return J}function L(A){var J=false;return Array.isArray(A)&&(J=A.filter(function(I){return typeof I!="string"}).length===0),J}function ne(A){var J=false;return Array.isArray(A)&&(J=A.filter(function(I){return !m(I)}).length===0),J}function ee(){var A=[];return A.sequence=true,arguments.length===1&&A.push(arguments[0]),A}function ie(A){return A.sequence===true&&Array.isArray(A)}function _(A){return A&&(A._jsonata_function===true||A._jsonata_lambda===true)||typeof A=="function"}function k(A){var J=typeof A.arity=="number"?A.arity:typeof A.implementation=="function"?A.implementation.length:typeof A.length=="number"?A.length:A.arguments.length;return J}function w(A){return A&&A._jsonata_lambda===true}var T=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function re(A){return typeof A=="object"&&A!==null&&T in A&&"next"in A&&typeof A.next=="function"}function ce(A,J){if(A===J)return true;if(typeof A=="object"&&typeof J=="object"&&A!==null&&J!==null){if(Array.isArray(A)&&Array.isArray(J)){if(A.length!==J.length)return false;for(var I=0;I<A.length;I++)if(!ce(A[I],J[I]))return false;return true}var p=Object.getOwnPropertyNames(A),R=Object.getOwnPropertyNames(J);if(p.length!==R.length)return false;for(p=p.sort(),R=R.sort(),I=0;I<p.length;I++)if(p[I]!==R[I])return false;for(I=0;I<p.length;I++){var $=p[I];if(!ce(A[$],J[$]))return false}return true}return false}function z(A){return typeof A=="object"&&A!==null&&"then"in A&&typeof A.then=="function"}function q(A){var J=[];for(let I of A)J.push(I);return J}return {isNumeric:m,isArrayOfStrings:L,isArrayOfNumbers:ne,createSequence:ee,isSequence:ie,isFunction:_,isLambda:w,isIterable:re,getFunctionArity:k,isDeepEqual:ce,stringToArray:q,isPromise:z}})();C.exports=F;},{}]},{},[3])(3)});});var zn=an((Hn,on)=>{(function(c){if(typeof Hn=="object"&&typeof on<"u")on.exports=c();else if(typeof define=="function"&&define.amd)define([],c);else {var d;typeof window<"u"?d=window:typeof global<"u"?d=global:typeof self<"u"?d=self:d=this,d.jsonata=c();}})(function(){return (function(){function b(C,x,F){function m(ee,ie){if(!x[ee]){if(!C[ee]){var _=typeof bt=="function"&&bt;if(!ie&&_)return _(ee,true);if(L)return L(ee,true);var k=new Error("Cannot find module '"+ee+"'");throw k.code="MODULE_NOT_FOUND",k}var w=x[ee]={exports:{}};C[ee][0].call(w.exports,function(T){var re=C[ee][1][T];return m(re||T)},w,w.exports,b,C,x,F);}return x[ee].exports}for(var L=typeof bt=="function"&&bt,ne=0;ne<F.length;ne++)m(F[ne]);return m}return b})()({1:[function(b,C,x){let F=b("./utils"),m=(function(){let L=F.stringToArray,ne=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],ee=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],ie=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],_=["Thousand","Million","Billion","Trillion"];function k(l,v){var g=function(M,P,S){var j="";if(M<=19)j=(P?" and ":"")+(S?ee[M]:ne[M]);else if(M<100){let me=Math.floor(M/10),be=M%10;j=(P?" and ":"")+ie[me-2],be>0?j+="-"+g(be,false,S):S&&(j=j.substring(0,j.length-1)+"ieth");}else if(M<1e3){let me=Math.floor(M/100),be=M%100;j=(P?", ":"")+ne[me]+" Hundred",be>0?j+=g(be,true,S):S&&(j+="th");}else {var Y=Math.floor(Math.log10(M)/3);Y>_.length&&(Y=_.length);let me=Math.pow(10,Y*3),be=Math.floor(M/me),K=M-be*me;j=(P?", ":"")+g(be,false,false)+" "+_[Y-1],K>0?j+=g(K,true,S):S&&(j+="th");}return j},E=g(l,false,v);return E}let w={};ne.forEach(function(l,v){w[l.toLowerCase()]=v;}),ee.forEach(function(l,v){w[l.toLowerCase()]=v;}),ie.forEach(function(l,v){let g=l.toLowerCase();w[g]=(v+2)*10,w[g.substring(0,l.length-1)+"ieth"]=w[g];}),w.hundredth=100,_.forEach(function(l,v){let g=l.toLowerCase(),E=Math.pow(10,(v+1)*3);w[g]=E,w[g+"th"]=E;});function T(l){let g=l.split(/,\s|\sand\s|[\s\\-]/).map(P=>w[P]),E=[0];return g.forEach(P=>{if(P<100){let S=E.pop();S>=1e3&&(E.push(S),S=0),E.push(S+P);}else E.push(E.pop()*P);}),E.reduce((P,S)=>P+S,0)}let re=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],ce={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function z(l){for(var v=0;v<re.length;v++){let g=re[v];if(l>=g[0])return g[1]+z(l-g[0])}return ""}function q(l){for(var v=0,g=1,E=l.length-1;E>=0;E--){let M=l[E],P=ce[M];P<g?v-=P:(g=P,v+=P);}return v}function A(l,v){for(var g=[],E=v.charCodeAt(0);l>0;)g.unshift(String.fromCharCode((l-1)%26+E)),l=Math.floor((l-1)/26);return g.join("")}function J(l,v){for(var g=v.charCodeAt(0),E=0,M=0;M<l.length;M++)E+=(l.charCodeAt(l.length-M-1)-g+1)*Math.pow(26,M);return E}function I(l,v){if(typeof l>"u")return;l=Math.floor(l);let g=ue(v);return $(l,g)}let p={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},R={UPPER:"upper",LOWER:"lower",TITLE:"title"};function $(l,v){let g,E=l<0;switch(l=Math.abs(l),v.primary){case p.LETTERS:g=A(l,v.case===R.UPPER?"A":"a");break;case p.ROMAN:g=z(l),v.case===R.UPPER&&(g=g.toUpperCase());break;case p.WORDS:g=k(l,v.ordinal),v.case===R.UPPER?g=g.toUpperCase():v.case===R.LOWER&&(g=g.toLowerCase());break;case p.DECIMAL:g=""+l;var M=v.mandatoryDigits-g.length;if(M>0){var P=new Array(M+1).join("0");g=P+g;}if(v.zeroCode!==48&&(g=L(g).map(me=>String.fromCodePoint(me.codePointAt(0)+v.zeroCode-48)).join("")),v.regular){let me=Math.floor((g.length-1)/v.groupingSeparators.position);for(let be=me;be>0;be--){let K=g.length-be*v.groupingSeparators.position;g=g.substr(0,K)+v.groupingSeparators.character+g.substr(K);}}else v.groupingSeparators.reverse().forEach(me=>{let be=g.length-me.position;g=g.substr(0,be)+me.character+g.substr(be);});if(v.ordinal){var S={1:"st",2:"nd",3:"rd"},j=g[g.length-1],Y=S[j];(!Y||g.length>1&&g[g.length-2]==="1")&&(Y="th"),g=g+Y;}break;case p.SEQUENCE:throw {code:"D3130",value:v.token}}return E&&(g="-"+g),g}let Z=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function ue(l){let v={type:"integer",primary:p.DECIMAL,case:R.LOWER,ordinal:false},g,E,M=l.lastIndexOf(";");switch(M===-1?g=l:(g=l.substring(0,M),E=l.substring(M+1),E[0]==="o"&&(v.ordinal=true)),g){case "A":v.case=R.UPPER;case "a":v.primary=p.LETTERS;break;case "I":v.case=R.UPPER;case "i":v.primary=p.ROMAN;break;case "W":v.case=R.UPPER,v.primary=p.WORDS;break;case "Ww":v.case=R.TITLE,v.primary=p.WORDS;break;case "w":v.primary=p.WORDS;break;default:{let P=null,S=0,j=0,Y=[],me=0;if(L(g).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let X=false;for(let de=0;de<Z.length;de++){let H=Z[de];if(K>=H&&K<=H+9){if(X=true,S++,me++,P===null)P=H;else if(H!==P)throw {code:"D3131"};break}}X||(K===35?(me++,j++):Y.push({position:me,character:String.fromCodePoint(K)}));}),S>0){v.primary=p.DECIMAL,v.zeroCode=P,v.mandatoryDigits=S,v.optionalDigits=j;let X=function(de){if(de.length===0)return 0;let H=de[0].character;for(let te=1;te<de.length;te++)if(de[te].character!==H)return 0;let Ie=de.map(te=>te.position),Ge=function(te,ge){return ge===0?te:Ge(ge,te%ge)},Ne=Ie.reduce(Ge);for(let te=1;te<=Ie.length;te++)if(Ie.indexOf(te*Ne)===-1)return 0;return Ne}(Y);X>0?(v.regular=true,v.groupingSeparators={position:X,character:Y[0].character}):(v.regular=false,v.groupingSeparators=Y);}else v.primary=p.SEQUENCE,v.token=g;}}return v}let fe={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function le(l){var v=[];let g={type:"datetime",parts:v},E=function(X,de){if(de>X){let H=l.substring(X,de);H=H.split("]]").join("]"),v.push({type:"literal",value:H});}};for(var M=0,P=0;P<l.length;){if(l.charAt(P)==="["){if(l.charAt(P+1)==="["){E(M,P),v.push({type:"literal",value:"["}),P+=2,M=P;continue}if(E(M,P),M=P,P=l.indexOf("]",M),P===-1)throw {code:"D3135"};let X=l.substring(M+1,P);X=X.split(/\s+/).join("");var S={type:"marker",component:X.charAt(0)},j=X.lastIndexOf(","),Y;if(j!==-1){let de=X.substring(j+1),H=de.indexOf("-"),Ie,Ge,Ne=function(ge){if(!(typeof ge>"u"||ge==="*"))return parseInt(ge)};H===-1?Ie=de:(Ie=de.substring(0,H),Ge=de.substring(H+1));let te={min:Ne(Ie),max:Ne(Ge)};S.width=te,Y=X.substring(1,j);}else Y=X.substring(1);if(Y.length===1)S.presentation1=Y;else if(Y.length>1){var me=Y.charAt(Y.length-1);"atco".indexOf(me)!==-1?(S.presentation2=me,me==="o"&&(S.ordinal=true),S.presentation1=Y.substring(0,Y.length-1)):S.presentation1=Y;}else S.presentation1=fe[S.component];if(typeof S.presentation1>"u")throw {code:"D3132",value:S.component};if(S.presentation1[0]==="n")S.names=R.LOWER;else if(S.presentation1[0]==="N")S.presentation1[1]==="n"?S.names=R.TITLE:S.names=R.UPPER;else if("YMDdFWwXxHhmsf".indexOf(S.component)!==-1){var be=S.presentation1;if(S.presentation2&&(be+=";"+S.presentation2),S.integerFormat=ue(be),S.width&&S.width.min!==void 0&&S.integerFormat.mandatoryDigits<S.width.min&&(S.integerFormat.mandatoryDigits=S.width.min),S.component==="Y")if(S.n=-1,S.width&&S.width.max!==void 0)S.n=S.width.max,S.integerFormat.mandatoryDigits=S.n;else {var K=S.integerFormat.mandatoryDigits+S.integerFormat.optionalDigits;K>=2&&(S.n=K);}let de=v[v.length-1];de&&de.integerFormat&&(de.integerFormat.parseWidth=de.integerFormat.mandatoryDigits);}(S.component==="Z"||S.component==="z")&&(S.integerFormat=ue(S.presentation1)),v.push(S),M=P+1;}P++;}return E(M,P),g}let pe=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],xe=["January","February","March","April","May","June","July","August","September","October","November","December"],qe=1e3*60*60*24,ve=function(l){let v=Date.UTC(l.year,l.month);var g=new Date(v).getUTCDay();return g===0&&(g=7),g>4?v+(8-g)*qe:v-(g-1)*qe},D=function(l,v){return {year:l,month:v,nextMonth:function(){return v===11?D(l+1,0):D(l,v+1)},previousMonth:function(){return v===0?D(l-1,11):D(l,v-1)},nextYear:function(){return D(l+1,v)},previousYear:function(){return D(l-1,v)}}},N=function(l,v){return (v-l)/(qe*7)+1},U=(l,v)=>{let g;switch(v){case "Y":g=l.getUTCFullYear();break;case "M":g=l.getUTCMonth()+1;break;case "D":g=l.getUTCDate();break;case "d":{let E=Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),M=Date.UTC(l.getUTCFullYear(),0);g=(E-M)/qe+1;break}case "F":g=l.getUTCDay(),g===0&&(g=7);break;case "W":{let E=D(l.getUTCFullYear(),0),M=ve(E),P=Date.UTC(E.year,l.getUTCMonth(),l.getUTCDate()),S=N(M,P);if(S>52){let j=ve(E.nextYear());P>=j&&(S=1);}else if(S<1){let j=ve(E.previousYear());S=N(j,P);}g=Math.floor(S);break}case "w":{let E=D(l.getUTCFullYear(),l.getUTCMonth()),M=ve(E),P=Date.UTC(E.year,E.month,l.getUTCDate()),S=N(M,P);if(S>4){let j=ve(E.nextMonth());P>=j&&(S=1);}else if(S<1){let j=ve(E.previousMonth());S=N(j,P);}g=Math.floor(S);break}case "X":{let E=D(l.getUTCFullYear(),0),M=ve(E),P=ve(E.nextYear()),S=l.getTime();S<M?g=E.year-1:S>=P?g=E.year+1:g=E.year;break}case "x":{let E=D(l.getUTCFullYear(),l.getUTCMonth()),M=ve(E),P=E.nextMonth(),S=ve(P),j=l.getTime();j<M?g=E.previousMonth().month+1:j>=S?g=P.month+1:g=E.month+1;break}case "H":g=l.getUTCHours();break;case "h":g=l.getUTCHours(),g=g%12,g===0&&(g=12);break;case "P":g=l.getUTCHours()>=12?"pm":"am";break;case "m":g=l.getUTCMinutes();break;case "s":g=l.getUTCSeconds();break;case "f":g=l.getUTCMilliseconds();break;case "Z":case "z":break;case "C":g="ISO";break;case "E":g="ISO";break}return g},oe=null;function Ce(l,v,g){var E=0,M=0;if(typeof g<"u"){let be=parseInt(g);E=Math.floor(be/100),M=be%100;}var P=function(be,K){var X=U(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(X=X%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")X=xe[X-1];else if(K.component==="F")X=pe[X];else throw {code:"D3133",value:K.component};K.names===R.UPPER?X=X.toUpperCase():K.names===R.LOWER&&(X=X.toLowerCase()),K.width&&X.length>K.width.max&&(X=X.substring(0,K.width.max));}else X=$(X,K.integerFormat);else if(K.component==="f")X=$(X,K.integerFormat);else if(K.component==="Z"||K.component==="z"){let de=E*100+M;if(K.integerFormat.regular)X=$(de,K.integerFormat);else {let H=K.integerFormat.mandatoryDigits;if(H===1||H===2)X=$(E,K.integerFormat),M!==0&&(X+=":"+I(M,"00"));else if(H===3||H===4)X=$(de,K.integerFormat);else throw {code:"D3134",value:H}}de>=0&&(X="+"+X),K.component==="z"&&(X="GMT"+X),de===0&&K.presentation2==="t"&&(X="Z");}else K.component==="P"&&K.names===R.UPPER&&(X=X.toUpperCase());return X};let S;typeof v>"u"?(oe===null&&(oe=le("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),S=oe):S=le(v);let j=(60*E+M)*60*1e3,Y=new Date(l+j),me="";return S.parts.forEach(function(be){be.type==="literal"?me+=be.value:me+=P(Y,be);}),me}function o(l){var v={};if(l.type==="datetime")v.type="datetime",v.parts=l.parts.map(function(g){var E={};if(g.type==="literal")E.regex=g.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(g.component==="Z"||g.component==="z"){let P;Array.isArray(g.integerFormat.groupingSeparators)||(P=g.integerFormat.groupingSeparators),E.regex="",g.component==="z"&&(E.regex="GMT"),E.regex+="[-+][0-9]+",P&&(E.regex+=P.character+"[0-9]+"),E.parse=function(S){g.component==="z"&&(S=S.substring(3));let j=0,Y=0;return P?(j=Number.parseInt(S.substring(0,S.indexOf(P.character))),Y=Number.parseInt(S.substring(S.indexOf(P.character)+1))):S.length-1<=2?j=Number.parseInt(S):(j=Number.parseInt(S.substring(0,3)),Y=Number.parseInt(S.substring(3))),j*60+Y};}else if(g.integerFormat)E=o(g.integerFormat);else {E.regex="[a-zA-Z]+";var M={};if(g.component==="M"||g.component==="x")xe.forEach(function(P,S){g.width&&g.width.max?M[P.substring(0,g.width.max)]=S+1:M[P]=S+1;});else if(g.component==="F")pe.forEach(function(P,S){S>0&&(g.width&&g.width.max?M[P.substring(0,g.width.max)]=S:M[P]=S);});else if(g.component==="P")M={am:0,AM:0,pm:1,PM:1};else throw {code:"D3133",value:g.component};E.parse=function(P){return M[P]};}return E.component=g.component,E});else {v.type="integer";let g=l.case===R.UPPER;switch(l.primary){case p.LETTERS:v.regex=g?"[A-Z]+":"[a-z]+",v.parse=function(E){return J(E,g?"A":"a")};break;case p.ROMAN:v.regex=g?"[MDCLXVI]+":"[mdclxvi]+",v.parse=function(E){return q(g?E:E.toUpperCase())};break;case p.WORDS:v.regex="(?:"+Object.keys(w).concat("and","[\\-, ]").join("|")+")+",v.parse=function(E){return T(E.toLowerCase())};break;case p.DECIMAL:v.regex="[0-9]",l.parseWidth?v.regex+=`{${l.parseWidth}}`:v.regex+="+",l.ordinal&&(v.regex+="(?:th|st|nd|rd)"),v.parse=function(E){let M=E;return l.ordinal&&(M=E.substring(0,E.length-2)),l.regular?M=M.split(",").join(""):l.groupingSeparators.forEach(P=>{M=M.split(P.character).join("");}),l.zeroCode!==48&&(M=M.split("").map(P=>String.fromCodePoint(P.codePointAt(0)-l.zeroCode+48)).join("")),parseInt(M)};break;case p.SEQUENCE:throw {code:"D3130",value:l.token}}}return v}function u(l,v){if(typeof l>"u")return;let g=ue(v);return o(g).parse(l)}function B(l,v){let g=le(v),E=o(g),M="^"+E.parts.map(Y=>"("+Y.regex+")").join("")+"$";var S=new RegExp(M,"i").exec(l);if(S!==null){let H={};for(let Ae=1;Ae<S.length;Ae++){let n=E.parts[Ae-1];n.parse&&(H[n.component]=n.parse(S[Ae]));}if(Object.getOwnPropertyNames(H).length===0)return;let Ie=0,Ge=Ae=>{Ie<<=1,Ie+=Ae?1:0;},Ne=Ae=>!(~Ae&Ie)&&!!(Ae&Ie);"YXMxWwdD".split("").forEach(Ae=>Ge(H[Ae]));let ge=!Ne(161)&&Ne(130),Fe=Ne(84),Ke=!Fe&&Ne(72);Ie=0,"PHhmsf".split("").forEach(Ae=>Ge(H[Ae]));let Xe=!Ne(23)&&Ne(47),ht=(ge?"YD":Fe?"XxwF":Ke?"XWF":"YMD")+(Xe?"Phmsf":"Hmsf"),Ye=this.environment.timestamp,ut=false,Ze=false;if(ht.split("").forEach(Ae=>{if(typeof H[Ae]>"u")ut?(H[Ae]="MDd".indexOf(Ae)!==-1?1:0,Ze=true):H[Ae]=U(Ye,Ae);else if(ut=true,Ze)throw {code:"D3136"}}),H.M>0?H.M-=1:H.M=0,ge){let Ae=Date.UTC(H.Y,0),n=(H.d-1)*1e3*60*60*24,a=new Date(Ae+n);H.M=a.getUTCMonth(),H.D=a.getUTCDate();}if(Fe)throw {code:"D3136"};if(Ke)throw {code:"D3136"};Xe&&(H.H=H.h===12?0:H.h,H.P===1&&(H.H+=12));var j=Date.UTC(H.Y,H.M,H.D,H.H,H.m,H.s,H.f);return (H.Z||H.z)&&(j-=(H.Z||H.z)*60*1e3),j}}var ae=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function we(l,v){if(!(typeof l>"u"))if(typeof v>"u"){if(!ae.test(l))throw {stack:new Error().stack,code:"D3110",value:l};return Date.parse(l)}else return B.call(this,l,v)}function ye(l,v,g){if(!(typeof l>"u"))return Ce.call(this,l,v,g)}return {formatInteger:I,parseInteger:u,fromMillis:ye,toMillis:we}})();C.exports=m;},{"./utils":6}],2:[function(b,C,x){(function(F){(function(){var m=b("./utils");let L=(()=>{var ne=m.isNumeric,ee=m.isArrayOfStrings,ie=m.isArrayOfNumbers,_=m.createSequence,k=m.isSequence,w=m.isFunction,T=m.isLambda,re=m.isPromise,ce=m.getFunctionArity,z=m.isDeepEqual,q=m.stringToArray;function A(e){if(!(typeof e>"u")){var t=0;return e.forEach(function(r){t+=r;}),t}}function J(e){return typeof e>"u"?0:e.length}function I(e){if(!(typeof e>"u"||e.length===0))return Math.max.apply(Math,e)}function p(e){if(!(typeof e>"u"||e.length===0))return Math.min.apply(Math,e)}function R(e){if(!(typeof e>"u"||e.length===0)){var t=0;return e.forEach(function(r){t+=r;}),t/e.length}}function $(e,t=false){if(!(typeof e>"u")){var r;if(typeof e=="string")r=e;else if(w(e))r="";else {if(typeof e=="number"&&!isFinite(e))throw {code:"D3001",value:e,stack:new Error().stack};var f=t?2:0;Array.isArray(e)&&e.outerWrapper&&(e=e[0]),r=JSON.stringify(e,function(s,y){return typeof y<"u"&&y!==null&&y.toPrecision&&ne(y)?Number(y.toPrecision(15)):y&&w(y)?"":y},f);}return r}}function Z(e,t,r){if(!(typeof e>"u")){var f=q(e),s=f.length;if(s+t<0&&(t=0),typeof r<"u"){if(r<=0)return "";var y=t>=0?t+r:s+t+r;return f.slice(t,y).join("")}return f.slice(t).join("")}}function ue(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(0,r):e}}function fe(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(r+t.length):e}}function le(e){if(!(typeof e>"u"))return e.toLowerCase()}function pe(e){if(!(typeof e>"u"))return e.toUpperCase()}function xe(e){if(!(typeof e>"u"))return q(e).length}function qe(e){if(!(typeof e>"u")){var t=e.replace(/[ \t\n\r]+/gm," ");return t.charAt(0)===" "&&(t=t.substring(1)),t.charAt(t.length-1)===" "&&(t=t.substring(0,t.length-1)),t}}function ve(e,t,r){if(!(typeof e>"u")){(typeof r>"u"||r.length===0)&&(r=" ");var f;t=Math.trunc(t);var s=Math.abs(t)-xe(e);if(s>0){var y=new Array(s+1).join(r);r.length>1&&(y=Z(y,0,s)),t>0?f=e+y:f=y+e;}else f=e;return f}}function D(e,t){var r=e.apply(this,[t]);if(re(r)&&(r=r),r&&!(typeof r.start=="number"||r.end==="number"||Array.isArray(r.groups)||w(r.next)))throw {code:"T1010",stack:new Error().stack};return r}function N(e,t){if(!(typeof e>"u")){var r;if(typeof t=="string")r=e.indexOf(t)!==-1;else {var f=D(t,e);r=typeof f<"u";}return r}}function U(e,t,r){if(!(typeof e>"u")){if(r<0)throw {stack:new Error().stack,value:r,code:"D3040",index:3};var f=_();if(typeof r>"u"||r>0){var s=0,y=D(t,e);if(typeof y<"u")for(;typeof y<"u"&&(typeof r>"u"||s<r);)f.push({match:y.match,index:y.start,groups:y.groups}),y=D(y.next),s++;}return f}}function oe(e,t,r,f){if(!(typeof e>"u")){var s=this;if(t==="")throw {code:"D3010",stack:new Error().stack,value:t,index:2};if(f<0)throw {code:"D3011",stack:new Error().stack,value:f,index:4};var y;typeof r=="string"?y=function(Se){for(var je="",ke=0,De=r.indexOf("$",ke);De!==-1&&ke<r.length;){je+=r.substring(ke,De),ke=De+1;var Je=r.charAt(ke);if(Je==="$")je+="$",ke++;else if(Je==="0")je+=Se.match,ke++;else {var Me;if(Se.groups.length===0?Me=1:Me=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,De=parseInt(r.substring(ke,ke+Me),10),Me>1&&De>Se.groups.length&&(De=parseInt(r.substring(ke,ke+Me-1),10)),isNaN(De))je+="$";else {if(Se.groups.length>0){var ct=Se.groups[De-1];typeof ct<"u"&&(je+=ct);}ke+=De.toString().length;}}De=r.indexOf("$",ke);}return je+=r.substring(ke),je}:y=r;var O="",V=0;if(typeof f>"u"||f>0){var W=0;if(typeof t=="string"){for(var Ee=e.indexOf(t,V);Ee!==-1&&(typeof f>"u"||W<f);)O+=e.substring(V,Ee),O+=r,V=Ee+t.length,W++,Ee=e.indexOf(t,V);O+=e.substring(V);}else {var he=D(t,e);if(typeof he<"u"){for(;typeof he<"u"&&(typeof f>"u"||W<f);){O+=e.substring(V,he.start);var Te=y.apply(s,[he]);if(re(Te)&&(Te=Te),typeof Te=="string")O+=Te;else throw {code:"D3012",stack:new Error().stack,value:Te};V=he.start+he.match.length,W++,he=D(he.next);}O+=e.substring(V);}else O=e;}}else O=e;return O}}function Ce(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.btoa:function(r){return new F.Buffer.from(r,"binary").toString("base64")};return t(e)}}function o(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.atob:function(r){return new F.Buffer.from(r,"base64").toString("binary")};return t(e)}}function u(e){if(!(typeof e>"u")){var t;try{t=encodeURIComponent(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrlComponent"}}return t}}function B(e){if(!(typeof e>"u")){var t;try{t=encodeURI(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"encodeUrl"}}return t}}function ae(e){if(!(typeof e>"u")){var t;try{t=decodeURIComponent(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrlComponent"}}return t}}function we(e){if(!(typeof e>"u")){var t;try{t=decodeURI(e);}catch{throw {code:"D3140",stack:new Error().stack,value:e,functionName:"decodeUrl"}}return t}}function ye(e,t,r){if(!(typeof e>"u")){if(r<0)throw {code:"D3020",stack:new Error().stack,value:r,index:3};var f=[];if(typeof r>"u"||r>0)if(typeof t=="string")f=e.split(t,r);else {var s=0,y=D(t,e);if(typeof y<"u"){for(var O=0;typeof y<"u"&&(typeof r>"u"||s<r);)f.push(e.substring(O,y.start)),O=y.end,y=D(y.next),s++;(typeof r>"u"||s<r)&&f.push(e.substring(O));}else f.push(e);}return f}}function l(e,t){if(!(typeof e>"u"))return typeof t>"u"&&(t=""),e.join(t)}function v(e,t,r){if(!(typeof e>"u")){var f={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"\u2030","zero-digit":"0",digit:"#","pattern-separator":";"},s=f;typeof r<"u"&&Object.keys(r).forEach(function(Q){s[Q]=r[Q];});for(var y=[],O=s["zero-digit"].charCodeAt(0),V=O;V<O+10;V++)y.push(String.fromCharCode(V));var W=y.concat([s["decimal-separator"],s["exponent-separator"],s["grouping-separator"],s.digit,s["pattern-separator"]]),Ee=t.split(s["pattern-separator"]);if(Ee.length>2)throw {code:"D3080",stack:new Error().stack};var he=function(Q){var Oe=(function(){for(var _e,ze=0;ze<Q.length;ze++)if(_e=Q.charAt(ze),W.indexOf(_e)!==-1&&_e!==s["exponent-separator"])return Q.substring(0,ze)})(),$e=(function(){for(var _e,ze=Q.length-1;ze>=0;ze--)if(_e=Q.charAt(ze),W.indexOf(_e)!==-1&&_e!==s["exponent-separator"])return Q.substring(ze+1)})(),Re=Q.substring(Oe.length,Q.length-$e.length),Be,rt,Ve,st,He=Q.indexOf(s["exponent-separator"],Oe.length);He===-1||He>Q.length-$e.length?(Be=Re,rt=void 0):(Be=Re.substring(0,He),rt=Re.substring(He+1));var We=Be.indexOf(s["decimal-separator"]);return We===-1?(Ve=Be,st=$e):(Ve=Be.substring(0,We),st=Be.substring(We+1)),{prefix:Oe,suffix:$e,activePart:Re,mantissaPart:Be,exponentPart:rt,integerPart:Ve,fractionalPart:st,subpicture:Q}},Te=function(Q){var Oe,$e,Re=Q.subpicture,Be=Re.indexOf(s["decimal-separator"]);Be!==Re.lastIndexOf(s["decimal-separator"])&&(Oe="D3081"),Re.indexOf(s.percent)!==Re.lastIndexOf(s.percent)&&(Oe="D3082"),Re.indexOf(s["per-mille"])!==Re.lastIndexOf(s["per-mille"])&&(Oe="D3083"),Re.indexOf(s.percent)!==-1&&Re.indexOf(s["per-mille"])!==-1&&(Oe="D3084");var rt=false;for($e=0;$e<Q.mantissaPart.length;$e++){var Ve=Q.mantissaPart.charAt($e);if(y.indexOf(Ve)!==-1||Ve===s.digit){rt=true;break}}rt||(Oe="D3085");var st=Q.activePart.split("").map(function(_e){return W.indexOf(_e)===-1?"p":"a"}).join("");st.indexOf("p")!==-1&&(Oe="D3086"),Be!==-1?(Re.charAt(Be-1)===s["grouping-separator"]||Re.charAt(Be+1)===s["grouping-separator"])&&(Oe="D3087"):Q.integerPart.charAt(Q.integerPart.length-1)===s["grouping-separator"]&&(Oe="D3088"),Re.indexOf(s["grouping-separator"]+s["grouping-separator"])!==-1&&(Oe="D3089");var He=Q.integerPart.indexOf(s.digit);He!==-1&&Q.integerPart.substring(0,He).split("").filter(function(_e){return y.indexOf(_e)>-1}).length>0&&(Oe="D3090"),He=Q.fractionalPart.lastIndexOf(s.digit),He!==-1&&Q.fractionalPart.substring(He).split("").filter(function(_e){return y.indexOf(_e)>-1}).length>0&&(Oe="D3091");var We=typeof Q.exponentPart=="string";if(We&&Q.exponentPart.length>0&&(Re.indexOf(s.percent)!==-1||Re.indexOf(s["per-mille"])!==-1)&&(Oe="D3092"),We&&(Q.exponentPart.length===0||Q.exponentPart.split("").filter(function(_e){return y.indexOf(_e)===-1}).length>0)&&(Oe="D3093"),Oe)throw {code:Oe,stack:new Error().stack}},Se=function(Q){var Oe=function(Ue,St){for(var vt=[],tt=Ue.indexOf(s["grouping-separator"]);tt!==-1;){var Ct=(St?Ue.substring(0,tt):Ue.substring(tt)).split("").filter(function(dt){return y.indexOf(dt)!==-1||dt===s.digit}).length;vt.push(Ct),tt=Q.integerPart.indexOf(s["grouping-separator"],tt+1);}return vt},$e=Oe(Q.integerPart),Re=function(Ue){if(Ue.length===0)return 0;for(var St=function(Ct,dt){return dt===0?Ct:St(dt,Ct%dt)},vt=Ue.reduce(St),tt=1;tt<=Ue.length;tt++)if(Ue.indexOf(tt*vt)===-1)return 0;return vt},Be=Re($e),rt=Oe(Q.fractionalPart,true),Ve=Q.integerPart.split("").filter(function(Ue){return y.indexOf(Ue)!==-1}).length,st=Ve,He=Q.fractionalPart.split(""),We=He.filter(function(Ue){return y.indexOf(Ue)!==-1}).length,_e=He.filter(function(Ue){return y.indexOf(Ue)!==-1||Ue===s.digit}).length,ze=typeof Q.exponentPart=="string";Ve===0&&_e===0&&(ze?(We=1,_e=1):Ve=1),ze&&Ve===0&&Q.integerPart.indexOf(s.digit)!==-1&&(Ve=1),Ve===0&&We===0&&(We=1);var Dt=0;return ze&&(Dt=Q.exponentPart.split("").filter(function(Ue){return y.indexOf(Ue)!==-1}).length),{integerPartGroupingPositions:$e,regularGrouping:Be,minimumIntegerPartSize:Ve,scalingFactor:st,prefix:Q.prefix,fractionalPartGroupingPositions:rt,minimumFactionalPartSize:We,maximumFactionalPartSize:_e,minimumExponentSize:Dt,suffix:Q.suffix,picture:Q.subpicture}},je=Ee.map(he);je.forEach(Te);var ke=je.map(Se),De=s["minus-sign"],Je=s["zero-digit"],Me=s["decimal-separator"],ct=s["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=De+ke[1].prefix);var Pe;e>=0?Pe=ke[0]:Pe=ke[1];var mt;Pe.picture.indexOf(s.percent)!==-1?mt=e*100:Pe.picture.indexOf(s["per-mille"])!==-1?mt=e*1e3:mt=e;var it,ft;if(Pe.minimumExponentSize===0)it=mt;else {var Bt=Math.pow(10,Pe.scalingFactor),Vt=Math.pow(10,Pe.scalingFactor-1);for(it=mt,ft=0;it<Vt;)it*=10,ft-=1;for(;it>Bt;)it/=10,ft+=1;}var Ht=j(it,Pe.maximumFactionalPartSize),Rt=function(Q,Oe){var $e=Math.abs(Q).toFixed(Oe);return Je!=="0"&&($e=$e.split("").map(function(Re){return Re>="0"&&Re<="9"?y[Re.charCodeAt(0)-48]:Re}).join("")),$e},se=Rt(Ht,Pe.maximumFactionalPartSize),Le=se.indexOf(".");for(Le===-1?se=se+Me:se=se.replace(".",Me);se.charAt(0)===Je;)se=se.substring(1);for(;se.charAt(se.length-1)===Je;)se=se.substring(0,se.length-1);Le=se.indexOf(Me);var yt=Pe.minimumIntegerPartSize-Le,Ot=Pe.minimumFactionalPartSize-(se.length-Le-1);if(se=(yt>0?new Array(yt+1).join(Je):"")+se,se=se+(Ot>0?new Array(Ot+1).join(Je):""),Le=se.indexOf(Me),Pe.regularGrouping>0)for(var zt=Math.floor((Le-1)/Pe.regularGrouping),kt=1;kt<=zt;kt++)se=[se.slice(0,Le-kt*Pe.regularGrouping),ct,se.slice(Le-kt*Pe.regularGrouping)].join("");else Pe.integerPartGroupingPositions.forEach(function(Q){se=[se.slice(0,Le-Q),ct,se.slice(Le-Q)].join(""),Le++;});if(Le=se.indexOf(Me),Pe.fractionalPartGroupingPositions.forEach(function(Q){se=[se.slice(0,Q+Le+1),ct,se.slice(Q+Le+1)].join("");}),Le=se.indexOf(Me),(Pe.picture.indexOf(Me)===-1||Le===se.length-1)&&(se=se.substring(0,se.length-1)),typeof ft<"u"){var wt=Rt(ft,0);yt=Pe.minimumExponentSize-wt.length,yt>0&&(wt=new Array(yt+1).join(Je)+wt),se=se+s["exponent-separator"]+(ft<0?De:"")+wt;}return se=Pe.prefix+se+Pe.suffix,se}}function g(e,t){if(!(typeof e>"u")){if(e=j(e),typeof t>"u"?t=10:t=j(t),t<2||t>36)throw {code:"D3100",stack:new Error().stack,value:t};var r=e.toString(t);return r}}function E(e){var t;if(!(typeof e>"u")){if(typeof e=="number")t=e;else if(typeof e=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(e)&&!isNaN(parseFloat(e))&&isFinite(e))t=parseFloat(e);else if(typeof e=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(e))t=Number(e);else if(e===true)t=1;else if(e===false)t=0;else throw {code:"D3030",value:e,stack:new Error().stack,index:1};return t}}function M(e){var t;if(!(typeof e>"u"))return t=Math.abs(e),t}function P(e){var t;if(!(typeof e>"u"))return t=Math.floor(e),t}function S(e){var t;if(!(typeof e>"u"))return t=Math.ceil(e),t}function j(e,t){var r;if(!(typeof e>"u")){if(t){var f=e.toString().split("e");e=+(f[0]+"e"+(f[1]?+f[1]+t:t));}r=Math.round(e);var s=r-e;return Math.abs(s)===.5&&Math.abs(r%2)===1&&(r=r-1),t&&(f=r.toString().split("e"),r=+(f[0]+"e"+(f[1]?+f[1]-t:-t))),Object.is(r,-0)&&(r=0),r}}function Y(e){var t;if(!(typeof e>"u")){if(e<0)throw {stack:new Error().stack,code:"D3060",index:1,value:e};return t=Math.sqrt(e),t}}function me(e,t){var r;if(!(typeof e>"u")){if(r=Math.pow(e,t),!isFinite(r))throw {stack:new Error().stack,code:"D3061",index:1,value:e,exp:t};return r}}function be(){return Math.random()}function K(e){if(!(typeof e>"u")){var t=false;if(Array.isArray(e)){if(e.length===1)t=K(e[0]);else if(e.length>1){var r=e.filter(function(f){return K(f)});t=r.length>0;}}else typeof e=="string"?e.length>0&&(t=true):ne(e)?e!==0&&(t=true):e!==null&&typeof e=="object"&&!w(e)?Object.keys(e).length>0&&(t=true):typeof e=="boolean"&&e===true&&(t=true);return t}}function X(e){if(!(typeof e>"u"))return !K(e)}function de(e,t,r,f){var s=[t],y=ce(e);return y>=2&&s.push(r),y>=3&&s.push(f),s}function H(e,t){if(!(typeof e>"u")){for(var r=_(),f=0;f<e.length;f++){var s=de(t,e[f],f,e),y=t.apply(this,s);typeof y<"u"&&r.push(y);}return r}}function Ie(e,t){if(!(typeof e>"u")){for(var r=_(),f=0;f<e.length;f++){var s=e[f],y=de(t,s,f,e),O=t.apply(this,y);K(O)&&r.push(s);}return r}}function Ge(e,t){if(!(typeof e>"u")){for(var r=false,f,s=0;s<e.length;s++){var y=e[s],O=true;if(typeof t<"u"){var V=de(t,y,s,e),W=t.apply(this,V);O=K(W);}if(O)if(!r)f=y,r=true;else throw {stack:new Error().stack,code:"D3138",index:s}}if(!r)throw {stack:new Error().stack,code:"D3139"};return f}}function Ne(){for(var e=[],t=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,t.map(function(y){return Array.isArray(y)?y.length:0})),f=0;f<r;f++){var s=t.map(y=>y[f]);e.push(s);}return e}function te(e,t,r){if(!(typeof e>"u")){var f,s=ce(t);if(s<2)throw {stack:new Error().stack,code:"D3050",index:1};var y;for(typeof r>"u"&&e.length>0?(f=e[0],y=1):(f=r,y=0);y<e.length;){var O=[f,e[y]];s>=3&&O.push(y),s>=4&&O.push(e),f=t.apply(this,O),y++;}return f}}function ge(e){var t=_();if(Array.isArray(e)){var r={};e.forEach(function(f){var s=ge(f);s.forEach(function(y){r[y]=true;});}),t=ge(r);}else e!==null&&typeof e=="object"&&!w(e)&&Object.keys(e).forEach(f=>t.push(f));return t}function Fe(e,t){var r;if(Array.isArray(e)){r=_();for(var f=0;f<e.length;f++){var s=Fe(e[f],t);typeof s<"u"&&(Array.isArray(s)?s.forEach(y=>r.push(y)):r.push(s));}}else e!==null&&typeof e=="object"&&!w(e)&&(r=e[t]);return r}function Ke(e,t){return typeof e>"u"?t:typeof t>"u"?e:(Array.isArray(e)||(e=_(e)),Array.isArray(t)||(t=[t]),e.concat(t))}function nt(e){return !(typeof e>"u")}function Xe(e){var t=_();if(Array.isArray(e))e.forEach(function(s){t=Ke(t,Xe(s));});else if(e!==null&&typeof e=="object"&&!T(e))for(var r in e){var f={};f[r]=e[r],t.push(f);}else t=e;return t}function G(e){if(!(typeof e>"u")){var t={};return e.forEach(function(r){for(var f in r)t[f]=r[f];}),t}}function gt(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=e.length,r=new Array(t),f=0;f<t;f++)r[t-f-1]=e[f];return r}}function ht(e,t){var r=_();for(var f in e){var s=de(t,e[f],f,e),y=t.apply(this,s);typeof y<"u"&&r.push(y);}return r}function Ye(e){throw {code:"D3137",stack:new Error().stack,message:e||"$error() function evaluated"}}function ut(e,t){if(!e)throw {code:"D3141",stack:new Error().stack,message:t||"$assert() statement failed"}}function Ze(e){if(e!==void 0)return e===null?"null":ne(e)?"number":typeof e=="string"?"string":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":w(e)?"function":"object"}function Ae(e,t){if(!(typeof e>"u")){if(e.length<=1)return e;var r;if(typeof t>"u"){if(!ie(e)&&!ee(e))throw {stack:new Error().stack,code:"D3070",index:1};r=function(O,V){return O>V};}else r=t;var f=function(O,V){var W=function(he,Te,Se){Te.length===0?Array.prototype.push.apply(he,Se):Se.length===0?Array.prototype.push.apply(he,Te):r(Te[0],Se[0])?(he.push(Se[0]),W(he,Te,Se.slice(1))):(he.push(Te[0]),W(he,Te.slice(1),Se));},Ee=[];return W(Ee,O,V),Ee},s=function(O){if(!Array.isArray(O)||O.length<=1)return O;var V=Math.floor(O.length/2),W=O.slice(0,V),Ee=O.slice(V);return W=s(W),Ee=s(Ee),f(W,Ee)},y=s(e);return y}}function n(e){if(!(typeof e>"u")){if(e.length<=1)return e;for(var t=new Array(e.length),r=0;r<e.length;r++){var f=Math.floor(Math.random()*(r+1));r!==f&&(t[r]=t[f]),t[f]=e[r];}return t}}function a(e){if(!(typeof e>"u")){if(!Array.isArray(e)||e.length<=1)return e;for(var t=k(e)?_():[],r=0;r<e.length;r++){for(var f=e[r],s=false,y=0;y<t.length;y++)if(z(f,t[y])){s=true;break}s||t.push(f);}return t}}function i(e,t){var r={};for(var f in e){var s=e[f],y=de(t,s,f,e),O=t.apply(this,y);K(O)&&(r[f]=s);}return Object.keys(r).length===0&&(r=void 0),r}return {sum:A,count:J,max:I,min:p,average:R,string:$,substring:Z,substringBefore:ue,substringAfter:fe,lowercase:le,uppercase:pe,length:xe,trim:qe,pad:ve,match:U,contains:N,replace:oe,split:ye,join:l,formatNumber:v,formatBase:g,number:E,floor:P,ceil:S,round:j,abs:M,sqrt:Y,power:me,random:be,boolean:K,not:X,map:H,zip:Ne,filter:Ie,single:Ge,foldLeft:te,sift:i,keys:ge,lookup:Fe,append:Ke,exists:nt,spread:Xe,merge:G,reverse:gt,each:ht,error:Ye,assert:ut,type:Ze,sort:Ae,shuffle:n,distinct:a,base64encode:Ce,base64decode:o,encodeUrlComponent:u,encodeUrl:B,decodeUrlComponent:ae,decodeUrl:we}})();C.exports=L;}).call(this);}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{});},{"./utils":6}],3:[function(b,C,x){var F=b("./datetime"),m=b("./functions"),L=b("./utils"),ne=b("./parser"),ee=b("./signature"),ie=(function(){var _=L.isNumeric,k=L.isArrayOfStrings,w=L.isArrayOfNumbers,T=L.createSequence,re=L.isSequence,ce=L.isFunction,z=L.isLambda,q=L.isIterable,A=L.isPromise,J=L.getFunctionArity,I=L.isDeepEqual,p=Ye(null);function R(n,a,i){var e,t=i.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(t&&t(n,a,i),n.type){case "path":e=$(n,a,i);break;case "binary":e=xe(n,a,i);break;case "unary":e=qe(n,a,i);break;case "name":e=ve(n,a);break;case "string":case "number":case "value":e=D(n);break;case "wildcard":e=N(n,a);break;case "descendant":e=oe(n,a);break;case "parent":e=i.lookup(n.slot.label);break;case "condition":e=P(n,a,i);break;case "block":e=S(n,a,i);break;case "bind":e=M(n,a,i);break;case "regex":e=j(n);break;case "function":e=de(n,a,i);break;case "variable":e=Y(n,a,i);break;case "lambda":e=Ge(n,a,i);break;case "partial":e=Ne(n,a,i);break;case "apply":e=X(n,a,i);break;case "transform":e=be(n,a,i);break}if(Object.prototype.hasOwnProperty.call(n,"predicate"))for(var r=0;r<n.predicate.length;r++)e=pe(n.predicate[r].expr,e,i);n.type!=="path"&&Object.prototype.hasOwnProperty.call(n,"group")&&(e=v(n.group,e,i));var f=i.lookup(Symbol.for("jsonata.__evaluate_exit"));return f&&f(n,a,i,e),e&&re(e)&&!e.tupleStream&&(n.keepArray&&(e.keepSingleton=true),e.length===0?e=void 0:e.length===1&&(e=e.keepSingleton?e:e[0])),e}function $(n,a,i){var e;Array.isArray(a)&&n.steps[0].type!=="variable"?e=a:e=T(a);for(var t,r=false,f=void 0,s=0;s<n.steps.length;s++){var y=n.steps[s];if(y.tuple&&(r=true),s===0&&y.consarray?t=R(y,e,i):r?f=le(y,e,f,i):t=ue(y,e,i,s===n.steps.length-1),!r&&(typeof t>"u"||t.length===0))break;typeof y.focus>"u"&&(e=t);}if(r)if(n.tuple)t=f;else for(t=T(),s=0;s<f.length;s++)t.push(f[s]["@"]);return n.keepSingletonArray&&(Array.isArray(t)&&t.cons&&!t.sequence&&(t=T(t)),t.keepSingleton=true),n.hasOwnProperty("group")&&(t=v(n.group,r?f:t,i)),t}function Z(n,a){var i=Ye(n);for(let e in a)i.bind(e,a[e]);return i}function ue(n,a,i,e){var t;if(n.type==="sort")return t=me(n,a,i),n.stages&&(t=fe(n.stages,t,i)),t;t=T();for(var r=0;r<a.length;r++){var f=R(n,a[r],i);if(n.stages)for(var s=0;s<n.stages.length;s++)f=pe(n.stages[s].expr,f,i);typeof f<"u"&&t.push(f);}var y=T();return e&&t.length===1&&Array.isArray(t[0])&&!re(t[0])?y=t[0]:t.forEach(function(O){!Array.isArray(O)||O.cons?y.push(O):O.forEach(V=>y.push(V));}),y}function fe(n,a,i){for(var e=a,t=0;t<n.length;t++){var r=n[t];switch(r.type){case "filter":e=pe(r.expr,e,i);break;case "index":for(var f=0;f<e.length;f++){var s=e[f];s[r.value]=f;}break}}return e}function le(n,a,i,e){var t;if(n.type==="sort"){if(i)t=me(n,i,e);else {var r=me(n,a,e);t=T(),t.tupleStream=true;for(var f=0;f<r.length;f++){var s={"@":r[f]};s[n.index]=f,t.push(s);}}return n.stages&&(t=fe(n.stages,t,e)),t}t=T(),t.tupleStream=true;var y=e;i===void 0&&(i=a.map(Ee=>({"@":Ee})));for(var O=0;O<i.length;O++){y=Z(e,i[O]);var V=R(n,i[O]["@"],y);if(typeof V<"u"){Array.isArray(V)||(V=[V]);for(var W=0;W<V.length;W++)s={},Object.assign(s,i[O]),V.tupleStream?Object.assign(s,V[W]):(n.focus?(s[n.focus]=V[W],s["@"]=i[O]["@"]):s["@"]=V[W],n.index&&(s[n.index]=W),n.ancestor&&(s[n.ancestor.label]=i[O]["@"])),t.push(s);}}return n.stages&&(t=fe(n.stages,t,e)),t}function pe(n,a,i){var e=T();if(a&&a.tupleStream&&(e.tupleStream=true),Array.isArray(a)||(a=T(a)),n.type==="number"){var t=Math.floor(n.value);t<0&&(t=a.length+t);var r=a[t];typeof r<"u"&&(Array.isArray(r)?e=r:e.push(r));}else for(t=0;t<a.length;t++){var r=a[t],f=r,s=i;a.tupleStream&&(f=r["@"],s=Z(i,r));var y=R(n,f,s);_(y)&&(y=[y]),w(y)?y.forEach(function(V){var W=Math.floor(V);W<0&&(W=a.length+W),W===t&&e.push(r);}):m.boolean(y)&&e.push(r);}return e}function xe(n,a,i){var e,t=R(n.lhs,a,i),r=n.value,f=()=>R(n.rhs,a,i);if(r==="and"||r==="or")try{return we(t,f,r)}catch(y){throw y.position=n.position,y.token=r,y}var s=f();try{switch(r){case "+":case "-":case "*":case "/":case "%":e=o(t,s,r);break;case "=":case "!=":e=u(t,s,r);break;case "<":case "<=":case ">":case ">=":e=B(t,s,r);break;case "&":e=l(t,s);break;case "..":e=E(t,s);break;case "in":e=ae(t,s);break}}catch(y){throw y.position=n.position,y.token=r,y}return e}function qe(n,a,i){var e;switch(n.value){case "-":if(e=R(n.expression,a,i),typeof e>"u")e=void 0;else if(_(e))e=-e;else throw {code:"D1002",stack:new Error().stack,position:n.position,token:n.value,value:e};break;case "[":e=[];let f=n.expressions.map((s,y)=>(i.isParallelCall=y>0,[s,R(s,a,i)]));for(let s of f){var[t,r]=s;typeof r<"u"&&(t.value==="["?e.push(r):e=m.append(e,r));}n.consarray&&Object.defineProperty(e,"cons",{enumerable:false,configurable:false,value:true});break;case "{":e=v(n,a,i);break}return e}function ve(n,a,i){return m.lookup(a,n.value)}function D(n){return n.value}function N(n,a){var i=T();return Array.isArray(a)&&a.outerWrapper&&a.length>0&&(a=a[0]),a!==null&&typeof a=="object"&&Object.keys(a).forEach(function(e){var t=a[e];Array.isArray(t)?(t=U(t),i=m.append(i,t)):i.push(t);}),i}function U(n,a){return typeof a>"u"&&(a=[]),Array.isArray(n)?n.forEach(function(i){U(i,a);}):a.push(n),a}function oe(n,a){var i,e=T();return typeof a<"u"&&(Ce(a,e),e.length===1?i=e[0]:i=e),i}function Ce(n,a){Array.isArray(n)||a.push(n),Array.isArray(n)?n.forEach(function(i){Ce(i,a);}):n!==null&&typeof n=="object"&&Object.keys(n).forEach(function(i){Ce(n[i],a);});}function o(n,a,i){var e;if(typeof n<"u"&&!_(n))throw {code:"T2001",stack:new Error().stack,value:n};if(typeof a<"u"&&!_(a))throw {code:"T2002",stack:new Error().stack,value:a};if(typeof n>"u"||typeof a>"u")return e;switch(i){case "+":e=n+a;break;case "-":e=n-a;break;case "*":e=n*a;break;case "/":e=n/a;break;case "%":e=n%a;break}return e}function u(n,a,i){var e,t=typeof n,r=typeof a;if(t==="undefined"||r==="undefined")return false;switch(i){case "=":e=I(n,a);break;case "!=":e=!I(n,a);break}return e}function B(n,a,i){var e,t=typeof n,r=typeof a,f=t==="undefined"||t==="string"||t==="number",s=r==="undefined"||r==="string"||r==="number";if(!f||!s)throw {code:"T2010",stack:new Error().stack,value:t==="string"||t==="number"?a:n};if(!(t==="undefined"||r==="undefined")){if(t!==r)throw {code:"T2009",stack:new Error().stack,value:n,value2:a};switch(i){case "<":e=n<a;break;case "<=":e=n<=a;break;case ">":e=n>a;break;case ">=":e=n>=a;break}return e}}function ae(n,a){var i=false;if(typeof n>"u"||typeof a>"u")return false;Array.isArray(a)||(a=[a]);for(var e=0;e<a.length;e++)if(a[e]===n){i=true;break}return i}function we(n,a,i){var e,t=ye(n);switch(i){case "and":e=t&&ye(a());break;case "or":e=t||ye(a());break}return e}function ye(n){var a=m.boolean(n);return typeof a>"u"?false:a}function l(n,a){var i,e="",t="";return typeof n<"u"&&(e=m.string(n)),typeof a<"u"&&(t=m.string(a)),i=e.concat(t),i}function v(n,a,i){var e={},t={},r=!!(a&&a.tupleStream);Array.isArray(a)||(a=T(a)),a.length===0&&a.push(void 0);for(var f=0;f<a.length;f++)for(var s=a[f],y=r?Z(i,s):i,O=0;O<n.lhs.length;O++){var V=n.lhs[O],W=R(V[0],r?s["@"]:s,y);if(typeof W!="string"&&W!==void 0)throw {code:"T1003",stack:new Error().stack,position:n.position,value:W};if(W!==void 0){var Ee={data:s,exprIndex:O};if(t.hasOwnProperty(W)){if(t[W].exprIndex!==O)throw {code:"D1009",stack:new Error().stack,position:n.position,value:W};t[W].data=m.append(t[W].data,s);}else t[W]=Ee;}}let he=Object.keys(t).map((Se,je)=>{let ke=t[Se];var De=ke.data,Je=i;if(r){var Me=g(ke.data);De=Me["@"],delete Me["@"],Je=Z(i,Me);}return i.isParallelCall=je>0,[Se,R(n.lhs[ke.exprIndex][1],De,Je)]});for(let Se of he){var[W,Te]=Se;typeof Te<"u"&&(e[W]=Te);}return e}function g(n){if(!Array.isArray(n))return n;var a={};Object.assign(a,n[0]);for(var i=1;i<n.length;i++)for(let e in n[i])a[e]=m.append(a[e],n[i][e]);return a}function E(n,a){var i;if(typeof n<"u"&&!Number.isInteger(n))throw {code:"T2003",stack:new Error().stack,value:n};if(typeof a<"u"&&!Number.isInteger(a))throw {code:"T2004",stack:new Error().stack,value:a};if(typeof n>"u"||typeof a>"u"||n>a)return i;var e=a-n+1;if(e>1e7)throw {code:"D2014",stack:new Error().stack,value:e};i=new Array(e);for(var t=n,r=0;t<=a;t++,r++)i[r]=t;return i.sequence=true,i}function M(n,a,i){var e=R(n.rhs,a,i);return i.bind(n.lhs.value,e),e}function P(n,a,i){var e,t=R(n.condition,a,i);return m.boolean(t)?e=R(n.then,a,i):typeof n.else<"u"&&(e=R(n.else,a,i)),e}function S(n,a,i){for(var e,t=Ye(i),r=0;r<n.expressions.length;r++)e=R(n.expressions[r],a,t);return e}function j(n){var a=new Ae.RegexEngine(n.value),i=function(e,t){var r;a.lastIndex=t||0;var f=a.exec(e);if(f!==null){if(r={match:f[0],start:f.index,end:f.index+f[0].length,groups:[]},f.length>1)for(var s=1;s<f.length;s++)r.groups.push(f[s]);r.next=function(){if(!(a.lastIndex>=e.length)){var y=i(e,a.lastIndex);if(y&&y.match==="")throw {code:"D1004",stack:new Error().stack,position:n.position,value:n.value.source};return y}};}return r};return i}function Y(n,a,i){var e;return n.value===""?e=a&&a.outerWrapper?a[0]:a:e=i.lookup(n.value),e}function me(n,a,i){var e,t=a,r=!!a.tupleStream,f=function(y,O){for(var V=0,W=0;V===0&&W<n.terms.length;W++){var Ee=n.terms[W],he=y,Te=i;r&&(he=y["@"],Te=Z(i,y));var Se=R(Ee.expression,he,Te);he=O,Te=i,r&&(he=O["@"],Te=Z(i,O));var je=R(Ee.expression,he,Te),ke=typeof Se,De=typeof je;if(ke==="undefined"){V=De==="undefined"?0:1;continue}if(De==="undefined"){V=-1;continue}if(!(ke==="string"||ke==="number")||!(De==="string"||De==="number"))throw {code:"T2008",stack:new Error().stack,position:n.position,value:ke==="string"||ke==="number"?je:Se};if(ke!==De)throw {code:"T2007",stack:new Error().stack,position:n.position,value:Se,value2:je};Se!==je&&(Se<je?V=-1:V=1,Ee.descending===true&&(V=-V));}return V===1},s={environment:i,input:a};return e=m.sort.apply(s,[t,f]),e}function be(n,a,i){var e=function(t){if(!(typeof t>"u")){var r=i.lookup("clone");if(!ce(r))throw {code:"T2013",stack:new Error().stack,position:n.position};var f=H(r,[t],null,i),s=R(n.pattern,f,i);if(typeof s<"u"){Array.isArray(s)||(s=[s]);for(var y=0;y<s.length;y++){var O=s[y];if(O&&(O.isPrototypeOf(f)||O instanceof Object.constructor))throw {code:"D1010",stack:new Error().stack,position:n.position};var V=R(n.update,O,i),W=typeof V;if(W!=="undefined"){if(W!=="object"||V===null||Array.isArray(V))throw {code:"T2011",stack:new Error().stack,position:n.update.position,value:V};for(var Ee in V)O[Ee]=V[Ee];}if(typeof n.delete<"u"){var he=R(n.delete,O,i);if(typeof he<"u"){var Te=he;if(Array.isArray(he)||(he=[he]),!k(he))throw {code:"T2012",stack:new Error().stack,position:n.delete.position,value:Te};for(var Se=0;Se<he.length;Se++)typeof O=="object"&&O!==null&&delete O[he[Se]];}}}}return f}};return G(e,"<(oa):o>")}var K=ne("function($f, $g) { function($x){ $g($f($x)) } }");function X(n,a,i){var e,t=R(n.lhs,a,i);if(n.rhs.type==="function")e=de(n.rhs,a,i,{context:t});else {var r=R(n.rhs,a,i);if(!ce(r))throw {code:"T2006",stack:new Error().stack,position:n.position,value:r};if(ce(t)){var f=R(K,null,i);e=H(f,[t,r],null,i);}else e=H(r,[t],null,i);}return e}function de(n,a,i,e){var t,r=R(n.procedure,a,i);if(typeof r>"u"&&n.procedure.type==="path"&&i.lookup(n.procedure.steps[0].value))throw {code:"T1005",stack:new Error().stack,position:n.position,token:n.procedure.steps[0].value};var f=[];typeof e<"u"&&f.push(e.context);for(var s=0;s<n.arguments.length;s++){let O=R(n.arguments[s],a,i);if(ce(O)){let V=function(...W){return H(O,W,null,i)};V.arity=J(O),f.push(V);}else f.push(O);}var y=n.procedure.type==="path"?n.procedure.steps[0].value:n.procedure.value;try{typeof r=="object"&&(r.token=y,r.position=n.position),t=H(r,f,a,i);}catch(O){throw O.position||(O.position=n.position),O.token||(O.token=y),O}return t}function H(n,a,i,e){var t;for(t=Ie(n,a,i,e);z(t)&&t.thunk===true;){var r=R(t.body.procedure,t.input,t.environment);t.body.procedure.type==="variable"&&(r.token=t.body.procedure.value),r.position=t.body.procedure.position;for(var f=[],s=0;s<t.body.arguments.length;s++)f.push(R(t.body.arguments[s],t.input,t.environment));t=Ie(r,f,i,e);}return t}function Ie(n,a,i,e){var t;try{var r=a;if(n&&(r=te(n.signature,a,i)),z(n))t=ge(n,r);else if(n&&n._jsonata_function===!0){var f={environment:e,input:i};t=n.implementation.apply(f,r),q(t)&&(t=t.next().value),A(t)&&(t=t);}else if(typeof n=="function")t=n.apply(i,r),A(t)&&(t=t);else throw {code:"T1006",stack:new Error().stack}}catch(s){throw n&&(typeof s.token>"u"&&typeof n.token<"u"&&(s.token=n.token),s.position=n.position||s.position),s}return t}function Ge(n,a,i){var e={_jsonata_lambda:true,input:a,environment:i,arguments:n.arguments,signature:n.signature,body:n.body};return n.thunk===true&&(e.thunk=true),e.apply=function(t,r){return H(e,r,a,t?t.environment:i)},e}function Ne(n,a,i){for(var e,t=[],r=0;r<n.arguments.length;r++){var f=n.arguments[r];f.type==="operator"&&f.value==="?"?t.push(f):t.push(R(f,a,i));}var s=R(n.procedure,a,i);if(typeof s>"u"&&n.procedure.type==="path"&&i.lookup(n.procedure.steps[0].value))throw {code:"T1007",stack:new Error().stack,position:n.position,token:n.procedure.steps[0].value};if(z(s))e=Fe(s,t);else if(s&&s._jsonata_function===true)e=Ke(s.implementation,t);else if(typeof s=="function")e=Ke(s,t);else throw {code:"T1008",stack:new Error().stack,position:n.position,token:n.procedure.type==="path"?n.procedure.steps[0].value:n.procedure.value};return e}function te(n,a,i){if(typeof n>"u")return a;var e=n.validate(a,i);return e}function ge(n,a){var i,e=Ye(n.environment);return n.arguments.forEach(function(t,r){e.bind(t.value,a[r]);}),typeof n.body=="function"?i=nt(n.body,e):i=R(n.body,n.input,e),i}function Fe(n,a){var i=Ye(n.environment),e=[];n.arguments.forEach(function(r,f){var s=a[f];s&&s.type==="operator"&&s.value==="?"?e.push(r):i.bind(r.value,s);});var t={_jsonata_lambda:true,input:n.input,environment:i,arguments:e,body:n.body};return t}function Ke(n,a){var i=Xe(n);i=i.map(function(f){return "$"+f.trim()});var e="function("+i.join(", ")+"){ _ }",t=ne(e);t.body=n;var r=Fe(t,a);return r}function nt(n,a){var i=Xe(n),e=i.map(function(f){return a.lookup(f.trim())}),t={environment:a},r=n.apply(t,e);return A(r)&&(r=r),r}function Xe(n){var a=n.toString(),i=/\(([^)]*)\)/.exec(a)[1],e=i.split(",");return e}function G(n,a){var i={_jsonata_function:true,implementation:n};return typeof a<"u"&&(i.signature=ee(a)),i}function gt(n,a){if(!(typeof n>"u")){var i=this.input;typeof a<"u"&&(i=a,Array.isArray(i)&&!re(i)&&(i=T(i),i.outerWrapper=true));try{var e=ne(n,!1);}catch(r){throw Ze(r),{stack:new Error().stack,code:"D3120",value:r.message,error:r}}try{var t=R(e,i,this.environment);}catch(r){throw Ze(r),{stack:new Error().stack,code:"D3121",value:r.message,error:r}}return t}}function ht(n){if(!(typeof n>"u"))return JSON.parse(m.string(n))}function Ye(n){var a={};let i={bind:function(t,r){a[t]=r;},lookup:function(t){var r;return a.hasOwnProperty(t)?r=a[t]:n&&(r=n.lookup(t)),r},timestamp:n?n.timestamp:null,async:n?n.async:false,isParallelCall:n?n.isParallelCall:false,global:n?n.global:{ancestry:[null]}};if(n){var e=n.lookup(Symbol.for("jsonata.__createFrame_push"));e&&e(n,i);}return i}p.bind("sum",G(m.sum,"<a<n>:n>")),p.bind("count",G(m.count,"<a:n>")),p.bind("max",G(m.max,"<a<n>:n>")),p.bind("min",G(m.min,"<a<n>:n>")),p.bind("average",G(m.average,"<a<n>:n>")),p.bind("string",G(m.string,"<x-b?:s>")),p.bind("substring",G(m.substring,"<s-nn?:s>")),p.bind("substringBefore",G(m.substringBefore,"<s-s:s>")),p.bind("substringAfter",G(m.substringAfter,"<s-s:s>")),p.bind("lowercase",G(m.lowercase,"<s-:s>")),p.bind("uppercase",G(m.uppercase,"<s-:s>")),p.bind("length",G(m.length,"<s-:n>")),p.bind("trim",G(m.trim,"<s-:s>")),p.bind("pad",G(m.pad,"<s-ns?:s>")),p.bind("match",G(m.match,"<s-f<s:o>n?:a<o>>")),p.bind("contains",G(m.contains,"<s-(sf):b>")),p.bind("replace",G(m.replace,"<s-(sf)(sf)n?:s>")),p.bind("split",G(m.split,"<s-(sf)n?:a<s>>")),p.bind("join",G(m.join,"<a<s>s?:s>")),p.bind("formatNumber",G(m.formatNumber,"<n-so?:s>")),p.bind("formatBase",G(m.formatBase,"<n-n?:s>")),p.bind("formatInteger",G(F.formatInteger,"<n-s:s>")),p.bind("parseInteger",G(F.parseInteger,"<s-s:n>")),p.bind("number",G(m.number,"<(nsb)-:n>")),p.bind("floor",G(m.floor,"<n-:n>")),p.bind("ceil",G(m.ceil,"<n-:n>")),p.bind("round",G(m.round,"<n-n?:n>")),p.bind("abs",G(m.abs,"<n-:n>")),p.bind("sqrt",G(m.sqrt,"<n-:n>")),p.bind("power",G(m.power,"<n-n:n>")),p.bind("random",G(m.random,"<:n>")),p.bind("boolean",G(m.boolean,"<x-:b>")),p.bind("not",G(m.not,"<x-:b>")),p.bind("map",G(m.map,"<af>")),p.bind("zip",G(m.zip,"<a+>")),p.bind("filter",G(m.filter,"<af>")),p.bind("single",G(m.single,"<af?>")),p.bind("reduce",G(m.foldLeft,"<afj?:j>")),p.bind("sift",G(m.sift,"<o-f?:o>")),p.bind("keys",G(m.keys,"<x-:a<s>>")),p.bind("lookup",G(m.lookup,"<x-s:x>")),p.bind("append",G(m.append,"<xx:a>")),p.bind("exists",G(m.exists,"<x:b>")),p.bind("spread",G(m.spread,"<x-:a<o>>")),p.bind("merge",G(m.merge,"<a<o>:o>")),p.bind("reverse",G(m.reverse,"<a:a>")),p.bind("each",G(m.each,"<o-f:a>")),p.bind("error",G(m.error,"<s?:x>")),p.bind("assert",G(m.assert,"<bs?:x>")),p.bind("type",G(m.type,"<x:s>")),p.bind("sort",G(m.sort,"<af?:a>")),p.bind("shuffle",G(m.shuffle,"<a:a>")),p.bind("distinct",G(m.distinct,"<x:x>")),p.bind("base64encode",G(m.base64encode,"<s-:s>")),p.bind("base64decode",G(m.base64decode,"<s-:s>")),p.bind("encodeUrlComponent",G(m.encodeUrlComponent,"<s-:s>")),p.bind("encodeUrl",G(m.encodeUrl,"<s-:s>")),p.bind("decodeUrlComponent",G(m.decodeUrlComponent,"<s-:s>")),p.bind("decodeUrl",G(m.decodeUrl,"<s-:s>")),p.bind("eval",G(gt,"<sx?:x>")),p.bind("toMillis",G(F.toMillis,"<s-s?:n>")),p.bind("fromMillis",G(F.fromMillis,"<n-s?s?:s>")),p.bind("clone",G(ht,"<(oa)-:o>"));var ut={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",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",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",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this 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",S0500:"Attempted to evaluate an expression containing syntax error(s)",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}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",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",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",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",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 $)",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",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",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:"The second argument of reduce function must be a function with at least 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",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Ze(n){var a=ut[n.code];if(typeof a<"u"){var i=a.replace(/\{\{\{([^}]+)}}}/g,function(){return n[arguments[1]]});i=i.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(n[arguments[1]])}),n.message=i;}}function Ae(n,a){var i,e;try{i=ne(n,a&&a.recover),e=i.errors,delete i.errors;}catch(f){throw Ze(f),f}var t=Ye(p),r=new Date;return t.bind("now",G(function(f,s){return F.fromMillis(r.getTime(),f,s)},"<s?s?:s>")),t.bind("millis",G(function(){return r.getTime()},"<:n>")),a&&a.RegexEngine?Ae.RegexEngine=a.RegexEngine:Ae.RegexEngine=RegExp,{evaluate:function(f,s,y){if(typeof e<"u"){var O={code:"S0500",position:0};throw Ze(O),O}if(typeof s<"u"){var V;V=Ye(t);for(var W in s)V.bind(W,s[W]);}else V=t;V.bind("$",f),r=new Date,V.timestamp=r,Array.isArray(f)&&!re(f)&&(f=T(f),f.outerWrapper=true);var Ee;try{return Ee=R(i,f,V),typeof y=="function"&&y(null,Ee),Ee}catch(he){throw Ze(he),he}},assign:function(f,s){t.bind(f,s);},registerFunction:function(f,s,y){var O=G(s,y);t.bind(f,O);},ast:function(){return i},errors:function(){return e}}}return Ae.parser=ne,Ae})();C.exports=ie;},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(b,C,x){var F=b("./signature");let m=(()=>{var L={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},ne={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
5
|
+
`,r:"\r",t:" "},ee=function(_){var k=0,w=_.length,T=function(z,q){var A={type:z,value:q,position:k};return A},re=function(){for(var z=k,q=0,A,J,I=function(R){if(_.charAt(R)==="/"&&q===0){for(var $=0;_.charAt(R-($+1))==="\\";)$++;if($%2===0)return true}return false};k<w;){var p=_.charAt(k);if(I(k)){if(A=_.substring(z,k),A==="")throw {code:"S0301",stack:new Error().stack,position:k};for(k++,p=_.charAt(k),z=k;p==="i"||p==="m";)k++,p=_.charAt(k);return J=_.substring(z,k)+"g",new RegExp(A,J)}(p==="("||p==="["||p==="{")&&_.charAt(k-1)!=="\\"&&q++,(p===")"||p==="]"||p==="}")&&_.charAt(k-1)!=="\\"&&q--,k++;}throw {code:"S0302",stack:new Error().stack,position:k}},ce=function(z){if(k>=w)return null;for(var q=_.charAt(k);k<w&&`
|
|
6
|
+
\r\v`.indexOf(q)>-1;)k++,q=_.charAt(k);if(q==="/"&&_.charAt(k+1)==="*"){var A=k;for(k+=2,q=_.charAt(k);!(q==="*"&&_.charAt(k+1)==="/");)if(q=_.charAt(++k),k>=w)throw {code:"S0106",stack:new Error().stack,position:A};return k+=2,q=_.charAt(k),ce(z)}if(z!==true&&q==="/")return k++,T("regex",re());if(q==="."&&_.charAt(k+1)===".")return k+=2,T("operator","..");if(q===":"&&_.charAt(k+1)==="=")return k+=2,T("operator",":=");if(q==="!"&&_.charAt(k+1)==="=")return k+=2,T("operator","!=");if(q===">"&&_.charAt(k+1)==="=")return k+=2,T("operator",">=");if(q==="<"&&_.charAt(k+1)==="=")return k+=2,T("operator","<=");if(q==="*"&&_.charAt(k+1)==="*")return k+=2,T("operator","**");if(q==="~"&&_.charAt(k+1)===">")return k+=2,T("operator","~>");if(q==="?"&&_.charAt(k+1)===":")return k+=2,T("operator","?:");if(q==="?"&&_.charAt(k+1)==="?")return k+=2,T("operator","??");if(Object.prototype.hasOwnProperty.call(L,q))return k++,T("operator",q);if(q==='"'||q==="'"){var J=q;k++;for(var I="";k<w;){if(q=_.charAt(k),q==="\\")if(k++,q=_.charAt(k),Object.prototype.hasOwnProperty.call(ne,q))I+=ne[q];else if(q==="u"){var p=_.substr(k+1,4);if(/^[0-9a-fA-F]+$/.test(p)){var R=parseInt(p,16);I+=String.fromCharCode(R),k+=4;}else throw {code:"S0104",stack:new Error().stack,position:k}}else throw {code:"S0103",stack:new Error().stack,position:k,token:q};else {if(q===J)return k++,T("string",I);I+=q;}k++;}throw {code:"S0101",stack:new Error().stack,position:k}}var $=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,Z=$.exec(_.substring(k));if(Z!==null){var ue=parseFloat(Z[0]);if(!isNaN(ue)&&isFinite(ue))return k+=Z[0].length,T("number",ue);throw {code:"S0102",stack:new Error().stack,position:k,token:Z[0]}}var fe;if(q==="`"){k++;var le=_.indexOf("`",k);if(le!==-1)return fe=_.substring(k,le),k=le+1,T("name",fe);throw k=w,{code:"S0105",stack:new Error().stack,position:k}}for(var pe=k,xe;;)if(xe=_.charAt(pe),pe===w||`
|
|
7
|
+
\r\v`.indexOf(xe)>-1||Object.prototype.hasOwnProperty.call(L,xe)){if(_.charAt(k)==="$")return fe=_.substring(k+1,pe),k=pe,T("variable",fe);switch(fe=_.substring(k,pe),k=pe,fe){case "or":case "in":case "and":return T("operator",fe);case "true":return T("value",true);case "false":return T("value",false);case "null":return T("value",null);default:return k===w&&fe===""?null:T("name",fe)}}else pe++;};return ce},ie=function(_,k){var w,T,re={},ce=[],z=function(){var o=[];w.id!=="(end)"&&o.push({type:w.type,value:w.value,position:w.position});for(var u=T();u!==null;)o.push(u),u=T();return o},q={nud:function(){var o={code:"S0211",token:this.value,position:this.position};if(k)return o.remaining=z(),o.type="error",ce.push(o),o;throw o.stack=new Error().stack,o}},A=function(o,u){var B=re[o];return u=u||0,B?u>=B.lbp&&(B.lbp=u):(B=Object.create(q),B.id=B.value=o,B.lbp=u,re[o]=B),B},J=function(o){if(k){o.remaining=z(),ce.push(o);var u=re["(error)"];return w=Object.create(u),w.error=o,w.type="(error)",w}else throw o.stack=new Error().stack,o},I=function(o,u){if(o&&w.id!==o){var B;w.id==="(end)"?B="S0203":B="S0202";var ae={code:B,position:w.position,token:w.value,value:o};return J(ae)}var we=T(u);if(we===null)return w=re["(end)"],w.position=_.length,w;var ye=we.value,l=we.type,v;switch(l){case "name":case "variable":v=re["(name)"];break;case "operator":if(v=re[ye],!v)return J({code:"S0204",stack:new Error().stack,position:we.position,token:ye});break;case "string":case "number":case "value":v=re["(literal)"];break;case "regex":l="regex",v=re["(regex)"];break;default:return J({code:"S0205",stack:new Error().stack,position:we.position,token:ye})}return w=Object.create(v),w.value=ye,w.type=l,w.position=we.position,w},p=function(o){var u,B=w;for(I(null,true),u=B.nud();o<w.lbp;)B=w,I(),u=B.led(u);return u},R=function(o){var u=A(o,0);u.nud=function(){return this};},$=function(o,u,B){var ae=u||L[o],we=A(o,ae);return we.led=B||function(ye){return this.lhs=ye,this.rhs=p(ae),this.type="binary",this},we},Z=function(o,u,B){var ae=A(o,u);return ae.led=B,ae},ue=function(o,u){var B=A(o);return B.nud=u||function(){return this.expression=p(70),this.type="unary",this},B};R("(end)"),R("(name)"),R("(literal)"),R("(regex)"),A(":"),A(";"),A(","),A(")"),A("]"),A("}"),A(".."),$("."),$("+"),$("-"),$("*"),$("/"),$("%"),$("="),$("<"),$(">"),$("!="),$("<="),$(">="),$("&"),$("and"),$("or"),$("in"),R("and"),R("or"),R("in"),ue("-"),$("~>"),$("??",L["??"],function(o){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[o]},this.then=o,this.else=p(0),this}),Z("(error)",10,function(o){return this.lhs=o,this.error=w.error,this.remaining=z(),this.type="error",this}),ue("*",function(){return this.type="wildcard",this}),ue("**",function(){return this.type="descendant",this}),ue("%",function(){return this.type="parent",this}),$("(",L["("],function(o){if(this.procedure=o,this.type="function",this.arguments=[],w.id!==")")for(;w.type==="operator"&&w.id==="?"?(this.type="partial",this.arguments.push(w),I("?")):this.arguments.push(p(0)),w.id===",";)I(",");if(I(")",true),o.type==="name"&&(o.value==="function"||o.value==="\u03BB")){if(this.arguments.forEach(function(ye,l){if(ye.type!=="variable")return J({code:"S0208",stack:new Error().stack,position:ye.position,token:ye.value,value:l+1})}),this.type="lambda",w.id==="<"){for(var u=w.position,B=1,ae="<";B>0&&w.id!=="{"&&w.id!=="(end)";){var we=I();we.id===">"?B--:we.id==="<"&&B++,ae+=we.value;}I(">");try{this.signature=F(ae);}catch(ye){return ye.position=u+ye.offset,J(ye)}}I("{"),this.body=p(0),I("}");}return this}),ue("(",function(){for(var o=[];w.id!==")"&&(o.push(p(0)),w.id===";");)I(";");return I(")",true),this.type="block",this.expressions=o,this}),ue("[",function(){var o=[];if(w.id!=="]")for(;;){var u=p(0);if(w.id===".."){var B={type:"binary",value:"..",position:w.position,lhs:u};I(".."),B.rhs=p(0),u=B;}if(o.push(u),w.id!==",")break;I(",");}return I("]",true),this.expressions=o,this.type="unary",this}),$("[",L["["],function(o){if(w.id==="]"){for(var u=o;u&&u.type==="binary"&&u.value==="[";)u=u.lhs;return u.keepArray=true,I("]"),o}else return this.lhs=o,this.rhs=p(L["]"]),this.type="binary",I("]",true),this}),$("^",L["^"],function(o){I("(");for(var u=[];;){var B={descending:false};if(w.id==="<"?I("<"):w.id===">"&&(B.descending=true,I(">")),B.expression=p(0),u.push(B),w.id!==",")break;I(",");}return I(")"),this.lhs=o,this.rhs=u,this.type="binary",this});var fe=function(o){var u=[];if(w.id!=="}")for(;;){var B=p(0);I(":");var ae=p(0);if(u.push([B,ae]),w.id!==",")break;I(",");}return I("}",true),typeof o>"u"?(this.lhs=u,this.type="unary"):(this.lhs=o,this.rhs=u,this.type="binary"),this};ue("{",fe),$("{",L["{"],fe),Z(":=",L[":="],function(o){return o.type!=="variable"?J({code:"S0212",stack:new Error().stack,position:o.position,token:o.value}):(this.lhs=o,this.rhs=p(L[":="]-1),this.type="binary",this)}),$("@",L["@"],function(o){return this.lhs=o,this.rhs=p(L["@"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),$("#",L["#"],function(o){return this.lhs=o,this.rhs=p(L["#"]),this.rhs.type!=="variable"?J({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),$("?",L["?"],function(o){return this.type="condition",this.condition=o,this.then=p(0),w.id===":"&&(I(":"),this.else=p(0)),this}),$("?:",L["?:"],function(o){return this.type="condition",this.condition=o,this.then=o,this.else=p(0),this}),ue("|",function(){return this.type="transform",this.pattern=p(0),I("|"),this.update=p(0),w.id===","&&(I(","),this.delete=p(0)),I("|"),this});var le=function(o){var u;if(o.type==="function"&&!o.predicate){var B={type:"lambda",thunk:true,arguments:[],position:o.position};B.body=o,u=B;}else if(o.type==="condition")o.then=le(o.then),typeof o.else<"u"&&(o.else=le(o.else)),u=o;else if(o.type==="block"){var ae=o.expressions.length;ae>0&&(o.expressions[ae-1]=le(o.expressions[ae-1])),u=o;}else u=o;return u},pe=0,xe=0,qe=[],ve=function(o,u){switch(o.type){case "name":case "wildcard":u.level--,u.level===0&&(typeof o.ancestor>"u"||(qe[u.index].slot.label=o.ancestor.label),o.ancestor=u,o.tuple=true);break;case "parent":u.level++;break;case "block":o.expressions.length>0&&(o.tuple=true,u=ve(o.expressions[o.expressions.length-1],u));break;case "path":o.tuple=true;var B=o.steps.length-1;for(u=ve(o.steps[B--],u);u.level>0&&B>=0;)u=ve(o.steps[B--],u);break;default:throw {code:"S0217",token:o.type,position:o.position}}return u},D=function(o,u){if(typeof u.seekingParent<"u"||u.type==="parent"){var B=typeof u.seekingParent<"u"?u.seekingParent:[];u.type==="parent"&&B.push(u.slot),typeof o.seekingParent>"u"?o.seekingParent=B:Array.prototype.push.apply(o.seekingParent,B);}},N=function(o){var u=o.steps.length-1,B=o.steps[u],ae=typeof B.seekingParent<"u"?B.seekingParent:[];B.type==="parent"&&ae.push(B.slot);for(var we=0;we<ae.length;we++){var ye=ae[we];for(u=o.steps.length-2;ye.level>0;){if(u<0){typeof o.seekingParent>"u"?o.seekingParent=[ye]:o.seekingParent.push(ye);break}for(var l=o.steps[u--];u>=0&&l.focus&&o.steps[u].focus;)l=o.steps[u--];ye=ve(l,ye);}}},U=function(o){var u;switch(o.type){case "binary":switch(o.value){case ".":var B=U(o.lhs);B.type==="path"?u=B:u={type:"path",steps:[B]},B.type==="parent"&&(u.seekingParent=[B.slot]);var ae=U(o.rhs);ae.type==="function"&&ae.procedure.type==="path"&&ae.procedure.steps.length===1&&ae.procedure.steps[0].type==="name"&&u.steps[u.steps.length-1].type==="function"&&(u.steps[u.steps.length-1].nextFunction=ae.procedure.steps[0].value),ae.type==="path"?Array.prototype.push.apply(u.steps,ae.steps):(typeof ae.predicate<"u"&&(ae.stages=ae.predicate,delete ae.predicate),u.steps.push(ae)),u.steps.filter(function(j){if(j.type==="number"||j.type==="value")throw {code:"S0213",stack:new Error().stack,position:j.position,value:j.value};return j.type==="string"}).forEach(function(j){j.type="name";}),u.steps.filter(function(j){return j.keepArray===true}).length>0&&(u.keepSingletonArray=true);var we=u.steps[0];we.type==="unary"&&we.value==="["&&(we.consarray=true);var ye=u.steps[u.steps.length-1];ye.type==="unary"&&ye.value==="["&&(ye.consarray=true),N(u);break;case "[":u=U(o.lhs);var l=u,v="predicate";if(u.type==="path"&&(l=u.steps[u.steps.length-1],v="stages"),typeof l.group<"u")throw {code:"S0209",stack:new Error().stack,position:o.position};typeof l[v]>"u"&&(l[v]=[]);var g=U(o.rhs);typeof g.seekingParent<"u"&&(g.seekingParent.forEach(j=>{j.level===1?ve(l,j):j.level--;}),D(l,g)),l[v].push({type:"filter",expr:g,position:o.position});break;case "{":if(u=U(o.lhs),typeof u.group<"u")throw {code:"S0210",stack:new Error().stack,position:o.position};u.group={lhs:o.rhs.map(function(j){return [U(j[0]),U(j[1])]}),position:o.position};break;case "^":u=U(o.lhs),u.type!=="path"&&(u={type:"path",steps:[u]});var E={type:"sort",position:o.position};E.terms=o.rhs.map(function(j){var Y=U(j.expression);return D(E,Y),{descending:j.descending,expression:Y}}),u.steps.push(E),N(u);break;case ":=":u={type:"bind",value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),D(u,u.rhs);break;case "@":if(u=U(o.lhs),l=u,u.type==="path"&&(l=u.steps[u.steps.length-1]),typeof l.stages<"u"||typeof l.predicate<"u")throw {code:"S0215",stack:new Error().stack,position:o.position};if(l.type==="sort")throw {code:"S0216",stack:new Error().stack,position:o.position};o.keepArray&&(l.keepArray=true),l.focus=o.rhs.value,l.tuple=true;break;case "#":u=U(o.lhs),l=u,u.type==="path"?l=u.steps[u.steps.length-1]:(u={type:"path",steps:[u]},typeof l.predicate<"u"&&(l.stages=l.predicate,delete l.predicate)),typeof l.stages>"u"?l.index=o.rhs.value:l.stages.push({type:"index",value:o.rhs.value,position:o.position}),l.tuple=true;break;case "~>":u={type:"apply",value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),u.keepArray=u.lhs.keepArray||u.rhs.keepArray;break;default:u={type:o.type,value:o.value,position:o.position},u.lhs=U(o.lhs),u.rhs=U(o.rhs),D(u,u.lhs),D(u,u.rhs);}break;case "unary":u={type:o.type,value:o.value,position:o.position},o.value==="["?u.expressions=o.expressions.map(function(j){var Y=U(j);return D(u,Y),Y}):o.value==="{"?u.lhs=o.lhs.map(function(j){var Y=U(j[0]);D(u,Y);var me=U(j[1]);return D(u,me),[Y,me]}):(u.expression=U(o.expression),o.value==="-"&&u.expression.type==="number"?(u=u.expression,u.value=-u.value):D(u,u.expression));break;case "function":case "partial":u={type:o.type,name:o.name,value:o.value,position:o.position},u.arguments=o.arguments.map(function(j){var Y=U(j);return D(u,Y),Y}),u.procedure=U(o.procedure);break;case "lambda":u={type:o.type,arguments:o.arguments,signature:o.signature,position:o.position};var M=U(o.body);u.body=le(M);break;case "condition":u={type:o.type,position:o.position},u.condition=U(o.condition),D(u,u.condition),u.then=U(o.then),D(u,u.then),typeof o.else<"u"&&(u.else=U(o.else),D(u,u.else));break;case "transform":u={type:o.type,position:o.position},u.pattern=U(o.pattern),u.update=U(o.update),typeof o.delete<"u"&&(u.delete=U(o.delete));break;case "block":u={type:o.type,position:o.position},u.expressions=o.expressions.map(function(j){var Y=U(j);return D(u,Y),(Y.consarray||Y.type==="path"&&Y.steps[0].consarray)&&(u.consarray=true),Y});break;case "name":u={type:"path",steps:[o]},o.keepArray&&(u.keepSingletonArray=true);break;case "parent":u={type:"parent",slot:{label:"!"+pe++,level:1,index:xe++}},qe.push(u);break;case "string":case "number":case "value":case "wildcard":case "descendant":case "variable":case "regex":u=o;break;case "operator":if(o.value==="and"||o.value==="or"||o.value==="in")o.type="name",u=U(o);else if(o.value==="?")u=o;else throw {code:"S0201",stack:new Error().stack,position:o.position,token:o.value};break;case "error":u=o,o.lhs&&(u=U(o.lhs));break;default:var P="S0206";o.id==="(end)"&&(P="S0207");var S={code:P,position:o.position,token:o.value};if(k)return ce.push(S),{type:"error",error:S};throw S.stack=new Error().stack,S}return o.keepArray&&(u.keepArray=true),u};T=ee(_),I();var oe=p(0);if(w.id!=="(end)"){var Ce={code:"S0201",position:w.position,token:w.value};J(Ce);}if(oe=U(oe),oe.type==="parent"||typeof oe.seekingParent<"u")throw {code:"S0217",token:oe.type,position:oe.position};return ce.length>0&&(oe.errors=ce),oe};return ie})();C.exports=m;},{"./signature":5}],5:[function(b,C,x){var F=b("./utils");let m=(()=>{var L={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function ne(ee){for(var ie=1,_=[],k={},w=k;ie<ee.length;){var T=ee.charAt(ie);if(T===":")break;var re=function(){_.push(k),w=k,k={};},ce=function($,Z,ue,fe){for(var le=1,pe=Z;pe<$.length;)if(pe++,T=$.charAt(pe),T===fe){if(le--,le===0)break}else T===ue&&le++;return pe};switch(T){case "s":case "n":case "b":case "l":case "o":k.regex="["+T+"m]",k.type=T,re();break;case "a":k.regex="[asnblfom]",k.type=T,k.array=true,re();break;case "f":k.regex="f",k.type=T,re();break;case "j":k.regex="[asnblom]",k.type=T,re();break;case "x":k.regex="[asnblfom]",k.type=T,re();break;case "-":w.context=true,w.contextRegex=new RegExp(w.regex),w.regex+="?";break;case "?":case "+":w.regex+=T;break;case "(":var z=ce(ee,ie,"(",")"),q=ee.substring(ie+1,z);if(q.indexOf("<")===-1)k.regex="["+q+"m]";else throw {code:"S0402",stack:new Error().stack,value:q,offset:ie};k.type="("+q+")",ie=z,re();break;case "<":if(w.type==="a"||w.type==="f"){var A=ce(ee,ie,"<",">");w.subtype=ee.substring(ie+1,A),ie=A;}else throw {code:"S0401",stack:new Error().stack,value:w.type,offset:ie};break}ie++;}var J="^"+_.map(function($){return "("+$.regex+")"}).join("")+"$",I=new RegExp(J),p=function($){var Z;if(F.isFunction($))Z="f";else {var ue=typeof $;switch(ue){case "string":Z="s";break;case "number":Z="n";break;case "boolean":Z="b";break;case "object":$===null?Z="l":Array.isArray($)?Z="a":Z="o";break;default:Z="m";}}return Z},R=function($,Z){for(var ue="^",fe=0,le=0;le<_.length;le++){ue+=_[le].regex;var pe=Z.match(ue);if(pe===null)throw {code:"T0410",stack:new Error().stack,value:$[fe],index:fe+1};fe=pe[0].length;}throw {code:"T0410",stack:new Error().stack,value:$[fe],index:fe+1}};return {definition:ee,validate:function($,Z){var ue="";$.forEach(function(xe){ue+=p(xe);});var fe=I.exec(ue);if(fe){var le=[],pe=0;return _.forEach(function(xe,qe){var ve=$[pe],D=fe[qe+1];if(D==="")if(xe.context&&xe.contextRegex){var N=p(Z);if(xe.contextRegex.test(N))le.push(Z);else throw {code:"T0411",stack:new Error().stack,value:Z,index:pe+1}}else le.push(ve),pe++;else D.split("").forEach(function(U){if(xe.type==="a"){if(U==="m")ve=void 0;else {ve=$[pe];var oe=true;if(typeof xe.subtype<"u"){if(U!=="a"&&D!==xe.subtype)oe=false;else if(U==="a"&&ve.length>0){var Ce=p(ve[0]);if(Ce!==xe.subtype.charAt(0))oe=false;else {var o=ve.filter(function(u){return p(u)!==Ce});oe=o.length===0;}}}if(!oe)throw {code:"T0412",stack:new Error().stack,value:ve,index:pe+1,type:L[xe.subtype]};U!=="a"&&(ve=[ve]);}le.push(ve),pe++;}else le.push(ve),pe++;});}),le}R($,ue);}}}return ne})();C.exports=m;},{"./utils":6}],6:[function(b,C,x){let F=(()=>{function m(A){var J=false;if(typeof A=="number"&&(J=!isNaN(A),J&&!isFinite(A)))throw {code:"D1001",value:A,stack:new Error().stack};return J}function L(A){var J=false;return Array.isArray(A)&&(J=A.filter(function(I){return typeof I!="string"}).length===0),J}function ne(A){var J=false;return Array.isArray(A)&&(J=A.filter(function(I){return !m(I)}).length===0),J}function ee(){var A=[];return A.sequence=true,arguments.length===1&&A.push(arguments[0]),A}function ie(A){return A.sequence===true&&Array.isArray(A)}function _(A){return A&&(A._jsonata_function===true||A._jsonata_lambda===true)||typeof A=="function"}function k(A){var J=typeof A.arity=="number"?A.arity:typeof A.implementation=="function"?A.implementation.length:typeof A.length=="number"?A.length:A.arguments.length;return J}function w(A){return A&&A._jsonata_lambda===true}var T=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function re(A){return typeof A=="object"&&A!==null&&T in A&&"next"in A&&typeof A.next=="function"}function ce(A,J){if(A===J)return true;if(typeof A=="object"&&typeof J=="object"&&A!==null&&J!==null){if(Array.isArray(A)&&Array.isArray(J)){if(A.length!==J.length)return false;for(var I=0;I<A.length;I++)if(!ce(A[I],J[I]))return false;return true}var p=Object.getOwnPropertyNames(A),R=Object.getOwnPropertyNames(J);if(p.length!==R.length)return false;for(p=p.sort(),R=R.sort(),I=0;I<p.length;I++)if(p[I]!==R[I])return false;for(I=0;I<p.length;I++){var $=p[I];if(!ce(A[$],J[$]))return false}return true}return false}function z(A){return typeof A=="object"&&A!==null&&"then"in A&&typeof A.then=="function"}function q(A){var J=[];for(let I of A)J.push(I);return J}return {isNumeric:m,isArrayOfStrings:L,isArrayOfNumbers:ne,createSequence:ee,isSequence:ie,isFunction:_,isLambda:w,isIterable:re,getFunctionArity:k,isDeepEqual:ce,stringToArray:q,isPromise:z}})();C.exports=F;},{}]},{},[3])(3)});});function At(c){return `::${c.kind}::${c.value}`}function Pt(c){if(!c.startsWith("::"))throw new Error(`Invalid ref format (expected ::kind::value): ${c}`);let d=c.slice(2),h=d.indexOf("::");if(h===-1)throw new Error(`Invalid ref format (expected ::kind::value): ${c}`);return {kind:d.slice(0,h),value:d.slice(h+2)}}async function un(c,d,h){let b=c.tryAcquire();if(!b)return false;try{await d();}finally{b();}return h?.(),true}var Et={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function lt(c){return c?Array.isArray(c.provides)?c.provides:[]:[]}function xt(c){return c?Array.isArray(c.requires)?c.requires:[]:[]}function cn(c){return c.tasks??{}}function Yt(c){return c?c.status===Et.FAILED||c.status===Et.INACTIVATED:false}function fn(c,d){return c.refreshStrategy??d?.refreshStrategy??"data-changed"}function dn(c){return c.maxExecutions}function ln(c,d){let h=new Set;for(let[b,C]of Object.entries(d))if(C.status===Et.COMPLETED){let x=c.tasks[b];x&<(x).forEach(m=>h.add(m));}return Array.from(h)}function pn(c,d){let h={};return c.forEach(b=>{let C=d[b];if(!C)return;lt(C).forEach(F=>{h[F]||(h[F]=[]),h[F].push(b);});}),h}function gn(c,d,h){let b=c.tasks[d]??Nt(),C={};if(h){let F=h.tasks[d],m=xt(F);for(let L of m)for(let[ne,ee]of Object.entries(h.tasks))if(lt(ee).includes(L)){let ie=c.tasks[ne];ie?.lastDataHash&&(C[L]=ie.lastDataHash);break}}let x={...b,status:"running",startedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),progress:0,error:void 0,startConsumedHashes:C};return {...c,tasks:{...c.tasks,[d]:x},lastUpdated:new Date().toISOString()}}function hn(c,d,h,b,C,x){let F=c.tasks[h]??Nt(),m=d.tasks[h];if(!m)throw new Error(`Task "${h}" not found in graph`);let L;b&&m.on&&m.on[b]?L=m.on[b]:L=lt(m);let ne=F.startConsumedHashes?{...F.startConsumedHashes}:{...F.lastConsumedHashes};if(!F.startConsumedHashes){let _=m.requires??[];for(let k of _)for(let[w,T]of Object.entries(d.tasks))if(lt(T).includes(k)){let re=c.tasks[w];re?.lastDataHash&&(ne[k]=re.lastDataHash);break}}let ee={...F,status:"completed",completedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),executionCount:F.executionCount+1,lastEpoch:F.executionCount+1,lastDataHash:C,data:x,lastConsumedHashes:ne,error:void 0},ie=[...new Set([...c.availableOutputs,...L])];return {...c,tasks:{...c.tasks,[h]:ee},availableOutputs:ie,lastUpdated:new Date().toISOString()}}function mn(c,d,h,b){let C=c.tasks[h]??Nt(),x=d.tasks[h];if(x?.retry){let L=C.retryCount+1;if(L<=x.retry.max_attempts){let ne={...C,status:"not-started",retryCount:L,lastUpdated:new Date().toISOString(),error:b};return {...c,tasks:{...c.tasks,[h]:ne},lastUpdated:new Date().toISOString()}}}let F={...C,status:"failed",failedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),error:b,executionCount:C.executionCount+1},m=c.availableOutputs;if(x?.on_failure&&x.on_failure.length>0&&(m=[...new Set([...c.availableOutputs,...x.on_failure])]),x?.circuit_breaker&&F.executionCount>=x.circuit_breaker.max_executions){let L=x.circuit_breaker.on_break;m=[...new Set([...m,...L])];}return {...c,tasks:{...c.tasks,[h]:F},availableOutputs:m,lastUpdated:new Date().toISOString()}}function yn(c,d,h,b){let C=c.tasks[d]??Nt(),x={...C,progress:typeof b=="number"?b:C.progress,messages:[...C.messages??[],...h?[{message:h,timestamp:new Date().toISOString(),status:C.status}]:[]],lastUpdated:new Date().toISOString()};return {...c,tasks:{...c.tasks,[d]:x},lastUpdated:new Date().toISOString()}}function vn(c,d){let h=c.tasks[d];if(!h)return c;let b={...h,status:"not-started",startedAt:void 0,completedAt:void 0,failedAt:void 0,error:void 0,data:void 0,progress:null,lastUpdated:new Date().toISOString()};return {...c,tasks:{...c.tasks,[d]:b},lastUpdated:new Date().toISOString()}}function Nt(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Mt(c,d){let h=`live-${Date.now()}`,b={};for(let x of Object.keys(c.tasks))b[x]=kn();let C={status:"running",tasks:b,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:h,executionConfig:{executionMode:c.settings.execution_mode??"eligibility-mode",conflictStrategy:c.settings.conflict_strategy??"alphabetical",completionStrategy:c.settings.completion}};return {config:c,state:C}}function tr(c,d){let{config:h,state:b}=c;if("executionId"in d&&d.executionId&&d.executionId!==b.executionId)return c;switch(d.type){case "task-started":return {config:h,state:gn(b,d.taskName,h)};case "task-completed":return {config:h,state:hn(b,h,d.taskName,d.result,d.dataHash,d.data)};case "task-failed":return {config:h,state:mn(b,h,d.taskName,d.error)};case "task-progress":return {config:h,state:yn(b,d.taskName,d.message,d.progress)};case "task-restart":return {config:h,state:vn(b,d.taskName)};case "inject-tokens":return {config:h,state:{...b,availableOutputs:[...new Set([...b.availableOutputs,...d.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:h,state:ur(b,d.action)};case "task-upsert":return nr(c,d.taskName,d.taskConfig);case "task-removal":return rr(c,d.taskName);case "node-requires-add":return or(c,d.nodeName,d.tokens);case "node-requires-remove":return ar(c,d.nodeName,d.tokens);case "node-provides-add":return ir(c,d.nodeName,d.tokens);case "node-provides-remove":return sr(c,d.nodeName,d.tokens);default:return c}}function bn(c,d){return d.reduce((h,b)=>tr(h,b),c)}function nr(c,d,h){let b=!!c.config.tasks[d];return {config:{...c.config,tasks:{...c.config.tasks,[d]:h}},state:{...c.state,tasks:{...c.state.tasks,[d]:b?c.state.tasks[d]:kn()},lastUpdated:new Date().toISOString()}}}function rr(c,d){if(!c.config.tasks[d])return c;let{[d]:h,...b}=c.config.tasks,{[d]:C,...x}=c.state.tasks;return {config:{...c.config,tasks:b},state:{...c.state,tasks:x,lastUpdated:new Date().toISOString()}}}function or(c,d,h){let b=c.config.tasks[d];if(!b)return c;let C=xt(b),x=h.filter(F=>!C.includes(F));return x.length===0?c:{config:{...c.config,tasks:{...c.config.tasks,[d]:{...b,requires:[...C,...x]}}},state:c.state}}function ar(c,d,h){let b=c.config.tasks[d];if(!b)return c;let C=xt(b),x=C.filter(F=>!h.includes(F));return x.length===C.length?c:{config:{...c.config,tasks:{...c.config.tasks,[d]:{...b,requires:x}}},state:c.state}}function ir(c,d,h){let b=c.config.tasks[d];if(!b)return c;let C=lt(b),x=h.filter(F=>!C.includes(F));return x.length===0?c:{config:{...c.config,tasks:{...c.config.tasks,[d]:{...b,provides:[...C,...x]}}},state:c.state}}function sr(c,d,h){let b=c.config.tasks[d];if(!b)return c;let C=lt(b),x=C.filter(F=>!h.includes(F));return x.length===C.length?c:{config:{...c.config,tasks:{...c.config.tasks,[d]:{...b,provides:x}}},state:c.state}}function It(c){return {version:1,config:c.config,state:c.state,snapshotAt:new Date().toISOString()}}function Ut(c){if(!c||typeof c!="object")throw new Error("Invalid snapshot: expected an object");let d=c;if(!d.config||typeof d.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!d.state||typeof d.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let h=d.config,b=d.state;if(!h.settings||typeof h.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!h.tasks||typeof h.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!b.tasks||typeof b.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(b.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:h,state:b}}function kn(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function ur(c,d){let h=new Date().toISOString();switch(d){case "stop":return {...c,status:"stopped",lastUpdated:h};case "pause":return {...c,status:"paused",lastUpdated:h};case "resume":return {...c,status:"running",lastUpdated:h};default:return c}}function Ft(c){let{config:d,state:h}=c,b=cn(d);if(Object.keys(b).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let x=cr(b),F=ln(d,h.tasks),m=new Set([...F,...h.availableOutputs]),L=[],ne=[],ee=[],ie=[];for(let[k,w]of Object.entries(b)){let T=h.tasks[k],re=fn(w,d.settings),ce=re!=="once";if(T?.status===Et.RUNNING||Yt(T))continue;let z=dn(w);if(z!==void 0&&T&&T.executionCount>=z||w.circuit_breaker&&T&&T.executionCount>=w.circuit_breaker.max_executions||!ce&&T?.status===Et.COMPLETED)continue;if(ce&&T?.status===Et.COMPLETED){let p=xt(w),R=false;switch(re){case "data-changed":{p.length>0&&p.some(Z=>{for(let[ue,fe]of Object.entries(b))if(lt(fe).includes(Z)){let le=h.tasks[ue];if(!le)continue;let pe=T.lastConsumedHashes?.[Z];return le.lastDataHash==null?le.executionCount>T.lastEpoch:le.lastDataHash!==pe}return false})||(R=true);break}case "epoch-changed":{p.length>0&&p.some(Z=>{for(let[ue,fe]of Object.entries(b))if(lt(fe).includes(Z)){let le=h.tasks[ue];if(le&&le.executionCount>T.lastEpoch)return true}return false})||(R=true);break}case "time-based":{let $=w.refreshInterval??0;if($<=0){R=true;break}let Z=T.completedAt;if(!Z){R=true;break}(Date.now()-Date.parse(Z))/1e3<$&&(R=true);break}case "manual":R=true;break}if(R)continue}let q=xt(w);if(q.length===0){L.push(k);continue}let A=[],J=[],I=[];for(let p of q){if(m.has(p))continue;let R=x[p]||[];R.length===0?A.push(p):R.every(Z=>Yt(h.tasks[Z]))?I.push({token:p,failedProducer:R[0]}):J.push(p);}A.length>0?ee.push({taskName:k,missingTokens:A}):I.length>0?ie.push({taskName:k,failedTokens:I.map(p=>p.token),failedProducers:[...new Set(I.map(p=>p.failedProducer))]}):J.length>0?ne.push({taskName:k,waitingOn:J}):L.push(k);}let _={};if(L.length>1){let k=pn(L,b);for(let[w,T]of Object.entries(k))T.length>1&&(_[w]=T);}return {eligible:L,pending:ne,unresolved:ee,blocked:ie,conflicts:_}}function cr(c){let d={};for(let[h,b]of Object.entries(c)){for(let C of lt(b))d[C]||(d[C]=[]),d[C].push(h);if(b.on)for(let C of Object.values(b.on))for(let x of C)d[x]||(d[x]=[]),d[x].includes(h)||d[x].push(h);if(b.on_failure)for(let C of b.on_failure)d[C]||(d[C]=[]),d[C].includes(h)||d[C].push(h);}return d}var _t=class{constructor(){sn(this,"buffer",[]);}append(d){this.buffer.push(d);}drain(){let d=this.buffer;return this.buffer=[],d}get size(){return this.buffer.length}};function Wt(c){let d=Xt(c);return fr(d)}function Xt(c){if(c==null||typeof c!="object")return JSON.stringify(c);if(Array.isArray(c))return "["+c.map(Xt).join(",")+"]";let d=c;return "{"+Object.keys(d).sort().map(b=>JSON.stringify(b)+":"+Xt(d[b])).join(",")+"}"}function fr(c){let d=0xcbf29ce484222325n,h=0x100000001b3n,b=0xffffffffffffffffn;for(let C=0;C<c.length;C++)d^=BigInt(c.charCodeAt(C)),d=d*h&b;return d.toString(16).padStart(16,"0")}function dr(c){if(typeof Buffer<"u")return Buffer.from(c,"utf8").toString("base64url");if(typeof btoa=="function"){let d=new TextEncoder().encode(c),h="";for(let b of d)h+=String.fromCharCode(b);return btoa(h).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function lr(c){if(typeof Buffer<"u")return Buffer.from(c,"base64url").toString("utf8");if(typeof atob=="function"){let d=c.replace(/-/g,"+").replace(/_/g,"/"),h=d+"=".repeat((4-d.length%4)%4),b=atob(h),C=new Uint8Array(b.length);for(let x=0;x<b.length;x++)C[x]=b.charCodeAt(x);return new TextDecoder().decode(C)}throw new Error("No base64 decoder available in this runtime")}function wn(c){let d=JSON.stringify({t:c,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return dr(d)}function pr(c){try{let d=JSON.parse(lr(c));return typeof d?.t=="string"?{taskName:d.t}:null}catch{return null}}function Sn(c,d,h){let{handlers:b,onDrain:C}=d,x=new _t,F="state"in c&&"config"in c?c:Mt(c),m=false,L=new Set,ne=new Map(Object.entries(b)),ee=new _t,ie=false,_=false;function k(){if(!m){if(ie){_=true;return}ie=true;try{do _=!1,w();while(_)}finally{ie=false;}}}function w(){let z=ee.drain(),q=x.drain(),A=[...z,...q];A.length>0&&(F=bn(F,A));let J=Ft(F);A.length>0&&C?.(A,F,J);for(let I of J.eligible)ce(I);for(let I of A)if(I.type==="task-progress"){let{taskName:p,update:R}=I;if(!F.config.tasks[p])continue;let Z=F.state.tasks[p];if(!Z||Z.status!=="running")continue;let ue=wn(p),fe=re(p,ue,R).catch(le=>{m||(ee.append({type:"task-failed",taskName:p,error:le.message??String(le),timestamp:new Date().toISOString()}),k());}).finally(()=>{L.delete(fe);});L.add(fe);}}function T(z){let A=F.config.tasks[z].requires??[],J=new Map;for(let[p,R]of Object.entries(F.config.tasks))for(let $ of R.provides??[])J.set($,p);let I={};for(let p of A){let R=J.get(p);R?I[p]=F.state.tasks[R]?.data:I[p]=void 0;}return I}async function re(z,q,A){let J=F.config.tasks[z],I=J.taskHandlers??[],p=T(z);for(let R of I){let $=ne.get(R);if(!$)throw new Error(`Handler '${R}' not found in registry (task '${z}')`);let Z={nodeId:z,state:p,taskState:F.state.tasks[z],config:J,callbackToken:q,update:A};if(await $(Z)==="task-initiate-failure")throw new Error(`Handler '${R}' returned task-initiate-failure (task '${z}')`)}}function ce(z){let A=F.config.tasks[z]?.taskHandlers;if(!A||A.length===0)return;ee.append({type:"task-started",taskName:z,timestamp:new Date().toISOString()}),k();let J=wn(z),I=re(z,J).catch(p=>{m||(ee.append({type:"task-failed",taskName:z,error:p.message??String(p),timestamp:new Date().toISOString()}),k());}).finally(()=>{L.delete(I);});L.add(I);}return {push(z){m||(z.type==="task-completed"&&z.data&&!z.dataHash&&(z={...z,dataHash:Wt(z.data)}),x.append(z),k());},pushAll(z){if(!m){for(let q of z)q.type==="task-completed"&&q.data&&!q.dataHash?x.append({...q,dataHash:Wt(q.data)}):x.append(q);k();}},resolveCallback(z,q,A){if(m)return;let J=pr(z);if(!J)return;let{taskName:I}=J;if(F.config.tasks[I]){if(A&&A.length>0)x.append({type:"task-failed",taskName:I,error:A.join("; "),timestamp:new Date().toISOString()});else {let p=q&&Object.keys(q).length>0?Wt(q):void 0;x.append({type:"task-completed",taskName:I,data:q,dataHash:p,timestamp:new Date().toISOString()});}k();}},addNode(z,q){m||(x.append({type:"task-upsert",taskName:z,taskConfig:q,timestamp:new Date().toISOString()}),k());},removeNode(z){m||(x.append({type:"task-removal",taskName:z,timestamp:new Date().toISOString()}),k());},addRequires(z,q){m||(x.append({type:"node-requires-add",nodeName:z,tokens:q,timestamp:new Date().toISOString()}),k());},removeRequires(z,q){m||(x.append({type:"node-requires-remove",nodeName:z,tokens:q,timestamp:new Date().toISOString()}),k());},addProvides(z,q){m||(x.append({type:"node-provides-add",nodeName:z,tokens:q,timestamp:new Date().toISOString()}),k());},removeProvides(z,q){m||(x.append({type:"node-provides-remove",nodeName:z,tokens:q,timestamp:new Date().toISOString()}),k());},registerHandler(z,q){ne.set(z,q);},unregisterHandler(z){ne.delete(z);},retrigger(z){m||F.config.tasks[z]&&(x.append({type:"task-restart",taskName:z,timestamp:new Date().toISOString()}),k());},retriggerAll(z){if(!m){for(let q of z)F.config.tasks[q]&&x.append({type:"task-restart",taskName:q,timestamp:new Date().toISOString()});k();}},snapshot(){return It(F)},getState(){return F},getSchedule(){return Ft(F)},async waitForHandlers(){L.size>0&&await Promise.allSettled([...L]);},async dispose(z){z?.wait&&L.size>0&&await Promise.allSettled([...L]),m=true;}}}function Zt(c){return JSON.stringify(c)}function Qt(c){let d;try{d=JSON.parse(c);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${c}`)}if(typeof d!="object"||d===null||typeof d.howToRun!="string"||typeof d.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${c}`);return d}var jt=Kt(tn());function An(){return function(c){if(c==="./jsonata-sync.cjs")return typeof globalThis<"u"&&globalThis.__jsonataSync||typeof globalThis<"u"&&globalThis.jsonata;throw new Error("Unsupported require in QuickJS bundle: "+c)}}Kt(tn());var hr=An(),Tn=hr("./jsonata-sync.cjs")??jt.default;function En(c,d){if(!d||!c)return;let h=d.split("."),b=c;for(let C=0;C<h.length;C++){if(b==null)return;b=b[h[C]];}return b}function Rn(c,d,h){let b=d.split("."),C=c;for(let x=0;x<b.length-1;x++)(C[b[x]]==null||typeof C[b[x]]!="object")&&(C[b[x]]={}),C=C[b[x]];C[b[b.length-1]]=h;}async function mr(c,d){if(!c?.compute?.length)return c;c.card_data||(c.card_data={}),c.computed_values={},c._sourcesData=d?.sourcesData??{};let h={card_data:c.card_data,requires:c.requires??{},fetched_sources:c._sourcesData,computed_values:c.computed_values};for(let b of c.compute)try{let C=await(0,jt.default)(b.expr).evaluate(h);Rn(c.computed_values,b.bindTo,C),h.computed_values=c.computed_values;}catch(C){console.error(`CardCompute.run error on "${c.id??"?"}.${b.bindTo}":`,C);}return c}function yr(c,d){if(!c?.compute?.length)return {ok:true,node:c};c.card_data||(c.card_data={}),c.computed_values={},c._sourcesData=d?.sourcesData??{};let h={card_data:c.card_data,requires:c.requires??{},fetched_sources:c._sourcesData,computed_values:c.computed_values};for(let b of c.compute)try{let C=Tn(b.expr).evaluate(h);Rn(c.computed_values,b.bindTo,C),h.computed_values=c.computed_values;}catch(C){console.error(`CardCompute.runSync error on "${c.id??"?"}.${b.bindTo}":`,C);}return {ok:true,node:c}}async function vr(c,d){let h={card_data:d.card_data??{},requires:d.requires??{},fetched_sources:d._sourcesData??{},computed_values:d.computed_values??{}};return (0, jt.default)(c).evaluate(h)}function br(c,d){return d.startsWith("fetched_sources.")?En(c._sourcesData??{},d.slice(16)):En(c,d)}var xn=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),kr=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function wr(c){let d=[];if(!c||typeof c!="object"||Array.isArray(c))return {ok:false,errors:["Node must be a non-null object"]};let h=c;(typeof h.id!="string"||!h.id)&&d.push("id: required, must be a non-empty string");for(let b of Object.keys(h))kr.has(b)||d.push(`Unknown top-level key: "${b}"`);if((h.card_data==null||typeof h.card_data!="object"||Array.isArray(h.card_data))&&d.push("card_data: required, must be an object"),h.meta!=null)if(typeof h.meta!="object"||Array.isArray(h.meta))d.push("meta: must be an object");else {let b=h.meta;b.title!=null&&typeof b.title!="string"&&d.push("meta.title: must be a string"),b.tags!=null&&!Array.isArray(b.tags)&&d.push("meta.tags: must be an array");}if(h.requires!=null&&!Array.isArray(h.requires)&&d.push("requires: must be an array of strings"),h.provides!=null&&(Array.isArray(h.provides)?h.provides.forEach((b,C)=>{if(!b||typeof b!="object"||Array.isArray(b))d.push(`provides[${C}]: must be an object with bindTo and ref`);else {let x=b;(typeof x.bindTo!="string"||!x.bindTo)&&d.push(`provides[${C}]: missing required "bindTo" string`),(typeof x.ref!="string"||!x.ref)&&d.push(`provides[${C}]: missing required "ref" string`);}}):d.push("provides: must be an array of { bindTo, ref } bindings")),h.compute!=null&&(Array.isArray(h.compute)?h.compute.forEach((b,C)=>{if(!b||typeof b!="object"||Array.isArray(b))d.push(`compute[${C}]: must be a compute step object`);else {let x=b;(typeof x.bindTo!="string"||!x.bindTo)&&d.push(`compute[${C}]: missing required "bindTo" property`),(typeof x.expr!="string"||!x.expr)&&d.push(`compute[${C}]: missing required "expr" string (JSONata expression)`);}}):d.push("compute: must be an array of compute steps")),h.source_defs!=null)if(!Array.isArray(h.source_defs))d.push("source_defs: must be an array");else {let b=new Set,C=new Set;h.source_defs.forEach((x,F)=>{if(!x||typeof x!="object"||Array.isArray(x))d.push(`source_defs[${F}]: must be an object`);else {let m=x;typeof m.bindTo!="string"||!m.bindTo?d.push(`source_defs[${F}]: missing required "bindTo" property`):(b.has(m.bindTo)&&d.push(`source_defs[${F}]: bindTo "${m.bindTo}" is not unique across source_defs`),b.add(m.bindTo)),typeof m.outputFile!="string"||!m.outputFile?d.push(`source_defs[${F}]: missing required "outputFile" property`):(C.has(m.outputFile)&&d.push(`source_defs[${F}]: outputFile "${m.outputFile}" is not unique across source_defs`),C.add(m.outputFile)),m.optionalForCompletionGating!=null&&typeof m.optionalForCompletionGating!="boolean"&&d.push(`source_defs[${F}]: optionalForCompletionGating must be a boolean`);}});}if(h.view!=null)if(typeof h.view!="object"||Array.isArray(h.view))d.push("view: must be an object");else {let b=h.view;!Array.isArray(b.elements)||b.elements.length===0?d.push("view.elements: required, must be a non-empty array"):b.elements.forEach((C,x)=>{if(!C||typeof C!="object"){d.push(`view.elements[${x}]: must be an object`);return}!C.kind||typeof C.kind!="string"?d.push(`view.elements[${x}].kind: required, must be a string`):xn.has(C.kind)||d.push(`view.elements[${x}].kind: unknown kind "${C.kind}". Valid: ${[...xn].join(", ")}`),C.data!=null&&(typeof C.data!="object"||Array.isArray(C.data))&&d.push(`view.elements[${x}].data: must be an object`);}),b.layout!=null&&(typeof b.layout!="object"||Array.isArray(b.layout))&&d.push("view.layout: must be an object"),b.features!=null&&(typeof b.features!="object"||Array.isArray(b.features))&&d.push("view.features: must be an object");}return {ok:d.length===0,errors:d}}async function Sr(c,d){if(!c||c.length===0)return [];let h={card_data:d.card_data??{},requires:d.requires??{}};return Promise.all(c.map(async b=>{let C={};if(b.projections&&typeof b.projections=="object"&&!Array.isArray(b.projections)){for(let[x,F]of Object.entries(b.projections))if(typeof F=="string"&&F.trim().length>0)try{C[x]=await(0,jt.default)(F).evaluate(h);}catch{C[x]=void 0;}}return {...b,_projections:C}}))}function Cr(c,d){if(!c||c.length===0)return [];let h={card_data:d.card_data??{},requires:d.requires??{}};return c.map(b=>{let C={};if(b.projections&&typeof b.projections=="object"&&!Array.isArray(b.projections)){for(let[x,F]of Object.entries(b.projections))if(typeof F=="string"&&F.trim().length>0)try{C[x]=Tn(F).evaluate(h);}catch{C[x]=void 0;}}return {...b,_projections:C}})}var qt={run:mr,runSync:yr,eval:vr,resolve:br,validate:wr,enrichSources:Sr,enrichSourcesSync:Cr};function Dn(c,d){function h(){return c.readIndex()??{}}function b(C,x,F){let m=String(x||"").split(".").filter(Boolean);if(m.length===0)return F&&typeof F=="object"&&!Array.isArray(F)?F:{value:F};let L={...C},ne=L;for(let ee=0;ee<m.length-1;ee++){let ie=m[ee],_=ne[ie],k=_&&typeof _=="object"&&!Array.isArray(_)?{..._}:{};ne[ie]=k,ne=k;}return ne[m[m.length-1]]=F,L}return {readCard(C){let x=h()[C];return !x||!c.cardExists(x.key)?null:c.readCard(x.key)},readCardKey(C){return h()[C]?.key??null},readAllCards(){let C=[];for(let[x,F]of Object.entries(h())){if(!c.cardExists(F.key))continue;let m=c.readCard(F.key);m?C.push(m):d?.(`[card-store] could not read card "${x}" at key "${F.key}"`);}return C},readChecksumIndex(){let C={};for(let[x,F]of Object.entries(h()))C[x]=F.checksum;return C},changedSince(C){let x=h(),F=[];for(let[m,L]of Object.entries(x))C[m]!==L.checksum&&F.push(m);for(let m of Object.keys(C))x[m]||F.push(m);return F},validateUpsert(C,x){let F=h(),m=F[C],L=Object.entries(F).find(([,ne])=>ne.key===x);return m&&m.key!==x?{ok:false,error:`Card id "${C}" is already mapped to key "${m.key}", cannot remap to "${x}"`}:L&&L[0]!==C?{ok:false,error:`Key "${x}" is already mapped to card id "${L[0]}", cannot remap to "${C}"`}:{ok:true}},writeCard(C,x,F){let m=h(),L=F??m[C]?.key??c.defaultCardKey(C),ne=c.writeCard(L,x);m[C]={key:L,checksum:ne,updatedAt:new Date().toISOString()},c.writeIndex(m);},patchCard(C,x,F){let m=h(),L=m[C];if(!L||!c.cardExists(L.key))throw new Error(`card "${C}" not found`);let ne=c.readCard(L.key);if(!ne||typeof ne!="object"||Array.isArray(ne))throw new Error(`card "${C}" is not patchable`);let ee=b(ne,x,F),ie=c.writeCard(L.key,ee);m[C]={key:L.key,checksum:ie,updatedAt:new Date().toISOString()},c.writeIndex(m);},removeCard(C){let x=h();x[C]&&(delete x[C],c.writeIndex(x));},readIndex(){return h()}}}function nn(c,d){return {readSourceData(h,b){let C=c.read(`${h}/${b}`);if(C==null)return null;let x=C.trim();if(!x)return null;try{return JSON.parse(x)}catch{return x}},ingestSourceDataStaged(h,b,C,x){let F=d(C);c.write(`${h}/.staged/${x}/${b}`,F);},commitSourceData(h,b,C){let x=`${h}/.staged/${C}/${b}`,F=c.read(x);return F==null?false:(c.write(`${h}/${b}`,F),c.remove(x),true)},hasSource(h,b){return c.exists(`${h}/${b}`)}}}function Pn(c){function d(h){let b=c.readAllEntries();if(!h)return b;let C=b.findIndex(x=>x.id===h);return C===-1?b:b.slice(C+1)}return {readEntriesAfterCursor(h){let b=d(h);return b.length===0?{events:[],newCursor:h}:{events:b.map(C=>C.event),newCursor:b[b.length-1].id}},pendingCount(h){return d(h).length},appendEvent(h){c.appendEntry({id:c.generateId(),event:h});}}}function In(c,d){return {appendEntries(h,b){if(!h||b.length===0)return;let C=c.read(h)??[];c.write(h,[...C,...b]);},dispatchEntriesForJournalId(h,b){if(!h)return;let C=c.read(h);if(!(!C||C.length===0)){for(let x of C)try{b(x);}catch(F){let m=F instanceof Error?F.message:String(F);try{d(x,m);}catch{}}c.delete(h);}}}}var Lt="v1",Tt="board/graph",Fn="board/lastJournalProcessedId";function On(c){return `cards/${c}/runtime`}function _n(c){return {readRuntime(d){return c.read(On(d))??{_sources:{}}},writeRuntime(d,h){c.write(On(d),h);}}}function Ar(c,d){let h={...c};for(let b of d.deleteKeys)delete h[b];return {...h,...d.shallowMerge}}function jn(c){return {readSnapshot(d){return c.readValues(d)},commitSnapshot(d,h){if(h.schemaVersion!==Lt)throw new Error(`Unsupported snapshot schema version: ${h.schemaVersion}`);let b=c.readValues(d);if(b.version!==h.expectedVersion)return {ok:false,reason:"version-mismatch",currentVersion:b.version};let C=Ar(b.values,h);return {ok:true,newVersion:c.writeValues(d,C,h.deleteKeys)}}}}function Nn(c){function d(h){let b=c.read(h);return b==null?null:typeof b=="string"?b:JSON.stringify(b)}return {readTaskExecutorRef(){let h=d("task-executor");if(h?.trim())return Qt(h.trim())},writeTaskExecutorRef(h){c.write("task-executor",Zt(h));},readChatHandlerRef(){let h=d("chat-handler");if(h?.trim())return Qt(h.trim())},writeChatHandlerRef(h){c.write("chat-handler",Zt(h));},readCardStoreRef(){return d("card-store-ref")},writeCardStoreRef(h){c.write("card-store-ref",h);},readOutputsStoreRef(){return d("outputs-store-ref")},writeOutputsStoreRef(h){c.write("outputs-store-ref",h);},readChatHandler(){return d("chat-handler")?.trim()||void 0},writeChatHandler(h){c.write("chat-handler",h);}}}function Mn(c){return {writeComputedValues(d,h){c.write(`cards/${d}/computed_values`,h);},readComputedValues(d){return c.read(`cards/${d}/computed_values`)},readAllComputedValues(){let d={};for(let h of c.listKeys("cards/")){let b=h.match(/^cards\/([^/]+)\/computed_values$/);b&&(d[b[1]]=c.read(h));}return d},writeDataObjects(d){for(let[h,b]of Object.entries(d))h&&c.write(`data-objects/${h}`,b);},readDataObject(d){return c.read(`data-objects/${d}`)},readAllDataObjects(){let d={};for(let h of c.listKeys("data-objects/"))d[h.slice(13)]=c.read(h);return d},writeStatusSnapshot(d){c.write("status",d);},readStatusSnapshot(){return c.read("status")}}}function Er(c){return c?.lastRequestedAt?!c.lastFetchedAt||c.lastFetchedAt<c.lastRequestedAt:false}function xr(c,d){return c?.lastRequestedAt?Er(c)?"in-flight":!c.lastFetchedAt||c.lastFetchedAt<d?"dispatch":"idle":"dispatch"}function Tr(c,d){let h={...c,lastFetchedAt:d};return delete h.lastError,h}function Rr(c,d){let h={...c,lastError:d};return delete h.lastFetchedAt,h}function $t(c,d){let h=d.state.tasks,b=d.config.tasks,C=Object.keys(h),x=Ft(d),F={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},m=new Map;for(let w of x.pending)m.set(w.taskName,w.waitingOn);for(let w of x.unresolved)m.set(w.taskName,w.missingTokens);for(let w of x.blocked)m.set(w.taskName,w.failedTokens);let L=new Map;for(let[w,T]of Object.entries(b))for(let re of T.requires??[]){let ce=L.get(re)??[];ce.push(w),L.set(re,ce);}let ne=C.sort().map(w=>{let T=h[w],re=b[w]??{requires:[],provides:[]};T.status==="completed"?F.completed+=1:T.status==="failed"?F.failed+=1:T.status==="in-progress"&&(F.in_progress+=1);let ce=re.requires??[],z=re.provides??[],q=Object.keys(T.data??{}).sort(),A=ce.filter(Z=>d.state.availableOutputs.includes(Z)),J=ce.filter(Z=>!d.state.availableOutputs.includes(Z)),I=m.get(w)??J,p=new Set;for(let Z of z)for(let ue of L.get(Z)??[])ue!==w&&p.add(ue);let R=T.failedAt,$=T.error?{message:T.error,code:"TASK_FAILED",at:R,source:"task-runtime"}:void 0;return {name:w,status:T.status,error:$,requires:ce,requires_satisfied:A,requires_missing:J,provides_declared:z,provides_runtime:q,blocked_by:I,unblocks:Array.from(p).sort(),runtime:{attempt_count:T.executionCount??0,restart_count:T.retryCount??0,in_progress_since:T.status==="in-progress"?T.startedAt??null:null,last_transition_at:T.lastUpdated??null,last_completed_at:T.completedAt??null,last_restarted_at:T.startedAt??null,status_age_ms:T.lastUpdated?0:null}}});F.pending=x.pending.length,F.blocked=x.blocked.length,F.unresolved=x.unresolved.length;let ee=ne.map(w=>({name:w.name,fanOut:w.unblocks.length})).sort((w,T)=>T.fanOut-w.fanOut||w.name.localeCompare(T.name)),ie=ee.length>0?ee[0]:{name:null,fanOut:0},_=new Set;for(let w of Object.values(b))for(let T of w.requires??[])_.add(T);let k=0;for(let[w,T]of Object.entries(b)){let re=(T.requires??[]).length===0,z=(T.provides??[]).some(q=>(L.get(q)??[]).some(A=>A!==w));re&&!z&&(k+=1);}return {schema_version:"v1",meta:{board:{path:c}},summary:{card_count:C.length,completed:F.completed,eligible:x.eligible.length,pending:F.pending,blocked:F.blocked,unresolved:F.unresolved,failed:F.failed,in_progress:F.in_progress,orphan_cards:k,topology:{edge_count:Array.from(_).length,max_fan_out_card:ie.name,max_fan_out:ie.fanOut}},cards:ne}}function Or(){return new Date().toISOString()}function Un(c,d,h,b,C,x,F,m){return async L=>{let ne=[],ee=h.cardStore.readCard(L.nodeId);if(!ee)return "task-initiate-failure";let ie=ee.id;L.update||m?.(ie,ee);let _=ee.card_data??{},k=ee.source_defs??[],w=k.filter(D=>D.optionalForCompletionGating!==true),T=h.cardRuntimeStore.readRuntime(ie),re=false,ce=()=>{re&&(h.cardRuntimeStore.writeRuntime(ie,T),re=false);},z=D=>({...T._sources[D]??{}}),q=(D,N)=>{T._sources[D]=N,re=true;},A=L.taskState?.executionCount??0,J=T._lastExecutionCount;if(typeof J=="number"&&J!==A&&(T._sources={},re=true),J!==A&&(T._lastExecutionCount=A,re=true),L.update){let D=L.update,N=D.outputFile;if(N){let U=z(N);if(D.failure)q(N,Rr(U,D.reason??"unknown"));else {let oe=D.rqt;if(!U.lastFetchedAt||oe>U.lastFetchedAt){let Ce=typeof D.deliveryToken=="string"?D.deliveryToken:void 0;Ce&&h.fetchedSourcesStore.commitSourceData(ie,N,Ce),q(N,Tr(U,oe));}}ce();}}let I={};for(let D of k)if(D.outputFile){let N=h.fetchedSourcesStore.readSourceData(ie,D.outputFile);N!==null&&(I[D.bindTo]=N);}let p={};for(let[D,N]of Object.entries(L.state??{}))if(N!==null&&typeof N=="object"&&!Array.isArray(N)){let U=N[D];p[D]=U!==void 0?U:N;}else p[D]=N;let R={id:ie,card_data:{..._},requires:p,source_defs:k,compute:ee.compute};R._sourcesData=I,ee.compute&&qt.runSync(R,{sourcesData:I}),(x??h.outputStore.writeComputedValues.bind(h.outputStore))(ie,R.computed_values??{});let $={...ee},Z=qt.enrichSourcesSync(Array.isArray(ee.source_defs)?ee.source_defs:void 0,{card_data:ee.card_data,requires:p}),ue=c.value;$.source_defs=Array.isArray(Z)?Z.map(D=>({...D,boardDir:typeof D.boardDir=="string"&&D.boardDir?D.boardDir:ue})):Z;let fe=Or(),le=L.update?void 0:fe,pe=w.filter(D=>{let N=D.outputFile;if(typeof N!="string"||!N)return true;let U=z(N);le&&(U={...U,queueRequestedAt:le},q(N,U));let oe=U.queueRequestedAt??U.lastRequestedAt??fe,Ce=xr(U,oe);return Ce==="in-flight"?false:Ce==="dispatch"});if(ce(),pe.length>0){let D=false,N=fe;for(let U of pe){let oe=U.outputFile;if(typeof oe!="string"||!oe)continue;let Ce=z(oe),o=Ce.queueRequestedAt??fe;q(oe,{...Ce,lastRequestedAt:o}),N=o,D=true;}return D&&ce(),D&&(ne.push({taskKind:"source-fetch",payload:{boardRef:At(c),enrichedCard:$,callbackToken:L.callbackToken,rqt:N}}),h.executionRequestStore.appendEntries(d,ne)),"task-initiated"}let xe=ee.provides??[],qe={};for(let{bindTo:D,ref:N}of xe)qe[D]=qt.resolve(R,N);return (F??h.outputStore.writeDataObjects.bind(h.outputStore))(qe),k.filter(D=>{if(D.optionalForCompletionGating!==true)return false;let N=z(D.outputFile);return !N.lastRequestedAt||!N.lastFetchedAt?true:N.lastFetchedAt<=N.lastRequestedAt}).length>0&&ne.push({taskKind:"source-fetch",payload:{boardRef:At(c),enrichedCard:$,callbackToken:L.callbackToken,rqt:fe}}),b(L.nodeId,qe),ne.length>0&&h.executionRequestStore.appendEntries(d,ne),"task-initiated"}}var rn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function qn(c){return {[Tt]:c.graph,[Fn]:c.lastDrainedJournalId}}function Ln(c){let d=c[Tt],h=c[Fn];if(!d||typeof d!="object")throw new Error(`State snapshot is missing required key: ${Tt}`);return {graph:d,lastDrainedJournalId:typeof h=="string"?h:""}}function $n(c){let d=c.requires,h=c.provides?.map(b=>b.bindTo)??[];return {requires:d&&d.length>0?d:void 0,provides:h,taskHandlers:["card-handler"],description:c.meta?.title??c.id}}function ot(c){return c!==void 0?{status:"success",data:c}:{status:"success"}}function Qe(c){return {status:"fail",error:c}}function at(c){return {status:"error",error:c instanceof Error?c.message:String(c)}}function Dr(c){let d=new TextEncoder().encode(c),h=Array.from(d,b=>String.fromCharCode(b)).join("");return btoa(h).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Bn(c){let d=c.replace(/-/g,"+").replace(/_/g,"/"),h=d+"=".repeat((4-d.length%4)%4),b=atob(h),C=Uint8Array.from(b,x=>x.charCodeAt(0));return new TextDecoder().decode(C)}function Gt(c){try{let d=JSON.parse(Bn(c));return typeof d?.t=="string"?{taskName:d.t}:null}catch{return null}}function Pr(c){return Dr(JSON.stringify(c))}function Gn(c){try{let d=JSON.parse(Bn(c));return typeof d?.cbk=="string"&&typeof d?.cid=="string"&&typeof d?.b=="string"&&typeof d?.d=="string"?d:null}catch{return null}}function pt(){return new Date().toISOString()}function Vn(c,d){let h=d.onWarn??(()=>{}),b=At(c);function C(D){if(D.length!==0)try{let N=d.publishBoardChangeNotifications?.(D);N&&typeof N.catch=="function"&&N.catch(U=>h(`[board-live-cards-public] publishBoardChangeNotifications failed: ${U instanceof Error?U.message:String(U)}`));}catch(N){h(`[board-live-cards-public] publishBoardChangeNotifications failed: ${N instanceof Error?N.message:String(N)}`);}}function x(){let D=m().readCardStoreRef();if(!D)throw new Error(`Board at ${c.value} has no card store configured. Run: init --base-ref <ref> --store-ref <::kind::value>`);let N=d.kvStorageForRef(D);return {readIndex(){return N.read("_index")},writeIndex(U){N.write("_index",U);},readCard(U){return N.read(U)},writeCard(U,oe){return N.write(U,oe),d.hashFn(oe)},cardExists(U){return N.read(U)!==null},defaultCardKey(U){return U}}}let F={readValues(D){let N=d.kvStorage("state-snapshot"),U=N.listKeys().sort();if(U.length===0)return {version:null,values:{}};let oe={};for(let Ce of U)oe[Ce]=N.read(Ce);return {version:d.hashFn(oe),values:oe}},writeValues(D,N,U){let oe=d.kvStorage("state-snapshot");for(let Ce of U)oe.delete(Ce);for(let[Ce,o]of Object.entries(N))oe.write(Ce,o);return d.hashFn(N)}},m=()=>Nn(d.kvStorage("config")),L=()=>jn(F),ne=()=>Pn(d.journalAdapter()),ee=()=>Dn(x(),h),ie=()=>{let D=m().readOutputsStoreRef();if(!D)throw new Error(`Board at ${c.value} has no outputs store configured. Run: init --outputs-store-ref <::kind::value>`);return Mn(d.kvStorageForRef(D))};function _(){return !!L().readSnapshot(c.value).values[Tt]}function k(){let D=L().readSnapshot(c.value);if(!D.values[Tt])throw new Error(`Board not initialized at ${c.value}`);return Ln(D.values)}function w(D,N){let U=L().commitSnapshot(c.value,{schemaVersion:Lt,expectedVersion:N,commitId:d.genId(),committedAt:pt(),deleteKeys:[],shallowMerge:qn(D)});if(!U.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${N??"null"} current=${U.currentVersion??"null"}`)}function T(D){ne().appendEvent(D);}async function re(){let D=(te,ge)=>{let Fe=te.payload,nt=(Fe?.enrichedCard??{}).id??Fe?.cardId??"unknown";T({type:"task-failed",taskName:nt,error:ge,timestamp:pt()});},N=In(d.kvStorage("execution-requests"),D),U=_n(d.kvStorage("card-runtime")),oe=nn(d.blobStorage("sources"),te=>d.resolveBlob(te)),Ce=new Map,o={readRuntime(te){return Ce.get(te)??U.readRuntime(te)},writeRuntime(te,ge){Ce.set(te,ge);}},u=[],B=new Map,ae={readSourceData(te,ge){let Fe=`${te}/${ge}`;return B.has(Fe)?B.get(Fe):oe.readSourceData(te,ge)},ingestSourceDataStaged(te,ge,Fe,Ke){oe.ingestSourceDataStaged(te,ge,Fe,Ke);},commitSourceData(te,ge,Fe){let Ke=`${te}/.staged/${Fe}/${ge}`,Xe=d.blobStorage("sources").read(Ke);if(Xe==null)return false;let G=`${te}/${ge}`,gt=Xe.trim();try{B.set(G,JSON.parse(gt));}catch{B.set(G,gt);}return u.push({cardId:te,outputFile:ge,deliveryToken:Fe}),true},hasSource(te,ge){let Fe=`${te}/${ge}`;return B.has(Fe)?true:oe.hasSource(te,ge)}},we={cardStore:ee(),cardRuntimeStore:o,fetchedSourcesStore:ae,outputStore:ie(),executionRequestStore:N},ye=k(),l=Ut(ye.graph),{events:v,newCursor:g}=ne().readEntriesAfterCursor(ye.lastDrainedJournalId),E=[],M=[],P=[],S=new Map,j=(te,ge)=>{E.push({type:"task-completed",taskName:te,data:ge,timestamp:pt()});},Y=(te,ge)=>T({type:"task-failed",taskName:te,error:ge,timestamp:pt()}),X=Sn(l,{handlers:{"card-handler":Un(c,g,we,j,Y,(te,ge)=>{M.push({cardId:te,values:ge});},te=>{P.push(te);},(te,ge)=>{S.set(te,ge);})}});for(E=v;E.length>0;){let te=E;E=[],X.pushAll(te),await X.waitForHandlers();}let de=X.getState();await X.dispose({wait:true});let H=L().readSnapshot(c.value).version;w({lastDrainedJournalId:g,graph:It(de)},H);for(let{cardId:te,values:ge}of M)we.outputStore.writeComputedValues(te,ge);for(let te of P)we.outputStore.writeDataObjects(te);for(let[te,ge]of Ce)U.writeRuntime(te,ge);for(let{cardId:te,outputFile:ge,deliveryToken:Fe}of u)oe.commitSourceData(te,ge,Fe);let Ie;try{Ie=$t(b,de),we.outputStore.writeStatusSnapshot(Ie);}catch(te){h(`[board-live-cards-public] status publish failed: ${te instanceof Error?te.message:String(te)}`);}let Ge=[];for(let{cardId:te,values:ge}of M)Ge.push({kind:"computed_values",cardId:te,values:ge});for(let te of P)for(let[ge,Fe]of Object.entries(te))ge&&Ge.push({kind:"data_object",key:ge,payload:Fe});for(let[te,ge]of S)Ge.push({kind:"card_refreshed",cardId:te,card:ge});Ie!==void 0&&Ge.push({kind:"status",status:Ie}),C(Ge);let Ne=m().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:"::built-in::source-cli-task-executor"};N.dispatchEntriesForJournalId(g,te=>{if(te.taskKind!=="source-fetch"){h(`[process-accumulated-events] unknown taskKind "${te.taskKind}" \u2014 skipping`);return}let ge=te.payload,Fe=ge.enrichedCard?.id??"unknown",Ke=ge.enrichedCard?.source_defs??[];for(let nt of Ke){if(!nt.outputFile){h(`[dispatch] source "${nt.bindTo}" has no outputFile \u2014 skipping`);continue}let Xe=Pr({cbk:ge.callbackToken,rg:c.value,br:At(c),cid:Fe,b:nt.bindTo,d:nt.outputFile,cs:void 0,rqt:ge.rqt});d.dispatchExecution(Ne,{source_def:nt,base_ref:At(c),callback:{token:Xe,via:d.selfRef}}).catch(G=>Y(Fe,G instanceof Error?G.message:String(G)));}});}async function ce(){try{let D=()=>{let U=k(),{events:oe}=ne().readEntriesAfterCursor(U.lastDrainedJournalId);oe.length<=0||(ce(),d.requestProcessAccumulated?.());},N=await un(d.lock,re,D);return ot({ran:N!==!1})}catch(D){return at(D)}}function z(D){try{let N=D.params?.cardStoreRef;if(!N)return Qe("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!_()){let o=Mt(rn);w({lastDrainedJournalId:"",graph:It(o)},null);}let U=D.params?.outputsStoreRef;if(!U)return Qe("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let oe=m();oe.writeCardStoreRef(N),oe.writeOutputsStoreRef(U);let Ce=D.body??{};Ce["task-executor-ref"]&&oe.writeTaskExecutorRef(Ce["task-executor-ref"]),Ce["chat-handler-ref"]&&oe.writeChatHandlerRef(Ce["chat-handler-ref"]);try{ie().writeStatusSnapshot($t(b,Ut(k().graph)));}catch{}return ot()}catch(N){return at(N)}}function q(D){try{let N=ie().readStatusSnapshot();if(!N){N=$t(b,Ut(k().graph));try{ie().writeStatusSnapshot(N);}catch{}}return ot(N)}catch(N){return at(N)}}function A(D){try{let N=D.params?.id;return N?(T({type:"task-removal",taskName:N,timestamp:pt()}),ce(),ot()):Qe("removeCard requires params.id")}catch(N){return at(N)}}function J(D){try{let N=D.params?.id;return N?(T({type:"task-restart",taskName:N,timestamp:pt()}),ce(),ot()):Qe("retrigger requires params.id")}catch(N){return at(N)}}async function I(D){return ce()}function p(D){try{let N=D.params?.cardId,U=D.params?.all,oe=!!D.params?.restart;if(!N&&!U)return Qe("upsertCard requires --card-id <id> or --all");let Ce=U?ee().readAllCards().map(o=>o.id):[N];for(let o of Ce)if(!ee().readCard(o))return Qe(`Card "${o}" not found in board at ${c.value}`);for(let o of Ce){let u=ee().readCard(o),B=$n(u),ae=d.hashFn(B),we=d.kvStorage("card-upsert"),ye=we.read(o),l=ye?.taskConfigHash!==ae;if(!(!l&&!oe)){if(l){let v=ye?.blobRef??ee().readCardKey(o)??o;T({type:"task-upsert",taskName:o,taskConfig:B,timestamp:pt()}),we.write(o,{blobRef:v,taskConfigHash:ae,updatedAt:pt()});}oe&&T({type:"task-restart",taskName:o,timestamp:pt()});}}return ce(),ot()}catch(N){return at(N)}}function R(D){try{let N=D.params?.token;if(!N)return Qe("taskFailed requires params.token");let U=D.params?.error??"unknown error",oe=Gt(N);return oe?(T({type:"task-failed",taskName:oe.taskName,error:U,timestamp:pt()}),ce(),ot()):Qe("Invalid callback token")}catch(N){return at(N)}}function $(D){try{let N=D.params?.token;if(!N)return Qe("taskProgress requires params.token");let oe=(D.body??{}).update??{},Ce=Gt(N);return Ce?(T({type:"task-progress",taskName:Ce.taskName,update:oe,timestamp:pt()}),ce(),ot()):Qe("Invalid callback token")}catch(N){return at(N)}}function Z(D){try{let N=D.params?.token,U=D.params?.ref;if(!N)return Qe("sourceDataFetched requires params.token");if(!U)return Qe("sourceDataFetched requires params.ref");let oe=Gn(N);if(!oe)return Qe("Invalid source token");let{cbk:Ce,cid:o,b:u,d:B,cs:ae,rqt:we}=oe,ye=nn(d.blobStorage("sources"),E=>d.resolveBlob(E)),l=d.genId();ye.ingestSourceDataStaged(o,B,Pt(U),l);let v=Gt(Ce);if(!v)return Qe("Invalid callback token embedded in source token");let g=pt();return T({type:"task-progress",taskName:v.taskName,update:{bindTo:u,outputFile:B,fetchedAt:g,deliveryToken:l,sourceChecksum:ae,rqt:we},timestamp:g}),ce(),ot()}catch(N){return at(N)}}function ue(D){try{let N=D.params?.token,U=D.params?.reason??"unknown";if(!N)return Qe("sourceDataFetchFailure requires params.token");let oe=Gn(N);if(!oe)return Qe("Invalid source token");let{cbk:Ce,b:o,d:u,cs:B}=oe,ae=Gt(Ce);return ae?(T({type:"task-progress",taskName:ae.taskName,update:{bindTo:o,outputFile:u,failure:!0,reason:U,sourceChecksum:B},timestamp:pt()}),ce(),ot()):Qe("Invalid callback token embedded in source token")}catch(N){return at(N)}}function fe(D){try{let N=m().readCardStoreRef();return N?ot({storeRef:N}):Qe(`Board at ${c.value} has no card store configured`)}catch(N){return at(N)}}function le(D){try{let N=m().readOutputsStoreRef();return N?ot({storeRef:N}):Qe(`Board at ${c.value} has no outputs store configured`)}catch(N){return at(N)}}function pe(D){try{let N=D.params?.key;if(!N)return Qe("getOutputsDataObject requires params.key");let U=ie().readDataObject(N);return ot(U)}catch(N){return at(N)}}function xe(D){try{return ot(ie().readAllDataObjects())}catch(N){return at(N)}}function qe(D){try{let N=D.params?.key;if(!N)return Qe("getOutputsComputedValues requires params.key");let U=ie().readComputedValues(N);return ot(U)}catch(N){return at(N)}}function ve(D){try{return ot(ie().readAllComputedValues())}catch(N){return at(N)}}return {init:z,status:q,getCardStoreRef:fe,getOutputsStoreRef:le,getOutputsDataObject:pe,getAllOutputsDataObjects:xe,getOutputsComputedValues:qe,getAllOutputsComputedValues:ve,removeCard:A,retrigger:J,processAccumulatedEvents:I,upsertCard:p,taskFailed:R,taskProgress:$,sourceDataFetched:Z,sourceDataFetchFailure:ue}}var Jn=Kt(zn());function et(c){return globalThis.__hostCall(c)}function Ir(c){return {tryAcquire(){let d=et({op:"lock.tryAcquire",scope:c});return d?()=>{et({op:"lock.release",scope:c,token:d});}:null}}}function Fr(c,d){let h=c.value;function b(C,x){return {read(F){return et({op:"kv.read",scope:C,namespace:x,key:F})},write(F,m){et({op:"kv.write",scope:C,namespace:x,key:F,value:m});},delete(F){et({op:"kv.delete",scope:C,namespace:x,key:F});},listKeys(F){return et({op:"kv.list",scope:C,namespace:x,prefix:F})}}}return {kvStorage(C){return b(h,C)},kvStorageForRef(C){let x=Pt(C);return b(x.value,"")},requestProcessAccumulated(){et({op:"board.requestProcessAccumulated",scope:h,notifyChannel:d});},publishBoardChangeNotifications(C){!d||C.length===0||et({op:"board.publishNotifications",scope:h,notifyChannel:d,notifications:C});},blobStorage(C){return {read(x){return et({op:"blob.read",scope:h,namespace:C,key:x})},write(x,F){et({op:"blob.write",scope:h,namespace:C,key:x,content:F});},exists(x){return et({op:"blob.exists",scope:h,namespace:C,key:x})},remove(x){et({op:"blob.remove",scope:h,namespace:C,key:x});}}},journalAdapter(){return {readAllEntries(){return et({op:"journal.readAllEntries",scope:h})},appendEntry(C){et({op:"journal.appendEntry",scope:h,entry:C});},generateId(){return et({op:"journal.generateId",scope:h})}}},lock:Ir(h),selfRef:et({op:"self.ref",scope:h}),async dispatchExecution(C,x){return et({op:"execution.dispatch",scope:h,ref:C,args:x})},resolveBlob(C){let x=et({op:"blob.resolveRef",scope:h,ref:C});if(x===null)throw new Error(`resolveBlob: blob not found: ${At(C)}`);return x},hashFn(C){return et({op:"hash.computeStableJson",value:C})},genId(){return et({op:"id.gen"})},onWarn(C){et({op:"warn",msg:C});}}}async function _r(c){let d=Pt(c.baseRef),h=Vn(d,Fr(d,c.notifyChannel)),b=c.input??{};switch(c.command){case "init":return h.init(b);case "status":return h.status(b);case "getCardStoreRef":return h.getCardStoreRef(b);case "getOutputsStoreRef":return h.getOutputsStoreRef(b);case "getOutputsDataObject":return h.getOutputsDataObject(b);case "getAllOutputsDataObjects":return h.getAllOutputsDataObjects(b);case "getOutputsComputedValues":return h.getOutputsComputedValues(b);case "getAllOutputsComputedValues":return h.getAllOutputsComputedValues(b);case "removeCard":return h.removeCard(b);case "retrigger":return h.retrigger(b);case "processAccumulatedEvents":return h.processAccumulatedEvents(b);case "upsertCard":return h.upsertCard(b);case "taskFailed":return h.taskFailed(b);case "taskProgress":return h.taskProgress(b);case "sourceDataFetched":return h.sourceDataFetched(b);case "sourceDataFetchFailure":return h.sourceDataFetchFailure(b);default:return {status:"fail",error:`Unsupported command: ${c.command??"unknown"}`}}}globalThis.__jsonataSync=Jn.default;globalThis.pycliBoardInvoke=_r;
|
|
8
|
+
})();//# sourceMappingURL=quickjs-board-runtime.global.js.map
|
|
9
|
+
//# sourceMappingURL=quickjs-board-runtime.global.js.map
|