yaml-flow 6.0.0 → 7.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.
Files changed (162) hide show
  1. package/board-live-cards-cli.js +4 -4
  2. package/browser/asset-integrity.json +3 -3
  3. package/browser/board-livecards-client.js +2 -0
  4. package/browser/board-livecards-client.js.map +1 -0
  5. package/browser/board-livecards-localstorage.js +10 -0
  6. package/browser/board-livecards-localstorage.js.map +1 -0
  7. package/browser/board-livegraph-engine.js +2 -2
  8. package/browser/board-livegraph-engine.js.map +1 -1
  9. package/browser/card-compute.js +28 -28
  10. package/browser/compute-jsonata.js +5 -0
  11. package/browser/compute-jsonata.js.map +1 -0
  12. package/browser/live-cards.js +261 -150
  13. package/card-store.js +4 -4
  14. package/dist/{board-live-cards-public-CltXYgaY.d.cts → board-live-cards-public-CW5074xr.d.cts} +9 -5
  15. package/dist/{board-live-cards-public-f-E-FAyp.d.ts → board-live-cards-public-hnZo0mAf.d.ts} +9 -5
  16. package/dist/board-livegraph-runtime/index.cjs +2 -2
  17. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  18. package/dist/board-livegraph-runtime/index.d.cts +11 -9
  19. package/dist/board-livegraph-runtime/index.d.ts +11 -9
  20. package/dist/board-livegraph-runtime/index.js +2 -2
  21. package/dist/board-livegraph-runtime/index.js.map +1 -1
  22. package/dist/board-livegraph-runtime/jsonata-sync.cjs +37 -1
  23. package/dist/card-compute/index.cjs +4 -4
  24. package/dist/card-compute/index.cjs.map +1 -1
  25. package/dist/card-compute/index.d.cts +5 -1
  26. package/dist/card-compute/index.d.ts +5 -1
  27. package/dist/card-compute/index.js +4 -4
  28. package/dist/card-compute/index.js.map +1 -1
  29. package/dist/card-compute/jsonata-sync.cjs +37 -1
  30. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -1
  31. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -1
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +27 -14
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +27 -14
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -1
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -1
  36. package/dist/cli/browser-api/card-store-browser-api.cjs +1 -1
  37. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -1
  38. package/dist/cli/browser-api/card-store-browser-api.js +1 -1
  39. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -1
  40. package/dist/cli/browser-api/jsonata-sync.cjs +37 -1
  41. package/dist/cli/node/artifacts-store-cli.cjs +8 -8
  42. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -1
  43. package/dist/cli/node/artifacts-store-cli.js +8 -8
  44. package/dist/cli/node/artifacts-store-cli.js.map +1 -1
  45. package/dist/cli/node/board-live-cards-cli.cjs +7 -7
  46. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -1
  47. package/dist/cli/node/board-live-cards-cli.js +7 -7
  48. package/dist/cli/node/board-live-cards-cli.js.map +1 -1
  49. package/dist/cli/node/card-store-cli.cjs +5 -5
  50. package/dist/cli/node/card-store-cli.cjs.map +1 -1
  51. package/dist/cli/node/card-store-cli.js +5 -5
  52. package/dist/cli/node/card-store-cli.js.map +1 -1
  53. package/dist/cli/node/execution-adapter.cjs +3 -0
  54. package/dist/cli/node/execution-adapter.cjs.map +1 -0
  55. package/dist/cli/node/execution-adapter.d.cts +174 -0
  56. package/dist/cli/node/execution-adapter.d.ts +174 -0
  57. package/dist/cli/node/execution-adapter.js +3 -0
  58. package/dist/cli/node/execution-adapter.js.map +1 -0
  59. package/dist/cli/node/fs-board-adapter.cjs +7 -7
  60. package/dist/cli/node/fs-board-adapter.cjs.map +1 -1
  61. package/dist/cli/node/fs-board-adapter.d.cts +2 -2
  62. package/dist/cli/node/fs-board-adapter.d.ts +2 -2
  63. package/dist/cli/node/fs-board-adapter.js +7 -7
  64. package/dist/cli/node/fs-board-adapter.js.map +1 -1
  65. package/dist/cli/node/jsonata-sync.cjs +37 -1
  66. package/dist/cli/node/source-cli-task-executor.cjs +4 -4
  67. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -1
  68. package/dist/cli/node/source-cli-task-executor.js +4 -4
  69. package/dist/cli/node/source-cli-task-executor.js.map +1 -1
  70. package/dist/continuous-event-graph/index.cjs +2 -2
  71. package/dist/continuous-event-graph/index.cjs.map +1 -1
  72. package/dist/continuous-event-graph/index.js +2 -2
  73. package/dist/continuous-event-graph/index.js.map +1 -1
  74. package/dist/continuous-event-graph/jsonata-sync.cjs +37 -1
  75. package/dist/execution-refs.cjs +2 -1
  76. package/dist/execution-refs.cjs.map +1 -1
  77. package/dist/execution-refs.d.cts +49 -11
  78. package/dist/execution-refs.d.ts +49 -11
  79. package/dist/execution-refs.js +2 -1
  80. package/dist/execution-refs.js.map +1 -1
  81. package/dist/index.cjs +10 -10
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.js +10 -10
  84. package/dist/index.js.map +1 -1
  85. package/dist/jsonata-sync.cjs +37 -1
  86. package/dist/server-runtime/index.cjs +9 -0
  87. package/dist/server-runtime/index.cjs.map +1 -0
  88. package/dist/server-runtime/index.d.cts +31 -0
  89. package/dist/server-runtime/index.d.ts +31 -0
  90. package/dist/server-runtime/index.js +9 -0
  91. package/dist/server-runtime/index.js.map +1 -0
  92. package/dist/server-runtime/jsonata-sync.cjs +7623 -0
  93. package/dist/step-machine-public/index.cjs +2 -0
  94. package/dist/step-machine-public/index.cjs.map +1 -0
  95. package/dist/step-machine-public/index.d.cts +159 -0
  96. package/dist/step-machine-public/index.d.ts +159 -0
  97. package/dist/step-machine-public/index.js +2 -0
  98. package/dist/step-machine-public/index.js.map +1 -0
  99. package/dist/step-machine-public/jsonata-sync.cjs +7623 -0
  100. package/dist/storage-refs.cjs +2 -2
  101. package/dist/storage-refs.cjs.map +1 -1
  102. package/dist/storage-refs.d.cts +7 -6
  103. package/dist/storage-refs.d.ts +7 -6
  104. package/dist/storage-refs.js +2 -2
  105. package/dist/storage-refs.js.map +1 -1
  106. package/dist/types-B1ZRa4aI.d.ts +147 -0
  107. package/dist/types-BxEFcVK9.d.cts +147 -0
  108. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +9 -10
  109. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +357 -0
  110. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +9 -10
  111. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +300 -0
  112. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +617 -0
  113. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-sse-worker.js +48 -0
  114. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +11 -10
  115. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +19 -4
  116. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +4 -8
  117. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -10
  118. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +8 -16
  119. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +2 -6
  120. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +4 -8
  121. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +3 -7
  122. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +4 -8
  123. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +7 -16
  124. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +2 -6
  125. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +13 -3
  126. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +2 -1
  127. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +2 -1
  128. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +2 -1
  129. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +20 -24
  130. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +0 -3
  131. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +8 -13
  132. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +33 -9
  133. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +3 -1
  134. package/examples/cli/step-machine-demo/step2-double-cli.js +6 -12
  135. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +66 -4
  136. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +13 -5
  137. package/examples/example-board/cards/_index.json +47 -0
  138. package/examples/example-board/cards/card-market-prices.json +33 -9
  139. package/examples/example-board/cards/card-my-identity.json +30 -6
  140. package/examples/example-board/cards/card-portfolio-action.json +24 -6
  141. package/examples/example-board/cards/card-portfolio-intelligence.json +97 -0
  142. package/examples/example-board/cards/card-portfolio-risks.json +24 -6
  143. package/examples/example-board/cards/card-portfolio-value.json +38 -10
  144. package/examples/example-board/cards/card-portfolio.json +57 -13
  145. package/examples/example-board/cards/card-rebalance-impact.json +22 -6
  146. package/examples/example-board/cards/card-rebalance-sim.json +66 -15
  147. package/examples/example-board/demo-server.js +360 -69
  148. package/examples/example-board/demo-shell-localstorage.html +774 -0
  149. package/examples/example-board/demo-shell-with-server.html +18 -36
  150. package/examples/example-board/demo-shell.html +5 -4
  151. package/examples/example-board/demo-task-executor.js +217 -265
  152. package/package.json +15 -13
  153. package/step-machine-cli.js +43 -310
  154. package/board-livecards-server-runtime.js +0 -1513
  155. package/browser/board-livecards-runtime-client.js +0 -263
  156. package/dist/pycli/quickjs-board-runtime.global.js +0 -9
  157. package/dist/pycli/quickjs-board-runtime.global.js.map +0 -1
  158. package/dist/pycli/quickjs-step-machine-runtime.global.js +0 -5
  159. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +0 -1
  160. package/examples/cli/step-machine-demo/two-step-math-handlers.js +0 -32
  161. package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +0 -24
  162. package/examples/example-board/demo-shell-browser.html +0 -675
@@ -1,13 +1,14 @@
1
1
  // card-compute.js — JSONata-powered compute engine for LiveCards (browser build)
2
2
  //
3
- // Requires JSONata to be loaded first:
4
- // <script src="https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js"></script>
3
+ // Requires jsonata-sync to be loaded first:
4
+ // <script src="../../src/card-compute/jsonata-sync.cjs"></script>
5
5
  //
6
- // API (all async where noted):
7
- // CardCompute.run(node, options) → Promise<node> — eval all compute steps → computed_values
8
- // CardCompute.eval(expr, node) Promise<value> eval single JSONata expression
9
- // CardCompute.resolve(node, path) → value sync deep-get "card_data.foo" or "fetched_sources.foo"
10
- // CardCompute.validate(node) { ok, errors } — sync structural validator
6
+ // API (all synchronous):
7
+ // CardCompute.run(node, options) → node — eval all compute steps → computed_values
8
+ // CardCompute.runSync(node, options) node alias for run
9
+ // CardCompute.eval(expr, node) → value eval single JSONata expression
10
+ // CardCompute.resolve(node, path) value — deep-get "card_data.foo" or "fetched_sources.foo"
11
+ // CardCompute.validate(node) → { ok, errors } — structural validator
11
12
  //
12
13
  // Compute steps shape: { bindTo: string, expr: string }
13
14
  // expr is a JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }
@@ -53,19 +54,19 @@
53
54
  }
54
55
 
55
56
  // ===========================================================================
56
- // run — evaluate all compute steps on a node (async, returns Promise<node>)
57
+ // run — evaluate all compute steps on a node (sync, returns node)
57
58
  // ===========================================================================
58
59
 
59
60
  function run(node, options) {
60
- if (!node || !node.compute || !node.compute.length) return Promise.resolve(node);
61
+ if (!node || !node.compute || !node.compute.length) return node;
61
62
 
62
63
  if (!node.card_data) node.card_data = {};
63
64
  node.computed_values = {};
64
65
  node._sourcesData = (options && options.sourcesData) || {};
65
66
 
66
- if (typeof jsonata === 'undefined') {
67
- console.error('CardCompute: JSONata not loaded. Add <script src="https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js"></script> before card-compute.js');
68
- return Promise.resolve(node);
67
+ if (typeof jsonataSync === 'undefined') {
68
+ console.error('CardCompute: jsonataSync not loaded. Add <script src="../../src/card-compute/jsonata-sync.cjs"></script> before card-compute.js');
69
+ return node;
69
70
  }
70
71
 
71
72
  var ctx = {
@@ -75,30 +76,28 @@
75
76
  computed_values: node.computed_values,
76
77
  };
77
78
 
78
- var chain = Promise.resolve();
79
79
  node.compute.forEach(function (step) {
80
- chain = chain.then(function () {
81
- if (!step || typeof step.expr !== 'string') return;
82
- return jsonata(step.expr).evaluate(ctx).then(function (val) {
83
- _deepSet(node.computed_values, step.bindTo, val);
84
- ctx.computed_values = node.computed_values; // subsequent steps see earlier results
85
- }).catch(function (e) {
86
- console.error('CardCompute.run error on "' + (node.id || '?') + '.' + step.bindTo + '":', e);
87
- });
88
- });
80
+ if (!step || typeof step.expr !== 'string') return;
81
+ try {
82
+ var val = jsonataSync(step.expr).evaluate(ctx);
83
+ _deepSet(node.computed_values, step.bindTo, val);
84
+ ctx.computed_values = node.computed_values;
85
+ } catch (e) {
86
+ console.error('CardCompute.run error on "' + (node.id || '?') + '.' + step.bindTo + '":', e);
87
+ }
89
88
  });
90
89
 
91
- return chain.then(function () { return node; });
90
+ return node;
92
91
  }
93
92
 
94
93
  // ===========================================================================
95
- // eval — evaluate a single JSONata expression (async, returns Promise<value>)
94
+ // eval — evaluate a single JSONata expression (sync, returns value)
96
95
  // ===========================================================================
97
96
 
98
97
  function evalExpr(expr, node) {
99
- if (typeof jsonata === 'undefined') {
100
- console.error('CardCompute: JSONata not loaded.');
101
- return Promise.resolve(undefined);
98
+ if (typeof jsonataSync === 'undefined') {
99
+ console.error('CardCompute: jsonataSync not loaded.');
100
+ return undefined;
102
101
  }
103
102
  var ctx = {
104
103
  card_data: (node && node.card_data) || {},
@@ -106,7 +105,7 @@
106
105
  fetched_sources: (node && node._sourcesData) || {},
107
106
  computed_values: (node && node.computed_values) || {},
108
107
  };
109
- return jsonata(expr).evaluate(ctx);
108
+ return jsonataSync(expr).evaluate(ctx);
110
109
  }
111
110
 
112
111
  // ===========================================================================
@@ -257,6 +256,7 @@
257
256
 
258
257
  return {
259
258
  run: run,
259
+ runSync: run,
260
260
  eval: evalExpr,
261
261
  resolve: resolve,
262
262
  validate: validateNode,
@@ -0,0 +1,5 @@
1
+ (function(){'use strict';var Ft=Object.create;var At=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var Ut=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var lt=(be=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(be,{get:(me,Xe)=>(typeof require<"u"?require:me)[Xe]}):be)(function(be){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+be+'" is not supported')});var Nt=(be,me)=>()=>(me||be((me={exports:{}}).exports,me),me.exports);var It=(be,me,Xe,Te)=>{if(me&&typeof me=="object"||typeof me=="function")for(let ke of Mt(me))!jt.call(be,ke)&&ke!==Xe&&At(be,ke,{get:()=>me[ke],enumerable:!(Te=Ct(me,ke))||Te.enumerable});return be};var Rt=(be,me,Xe)=>(Xe=be!=null?Ft(Ut(be)):{},It(At(Xe,"default",{value:be,enumerable:true}),be));var Tt=Nt((Et,bt)=>{(function(be){if(typeof Et=="object"&&typeof bt<"u")bt.exports=be();else if(typeof define=="function"&&define.amd)define([],be);else {var me;typeof window<"u"?me=window:typeof global<"u"?me=global:typeof self<"u"?me=self:me=this,me.jsonataSync=be();}})(function(){return (function(){function Te(ke,He,De){function b(ue,ve){if(!He[ue]){if(!ke[ue]){var S=typeof lt=="function"&&lt;if(!ve&&S)return S(ue,true);if(q)return q(ue,true);var y=new Error("Cannot find module '"+ue+"'");throw y.code="MODULE_NOT_FOUND",y}var g=He[ue]={exports:{}};ke[ue][0].call(g.exports,function(M){var X=ke[ue][1][M];return b(X||M)},g,g.exports,Te,ke,He,De);}return He[ue].exports}for(var q=typeof lt=="function"&&lt,he=0;he<De.length;he++)b(De[he]);return b}return Te})()({1:[function(Te,ke,He){let De=Te("./utils"),b=(function(){let q=De.stringToArray,he=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],ue=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],ve=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function y(c,h){var l=function(T,A,v){var E="";if(T<=19)E=(A?" and ":"")+(v?ue[T]:he[T]);else if(T<100){let Z=Math.floor(T/10),Q=T%10;E=(A?" and ":"")+ve[Z-2],Q>0?E+="-"+l(Q,false,v):v&&(E=E.substring(0,E.length-1)+"ieth");}else if(T<1e3){let Z=Math.floor(T/100),Q=T%100;E=(A?", ":"")+he[Z]+" Hundred",Q>0?E+=l(Q,true,v):v&&(E+="th");}else {var I=Math.floor(Math.log10(T)/3);I>S.length&&(I=S.length);let Z=Math.pow(10,I*3),Q=Math.floor(T/Z),j=T-Q*Z;E=(A?", ":"")+l(Q,false,false)+" "+S[I-1],j>0?E+=l(j,true,v):v&&(E+="th");}return E},m=l(c,false,h);return m}let g={};he.forEach(function(c,h){g[c.toLowerCase()]=h;}),ue.forEach(function(c,h){g[c.toLowerCase()]=h;}),ve.forEach(function(c,h){let l=c.toLowerCase();g[l]=(h+2)*10,g[l.substring(0,c.length-1)+"ieth"]=g[l];}),g.hundredth=100,S.forEach(function(c,h){let l=c.toLowerCase(),m=Math.pow(10,(h+1)*3);g[l]=m,g[l+"th"]=m;});function M(c){let l=c.split(/,\s|\sand\s|[\s\\-]/).map(A=>g[A]),m=[0];return l.forEach(A=>{if(A<100){let v=m.pop();v>=1e3&&(m.push(v),v=0),m.push(v+A);}else m.push(m.pop()*A);}),m.reduce((A,v)=>A+v,0)}let X=[[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"]],de={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ce(c){for(var h=0;h<X.length;h++){let l=X[h];if(c>=l[0])return l[1]+ce(c-l[0])}return ""}function R(c){for(var h=0,l=1,m=c.length-1;m>=0;m--){let T=c[m],A=de[T];A<l?h-=A:(l=A,h+=A);}return h}function w(c,h){for(var l=[],m=h.charCodeAt(0);c>0;)l.unshift(String.fromCharCode((c-1)%26+m)),c=Math.floor((c-1)/26);return l.join("")}function $(c,h){for(var l=h.charCodeAt(0),m=0,T=0;T<c.length;T++)m+=(c.charCodeAt(c.length-T-1)-l+1)*Math.pow(26,T);return m}function x(c,h){if(typeof c>"u")return;c=Math.floor(c);let l=ee(h);return C(c,l)}let p={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},D={UPPER:"upper",LOWER:"lower",TITLE:"title"};function C(c,h){let l,m=c<0;switch(c=Math.abs(c),h.primary){case p.LETTERS:l=w(c,h.case===D.UPPER?"A":"a");break;case p.ROMAN:l=ce(c),h.case===D.UPPER&&(l=l.toUpperCase());break;case p.WORDS:l=y(c,h.ordinal),h.case===D.UPPER?l=l.toUpperCase():h.case===D.LOWER&&(l=l.toLowerCase());break;case p.DECIMAL:l=""+c;var T=h.mandatoryDigits-l.length;if(T>0){var A=new Array(T+1).join("0");l=A+l;}if(h.zeroCode!==48&&(l=q(l).map(Z=>String.fromCodePoint(Z.codePointAt(0)+h.zeroCode-48)).join("")),h.regular){let Z=Math.floor((l.length-1)/h.groupingSeparators.position);for(let Q=Z;Q>0;Q--){let j=l.length-Q*h.groupingSeparators.position;l=l.substr(0,j)+h.groupingSeparators.character+l.substr(j);}}else h.groupingSeparators.reverse().forEach(Z=>{let Q=l.length-Z.position;l=l.substr(0,Q)+Z.character+l.substr(Q);});if(h.ordinal){var v={1:"st",2:"nd",3:"rd"},E=l[l.length-1],I=v[E];(!I||l.length>1&&l[l.length-2]==="1")&&(I="th"),l=l+I;}break;case p.SEQUENCE:throw {code:"D3130",value:h.token}}return m&&(l="-"+l),l}let G=[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 ee(c){let h={type:"integer",primary:p.DECIMAL,case:D.LOWER,ordinal:false},l,m,T=c.lastIndexOf(";");switch(T===-1?l=c:(l=c.substring(0,T),m=c.substring(T+1),m[0]==="o"&&(h.ordinal=true)),l){case "A":h.case=D.UPPER;case "a":h.primary=p.LETTERS;break;case "I":h.case=D.UPPER;case "i":h.primary=p.ROMAN;break;case "W":h.case=D.UPPER,h.primary=p.WORDS;break;case "Ww":h.case=D.TITLE,h.primary=p.WORDS;break;case "w":h.primary=p.WORDS;break;default:{let A=null,v=0,E=0,I=[],Z=0;if(q(l).map(j=>j.codePointAt(0)).reverse().forEach(j=>{let z=false;for(let H=0;H<G.length;H++){let U=G[H];if(j>=U&&j<=U+9){if(z=true,v++,Z++,A===null)A=U;else if(U!==A)throw {code:"D3131"};break}}z||(j===35?(Z++,E++):I.push({position:Z,character:String.fromCodePoint(j)}));}),v>0){h.primary=p.DECIMAL,h.zeroCode=A,h.mandatoryDigits=v,h.optionalDigits=E;let z=function(H){if(H.length===0)return 0;let U=H[0].character;for(let Se=1;Se<H.length;Se++)if(H[Se].character!==U)return 0;let Pe=H.map(Se=>Se.position),We=function(Se,Ue){return Ue===0?Se:We(Ue,Se%Ue)},Me=Pe.reduce(We);for(let Se=1;Se<=Pe.length;Se++)if(Pe.indexOf(Se*Me)===-1)return 0;return Me}(I);z>0?(h.regular=true,h.groupingSeparators={position:z,character:I[0].character}):(h.regular=false,h.groupingSeparators=I);}else h.primary=p.SEQUENCE,h.token=l;}}return h}let re={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 ie(c){var h=[];let l={type:"datetime",parts:h},m=function(z,H){if(H>z){let U=c.substring(z,H);U=U.split("]]").join("]"),h.push({type:"literal",value:U});}};for(var T=0,A=0;A<c.length;){if(c.charAt(A)==="["){if(c.charAt(A+1)==="["){m(T,A),h.push({type:"literal",value:"["}),A+=2,T=A;continue}if(m(T,A),T=A,A=c.indexOf("]",T),A===-1)throw {code:"D3135"};let z=c.substring(T+1,A);z=z.split(/\s+/).join("");var v={type:"marker",component:z.charAt(0)},E=z.lastIndexOf(","),I;if(E!==-1){let H=z.substring(E+1),U=H.indexOf("-"),Pe,We,Me=function(Ue){if(!(typeof Ue>"u"||Ue==="*"))return parseInt(Ue)};U===-1?Pe=H:(Pe=H.substring(0,U),We=H.substring(U+1));let Se={min:Me(Pe),max:Me(We)};v.width=Se,I=z.substring(1,E);}else I=z.substring(1);if(I.length===1)v.presentation1=I;else if(I.length>1){var Z=I.charAt(I.length-1);"atco".indexOf(Z)!==-1?(v.presentation2=Z,Z==="o"&&(v.ordinal=true),v.presentation1=I.substring(0,I.length-1)):v.presentation1=I;}else v.presentation1=re[v.component];if(typeof v.presentation1>"u")throw {code:"D3132",value:v.component};if(v.presentation1[0]==="n")v.names=D.LOWER;else if(v.presentation1[0]==="N")v.presentation1[1]==="n"?v.names=D.TITLE:v.names=D.UPPER;else if("YMDdFWwXxHhmsf".indexOf(v.component)!==-1){var Q=v.presentation1;if(v.presentation2&&(Q+=";"+v.presentation2),v.integerFormat=ee(Q),v.width&&v.width.min!==void 0&&v.integerFormat.mandatoryDigits<v.width.min&&(v.integerFormat.mandatoryDigits=v.width.min),v.component==="Y")if(v.n=-1,v.width&&v.width.max!==void 0)v.n=v.width.max,v.integerFormat.mandatoryDigits=v.n;else {var j=v.integerFormat.mandatoryDigits+v.integerFormat.optionalDigits;j>=2&&(v.n=j);}let H=h[h.length-1];H&&H.integerFormat&&(H.integerFormat.parseWidth=H.integerFormat.mandatoryDigits);}(v.component==="Z"||v.component==="z")&&(v.integerFormat=ee(v.presentation1)),h.push(v),T=A+1;}A++;}return m(T,A),l}let J=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],ye=["January","February","March","April","May","June","July","August","September","October","November","December"],ze=1e3*60*60*24,te=function(c){let h=Date.UTC(c.year,c.month);var l=new Date(h).getUTCDay();return l===0&&(l=7),l>4?h+(8-l)*ze:h-(l-1)*ze},Y=function(c,h){return {year:c,month:h,nextMonth:function(){return h===11?Y(c+1,0):Y(c,h+1)},previousMonth:function(){return h===0?Y(c-1,11):Y(c,h-1)},nextYear:function(){return Y(c+1,h)},previousYear:function(){return Y(c-1,h)}}},Le=function(c,h){return (h-c)/(ze*7)+1},_=(c,h)=>{let l;switch(h){case "Y":l=c.getUTCFullYear();break;case "M":l=c.getUTCMonth()+1;break;case "D":l=c.getUTCDate();break;case "d":{let m=Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),T=Date.UTC(c.getUTCFullYear(),0);l=(m-T)/ze+1;break}case "F":l=c.getUTCDay(),l===0&&(l=7);break;case "W":{let m=Y(c.getUTCFullYear(),0),T=te(m),A=Date.UTC(m.year,c.getUTCMonth(),c.getUTCDate()),v=Le(T,A);if(v>52){let E=te(m.nextYear());A>=E&&(v=1);}else if(v<1){let E=te(m.previousYear());v=Le(E,A);}l=Math.floor(v);break}case "w":{let m=Y(c.getUTCFullYear(),c.getUTCMonth()),T=te(m),A=Date.UTC(m.year,m.month,c.getUTCDate()),v=Le(T,A);if(v>4){let E=te(m.nextMonth());A>=E&&(v=1);}else if(v<1){let E=te(m.previousMonth());v=Le(E,A);}l=Math.floor(v);break}case "X":{let m=Y(c.getUTCFullYear(),0),T=te(m),A=te(m.nextYear()),v=c.getTime();v<T?l=m.year-1:v>=A?l=m.year+1:l=m.year;break}case "x":{let m=Y(c.getUTCFullYear(),c.getUTCMonth()),T=te(m),A=m.nextMonth(),v=te(A),E=c.getTime();E<T?l=m.previousMonth().month+1:E>=v?l=A.month+1:l=m.month+1;break}case "H":l=c.getUTCHours();break;case "h":l=c.getUTCHours(),l=l%12,l===0&&(l=12);break;case "P":l=c.getUTCHours()>=12?"pm":"am";break;case "m":l=c.getUTCMinutes();break;case "s":l=c.getUTCSeconds();break;case "f":l=c.getUTCMilliseconds();break;case "Z":case "z":break;case "C":l="ISO";break;case "E":l="ISO";break}return l},Ae=null;function qe(c,h,l){var m=0,T=0;if(typeof l<"u"){let Q=parseInt(l);m=Math.floor(Q/100),T=Q%100;}var A=function(Q,j){var z=_(Q,j.component);if("YMDdFWwXxHhms".indexOf(j.component)!==-1)if(j.component==="Y"&&j.n!==-1&&(z=z%Math.pow(10,j.n)),j.names){if(j.component==="M"||j.component==="x")z=ye[z-1];else if(j.component==="F")z=J[z];else throw {code:"D3133",value:j.component};j.names===D.UPPER?z=z.toUpperCase():j.names===D.LOWER&&(z=z.toLowerCase()),j.width&&z.length>j.width.max&&(z=z.substring(0,j.width.max));}else z=C(z,j.integerFormat);else if(j.component==="f")z=C(z,j.integerFormat);else if(j.component==="Z"||j.component==="z"){let H=m*100+T;if(j.integerFormat.regular)z=C(H,j.integerFormat);else {let U=j.integerFormat.mandatoryDigits;if(U===1||U===2)z=C(m,j.integerFormat),T!==0&&(z+=":"+x(T,"00"));else if(U===3||U===4)z=C(H,j.integerFormat);else throw {code:"D3134",value:U}}H>=0&&(z="+"+z),j.component==="z"&&(z="GMT"+z),H===0&&j.presentation2==="t"&&(z="Z");}else j.component==="P"&&j.names===D.UPPER&&(z=z.toUpperCase());return z};let v;typeof h>"u"?(Ae===null&&(Ae=ie("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),v=Ae):v=ie(h);let E=(60*m+T)*60*1e3,I=new Date(c+E),Z="";return v.parts.forEach(function(Q){Q.type==="literal"?Z+=Q.value:Z+=A(I,Q);}),Z}function i(c){var h={};if(c.type==="datetime")h.type="datetime",h.parts=c.parts.map(function(l){var m={};if(l.type==="literal")m.regex=l.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(l.component==="Z"||l.component==="z"){let A;Array.isArray(l.integerFormat.groupingSeparators)||(A=l.integerFormat.groupingSeparators),m.regex="",l.component==="z"&&(m.regex="GMT"),m.regex+="[-+][0-9]+",A&&(m.regex+=A.character+"[0-9]+"),m.parse=function(v){l.component==="z"&&(v=v.substring(3));let E=0,I=0;return A?(E=Number.parseInt(v.substring(0,v.indexOf(A.character))),I=Number.parseInt(v.substring(v.indexOf(A.character)+1))):v.length-1<=2?E=Number.parseInt(v):(E=Number.parseInt(v.substring(0,3)),I=Number.parseInt(v.substring(3))),E*60+I};}else if(l.integerFormat)m=i(l.integerFormat);else {m.regex="[a-zA-Z]+";var T={};if(l.component==="M"||l.component==="x")ye.forEach(function(A,v){l.width&&l.width.max?T[A.substring(0,l.width.max)]=v+1:T[A]=v+1;});else if(l.component==="F")J.forEach(function(A,v){v>0&&(l.width&&l.width.max?T[A.substring(0,l.width.max)]=v:T[A]=v);});else if(l.component==="P")T={am:0,AM:0,pm:1,PM:1};else throw {code:"D3133",value:l.component};m.parse=function(A){return T[A]};}return m.component=l.component,m});else {h.type="integer";let l=c.case===D.UPPER;switch(c.primary){case p.LETTERS:h.regex=l?"[A-Z]+":"[a-z]+",h.parse=function(m){return $(m,l?"A":"a")};break;case p.ROMAN:h.regex=l?"[MDCLXVI]+":"[mdclxvi]+",h.parse=function(m){return R(l?m:m.toUpperCase())};break;case p.WORDS:h.regex="(?:"+Object.keys(g).concat("and","[\\-, ]").join("|")+")+",h.parse=function(m){return M(m.toLowerCase())};break;case p.DECIMAL:h.regex="[0-9]",c.parseWidth?h.regex+=`{${c.parseWidth}}`:h.regex+="+",c.ordinal&&(h.regex+="(?:th|st|nd|rd)"),h.parse=function(m){let T=m;return c.ordinal&&(T=m.substring(0,m.length-2)),c.regular?T=T.split(",").join(""):c.groupingSeparators.forEach(A=>{T=T.split(A.character).join("");}),c.zeroCode!==48&&(T=T.split("").map(A=>String.fromCodePoint(A.codePointAt(0)-c.zeroCode+48)).join("")),parseInt(T)};break;case p.SEQUENCE:throw {code:"D3130",value:c.token}}}return h}function s(c,h){if(typeof c>"u")return;let l=ee(h);return i(l).parse(c)}function F(c,h){let l=ie(h),m=i(l),T="^"+m.parts.map(I=>"("+I.regex+")").join("")+"$";var v=new RegExp(T,"i").exec(c);if(v!==null){let U={};for(let oe=1;oe<v.length;oe++){let n=m.parts[oe-1];n.parse&&(U[n.component]=n.parse(v[oe]));}if(Object.getOwnPropertyNames(U).length===0)return;let Pe=0,We=oe=>{Pe<<=1,Pe+=oe?1:0;},Me=oe=>!(~oe&Pe)&&!!(oe&Pe);"YXMxWwdD".split("").forEach(oe=>We(U[oe]));let Ue=!Me(161)&&Me(130),Ze=Me(84),Qe=!Ze&&Me(72);Pe=0,"PHhmsf".split("").forEach(oe=>We(U[oe]));let Ke=!Me(23)&&Me(47),st=(Ue?"YD":Ze?"XxwF":Qe?"XWF":"YMD")+(Ke?"Phmsf":"Hmsf"),Be=this.environment.timestamp,rt=false,Ve=false;if(st.split("").forEach(oe=>{if(typeof U[oe]>"u")rt?(U[oe]="MDd".indexOf(oe)!==-1?1:0,Ve=true):U[oe]=_(Be,oe);else if(rt=true,Ve)throw {code:"D3136"}}),U.M>0?U.M-=1:U.M=0,Ue){let oe=Date.UTC(U.Y,0),n=(U.d-1)*1e3*60*60*24,a=new Date(oe+n);U.M=a.getUTCMonth(),U.D=a.getUTCDate();}if(Ze)throw {code:"D3136"};if(Qe)throw {code:"D3136"};Ke&&(U.H=U.h===12?0:U.h,U.P===1&&(U.H+=12));var E=Date.UTC(U.Y,U.M,U.D,U.H,U.m,U.s,U.f);return (U.Z||U.z)&&(E-=(U.Z||U.z)*60*1e3),E}}var B=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 fe(c,h){if(!(typeof c>"u"))if(typeof h>"u"){if(!B.test(c))throw {stack:new Error().stack,code:"D3110",value:c};return Date.parse(c)}else return F.call(this,c,h)}function ne(c,h,l){if(!(typeof c>"u"))return qe.call(this,c,h,l)}return {formatInteger:x,parseInteger:s,fromMillis:ne,toMillis:fe}})();ke.exports=b;},{"./utils":6}],2:[function(Te,ke,He){(function(De){(function(){var b=Te("./utils");let q=(()=>{var he=b.isNumeric,ue=b.isArrayOfStrings,ve=b.isArrayOfNumbers,S=b.createSequence,y=b.isSequence,g=b.isFunction,M=b.isLambda,X=b.isPromise,de=b.getFunctionArity,ce=b.isDeepEqual,R=b.stringToArray;function w(e){if(!(typeof e>"u")){var t=0;return e.forEach(function(r){t+=r;}),t}}function $(e){return typeof e>"u"?0:e.length}function x(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 D(e){if(!(typeof e>"u"||e.length===0)){var t=0;return e.forEach(function(r){t+=r;}),t/e.length}}function C(e,t=false){if(!(typeof e>"u")){var r;if(typeof e=="string")r=e;else if(g(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(u,d){return typeof d<"u"&&d!==null&&d.toPrecision&&he(d)?Number(d.toPrecision(15)):d&&g(d)?"":d},f);}return r}}function G(e,t,r){if(!(typeof e>"u")){var f=R(e),u=f.length;if(u+t<0&&(t=0),typeof r<"u"){if(r<=0)return "";var d=t>=0?t+r:u+t+r;return f.slice(t,d).join("")}return f.slice(t).join("")}}function ee(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(0,r):e}}function re(e,t){if(!(typeof e>"u")){var r=e.indexOf(t);return r>-1?e.substr(r+t.length):e}}function ie(e){if(!(typeof e>"u"))return e.toLowerCase()}function J(e){if(!(typeof e>"u"))return e.toUpperCase()}function ye(e){if(!(typeof e>"u"))return R(e).length}function ze(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 te(e,t,r){if(!(typeof e>"u")){(typeof r>"u"||r.length===0)&&(r=" ");var f;t=Math.trunc(t);var u=Math.abs(t)-ye(e);if(u>0){var d=new Array(u+1).join(r);r.length>1&&(d=G(d,0,u)),t>0?f=e+d:f=d+e;}else f=e;return f}}function Y(e,t){var r=e.apply(this,[t]);if(X(r)&&(r=r),r&&!(typeof r.start=="number"||r.end==="number"||Array.isArray(r.groups)||g(r.next)))throw {code:"T1010",stack:new Error().stack};return r}function Le(e,t){if(!(typeof e>"u")){var r;if(typeof t=="string")r=e.indexOf(t)!==-1;else {var f=Y(t,e);r=typeof f<"u";}return r}}function _(e,t,r){if(!(typeof e>"u")){if(r<0)throw {stack:new Error().stack,value:r,code:"D3040",index:3};var f=S();if(typeof r>"u"||r>0){var u=0,d=Y(t,e);if(typeof d<"u")for(;typeof d<"u"&&(typeof r>"u"||u<r);)f.push({match:d.match,index:d.start,groups:d.groups}),d=Y(d.next),u++;}return f}}function Ae(e,t,r,f){if(!(typeof e>"u")){var u=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 d;typeof r=="string"?d=function(ae){for(var xe="",K=0,we=r.indexOf("$",K);we!==-1&&K<r.length;){xe+=r.substring(K,we),K=we+1;var Ye=r.charAt(K);if(Ye==="$")xe+="$",K++;else if(Ye==="0")xe+=ae.match,K++;else {var Fe;if(ae.groups.length===0?Fe=1:Fe=Math.floor(Math.log(ae.groups.length)*Math.LOG10E)+1,we=parseInt(r.substring(K,K+Fe),10),Fe>1&&we>ae.groups.length&&(we=parseInt(r.substring(K,K+Fe-1),10)),isNaN(we))xe+="$";else {if(ae.groups.length>0){var it=ae.groups[we-1];typeof it<"u"&&(xe+=it);}K+=we.toString().length;}}we=r.indexOf("$",K);}return xe+=r.substring(K),xe}:d=r;var k="",P=0;if(typeof f>"u"||f>0){var N=0;if(typeof t=="string"){for(var se=e.indexOf(t,P);se!==-1&&(typeof f>"u"||N<f);)k+=e.substring(P,se),k+=r,P=se+t.length,N++,se=e.indexOf(t,P);k+=e.substring(P);}else {var V=Y(t,e);if(typeof V<"u"){for(;typeof V<"u"&&(typeof f>"u"||N<f);){k+=e.substring(P,V.start);var le=d.apply(u,[V]);if(X(le)&&(le=le),typeof le=="string")k+=le;else throw {code:"D3012",stack:new Error().stack,value:le};P=V.start+V.match.length,N++,V=Y(V.next);}k+=e.substring(P);}else k=e;}}else k=e;return k}}function qe(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.btoa:function(r){return new De.Buffer.from(r,"binary").toString("base64")};return t(e)}}function i(e){if(!(typeof e>"u")){var t=typeof window<"u"?window.atob:function(r){return new De.Buffer.from(r,"base64").toString("binary")};return t(e)}}function s(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 F(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 B(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 fe(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 ne(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 u=0,d=Y(t,e);if(typeof d<"u"){for(var k=0;typeof d<"u"&&(typeof r>"u"||u<r);)f.push(e.substring(k,d.start)),k=d.end,d=Y(d.next),u++;(typeof r>"u"||u<r)&&f.push(e.substring(k));}else f.push(e);}return f}}function c(e,t){if(!(typeof e>"u"))return typeof t>"u"&&(t=""),e.join(t)}function h(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":";"},u=f;typeof r<"u"&&Object.keys(r).forEach(function(L){u[L]=r[L];});for(var d=[],k=u["zero-digit"].charCodeAt(0),P=k;P<k+10;P++)d.push(String.fromCharCode(P));var N=d.concat([u["decimal-separator"],u["exponent-separator"],u["grouping-separator"],u.digit,u["pattern-separator"]]),se=t.split(u["pattern-separator"]);if(se.length>2)throw {code:"D3080",stack:new Error().stack};var V=function(L){var ge=(function(){for(var Oe,$e=0;$e<L.length;$e++)if(Oe=L.charAt($e),N.indexOf(Oe)!==-1&&Oe!==u["exponent-separator"])return L.substring(0,$e)})(),Ne=(function(){for(var Oe,$e=L.length-1;$e>=0;$e--)if(Oe=L.charAt($e),N.indexOf(Oe)!==-1&&Oe!==u["exponent-separator"])return L.substring($e+1)})(),pe=L.substring(ge.length,L.length-Ne.length),Ie,et,Re,nt,_e=L.indexOf(u["exponent-separator"],ge.length);_e===-1||_e>L.length-Ne.length?(Ie=pe,et=void 0):(Ie=pe.substring(0,_e),et=pe.substring(_e+1));var Ge=Ie.indexOf(u["decimal-separator"]);return Ge===-1?(Re=Ie,nt=Ne):(Re=Ie.substring(0,Ge),nt=Ie.substring(Ge+1)),{prefix:ge,suffix:Ne,activePart:pe,mantissaPart:Ie,exponentPart:et,integerPart:Re,fractionalPart:nt,subpicture:L}},le=function(L){var ge,Ne,pe=L.subpicture,Ie=pe.indexOf(u["decimal-separator"]);Ie!==pe.lastIndexOf(u["decimal-separator"])&&(ge="D3081"),pe.indexOf(u.percent)!==pe.lastIndexOf(u.percent)&&(ge="D3082"),pe.indexOf(u["per-mille"])!==pe.lastIndexOf(u["per-mille"])&&(ge="D3083"),pe.indexOf(u.percent)!==-1&&pe.indexOf(u["per-mille"])!==-1&&(ge="D3084");var et=false;for(Ne=0;Ne<L.mantissaPart.length;Ne++){var Re=L.mantissaPart.charAt(Ne);if(d.indexOf(Re)!==-1||Re===u.digit){et=true;break}}et||(ge="D3085");var nt=L.activePart.split("").map(function(Oe){return N.indexOf(Oe)===-1?"p":"a"}).join("");nt.indexOf("p")!==-1&&(ge="D3086"),Ie!==-1?(pe.charAt(Ie-1)===u["grouping-separator"]||pe.charAt(Ie+1)===u["grouping-separator"])&&(ge="D3087"):L.integerPart.charAt(L.integerPart.length-1)===u["grouping-separator"]&&(ge="D3088"),pe.indexOf(u["grouping-separator"]+u["grouping-separator"])!==-1&&(ge="D3089");var _e=L.integerPart.indexOf(u.digit);_e!==-1&&L.integerPart.substring(0,_e).split("").filter(function(Oe){return d.indexOf(Oe)>-1}).length>0&&(ge="D3090"),_e=L.fractionalPart.lastIndexOf(u.digit),_e!==-1&&L.fractionalPart.substring(_e).split("").filter(function(Oe){return d.indexOf(Oe)>-1}).length>0&&(ge="D3091");var Ge=typeof L.exponentPart=="string";if(Ge&&L.exponentPart.length>0&&(pe.indexOf(u.percent)!==-1||pe.indexOf(u["per-mille"])!==-1)&&(ge="D3092"),Ge&&(L.exponentPart.length===0||L.exponentPart.split("").filter(function(Oe){return d.indexOf(Oe)===-1}).length>0)&&(ge="D3093"),ge)throw {code:ge,stack:new Error().stack}},ae=function(L){var ge=function(Ce,yt){for(var ct=[],Je=Ce.indexOf(u["grouping-separator"]);Je!==-1;){var gt=(yt?Ce.substring(0,Je):Ce.substring(Je)).split("").filter(function(ot){return d.indexOf(ot)!==-1||ot===u.digit}).length;ct.push(gt),Je=L.integerPart.indexOf(u["grouping-separator"],Je+1);}return ct},Ne=ge(L.integerPart),pe=function(Ce){if(Ce.length===0)return 0;for(var yt=function(gt,ot){return ot===0?gt:yt(ot,gt%ot)},ct=Ce.reduce(yt),Je=1;Je<=Ce.length;Je++)if(Ce.indexOf(Je*ct)===-1)return 0;return ct},Ie=pe(Ne),et=ge(L.fractionalPart,true),Re=L.integerPart.split("").filter(function(Ce){return d.indexOf(Ce)!==-1}).length,nt=Re,_e=L.fractionalPart.split(""),Ge=_e.filter(function(Ce){return d.indexOf(Ce)!==-1}).length,Oe=_e.filter(function(Ce){return d.indexOf(Ce)!==-1||Ce===u.digit}).length,$e=typeof L.exponentPart=="string";Re===0&&Oe===0&&($e?(Ge=1,Oe=1):Re=1),$e&&Re===0&&L.integerPart.indexOf(u.digit)!==-1&&(Re=1),Re===0&&Ge===0&&(Ge=1);var wt=0;return $e&&(wt=L.exponentPart.split("").filter(function(Ce){return d.indexOf(Ce)!==-1}).length),{integerPartGroupingPositions:Ne,regularGrouping:Ie,minimumIntegerPartSize:Re,scalingFactor:nt,prefix:L.prefix,fractionalPartGroupingPositions:et,minimumFactionalPartSize:Ge,maximumFactionalPartSize:Oe,minimumExponentSize:wt,suffix:L.suffix,picture:L.subpicture}},xe=se.map(V);xe.forEach(le);var K=xe.map(ae),we=u["minus-sign"],Ye=u["zero-digit"],Fe=u["decimal-separator"],it=u["grouping-separator"];K.length===1&&(K.push(JSON.parse(JSON.stringify(K[0]))),K[1].prefix=we+K[1].prefix);var Ee;e>=0?Ee=K[0]:Ee=K[1];var ut;Ee.picture.indexOf(u.percent)!==-1?ut=e*100:Ee.picture.indexOf(u["per-mille"])!==-1?ut=e*1e3:ut=e;var tt,at;if(Ee.minimumExponentSize===0)tt=ut;else {var St=Math.pow(10,Ee.scalingFactor),Ot=Math.pow(10,Ee.scalingFactor-1);for(tt=ut,at=0;tt<Ot;)tt*=10,at-=1;for(;tt>St;)tt/=10,at+=1;}var Pt=E(tt,Ee.maximumFactionalPartSize),mt=function(L,ge){var Ne=Math.abs(L).toFixed(ge);return Ye!=="0"&&(Ne=Ne.split("").map(function(pe){return pe>="0"&&pe<="9"?d[pe.charCodeAt(0)-48]:pe}).join("")),Ne},W=mt(Pt,Ee.maximumFactionalPartSize),je=W.indexOf(".");for(je===-1?W=W+Fe:W=W.replace(".",Fe);W.charAt(0)===Ye;)W=W.substring(1);for(;W.charAt(W.length-1)===Ye;)W=W.substring(0,W.length-1);je=W.indexOf(Fe);var ft=Ee.minimumIntegerPartSize-je,kt=Ee.minimumFactionalPartSize-(W.length-je-1);if(W=(ft>0?new Array(ft+1).join(Ye):"")+W,W=W+(kt>0?new Array(kt+1).join(Ye):""),je=W.indexOf(Fe),Ee.regularGrouping>0)for(var xt=Math.floor((je-1)/Ee.regularGrouping),ht=1;ht<=xt;ht++)W=[W.slice(0,je-ht*Ee.regularGrouping),it,W.slice(je-ht*Ee.regularGrouping)].join("");else Ee.integerPartGroupingPositions.forEach(function(L){W=[W.slice(0,je-L),it,W.slice(je-L)].join(""),je++;});if(je=W.indexOf(Fe),Ee.fractionalPartGroupingPositions.forEach(function(L){W=[W.slice(0,L+je+1),it,W.slice(L+je+1)].join("");}),je=W.indexOf(Fe),(Ee.picture.indexOf(Fe)===-1||je===W.length-1)&&(W=W.substring(0,W.length-1)),typeof at<"u"){var vt=mt(at,0);ft=Ee.minimumExponentSize-vt.length,ft>0&&(vt=new Array(ft+1).join(Ye)+vt),W=W+u["exponent-separator"]+(at<0?we:"")+vt;}return W=Ee.prefix+W+Ee.suffix,W}}function l(e,t){if(!(typeof e>"u")){if(e=E(e),typeof t>"u"?t=10:t=E(t),t<2||t>36)throw {code:"D3100",stack:new Error().stack,value:t};var r=e.toString(t);return r}}function m(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 T(e){var t;if(!(typeof e>"u"))return t=Math.abs(e),t}function A(e){var t;if(!(typeof e>"u"))return t=Math.floor(e),t}function v(e){var t;if(!(typeof e>"u"))return t=Math.ceil(e),t}function E(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 u=r-e;return Math.abs(u)===.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 I(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 Z(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 Q(){return Math.random()}function j(e){if(!(typeof e>"u")){var t=false;if(Array.isArray(e)){if(e.length===1)t=j(e[0]);else if(e.length>1){var r=e.filter(function(f){return j(f)});t=r.length>0;}}else typeof e=="string"?e.length>0&&(t=true):he(e)?e!==0&&(t=true):e!==null&&typeof e=="object"&&!g(e)?Object.keys(e).length>0&&(t=true):typeof e=="boolean"&&e===true&&(t=true);return t}}function z(e){if(!(typeof e>"u"))return !j(e)}function H(e,t,r,f){var u=[t],d=de(e);return d>=2&&u.push(r),d>=3&&u.push(f),u}function U(e,t){if(!(typeof e>"u")){var r=S();r.keepSingleton=true;for(var f=0;f<e.length;f++){var u=H(t,e[f],f,e),d=t.apply(this,u);typeof d<"u"&&r.push(d);}return r}}function Pe(e,t){if(!(typeof e>"u")){var r=S();r.keepSingleton=true;for(var f=0;f<e.length;f++){var u=e[f],d=H(t,u,f,e),k=t.apply(this,d);j(k)&&r.push(u);}return r}}function We(e,t){if(!(typeof e>"u")){for(var r=false,f,u=0;u<e.length;u++){var d=e[u],k=true;if(typeof t<"u"){var P=H(t,d,u,e),N=t.apply(this,P);k=j(N);}if(k)if(!r)f=d,r=true;else throw {stack:new Error().stack,code:"D3138",index:u}}if(!r)throw {stack:new Error().stack,code:"D3139"};return f}}function Me(){for(var e=[],t=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,t.map(function(d){return Array.isArray(d)?d.length:0})),f=0;f<r;f++){var u=t.map(d=>d[f]);e.push(u);}return e}function Se(e,t,r){if(!(typeof e>"u")){var f,u=de(t);if(u<2)throw {stack:new Error().stack,code:"D3050",index:1};var d;for(typeof r>"u"&&e.length>0?(f=e[0],d=1):(f=r,d=0);d<e.length;){var k=[f,e[d]];u>=3&&k.push(d),u>=4&&k.push(e),f=t.apply(this,k),d++;}return f}}function Ue(e){var t=S();if(Array.isArray(e)){var r={};e.forEach(function(f){var u=Ue(f);u.forEach(function(d){r[d]=true;});}),t=Ue(r);}else e!==null&&typeof e=="object"&&!g(e)&&Object.keys(e).forEach(f=>t.push(f));return t.keepSingleton=true,t}function Ze(e,t){var r;if(Array.isArray(e)){r=S();for(var f=0;f<e.length;f++){var u=Ze(e[f],t);typeof u<"u"&&(Array.isArray(u)?u.forEach(d=>r.push(d)):r.push(u));}}else e!==null&&typeof e=="object"&&!g(e)&&(r=e[t]);return r}function Qe(e,t){return typeof e>"u"?t:typeof t>"u"?e:(Array.isArray(e)||(e=S(e)),Array.isArray(t)||(t=[t]),e.concat(t))}function dt(e){return !(typeof e>"u")}function Ke(e){var t=S();if(t.keepSingleton=true,Array.isArray(e))e.forEach(function(u){t=Qe(t,Ke(u));});else if(e!==null&&typeof e=="object"&&!M(e))for(var r in e){var f={};f[r]=e[r],t.push(f);}else t=e;return t}function O(e){if(!(typeof e>"u")){var t={};return e.forEach(function(r){for(var f in r)t[f]=r[f];}),t}}function pt(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 st(e,t){var r=S();r.keepSingleton=true;for(var f in e){var u=H(t,e[f],f,e),d=t.apply(this,u);typeof d<"u"&&r.push(d);}return r}function Be(e){throw {code:"D3137",stack:new Error().stack,message:e||"$error() function evaluated"}}function rt(e,t){if(!e)throw {code:"D3141",stack:new Error().stack,message:t||"$assert() statement failed"}}function Ve(e){if(e!==void 0)return e===null?"null":he(e)?"number":typeof e=="string"?"string":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":g(e)?"function":"object"}function oe(e,t){if(!(typeof e>"u")){if(e.length<=1)return e;var r;if(typeof t>"u"){if(!ve(e)&&!ue(e))throw {stack:new Error().stack,code:"D3070",index:1};r=function(k,P){return k>P};}else r=t;var f=function(k,P){var N=function(V,le,ae){le.length===0?Array.prototype.push.apply(V,ae):ae.length===0?Array.prototype.push.apply(V,le):r(le[0],ae[0])?(V.push(ae[0]),N(V,le,ae.slice(1))):(V.push(le[0]),N(V,le.slice(1),ae));},se=[];return N(se,k,P),se},u=function(k){if(!Array.isArray(k)||k.length<=1)return k;var P=Math.floor(k.length/2),N=k.slice(0,P),se=k.slice(P);return N=u(N),se=u(se),f(N,se)},d=u(e);return d}}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=y(e)?S():[],r=0;r<e.length;r++){for(var f=e[r],u=false,d=0;d<t.length;d++)if(ce(f,t[d])){u=true;break}u||t.push(f);}return t}}function o(e,t){var r={};for(var f in e){var u=e[f],d=H(t,u,f,e),k=t.apply(this,d);j(k)&&(r[f]=u);}return Object.keys(r).length===0&&(r=void 0),r}return {sum:w,count:$,max:x,min:p,average:D,string:C,substring:G,substringBefore:ee,substringAfter:re,lowercase:ie,uppercase:J,length:ye,trim:ze,pad:te,match:_,contains:Le,replace:Ae,split:ne,join:c,formatNumber:h,formatBase:l,number:m,floor:A,ceil:v,round:E,abs:T,sqrt:I,power:Z,random:Q,boolean:j,not:z,map:U,zip:Me,filter:Pe,single:We,foldLeft:Se,sift:o,keys:Ue,lookup:Ze,append:Qe,exists:dt,spread:Ke,merge:O,reverse:pt,each:st,error:Be,assert:rt,type:Ve,sort:oe,shuffle:n,distinct:a,base64encode:qe,base64decode:i,encodeUrlComponent:s,encodeUrl:F,decodeUrlComponent:B,decodeUrl:fe}})();ke.exports=q;}).call(this);}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{});},{"./utils":6}],3:[function(Te,ke,He){var De=Te("./datetime"),b=Te("./functions"),q=Te("./utils"),he=Te("./parser"),ue=Te("./signature"),ve=(function(){var S=q.isNumeric,y=q.isArrayOfStrings,g=q.isArrayOfNumbers,M=q.createSequence,X=q.isSequence,de=q.isFunction,ce=q.isLambda,R=q.isIterable,w=q.isPromise,$=q.getFunctionArity,x=q.isDeepEqual,p=Be(null);function D(n,a,o){var e,t=o.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(t&&t(n,a,o),n.type){case "path":e=C(n,a,o);break;case "binary":e=ye(n,a,o);break;case "unary":e=ze(n,a,o);break;case "name":e=te(n,a);break;case "string":case "number":case "value":e=Y(n);break;case "wildcard":e=Le(n,a);break;case "descendant":e=Ae(n,a);break;case "parent":e=o.lookup(n.slot.label);break;case "condition":e=A(n,a,o);break;case "block":e=v(n,a,o);break;case "bind":e=T(n,a,o);break;case "regex":e=E(n);break;case "function":e=H(n,a,o);break;case "variable":e=I(n,a,o);break;case "lambda":e=We(n,a,o);break;case "partial":e=Me(n,a,o);break;case "apply":e=z(n,a,o);break;case "transform":e=Q(n,a,o);break}if(Object.prototype.hasOwnProperty.call(n,"predicate"))for(var r=0;r<n.predicate.length;r++)e=J(n.predicate[r].expr,e,o);n.type!=="path"&&Object.prototype.hasOwnProperty.call(n,"group")&&(e=h(n.group,e,o));var f=o.lookup(Symbol.for("jsonata.__evaluate_exit"));return f&&f(n,a,o,e),e&&X(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 C(n,a,o){var e;Array.isArray(a)&&n.steps[0].type!=="variable"?e=a:e=M(a);for(var t,r=false,f=void 0,u=false,d=0;d<n.steps.length;d++){var k=n.steps[d];if(k.tuple&&(r=true),d===0&&k.consarray?t=D(k,e,o):r?f=ie(k,e,f,o):t=ee(k,e,o,d===n.steps.length-1),!r&&(typeof t>"u"||t.length===0))break;!r&&Array.isArray(t)&&t._fromArrayField&&(u=true),typeof k.focus>"u"&&(e=t);}if(r)if(n.tuple)t=f;else for(t=M(),d=0;d<f.length;d++)t.push(f[d]["@"]);return n.keepSingletonArray&&(Array.isArray(t)&&t.cons&&!t.sequence&&(t=M(t)),t.keepSingleton=true),u&&Array.isArray(t)&&t.sequence&&Object.defineProperty(t,"keepSingleton",{value:true,enumerable:false,configurable:true}),n.hasOwnProperty("group")&&(t=h(n.group,r?f:t,o)),t}function G(n,a){var o=Be(n);for(let e in a)o.bind(e,a[e]);return o}function ee(n,a,o,e){var t;if(n.type==="sort")return t=Z(n,a,o),n.stages&&(t=re(n.stages,t,o)),t;t=M();for(var r=0;r<a.length;r++){var f=D(n,a[r],o);if(n.stages)for(var u=0;u<n.stages.length;u++)f=J(n.stages[u].expr,f,o);typeof f<"u"&&t.push(f);}var d=M(),k=false;return e&&t.length===1&&Array.isArray(t[0])&&!X(t[0])?(d=t[0],k=true):t.forEach(function(P){!Array.isArray(P)||P.cons?d.push(P):(P.forEach(N=>d.push(N)),X(P)||(k=true));}),k&&Array.isArray(d)&&Object.defineProperty(d,"_fromArrayField",{value:true,enumerable:false,configurable:true}),d}function re(n,a,o){for(var e=a,t=0;t<n.length;t++){var r=n[t];switch(r.type){case "filter":e=J(r.expr,e,o);break;case "index":for(var f=0;f<e.length;f++){var u=e[f];u[r.value]=f;}break}}return e}function ie(n,a,o,e){var t;if(n.type==="sort"){if(o)t=Z(n,o,e);else {var r=Z(n,a,e);t=M(),t.tupleStream=true;for(var f=0;f<r.length;f++){var u={"@":r[f]};u[n.index]=f,t.push(u);}}return n.stages&&(t=re(n.stages,t,e)),t}t=M(),t.tupleStream=true;var d=e;o===void 0&&(o=a.map(se=>({"@":se})));for(var k=0;k<o.length;k++){d=G(e,o[k]);var P=D(n,o[k]["@"],d);if(typeof P<"u"){Array.isArray(P)||(P=[P]);for(var N=0;N<P.length;N++)u={},Object.assign(u,o[k]),P.tupleStream?Object.assign(u,P[N]):(n.focus?(u[n.focus]=P[N],u["@"]=o[k]["@"]):u["@"]=P[N],n.index&&(u[n.index]=N),n.ancestor&&(u[n.ancestor.label]=o[k]["@"])),t.push(u);}}return n.stages&&(t=re(n.stages,t,e)),t}function J(n,a,o){var e=M();if(a&&a.tupleStream&&(e.tupleStream=true),Array.isArray(a)||(a=M(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,u=o;a.tupleStream&&(f=r["@"],u=G(o,r));var d=D(n,f,u);S(d)&&(d=[d]),g(d)?d.forEach(function(P){var N=Math.floor(P);N<0&&(N=a.length+N),N===t&&e.push(r);}):b.boolean(d)&&e.push(r);}return e}function ye(n,a,o){var e,t=D(n.lhs,a,o),r=n.value,f=()=>D(n.rhs,a,o);if(r==="and"||r==="or")try{return fe(t,f,r)}catch(d){throw d.position=n.position,d.token=r,d}var u=f();try{switch(r){case "+":case "-":case "*":case "/":case "%":e=i(t,u,r);break;case "=":case "!=":e=s(t,u,r);break;case "<":case "<=":case ">":case ">=":e=F(t,u,r);break;case "&":e=c(t,u);break;case "..":e=m(t,u);break;case "in":e=B(t,u);break}}catch(d){throw d.position=n.position,d.token=r,d}return e}function ze(n,a,o){var e;switch(n.value){case "-":if(e=D(n.expression,a,o),typeof e>"u")e=void 0;else if(S(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((u,d)=>(o.isParallelCall=d>0,[u,D(u,a,o)]));for(let u of f){var[t,r]=u;typeof r<"u"&&(t.value==="["?e.push(r):e=b.append(e,r));}n.consarray&&Object.defineProperty(e,"cons",{enumerable:false,configurable:false,value:true});break;case "{":e=h(n,a,o);break}return e}function te(n,a,o){return b.lookup(a,n.value)}function Y(n){return n.value}function Le(n,a){var o=M();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=_(t),o=b.append(o,t)):o.push(t);}),o}function _(n,a){return typeof a>"u"&&(a=[]),Array.isArray(n)?n.forEach(function(o){_(o,a);}):a.push(n),a}function Ae(n,a){var o,e=M();return typeof a<"u"&&(qe(a,e),e.length===1?o=e[0]:o=e),o}function qe(n,a){Array.isArray(n)||a.push(n),Array.isArray(n)?n.forEach(function(o){qe(o,a);}):n!==null&&typeof n=="object"&&Object.keys(n).forEach(function(o){qe(n[o],a);});}function i(n,a,o){var e;if(typeof n<"u"&&!S(n))throw {code:"T2001",stack:new Error().stack,value:n};if(typeof a<"u"&&!S(a))throw {code:"T2002",stack:new Error().stack,value:a};if(typeof n>"u"||typeof a>"u")return e;switch(o){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 s(n,a,o){var e,t=typeof n,r=typeof a;if(t==="undefined"||r==="undefined")return false;switch(o){case "=":e=x(n,a);break;case "!=":e=!x(n,a);break}return e}function F(n,a,o){var e,t=typeof n,r=typeof a,f=t==="undefined"||t==="string"||t==="number",u=r==="undefined"||r==="string"||r==="number";if(!f||!u)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(o){case "<":e=n<a;break;case "<=":e=n<=a;break;case ">":e=n>a;break;case ">=":e=n>=a;break}return e}}function B(n,a){var o=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){o=true;break}return o}function fe(n,a,o){var e,t=ne(n);switch(o){case "and":e=t&&ne(a());break;case "or":e=t||ne(a());break}return e}function ne(n){var a=b.boolean(n);return typeof a>"u"?false:a}function c(n,a){var o,e="",t="";return typeof n<"u"&&(e=b.string(n)),typeof a<"u"&&(t=b.string(a)),o=e.concat(t),o}function h(n,a,o){var e={},t={},r=!!(a&&a.tupleStream);Array.isArray(a)||(a=M(a)),a.length===0&&a.push(void 0);for(var f=0;f<a.length;f++)for(var u=a[f],d=r?G(o,u):o,k=0;k<n.lhs.length;k++){var P=n.lhs[k],N=D(P[0],r?u["@"]:u,d);if(typeof N!="string"&&N!==void 0)throw {code:"T1003",stack:new Error().stack,position:n.position,value:N};if(N!==void 0){var se={data:u,exprIndex:k};if(t.hasOwnProperty(N)){if(t[N].exprIndex!==k)throw {code:"D1009",stack:new Error().stack,position:n.position,value:N};t[N].data=b.append(t[N].data,u);}else t[N]=se;}}let V=Object.keys(t).map((ae,xe)=>{let K=t[ae];var we=K.data,Ye=o;if(r){var Fe=l(K.data);we=Fe["@"],delete Fe["@"],Ye=G(o,Fe);}return o.isParallelCall=xe>0,[ae,D(n.lhs[K.exprIndex][1],we,Ye)]});for(let ae of V){var[N,le]=ae;typeof le<"u"&&(e[N]=le);}return e}function l(n){if(!Array.isArray(n))return n;var a={};Object.assign(a,n[0]);for(var o=1;o<n.length;o++)for(let e in n[o])a[e]=b.append(a[e],n[o][e]);return a}function m(n,a){var o;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 o;var e=a-n+1;if(e>1e7)throw {code:"D2014",stack:new Error().stack,value:e};o=new Array(e);for(var t=n,r=0;t<=a;t++,r++)o[r]=t;return o.sequence=true,o}function T(n,a,o){var e=D(n.rhs,a,o);return o.bind(n.lhs.value,e),e}function A(n,a,o){var e,t=D(n.condition,a,o);return b.boolean(t)?e=D(n.then,a,o):typeof n.else<"u"&&(e=D(n.else,a,o)),e}function v(n,a,o){for(var e,t=Be(o),r=0;r<n.expressions.length;r++)e=D(n.expressions[r],a,t);return e}function E(n){var a=new oe.RegexEngine(n.value),o=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 u=1;u<f.length;u++)r.groups.push(f[u]);r.next=function(){if(!(a.lastIndex>=e.length)){var d=o(e,a.lastIndex);if(d&&d.match==="")throw {code:"D1004",stack:new Error().stack,position:n.position,value:n.value.source};return d}};}return r};return o}function I(n,a,o){var e;return n.value===""?e=a&&a.outerWrapper?a[0]:a:e=o.lookup(n.value),e}function Z(n,a,o){var e,t=a,r=!!a.tupleStream,f=function(d,k){for(var P=0,N=0;P===0&&N<n.terms.length;N++){var se=n.terms[N],V=d,le=o;r&&(V=d["@"],le=G(o,d));var ae=D(se.expression,V,le);V=k,le=o,r&&(V=k["@"],le=G(o,k));var xe=D(se.expression,V,le),K=typeof ae,we=typeof xe;if(K==="undefined"){P=we==="undefined"?0:1;continue}if(we==="undefined"){P=-1;continue}if(!(K==="string"||K==="number")||!(we==="string"||we==="number"))throw {code:"T2008",stack:new Error().stack,position:n.position,value:K==="string"||K==="number"?xe:ae};if(K!==we)throw {code:"T2007",stack:new Error().stack,position:n.position,value:ae,value2:xe};ae!==xe&&(ae<xe?P=-1:P=1,se.descending===true&&(P=-P));}return P===1},u={environment:o,input:a};return e=b.sort.apply(u,[t,f]),e}function Q(n,a,o){var e=function(t){if(!(typeof t>"u")){var r=o.lookup("clone");if(!de(r))throw {code:"T2013",stack:new Error().stack,position:n.position};var f=U(r,[t],null,o),u=D(n.pattern,f,o);if(typeof u<"u"){Array.isArray(u)||(u=[u]);for(var d=0;d<u.length;d++){var k=u[d];if(k&&(k.isPrototypeOf(f)||k instanceof Object.constructor))throw {code:"D1010",stack:new Error().stack,position:n.position};var P=D(n.update,k,o),N=typeof P;if(N!=="undefined"){if(N!=="object"||P===null||Array.isArray(P))throw {code:"T2011",stack:new Error().stack,position:n.update.position,value:P};for(var se in P)k[se]=P[se];}if(typeof n.delete<"u"){var V=D(n.delete,k,o);if(typeof V<"u"){var le=V;if(Array.isArray(V)||(V=[V]),!y(V))throw {code:"T2012",stack:new Error().stack,position:n.delete.position,value:le};for(var ae=0;ae<V.length;ae++)typeof k=="object"&&k!==null&&delete k[V[ae]];}}}}return f}};return O(e,"<(oa):o>")}var j=he("function($f, $g) { function($x){ $g($f($x)) } }");function z(n,a,o){var e,t=D(n.lhs,a,o);if(n.rhs.type==="function")e=H(n.rhs,a,o,{context:t});else {var r=D(n.rhs,a,o);if(!de(r))throw {code:"T2006",stack:new Error().stack,position:n.position,value:r};if(de(t)){var f=D(j,null,o);e=U(f,[t,r],null,o);}else e=U(r,[t],null,o);}return e}function H(n,a,o,e){var t,r=D(n.procedure,a,o);if(typeof r>"u"&&n.procedure.type==="path"&&o.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 u=0;u<n.arguments.length;u++){let k=D(n.arguments[u],a,o);if(de(k)){let P=function(...N){return U(k,N,null,o)};P.arity=$(k),f.push(P);}else f.push(k);}var d=n.procedure.type==="path"?n.procedure.steps[0].value:n.procedure.value;try{typeof r=="object"&&(r.token=d,r.position=n.position),t=U(r,f,a,o);}catch(k){throw k.position||(k.position=n.position),k.token||(k.token=d),k}return t}function U(n,a,o,e){var t;for(t=Pe(n,a,o,e);ce(t)&&t.thunk===true;){var r=D(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=[],u=0;u<t.body.arguments.length;u++)f.push(D(t.body.arguments[u],t.input,t.environment));t=Pe(r,f,o,e);}return t}function Pe(n,a,o,e){var t;try{var r=a;if(n&&(r=Se(n.signature,a,o)),ce(n))t=Ue(n,r);else if(n&&n._jsonata_function===!0){var f={environment:e,input:o};t=n.implementation.apply(f,r),R(t)&&(t=t.next().value),w(t)&&(t=t);}else if(typeof n=="function")t=n.apply(o,r),w(t)&&(t=t);else throw {code:"T1006",stack:new Error().stack}}catch(u){throw n&&(typeof u.token>"u"&&typeof n.token<"u"&&(u.token=n.token),u.position=n.position||u.position),u}return t}function We(n,a,o){var e={_jsonata_lambda:true,input:a,environment:o,arguments:n.arguments,signature:n.signature,body:n.body};return n.thunk===true&&(e.thunk=true),e.apply=function(t,r){return U(e,r,a,t?t.environment:o)},e}function Me(n,a,o){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(D(f,a,o));}var u=D(n.procedure,a,o);if(typeof u>"u"&&n.procedure.type==="path"&&o.lookup(n.procedure.steps[0].value))throw {code:"T1007",stack:new Error().stack,position:n.position,token:n.procedure.steps[0].value};if(ce(u))e=Ze(u,t);else if(u&&u._jsonata_function===true)e=Qe(u.implementation,t);else if(typeof u=="function")e=Qe(u,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 Se(n,a,o){if(typeof n>"u")return a;var e=n.validate(a,o);return e}function Ue(n,a){var o,e=Be(n.environment);return n.arguments.forEach(function(t,r){e.bind(t.value,a[r]);}),typeof n.body=="function"?o=dt(n.body,e):o=D(n.body,n.input,e),o}function Ze(n,a){var o=Be(n.environment),e=[];n.arguments.forEach(function(r,f){var u=a[f];u&&u.type==="operator"&&u.value==="?"?e.push(r):o.bind(r.value,u);});var t={_jsonata_lambda:true,input:n.input,environment:o,arguments:e,body:n.body};return t}function Qe(n,a){var o=Ke(n);o=o.map(function(f){return "$"+f.trim()});var e="function("+o.join(", ")+"){ _ }",t=he(e);t.body=n;var r=Ze(t,a);return r}function dt(n,a){var o=Ke(n),e=o.map(function(f){return a.lookup(f.trim())}),t={environment:a},r=n.apply(t,e);return w(r)&&(r=r),r}function Ke(n){var a=n.toString(),o=/\(([^)]*)\)/.exec(a)[1],e=o.split(",");return e}function O(n,a){var o={_jsonata_function:true,implementation:n};return typeof a<"u"&&(o.signature=ue(a)),o}function pt(n,a){if(!(typeof n>"u")){var o=this.input;typeof a<"u"&&(o=a,Array.isArray(o)&&!X(o)&&(o=M(o),o.outerWrapper=true));try{var e=he(n,!1);}catch(r){throw Ve(r),{stack:new Error().stack,code:"D3120",value:r.message,error:r}}try{var t=D(e,o,this.environment);}catch(r){throw Ve(r),{stack:new Error().stack,code:"D3121",value:r.message,error:r}}return t}}function st(n){if(!(typeof n>"u"))return JSON.parse(b.string(n))}function Be(n){var a={};let o={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,o);}return o}p.bind("sum",O(b.sum,"<a<n>:n>")),p.bind("count",O(b.count,"<a:n>")),p.bind("max",O(b.max,"<a<n>:n>")),p.bind("min",O(b.min,"<a<n>:n>")),p.bind("average",O(b.average,"<a<n>:n>")),p.bind("string",O(b.string,"<x-b?:s>")),p.bind("substring",O(b.substring,"<s-nn?:s>")),p.bind("substringBefore",O(b.substringBefore,"<s-s:s>")),p.bind("substringAfter",O(b.substringAfter,"<s-s:s>")),p.bind("lowercase",O(b.lowercase,"<s-:s>")),p.bind("uppercase",O(b.uppercase,"<s-:s>")),p.bind("length",O(b.length,"<s-:n>")),p.bind("trim",O(b.trim,"<s-:s>")),p.bind("pad",O(b.pad,"<s-ns?:s>")),p.bind("match",O(b.match,"<s-f<s:o>n?:a<o>>")),p.bind("contains",O(b.contains,"<s-(sf):b>")),p.bind("replace",O(b.replace,"<s-(sf)(sf)n?:s>")),p.bind("split",O(b.split,"<s-(sf)n?:a<s>>")),p.bind("join",O(b.join,"<a<s>s?:s>")),p.bind("formatNumber",O(b.formatNumber,"<n-so?:s>")),p.bind("formatBase",O(b.formatBase,"<n-n?:s>")),p.bind("formatInteger",O(De.formatInteger,"<n-s:s>")),p.bind("parseInteger",O(De.parseInteger,"<s-s:n>")),p.bind("number",O(b.number,"<(nsb)-:n>")),p.bind("floor",O(b.floor,"<n-:n>")),p.bind("ceil",O(b.ceil,"<n-:n>")),p.bind("round",O(b.round,"<n-n?:n>")),p.bind("abs",O(b.abs,"<n-:n>")),p.bind("sqrt",O(b.sqrt,"<n-:n>")),p.bind("power",O(b.power,"<n-n:n>")),p.bind("random",O(b.random,"<:n>")),p.bind("boolean",O(b.boolean,"<x-:b>")),p.bind("not",O(b.not,"<x-:b>")),p.bind("map",O(b.map,"<af>")),p.bind("zip",O(b.zip,"<a+>")),p.bind("filter",O(b.filter,"<af>")),p.bind("single",O(b.single,"<af?>")),p.bind("reduce",O(b.foldLeft,"<afj?:j>")),p.bind("sift",O(b.sift,"<o-f?:o>")),p.bind("keys",O(b.keys,"<x-:a<s>>")),p.bind("lookup",O(b.lookup,"<x-s:x>")),p.bind("append",O(b.append,"<xx:a>")),p.bind("exists",O(b.exists,"<x:b>")),p.bind("spread",O(b.spread,"<x-:a<o>>")),p.bind("merge",O(b.merge,"<a<o>:o>")),p.bind("reverse",O(b.reverse,"<a:a>")),p.bind("each",O(b.each,"<o-f:a>")),p.bind("error",O(b.error,"<s?:x>")),p.bind("assert",O(b.assert,"<bs?:x>")),p.bind("type",O(b.type,"<x:s>")),p.bind("sort",O(b.sort,"<af?:a>")),p.bind("shuffle",O(b.shuffle,"<a:a>")),p.bind("distinct",O(b.distinct,"<x:x>")),p.bind("base64encode",O(b.base64encode,"<s-:s>")),p.bind("base64decode",O(b.base64decode,"<s-:s>")),p.bind("encodeUrlComponent",O(b.encodeUrlComponent,"<s-:s>")),p.bind("encodeUrl",O(b.encodeUrl,"<s-:s>")),p.bind("decodeUrlComponent",O(b.decodeUrlComponent,"<s-:s>")),p.bind("decodeUrl",O(b.decodeUrl,"<s-:s>")),p.bind("eval",O(pt,"<sx?:x>")),p.bind("toMillis",O(De.toMillis,"<s-s?:n>")),p.bind("fromMillis",O(De.fromMillis,"<n-s?s?:s>")),p.bind("clone",O(st,"<(oa)-:o>"));var rt={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 Ve(n){var a=rt[n.code];if(typeof a<"u"){var o=a.replace(/\{\{\{([^}]+)}}}/g,function(){return n[arguments[1]]});o=o.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(n[arguments[1]])}),n.message=o;}}function oe(n,a){var o,e;try{o=he(n,a&&a.recover),e=o.errors,delete o.errors;}catch(f){throw Ve(f),f}var t=Be(p),r=new Date;return t.bind("now",O(function(f,u){return De.fromMillis(r.getTime(),f,u)},"<s?s?:s>")),t.bind("millis",O(function(){return r.getTime()},"<:n>")),a&&a.RegexEngine?oe.RegexEngine=a.RegexEngine:oe.RegexEngine=RegExp,{evaluate:function(f,u,d){if(typeof e<"u"){var k={code:"S0500",position:0};throw Ve(k),k}if(typeof u<"u"){var P;P=Be(t);for(var N in u)P.bind(N,u[N]);}else P=t;P.bind("$",f),r=new Date,P.timestamp=r,Array.isArray(f)&&!X(f)&&(f=M(f),f.outerWrapper=true);var se;try{return se=D(o,f,P),typeof d=="function"&&d(null,se),se}catch(V){throw Ve(V),V}},assign:function(f,u){t.bind(f,u);},registerFunction:function(f,u,d){var k=O(u,d);t.bind(f,k);},ast:function(){return o},errors:function(){return e}}}return oe.parser=he,oe})();ke.exports=ve;},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(Te,ke,He){var De=Te("./signature");let b=(()=>{var q={".":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},he={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},ue=function(S){var y=0,g=S.length,M=function(ce,R){var w={type:ce,value:R,position:y};return w},X=function(){for(var ce=y,R=0,w,$,x=function(D){if(S.charAt(D)==="/"&&R===0){for(var C=0;S.charAt(D-(C+1))==="\\";)C++;if(C%2===0)return true}return false};y<g;){var p=S.charAt(y);if(x(y)){if(w=S.substring(ce,y),w==="")throw {code:"S0301",stack:new Error().stack,position:y};for(y++,p=S.charAt(y),ce=y;p==="i"||p==="m";)y++,p=S.charAt(y);return $=S.substring(ce,y)+"g",new RegExp(w,$)}(p==="("||p==="["||p==="{")&&S.charAt(y-1)!=="\\"&&R++,(p===")"||p==="]"||p==="}")&&S.charAt(y-1)!=="\\"&&R--,y++;}throw {code:"S0302",stack:new Error().stack,position:y}},de=function(ce){if(y>=g)return null;for(var R=S.charAt(y);y<g&&`
3
+ \r\v`.indexOf(R)>-1;)y++,R=S.charAt(y);if(R==="/"&&S.charAt(y+1)==="*"){var w=y;for(y+=2,R=S.charAt(y);!(R==="*"&&S.charAt(y+1)==="/");)if(R=S.charAt(++y),y>=g)throw {code:"S0106",stack:new Error().stack,position:w};return y+=2,R=S.charAt(y),de(ce)}if(ce!==true&&R==="/")return y++,M("regex",X());if(R==="."&&S.charAt(y+1)===".")return y+=2,M("operator","..");if(R===":"&&S.charAt(y+1)==="=")return y+=2,M("operator",":=");if(R==="!"&&S.charAt(y+1)==="=")return y+=2,M("operator","!=");if(R===">"&&S.charAt(y+1)==="=")return y+=2,M("operator",">=");if(R==="<"&&S.charAt(y+1)==="=")return y+=2,M("operator","<=");if(R==="*"&&S.charAt(y+1)==="*")return y+=2,M("operator","**");if(R==="~"&&S.charAt(y+1)===">")return y+=2,M("operator","~>");if(R==="?"&&S.charAt(y+1)===":")return y+=2,M("operator","?:");if(R==="?"&&S.charAt(y+1)==="?")return y+=2,M("operator","??");if(Object.prototype.hasOwnProperty.call(q,R))return y++,M("operator",R);if(R==='"'||R==="'"){var $=R;y++;for(var x="";y<g;){if(R=S.charAt(y),R==="\\")if(y++,R=S.charAt(y),Object.prototype.hasOwnProperty.call(he,R))x+=he[R];else if(R==="u"){var p=S.substr(y+1,4);if(/^[0-9a-fA-F]+$/.test(p)){var D=parseInt(p,16);x+=String.fromCharCode(D),y+=4;}else throw {code:"S0104",stack:new Error().stack,position:y}}else throw {code:"S0103",stack:new Error().stack,position:y,token:R};else {if(R===$)return y++,M("string",x);x+=R;}y++;}throw {code:"S0101",stack:new Error().stack,position:y}}var C=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,G=C.exec(S.substring(y));if(G!==null){var ee=parseFloat(G[0]);if(!isNaN(ee)&&isFinite(ee))return y+=G[0].length,M("number",ee);throw {code:"S0102",stack:new Error().stack,position:y,token:G[0]}}var re;if(R==="`"){y++;var ie=S.indexOf("`",y);if(ie!==-1)return re=S.substring(y,ie),y=ie+1,M("name",re);throw y=g,{code:"S0105",stack:new Error().stack,position:y}}for(var J=y,ye;;)if(ye=S.charAt(J),J===g||`
4
+ \r\v`.indexOf(ye)>-1||Object.prototype.hasOwnProperty.call(q,ye)){if(S.charAt(y)==="$")return re=S.substring(y+1,J),y=J,M("variable",re);switch(re=S.substring(y,J),y=J,re){case "or":case "in":case "and":return M("operator",re);case "true":return M("value",true);case "false":return M("value",false);case "null":return M("value",null);default:return y===g&&re===""?null:M("name",re)}}else J++;};return de},ve=function(S,y){var g,M,X={},de=[],ce=function(){var i=[];g.id!=="(end)"&&i.push({type:g.type,value:g.value,position:g.position});for(var s=M();s!==null;)i.push(s),s=M();return i},R={nud:function(){var i={code:"S0211",token:this.value,position:this.position};if(y)return i.remaining=ce(),i.type="error",de.push(i),i;throw i.stack=new Error().stack,i}},w=function(i,s){var F=X[i];return s=s||0,F?s>=F.lbp&&(F.lbp=s):(F=Object.create(R),F.id=F.value=i,F.lbp=s,X[i]=F),F},$=function(i){if(y){i.remaining=ce(),de.push(i);var s=X["(error)"];return g=Object.create(s),g.error=i,g.type="(error)",g}else throw i.stack=new Error().stack,i},x=function(i,s){if(i&&g.id!==i){var F;g.id==="(end)"?F="S0203":F="S0202";var B={code:F,position:g.position,token:g.value,value:i};return $(B)}var fe=M(s);if(fe===null)return g=X["(end)"],g.position=S.length,g;var ne=fe.value,c=fe.type,h;switch(c){case "name":case "variable":h=X["(name)"];break;case "operator":if(h=X[ne],!h)return $({code:"S0204",stack:new Error().stack,position:fe.position,token:ne});break;case "string":case "number":case "value":h=X["(literal)"];break;case "regex":c="regex",h=X["(regex)"];break;default:return $({code:"S0205",stack:new Error().stack,position:fe.position,token:ne})}return g=Object.create(h),g.value=ne,g.type=c,g.position=fe.position,g},p=function(i){var s,F=g;for(x(null,true),s=F.nud();i<g.lbp;)F=g,x(),s=F.led(s);return s},D=function(i){var s=w(i,0);s.nud=function(){return this};},C=function(i,s,F){var B=s||q[i],fe=w(i,B);return fe.led=F||function(ne){return this.lhs=ne,this.rhs=p(B),this.type="binary",this},fe},G=function(i,s,F){var B=w(i,s);return B.led=F,B},ee=function(i,s){var F=w(i);return F.nud=s||function(){return this.expression=p(70),this.type="unary",this},F};D("(end)"),D("(name)"),D("(literal)"),D("(regex)"),w(":"),w(";"),w(","),w(")"),w("]"),w("}"),w(".."),C("."),C("+"),C("-"),C("*"),C("/"),C("%"),C("="),C("<"),C(">"),C("!="),C("<="),C(">="),C("&"),C("and"),C("or"),C("in"),D("and"),D("or"),D("in"),ee("-"),C("~>"),C("??",q["??"],function(i){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[i]},this.then=i,this.else=p(0),this}),G("(error)",10,function(i){return this.lhs=i,this.error=g.error,this.remaining=ce(),this.type="error",this}),ee("*",function(){return this.type="wildcard",this}),ee("**",function(){return this.type="descendant",this}),ee("%",function(){return this.type="parent",this}),C("(",q["("],function(i){if(this.procedure=i,this.type="function",this.arguments=[],g.id!==")")for(;g.type==="operator"&&g.id==="?"?(this.type="partial",this.arguments.push(g),x("?")):this.arguments.push(p(0)),g.id===",";)x(",");if(x(")",true),i.type==="name"&&(i.value==="function"||i.value==="\u03BB")){if(this.arguments.forEach(function(ne,c){if(ne.type!=="variable")return $({code:"S0208",stack:new Error().stack,position:ne.position,token:ne.value,value:c+1})}),this.type="lambda",g.id==="<"){for(var s=g.position,F=1,B="<";F>0&&g.id!=="{"&&g.id!=="(end)";){var fe=x();fe.id===">"?F--:fe.id==="<"&&F++,B+=fe.value;}x(">");try{this.signature=De(B);}catch(ne){return ne.position=s+ne.offset,$(ne)}}x("{"),this.body=p(0),x("}");}return this}),ee("(",function(){for(var i=[];g.id!==")"&&(i.push(p(0)),g.id===";");)x(";");return x(")",true),this.type="block",this.expressions=i,this}),ee("[",function(){var i=[];if(g.id!=="]")for(;;){var s=p(0);if(g.id===".."){var F={type:"binary",value:"..",position:g.position,lhs:s};x(".."),F.rhs=p(0),s=F;}if(i.push(s),g.id!==",")break;x(",");}return x("]",true),this.expressions=i,this.type="unary",this}),C("[",q["["],function(i){if(g.id==="]"){for(var s=i;s&&s.type==="binary"&&s.value==="[";)s=s.lhs;return s.keepArray=true,x("]"),i}else return this.lhs=i,this.rhs=p(q["]"]),this.type="binary",x("]",true),this}),C("^",q["^"],function(i){x("(");for(var s=[];;){var F={descending:false};if(g.id==="<"?x("<"):g.id===">"&&(F.descending=true,x(">")),F.expression=p(0),s.push(F),g.id!==",")break;x(",");}return x(")"),this.lhs=i,this.rhs=s,this.type="binary",this});var re=function(i){var s=[];if(g.id!=="}")for(;;){var F=p(0);x(":");var B=p(0);if(s.push([F,B]),g.id!==",")break;x(",");}return x("}",true),typeof i>"u"?(this.lhs=s,this.type="unary"):(this.lhs=i,this.rhs=s,this.type="binary"),this};ee("{",re),C("{",q["{"],re),G(":=",q[":="],function(i){return i.type!=="variable"?$({code:"S0212",stack:new Error().stack,position:i.position,token:i.value}):(this.lhs=i,this.rhs=p(q[":="]-1),this.type="binary",this)}),C("@",q["@"],function(i){return this.lhs=i,this.rhs=p(q["@"]),this.rhs.type!=="variable"?$({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),C("#",q["#"],function(i){return this.lhs=i,this.rhs=p(q["#"]),this.rhs.type!=="variable"?$({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),C("?",q["?"],function(i){return this.type="condition",this.condition=i,this.then=p(0),g.id===":"&&(x(":"),this.else=p(0)),this}),C("?:",q["?:"],function(i){return this.type="condition",this.condition=i,this.then=i,this.else=p(0),this}),ee("|",function(){return this.type="transform",this.pattern=p(0),x("|"),this.update=p(0),g.id===","&&(x(","),this.delete=p(0)),x("|"),this});var ie=function(i){var s;if(i.type==="function"&&!i.predicate){var F={type:"lambda",thunk:true,arguments:[],position:i.position};F.body=i,s=F;}else if(i.type==="condition")i.then=ie(i.then),typeof i.else<"u"&&(i.else=ie(i.else)),s=i;else if(i.type==="block"){var B=i.expressions.length;B>0&&(i.expressions[B-1]=ie(i.expressions[B-1])),s=i;}else s=i;return s},J=0,ye=0,ze=[],te=function(i,s){switch(i.type){case "name":case "wildcard":s.level--,s.level===0&&(typeof i.ancestor>"u"||(ze[s.index].slot.label=i.ancestor.label),i.ancestor=s,i.tuple=true);break;case "parent":s.level++;break;case "block":i.expressions.length>0&&(i.tuple=true,s=te(i.expressions[i.expressions.length-1],s));break;case "path":i.tuple=true;var F=i.steps.length-1;for(s=te(i.steps[F--],s);s.level>0&&F>=0;)s=te(i.steps[F--],s);break;default:throw {code:"S0217",token:i.type,position:i.position}}return s},Y=function(i,s){if(typeof s.seekingParent<"u"||s.type==="parent"){var F=typeof s.seekingParent<"u"?s.seekingParent:[];s.type==="parent"&&F.push(s.slot),typeof i.seekingParent>"u"?i.seekingParent=F:Array.prototype.push.apply(i.seekingParent,F);}},Le=function(i){var s=i.steps.length-1,F=i.steps[s],B=typeof F.seekingParent<"u"?F.seekingParent:[];F.type==="parent"&&B.push(F.slot);for(var fe=0;fe<B.length;fe++){var ne=B[fe];for(s=i.steps.length-2;ne.level>0;){if(s<0){typeof i.seekingParent>"u"?i.seekingParent=[ne]:i.seekingParent.push(ne);break}for(var c=i.steps[s--];s>=0&&c.focus&&i.steps[s].focus;)c=i.steps[s--];ne=te(c,ne);}}},_=function(i){var s;switch(i.type){case "binary":switch(i.value){case ".":var F=_(i.lhs);F.type==="path"?s=F:s={type:"path",steps:[F]},F.type==="parent"&&(s.seekingParent=[F.slot]);var B=_(i.rhs);B.type==="function"&&B.procedure.type==="path"&&B.procedure.steps.length===1&&B.procedure.steps[0].type==="name"&&s.steps[s.steps.length-1].type==="function"&&(s.steps[s.steps.length-1].nextFunction=B.procedure.steps[0].value),B.type==="path"?Array.prototype.push.apply(s.steps,B.steps):(typeof B.predicate<"u"&&(B.stages=B.predicate,delete B.predicate),s.steps.push(B)),s.steps.filter(function(E){if(E.type==="number"||E.type==="value")throw {code:"S0213",stack:new Error().stack,position:E.position,value:E.value};return E.type==="string"}).forEach(function(E){E.type="name";}),s.steps.filter(function(E){return E.keepArray===true}).length>0&&(s.keepSingletonArray=true);var fe=s.steps[0];fe.type==="unary"&&fe.value==="["&&(fe.consarray=true);var ne=s.steps[s.steps.length-1];ne.type==="unary"&&ne.value==="["&&(ne.consarray=true),Le(s);break;case "[":s=_(i.lhs);var c=s,h="predicate";if(s.type==="path"&&(c=s.steps[s.steps.length-1],h="stages"),typeof c.group<"u")throw {code:"S0209",stack:new Error().stack,position:i.position};typeof c[h]>"u"&&(c[h]=[]);var l=_(i.rhs);typeof l.seekingParent<"u"&&(l.seekingParent.forEach(E=>{E.level===1?te(c,E):E.level--;}),Y(c,l)),c[h].push({type:"filter",expr:l,position:i.position});break;case "{":if(s=_(i.lhs),typeof s.group<"u")throw {code:"S0210",stack:new Error().stack,position:i.position};s.group={lhs:i.rhs.map(function(E){return [_(E[0]),_(E[1])]}),position:i.position};break;case "^":s=_(i.lhs),s.type!=="path"&&(s={type:"path",steps:[s]});var m={type:"sort",position:i.position};m.terms=i.rhs.map(function(E){var I=_(E.expression);return Y(m,I),{descending:E.descending,expression:I}}),s.steps.push(m),Le(s);break;case ":=":s={type:"bind",value:i.value,position:i.position},s.lhs=_(i.lhs),s.rhs=_(i.rhs),Y(s,s.rhs);break;case "@":if(s=_(i.lhs),c=s,s.type==="path"&&(c=s.steps[s.steps.length-1]),typeof c.stages<"u"||typeof c.predicate<"u")throw {code:"S0215",stack:new Error().stack,position:i.position};if(c.type==="sort")throw {code:"S0216",stack:new Error().stack,position:i.position};i.keepArray&&(c.keepArray=true),c.focus=i.rhs.value,c.tuple=true;break;case "#":s=_(i.lhs),c=s,s.type==="path"?c=s.steps[s.steps.length-1]:(s={type:"path",steps:[s]},typeof c.predicate<"u"&&(c.stages=c.predicate,delete c.predicate)),typeof c.stages>"u"?c.index=i.rhs.value:c.stages.push({type:"index",value:i.rhs.value,position:i.position}),c.tuple=true;break;case "~>":s={type:"apply",value:i.value,position:i.position},s.lhs=_(i.lhs),s.rhs=_(i.rhs),s.keepArray=s.lhs.keepArray||s.rhs.keepArray;break;default:s={type:i.type,value:i.value,position:i.position},s.lhs=_(i.lhs),s.rhs=_(i.rhs),Y(s,s.lhs),Y(s,s.rhs);}break;case "unary":s={type:i.type,value:i.value,position:i.position},i.value==="["?s.expressions=i.expressions.map(function(E){var I=_(E);return Y(s,I),I}):i.value==="{"?s.lhs=i.lhs.map(function(E){var I=_(E[0]);Y(s,I);var Z=_(E[1]);return Y(s,Z),[I,Z]}):(s.expression=_(i.expression),i.value==="-"&&s.expression.type==="number"?(s=s.expression,s.value=-s.value):Y(s,s.expression));break;case "function":case "partial":s={type:i.type,name:i.name,value:i.value,position:i.position},s.arguments=i.arguments.map(function(E){var I=_(E);return Y(s,I),I}),s.procedure=_(i.procedure);break;case "lambda":s={type:i.type,arguments:i.arguments,signature:i.signature,position:i.position};var T=_(i.body);s.body=ie(T);break;case "condition":s={type:i.type,position:i.position},s.condition=_(i.condition),Y(s,s.condition),s.then=_(i.then),Y(s,s.then),typeof i.else<"u"&&(s.else=_(i.else),Y(s,s.else));break;case "transform":s={type:i.type,position:i.position},s.pattern=_(i.pattern),s.update=_(i.update),typeof i.delete<"u"&&(s.delete=_(i.delete));break;case "block":s={type:i.type,position:i.position},s.expressions=i.expressions.map(function(E){var I=_(E);return Y(s,I),(I.consarray||I.type==="path"&&I.steps[0].consarray)&&(s.consarray=true),I});break;case "name":s={type:"path",steps:[i]},i.keepArray&&(s.keepSingletonArray=true);break;case "parent":s={type:"parent",slot:{label:"!"+J++,level:1,index:ye++}},ze.push(s);break;case "string":case "number":case "value":case "wildcard":case "descendant":case "variable":case "regex":s=i;break;case "operator":if(i.value==="and"||i.value==="or"||i.value==="in")i.type="name",s=_(i);else if(i.value==="?")s=i;else throw {code:"S0201",stack:new Error().stack,position:i.position,token:i.value};break;case "error":s=i,i.lhs&&(s=_(i.lhs));break;default:var A="S0206";i.id==="(end)"&&(A="S0207");var v={code:A,position:i.position,token:i.value};if(y)return de.push(v),{type:"error",error:v};throw v.stack=new Error().stack,v}return i.keepArray&&(s.keepArray=true),s};M=ue(S),x();var Ae=p(0);if(g.id!=="(end)"){var qe={code:"S0201",position:g.position,token:g.value};$(qe);}if(Ae=_(Ae),Ae.type==="parent"||typeof Ae.seekingParent<"u")throw {code:"S0217",token:Ae.type,position:Ae.position};return de.length>0&&(Ae.errors=de),Ae};return ve})();ke.exports=b;},{"./signature":5}],5:[function(Te,ke,He){var De=Te("./utils");let b=(()=>{var q={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function he(ue){for(var ve=1,S=[],y={},g=y;ve<ue.length;){var M=ue.charAt(ve);if(M===":")break;var X=function(){S.push(y),g=y,y={};},de=function(C,G,ee,re){for(var ie=1,J=G;J<C.length;)if(J++,M=C.charAt(J),M===re){if(ie--,ie===0)break}else M===ee&&ie++;return J};switch(M){case "s":case "n":case "b":case "l":case "o":y.regex="["+M+"m]",y.type=M,X();break;case "a":y.regex="[asnblfom]",y.type=M,y.array=true,X();break;case "f":y.regex="f",y.type=M,X();break;case "j":y.regex="[asnblom]",y.type=M,X();break;case "x":y.regex="[asnblfom]",y.type=M,X();break;case "-":g.context=true,g.contextRegex=new RegExp(g.regex),g.regex+="?";break;case "?":case "+":g.regex+=M;break;case "(":var ce=de(ue,ve,"(",")"),R=ue.substring(ve+1,ce);if(R.indexOf("<")===-1)y.regex="["+R+"m]";else throw {code:"S0402",stack:new Error().stack,value:R,offset:ve};y.type="("+R+")",ve=ce,X();break;case "<":if(g.type==="a"||g.type==="f"){var w=de(ue,ve,"<",">");g.subtype=ue.substring(ve+1,w),ve=w;}else throw {code:"S0401",stack:new Error().stack,value:g.type,offset:ve};break}ve++;}var $="^"+S.map(function(C){return "("+C.regex+")"}).join("")+"$",x=new RegExp($),p=function(C){var G;if(De.isFunction(C))G="f";else {var ee=typeof C;switch(ee){case "string":G="s";break;case "number":G="n";break;case "boolean":G="b";break;case "object":C===null?G="l":Array.isArray(C)?G="a":G="o";break;default:G="m";}}return G},D=function(C,G){for(var ee="^",re=0,ie=0;ie<S.length;ie++){ee+=S[ie].regex;var J=G.match(ee);if(J===null)throw {code:"T0410",stack:new Error().stack,value:C[re],index:re+1};re=J[0].length;}throw {code:"T0410",stack:new Error().stack,value:C[re],index:re+1}};return {definition:ue,validate:function(C,G){var ee="";C.forEach(function(ye){ee+=p(ye);});var re=x.exec(ee);if(re){var ie=[],J=0;return S.forEach(function(ye,ze){var te=C[J],Y=re[ze+1];if(Y==="")if(ye.context&&ye.contextRegex){var Le=p(G);if(ye.contextRegex.test(Le))ie.push(G);else throw {code:"T0411",stack:new Error().stack,value:G,index:J+1}}else ie.push(te),J++;else Y.split("").forEach(function(_){if(ye.type==="a"){if(_==="m")te=void 0;else {te=C[J];var Ae=true;if(typeof ye.subtype<"u"){if(_!=="a"&&Y!==ye.subtype)Ae=false;else if(_==="a"&&te.length>0){var qe=p(te[0]);if(qe!==ye.subtype.charAt(0))Ae=false;else {var i=te.filter(function(s){return p(s)!==qe});Ae=i.length===0;}}}if(!Ae)throw {code:"T0412",stack:new Error().stack,value:te,index:J+1,type:q[ye.subtype]};_!=="a"&&(te=[te]);}ie.push(te),J++;}else ie.push(te),J++;});}),ie}D(C,ee);}}}return he})();ke.exports=b;},{"./utils":6}],6:[function(Te,ke,He){let De=(()=>{function b(w){var $=false;if(typeof w=="number"&&($=!isNaN(w),$&&!isFinite(w)))throw {code:"D1001",value:w,stack:new Error().stack};return $}function q(w){var $=false;return Array.isArray(w)&&($=w.filter(function(x){return typeof x!="string"}).length===0),$}function he(w){var $=false;return Array.isArray(w)&&($=w.filter(function(x){return !b(x)}).length===0),$}function ue(){var w=[];return w.sequence=true,arguments.length===1&&w.push(arguments[0]),w}function ve(w){return w.sequence===true&&Array.isArray(w)}function S(w){return w&&(w._jsonata_function===true||w._jsonata_lambda===true)||typeof w=="function"}function y(w){var $=typeof w.arity=="number"?w.arity:typeof w.implementation=="function"?w.implementation.length:typeof w.length=="number"?w.length:w.arguments.length;return $}function g(w){return w&&w._jsonata_lambda===true}var M=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function X(w){return typeof w=="object"&&w!==null&&M in w&&"next"in w&&typeof w.next=="function"}function de(w,$){if(w===$)return true;if(typeof w=="object"&&typeof $=="object"&&w!==null&&$!==null){if(Array.isArray(w)&&Array.isArray($)){if(w.length!==$.length)return false;for(var x=0;x<w.length;x++)if(!de(w[x],$[x]))return false;return true}var p=Object.getOwnPropertyNames(w),D=Object.getOwnPropertyNames($);if(p.length!==D.length)return false;for(p=p.sort(),D=D.sort(),x=0;x<p.length;x++)if(p[x]!==D[x])return false;for(x=0;x<p.length;x++){var C=p[x];if(!de(w[C],$[C]))return false}return true}return false}function ce(w){return typeof w=="object"&&w!==null&&"then"in w&&typeof w.then=="function"}function R(w){var $=[];for(let x of w)$.push(x);return $}return {isNumeric:b,isArrayOfStrings:q,isArrayOfNumbers:he,createSequence:ue,isSequence:ve,isFunction:S,isLambda:g,isIterable:X,getFunctionArity:y,isDeepEqual:de,stringToArray:R,isPromise:ce}})();ke.exports=De;},{}]},{},[3])(3)});});var Dt=Rt(Tt());globalThis.jsonataSync=Dt.default;})();//# sourceMappingURL=compute-jsonata.js.map
5
+ //# sourceMappingURL=compute-jsonata.js.map