@fincity/kirun-js 3.7.0 → 3.8.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.
@@ -28,6 +28,21 @@ test('LinkedList Test', () => {
28
28
  expect(x.toArray()).toStrictEqual([1, 2, 3, 4]);
29
29
  });
30
30
 
31
+ test('LinkedList Test - set at every index', () => {
32
+ // the walk in set() used to re-read from head each iteration, so any index
33
+ // of 2 or more wrote over element 1 instead of the requested one
34
+ for (let i = 0; i < 5; i++) {
35
+ const x = new LinkedList([10, 20, 30, 40, 50]);
36
+ x.set(i, 999);
37
+ const expected = [10, 20, 30, 40, 50];
38
+ expected[i] = 999;
39
+ expect(x.toArray()).toStrictEqual(expected);
40
+ }
41
+ const y = new LinkedList([1, 2, 3]);
42
+ expect(() => y.set(-1, 0)).toThrow();
43
+ expect(() => y.set(3, 0)).toThrow();
44
+ });
45
+
31
46
  test('LinkedList Test - peekLastTest', () => {
32
47
  let x = new LinkedList();
33
48
  x.push(230);
@@ -102,3 +102,65 @@ test('deepEqual', () => {
102
102
  deepEqual([1, 2, 3, { a: [3, 4], b: null }], [1, 2, 3, { a: [3, 4], b: undefined }]),
103
103
  ).toBeTruthy();
104
104
  });
105
+
106
+ test('deepEqual key sets of the same size but different names', () => {
107
+ expect(deepEqual({ x: 1 }, { y: 1 })).toBeFalsy();
108
+ expect(deepEqual({ a: 1, b: 2 }, { a: 1, c: 2 })).toBeFalsy();
109
+ // a present-but-undefined key still counts towards the key set
110
+ expect(deepEqual({ a: 1 }, { a: 1, b: undefined })).toBeFalsy();
111
+ });
112
+
113
+ test('deepEqual does not conflate falsy values of different types', () => {
114
+ expect(deepEqual(0, '')).toBeFalsy();
115
+ expect(deepEqual(0, false)).toBeFalsy();
116
+ expect(deepEqual({ a: 0 }, { a: false })).toBeFalsy();
117
+ expect(deepEqual([1], null)).toBeFalsy();
118
+ expect(deepEqual(null, [1])).toBeFalsy();
119
+ });
120
+
121
+ // An array is never equal to a plain object, in either direction. This matches
122
+ // kirun-java (LogicalEqualOperator guards both directions explicitly) and
123
+ // kirun-py (deep_equal rejects on type(a) is not type(b)).
124
+ test('deepEqual never equates an object with an array', () => {
125
+ expect(deepEqual([], {})).toBeFalsy();
126
+ expect(deepEqual({}, [])).toBeFalsy();
127
+ expect(deepEqual([1], { 0: 1 })).toBeFalsy();
128
+ expect(deepEqual({ 0: 1 }, [1])).toBeFalsy();
129
+ expect(deepEqual([1], { a: 1 })).toBeFalsy();
130
+ expect(deepEqual({ a: 1 }, [1])).toBeFalsy();
131
+ // nested, not just at the top level
132
+ expect(deepEqual({ v: {} }, { v: [] })).toBeFalsy();
133
+ expect(deepEqual({ v: [] }, { v: {} })).toBeFalsy();
134
+ expect(deepEqual([[]], [{}])).toBeFalsy();
135
+ // and the cases that must keep working
136
+ expect(deepEqual([], [])).toBeTruthy();
137
+ expect(deepEqual({}, {})).toBeTruthy();
138
+ expect(deepEqual({ v: [1, 2] }, { v: [1, 2] })).toBeTruthy();
139
+ });
140
+
141
+ test('deepEqual short circuits on shared references', () => {
142
+ const shared = { big: Array.from({ length: 1000 }, (_, i) => ({ i })) };
143
+ expect(deepEqual({ v: shared }, { v: shared })).toBeTruthy();
144
+ expect(deepEqual({ v: shared }, { v: { ...shared } })).toBeTruthy();
145
+ });
146
+
147
+ test('deepEqual handles deeply nested values without overflowing the stack', () => {
148
+ const chain = (n: number) => {
149
+ const root: any = {};
150
+ let cur = root;
151
+ for (let i = 0; i < n; i++) {
152
+ cur.next = {};
153
+ cur = cur.next;
154
+ }
155
+ cur.value = 1;
156
+ return root;
157
+ };
158
+ expect(deepEqual(chain(50000), chain(50000))).toBeTruthy();
159
+
160
+ const nestedArray = (n: number) => {
161
+ let a: any = [1];
162
+ for (let i = 0; i < n; i++) a = [a];
163
+ return a;
164
+ };
165
+ expect(deepEqual(nestedArray(50000), nestedArray(50000))).toBeTruthy();
166
+ });
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var $kEX8F$luxon=require("luxon");function $parcel$export(e,t,a,r){Object.defineProperty(e,t,{get:a,set:r,enumerable:!0,configurable:!0})}function $parcel$exportWildcard(e,t){return Object.keys(t).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[a]}})}),e}var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequiref35d;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var a={id:e,exports:{}};return $parcel$modules[e]=a,t.call(a.exports,a,a.exports),a.exports}var r=Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequiref35d=parcelRequire);var parcelRegister=parcelRequire.register;parcelRegister("ceUTq",function(e,t){$parcel$export(e.exports,"DSLCompiler",()=>o);var a=parcelRequire("4f8CX"),r=parcelRequire("jXSwJ"),$=parcelRequire("d9EbJ"),c=parcelRequire("7hMSn");class o{static compile(e){let t=new(0,a.DSLLexer)(e).tokenize(),c=new(0,r.DSLParser)(t,e).parse(),o=new(0,$.ASTToJSONTransformer);return o.flattenNestedBlocks(c),o.transform(c)}static async decompile(e){let t=new(0,c.JSONToTextTransformer);return await t.transform(e)}static validate(e){try{return this.compile(e),{valid:!0,errors:[]}}catch(e){return{valid:!1,errors:[this.formatError(e)]}}}static async format(e){let t=this.compile(e);return await this.decompile(t)}static formatError(e){let t={message:e.message||"Unknown error"};return e.location&&(t.line=e.location.line,t.column=e.location.column),t}}}),parcelRegister("4f8CX",function(e,t){$parcel$export(e.exports,"DSLLexer",()=>c);var a=parcelRequire("lnzmS"),r=parcelRequire("2VbPC"),$=parcelRequire("kx6qK");class c{constructor(e){this.pos=0,this.line=1,this.column=1,this.tokens=[],this.input=e}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let e=this.readToken();e&&e.type!==a.DSLTokenType.WHITESPACE&&this.tokens.push(e)}return this.tokens.push(new(0,a.DSLToken)(a.DSLTokenType.EOF,"",new(0,a.SourceLocation)(this.line,this.column,this.pos,this.pos))),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.input[this.pos];if(" "===e||" "===e||"\r"===e)this.advance();else if("\n"===e)this.advance(),this.line++,this.column=1;else break}}readToken(){let e=this.pos,t=this.line,r=this.column,c=this.peek();if("/"===c&&"*"===this.peekAhead(1))return this.readBlockComment();if('"'===c||"'"===c)return this.readStringLiteral(c);if("`"===c)return this.readBacktickString();if(this.isDigit(c)||"-"===c&&this.isDigit(this.peekAhead(1)))return this.readNumber();if(this.isIdentifierStart(c))return this.readIdentifier();let o=this.readSingleCharToken();if(o)return o;throw new(0,$.LexerError)(`Unexpected character '${c}'`,new(0,a.SourceLocation)(t,r,e,this.pos),this.input)}readSingleCharToken(){let e=this.pos,t=this.line,r=this.column,$=this.peek(),c=this.tryReadMultiCharOperator();if(c)return new(0,a.DSLToken)(a.DSLTokenType.OPERATOR,c,new(0,a.SourceLocation)(t,r,e,this.pos));this.advance();let o=null;switch($){case":":o=a.DSLTokenType.COLON;break;case",":o=a.DSLTokenType.COMMA;break;case".":o=a.DSLTokenType.DOT;break;case"=":o=a.DSLTokenType.EQUALS;break;case"(":o=a.DSLTokenType.LEFT_PAREN;break;case")":o=a.DSLTokenType.RIGHT_PAREN;break;case"{":o=a.DSLTokenType.LEFT_BRACE;break;case"}":o=a.DSLTokenType.RIGHT_BRACE;break;case"[":o=a.DSLTokenType.LEFT_BRACKET;break;case"]":o=a.DSLTokenType.RIGHT_BRACKET;break;case"+":case"-":case"*":case"/":case"%":case"<":case">":case"!":case"?":case"&":case"|":case"@":case"^":case"~":case"#":case"\\":o=a.DSLTokenType.OPERATOR;break;default:return null}return new(0,a.DSLToken)(o,$,new(0,a.SourceLocation)(t,r,e,this.pos))}tryReadMultiCharOperator(){let e=this.peek()+this.peekAhead(1);return["!=","==","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/="].includes(e)?(this.advance(),this.advance(),e):null}readIdentifier(){let e=this.pos,t=this.line,$=this.column,c="";for(;this.pos<this.input.length;){let e=this.peek();if(this.isIdentifierPart(e))c+=this.advance();else break}let o=new(0,a.SourceLocation)(t,$,e,this.pos);return(0,r.isKeyword)(c)?new(0,a.DSLToken)(a.DSLTokenType.KEYWORD,c,o):"true"===c||"false"===c?new(0,a.DSLToken)(a.DSLTokenType.BOOLEAN,c,o):"null"===c?new(0,a.DSLToken)(a.DSLTokenType.NULL,c,o):new(0,a.DSLToken)(a.DSLTokenType.IDENTIFIER,c,o)}readNumber(){let e=this.pos,t=this.line,r=this.column,$="";for("-"===this.peek()&&($+=this.advance());this.pos<this.input.length&&this.isDigit(this.peek());)$+=this.advance();if("."===this.peek()&&this.isDigit(this.peekAhead(1)))for($+=this.advance();this.pos<this.input.length&&this.isDigit(this.peek());)$+=this.advance();return new(0,a.DSLToken)(a.DSLTokenType.NUMBER,$,new(0,a.SourceLocation)(t,r,e,this.pos))}readStringLiteral(e){let t=this.pos,r=this.line,c=this.column,o="";for(this.advance(),o+=e;this.pos<this.input.length;){let t=this.peek();if(t===e){o+=this.advance();break}if("\\"===t){o+=this.advance(),this.pos<this.input.length&&(o+=this.advance());continue}o+=this.advance()}if(!o.endsWith(e))throw new(0,$.LexerError)("Unterminated string literal",new(0,a.SourceLocation)(r,c,t,this.pos),this.input);return new(0,a.DSLToken)(a.DSLTokenType.STRING,o,new(0,a.SourceLocation)(r,c,t,this.pos))}readBacktickString(){let e=this.pos,t=this.line,r=this.column,$="";for(this.advance();this.pos<this.input.length;){let e=this.peek();if("`"===e){this.advance();break}if("\\"===e){let e=this.peekAhead(1);if("`"===e||"\\"===e){this.advance(),$+=this.advance();continue}$+=this.advance();continue}$+=this.advance()}return new(0,a.DSLToken)(a.DSLTokenType.BACKTICK_STRING,$,new(0,a.SourceLocation)(t,r,e,this.pos))}readLineComment(){let e=this.pos,t=this.line,r=this.column,$="";for($+=this.advance(),$+=this.advance();this.pos<this.input.length&&"\n"!==this.peek();)$+=this.advance();return new(0,a.DSLToken)(a.DSLTokenType.COMMENT,$,new(0,a.SourceLocation)(t,r,e,this.pos))}readBlockComment(){let e=this.pos,t=this.line,r=this.column,c="";for(c+=this.advance(),c+=this.advance();this.pos<this.input.length;){if("*"===this.peek()&&"/"===this.peekAhead(1)){c+=this.advance(),c+=this.advance();break}let e=this.advance();c+=e,"\n"===e&&(this.line++,this.column=1)}if(!c.endsWith("*/"))throw new(0,$.LexerError)("Unterminated block comment",new(0,a.SourceLocation)(t,r,e,this.pos),this.input);return new(0,a.DSLToken)(a.DSLTokenType.COMMENT,c,new(0,a.SourceLocation)(t,r,e,this.pos))}peek(){return this.input[this.pos]||""}peekAhead(e){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos];return this.pos++,this.column++,e}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e}isIdentifierPart(e){return this.isIdentifierStart(e)||this.isDigit(e)}}}),parcelRegister("lnzmS",function(e,t){$parcel$export(e.exports,"DSLTokenType",()=>r),$parcel$export(e.exports,"SourceLocation",()=>$),$parcel$export(e.exports,"DSLToken",()=>c);var a,r=((a={}).KEYWORD="KEYWORD",a.IDENTIFIER="IDENTIFIER",a.NUMBER="NUMBER",a.STRING="STRING",a.BACKTICK_STRING="BACKTICK_STRING",a.BOOLEAN="BOOLEAN",a.NULL="NULL",a.COLON="COLON",a.COMMA="COMMA",a.DOT="DOT",a.EQUALS="EQUALS",a.OPERATOR="OPERATOR",a.LEFT_PAREN="LEFT_PAREN",a.RIGHT_PAREN="RIGHT_PAREN",a.LEFT_BRACE="LEFT_BRACE",a.RIGHT_BRACE="RIGHT_BRACE",a.LEFT_BRACKET="LEFT_BRACKET",a.RIGHT_BRACKET="RIGHT_BRACKET",a.NEWLINE="NEWLINE",a.COMMENT="COMMENT",a.WHITESPACE="WHITESPACE",a.EOF="EOF",a);class ${constructor(e,t,a,r){this.line=e,this.column=t,this.startPos=a,this.endPos=r}toString(){return`Line ${this.line}, Column ${this.column} (pos ${this.startPos}-${this.endPos})`}}class c{constructor(e,t,a){this.type=e,this.value=t,this.location=a}toString(){return`${this.type}(${JSON.stringify(this.value)}) at ${this.location}`}is(e,t){return void 0!==t?this.type===e&&this.value===t:this.type===e}}}),parcelRegister("2VbPC",function(e,t){$parcel$export(e.exports,"isKeyword",()=>c),$parcel$export(e.exports,"isBlockName",()=>o),$parcel$export(e.exports,"isPrimitiveType",()=>s);let a=new Set(["FUNCTION","NAMESPACE","PARAMETERS","EVENTS","LOGIC","AS","OF","WITH","DEFAULT","VALUE","AFTER","IF","INTEGER","LONG","FLOAT","DOUBLE","STRING","BOOLEAN","NULL","ANY","ARRAY","OBJECT","true","false","null"]),r=new Set(["iteration","true","false","output","error"]),$=new Set(["INTEGER","LONG","FLOAT","DOUBLE","STRING","BOOLEAN","NULL","ANY"]);function c(e){return a.has(e)}function o(e){return r.has(e)}function s(e){return $.has(e)}}),parcelRegister("kx6qK",function(e,t){$parcel$export(e.exports,"LexerError",()=>a);class a extends Error{constructor(e,t,a){super(e),this.location=t,this.context=a,this.name="LexerError",t&&(this.message=`${e} at ${t}`,a&&(this.message+=`
2
2
 
3
3
  ${this.formatContext(a,t)}`))}formatContext(e,t){let a=e.split("\n"),r=t.line-1;if(r<0||r>=a.length)return"";let $=a[r],c=" ".repeat(t.column-1)+"^";return`${$}
4
- ${c}`}}}),parcelRegister("jXSwJ",function(e,t){$parcel$export(e.exports,"DSLParser",()=>E);var a=parcelRequire("lnzmS");parcelRequire("ljJAk");var r=parcelRequire("TP9ar"),$=parcelRequire("kZUxs"),c=parcelRequire("3WTbA"),o=parcelRequire("jpfiN"),s=parcelRequire("5qcBL"),n=parcelRequire("amNrQ"),f=parcelRequire("9IcXU"),d=parcelRequire("hsyfz"),b=parcelRequire("4eaZb"),i=parcelRequire("jdXce"),p=parcelRequire("5kX2Z");class E{constructor(e,t=""){this.current=0,this.tokens=e,this.originalInput=t}parse(){return this.parseFunctionDefinition()}parseFunctionDefinition(){let e=this.expect(a.DSLTokenType.KEYWORD,"FUNCTION"),t=this.expectIdentifier(),r=this.parseNamespaceDecl(),$=this.parseParametersDecl(),c=this.parseEventsDecl();this.expect(a.DSLTokenType.KEYWORD,"LOGIC");let o=this.parseLogicBlock();return new(0,n.FunctionDefNode)(t,r,$,c,o,e.location)}parseNamespaceDecl(){if(this.match(a.DSLTokenType.KEYWORD,"NAMESPACE"))return this.advance(),this.expectDottedIdentifier()}parseParametersDecl(){if(!this.match(a.DSLTokenType.KEYWORD,"PARAMETERS"))return[];this.advance();let e=[];for(;!this.match(a.DSLTokenType.KEYWORD,"EVENTS")&&!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF);)e.push(this.parseParameterDecl());return e}parseParameterDecl(){let e=this.peek(),t=this.expectIdentifier();this.expect(a.DSLTokenType.KEYWORD,"AS");let r=this.parseSchemaSpec();return new(0,f.ParameterDeclNode)(t,r,e.location)}parseEventsDecl(){if(!this.match(a.DSLTokenType.KEYWORD,"EVENTS"))return[];this.advance();let e=[];for(;!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF);)e.push(this.parseEventDecl());return e}parseEventDecl(){let e=this.peek(),t=this.expectIdentifier(),r=[];for(;!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF)&&this.peek().type===a.DSLTokenType.IDENTIFIER;)if(this.peekAhead(1)?.is(a.DSLTokenType.KEYWORD,"AS"))r.push(this.parseParameterDecl());else break;return new(0,c.EventDeclNode)(t,r,e.location)}parseLogicBlock(){let e=[];for(;!this.match(a.DSLTokenType.EOF);)e.push(this.parseStatement());return e}parseStatement(e=0){let t,r=this.peek();this.match(a.DSLTokenType.COLON)?t=`_anonymous_${this.current}`:(t=this.expectIdentifier(),this.expect(a.DSLTokenType.COLON));let $=this.parseFunctionCall(),c=[];if(this.match(a.DSLTokenType.KEYWORD,"AFTER"))for(this.advance();;)if(c.push(this.expectStepReference()),this.match(a.DSLTokenType.COMMA))this.advance();else break;let o=[];if(this.match(a.DSLTokenType.KEYWORD,"IF"))for(this.advance();;)if(o.push(this.expectStepReference()),this.match(a.DSLTokenType.COMMA))this.advance();else break;let s="";this.match(a.DSLTokenType.COMMENT)&&(s=this.advance().value.replace(/^\/\*\s*/,"").replace(/\s*\*\/$/,"").trim());let n=this.parseNestedBlocks(e);return new(0,i.StatementNode)(t,$,c,o,n,r.location,s)}parseNestedBlocks(e=0){let t=new Map;for(;!this.match(a.DSLTokenType.EOF);){let r=this.peek(),$=r.type===a.DSLTokenType.IDENTIFIER||r.type===a.DSLTokenType.BOOLEAN||r.type===a.DSLTokenType.KEYWORD,c=this.peekAhead(1),o=c&&c.type===a.DSLTokenType.COLON,s=r.location.column;if(s<=e)break;if($&&!o){let e=this.advance().value,r=[];for(;!this.match(a.DSLTokenType.EOF);){let e=this.peek();if(e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD){let t=this.peekAhead(1);if(t&&t.type===a.DSLTokenType.COLON){if(e.location.column<=s)break}else if(e.location.column<=s)break}if(e.type===a.DSLTokenType.COLON)r.push(this.parseStatement(s));else if(e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD)r.push(this.parseStatement(s));else break}t.set(e,r)}else break}return t}parseFunctionCall(){let e=this.peek(),t=this.expectDottedIdentifier().split("."),r=t.pop(),$=t.join(".");this.expect(a.DSLTokenType.LEFT_PAREN);let c=this.parseArgumentList();return this.expect(a.DSLTokenType.RIGHT_PAREN),new(0,s.FunctionCallNode)($,r,c,e.location)}parseArgumentList(){let e=new Map;if(this.match(a.DSLTokenType.RIGHT_PAREN))return e;do{let t=this.peek(),$=this.expectIdentifier();this.expect(a.DSLTokenType.EQUALS);let c=this.parseArgumentValue(),o=e.get($);if(o?o.values.push(c):e.set($,new(0,r.ArgumentNode)($,c,t.location)),this.match(a.DSLTokenType.COMMA))this.advance();else break}while(!this.match(a.DSLTokenType.RIGHT_PAREN)&&!this.match(a.DSLTokenType.EOF))return e}parseArgumentValue(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_PAREN)){let e=this.current;try{return this.parseSchemaLiteral()}catch{this.current=e}}if(this.match(a.DSLTokenType.BACKTICK_STRING)){let e=this.advance();return new(0,o.ExpressionNode)(e.value,e.location)}if(this.match(a.DSLTokenType.STRING)){let e=this.peek();if("'"===e.value[0]){let t=this.peekAhead(1);return t&&t.type===a.DSLTokenType.OPERATOR?this.parseExpression():(this.advance(),new(0,o.ExpressionNode)(e.value,e.location))}{this.advance();let t=this.unescapeJsonString(e.value.slice(1,-1));return new(0,$.ComplexValueNode)(t,e.location)}}if(this.match(a.DSLTokenType.NUMBER)){let e=this.peekAhead(1);if(e&&(e.type===a.DSLTokenType.OPERATOR||e.type===a.DSLTokenType.EQUALS))return this.parseExpression();let t=this.advance();return new(0,$.ComplexValueNode)(parseFloat(t.value),t.location)}if(this.match(a.DSLTokenType.BOOLEAN)||this.match(a.DSLTokenType.KEYWORD)&&("true"===e.value||"false"===e.value)){let e=this.advance();return new(0,$.ComplexValueNode)("true"===e.value,e.location)}if(this.match(a.DSLTokenType.NULL)||this.match(a.DSLTokenType.KEYWORD)&&"null"===e.value){let e=this.advance();return new(0,$.ComplexValueNode)(null,e.location)}if(this.match(a.DSLTokenType.IDENTIFIER)&&"undefined"===e.value){let e=this.advance();return new(0,$.ComplexValueNode)(void 0,e.location)}if(this.match(a.DSLTokenType.LEFT_BRACE)){let e=this.peekAhead(1);if(e&&e.type!==a.DSLTokenType.LEFT_BRACE)return this.parseComplexValue()}return this.match(a.DSLTokenType.LEFT_BRACKET)?this.parseComplexValue():this.parseExpression()}parseExpression(){let e=this.peek(),t=e.location.startPos;if(e.type===a.DSLTokenType.COMMA||e.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.RIGHT_BRACE)return new(0,o.ExpressionNode)("",e.location);let r=0,$=e;for(;!this.match(a.DSLTokenType.EOF);){let e=this.peek();if(e.type===a.DSLTokenType.LEFT_PAREN||e.type===a.DSLTokenType.LEFT_BRACKET||e.type===a.DSLTokenType.LEFT_BRACE)r++;else if(e.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.RIGHT_BRACE){if(0===r)break;r--}else if(e.type===a.DSLTokenType.COMMA&&0===r)break;$=e,this.advance()}if(this.originalInput&&t>=0){let a=this.peek().location.startPos;if(a>t){let r=this.originalInput.substring(t,a);return new(0,o.ExpressionNode)(r.trimStart(),e.location)}}if(this.originalInput&&t>=0&&$.location.endPos>t){let a=this.originalInput.substring(t,$.location.endPos);return new(0,o.ExpressionNode)(a.trimStart(),e.location)}return this.reconstructExpressionFromTokens(e,$)}reconstructExpressionFromTokens(e,t){this.current;let r=0;for(let t=0;t<this.tokens.length;t++)if(this.tokens[t].location.startPos===e.location.startPos){r=t;break}let $="",c=0;for(let e=r;e<this.tokens.length;e++){let r=this.tokens[e];if(r.location.startPos>t.location.startPos)break;r.type===a.DSLTokenType.LEFT_PAREN||r.type===a.DSLTokenType.LEFT_BRACKET||r.type===a.DSLTokenType.LEFT_BRACE?c++:(r.type===a.DSLTokenType.RIGHT_PAREN||r.type===a.DSLTokenType.RIGHT_BRACKET||r.type===a.DSLTokenType.RIGHT_BRACE)&&c--,$+=r.value;let o=this.tokens[e+1];o&&o.location.startPos<=t.location.startPos&&this.needsSpaceBetween(r,o,c)&&($+=" ")}return new(0,o.ExpressionNode)($.trimStart(),e.location)}needsSpaceBetween(e,t,r){if(e.type===a.DSLTokenType.LEFT_BRACE&&t.type===a.DSLTokenType.LEFT_BRACE||e.type===a.DSLTokenType.RIGHT_BRACE&&t.type===a.DSLTokenType.RIGHT_BRACE||e.type===a.DSLTokenType.DOT||t.type===a.DSLTokenType.DOT||e.type===a.DSLTokenType.LEFT_BRACKET||t.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.LEFT_PAREN||t.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.LEFT_BRACE||t.type===a.DSLTokenType.RIGHT_BRACE||e.type===a.DSLTokenType.OPERATOR&&"??"===e.value||t.type===a.DSLTokenType.OPERATOR&&"??"===t.value||e.type===a.DSLTokenType.OPERATOR&&"-"===e.value||t.type===a.DSLTokenType.OPERATOR&&"-"===t.value)return!1;if(r>0){let r=["+","*","/","%"];if(e.type===a.DSLTokenType.OPERATOR&&r.includes(e.value)||t.type===a.DSLTokenType.OPERATOR&&r.includes(t.value))return!1}let $=e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.KEYWORD||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.NUMBER,c=t.type===a.DSLTokenType.IDENTIFIER||t.type===a.DSLTokenType.KEYWORD||t.type===a.DSLTokenType.BOOLEAN||t.type===a.DSLTokenType.NUMBER;return!!$&&!!c||e.type===a.DSLTokenType.EQUALS||t.type===a.DSLTokenType.EQUALS||e.type===a.DSLTokenType.OPERATOR||t.type===a.DSLTokenType.OPERATOR}parseSchemaSpec(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_BRACE)){let t=this.parseComplexValue();return new(0,b.SchemaNode)(t.value,e.location)}let t=this.parseSimpleSchema();return new(0,b.SchemaNode)(t,e.location)}parseSimpleSchema(){if(this.match(a.DSLTokenType.KEYWORD,"ARRAY")){this.advance(),this.expect(a.DSLTokenType.KEYWORD,"OF");let e=this.parseSimpleSchema();return`ARRAY OF ${e}`}if(this.match(a.DSLTokenType.KEYWORD,"OBJECT"))return this.advance().value;let e=this.peek();if(e.type===a.DSLTokenType.KEYWORD)return this.advance().value;throw new(0,p.DSLParserError)("Expected schema type",e.location,["INTEGER","LONG","FLOAT","DOUBLE","STRING","BOOLEAN","NULL","ANY","ARRAY","OBJECT"],e)}parseSchemaLiteral(){let e,t=this.peek();this.expect(a.DSLTokenType.LEFT_PAREN);let r=this.parseSchemaSpec();return this.expect(a.DSLTokenType.RIGHT_PAREN),this.match(a.DSLTokenType.KEYWORD,"WITH")&&(this.advance(),this.expect(a.DSLTokenType.KEYWORD,"DEFAULT"),this.expect(a.DSLTokenType.KEYWORD,"VALUE"),e=this.parseExpression()),new(0,d.SchemaLiteralNode)(r,e,t.location)}parseComplexValue(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_BRACE))return new(0,$.ComplexValueNode)(this.parseObject(),e.location);if(this.match(a.DSLTokenType.LEFT_BRACKET))return new(0,$.ComplexValueNode)(this.parseArray(),e.location);throw new(0,p.DSLParserError)("Expected { or [",e.location,["{","["],e)}parseObject(){this.expect(a.DSLTokenType.LEFT_BRACE);let e={};if(this.match(a.DSLTokenType.RIGHT_BRACE))return this.advance(),e;do{let t;if(t=this.match(a.DSLTokenType.STRING)?this.advance().value.slice(1,-1):this.expectIdentifier(),this.expect(a.DSLTokenType.COLON),e[t]=this.parseJsonValue(),this.match(a.DSLTokenType.COMMA))this.advance();else break}while(!this.match(a.DSLTokenType.RIGHT_BRACE)&&!this.match(a.DSLTokenType.EOF))return this.expect(a.DSLTokenType.RIGHT_BRACE),e}parseArray(){this.expect(a.DSLTokenType.LEFT_BRACKET);let e=[];if(this.match(a.DSLTokenType.RIGHT_BRACKET))return this.advance(),e;do if(e.push(this.parseJsonValue()),this.match(a.DSLTokenType.COMMA))this.advance();else break;while(!this.match(a.DSLTokenType.RIGHT_BRACKET)&&!this.match(a.DSLTokenType.EOF))return this.expect(a.DSLTokenType.RIGHT_BRACKET),e}parseJsonValue(){let e=this.peek();if(e.type===a.DSLTokenType.STRING){let e=this.advance();return this.unescapeJsonString(e.value.slice(1,-1))}return e.type===a.DSLTokenType.NUMBER?parseFloat(this.advance().value):e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD&&("true"===e.value||"false"===e.value)?"true"===this.advance().value:e.type===a.DSLTokenType.NULL||e.type===a.DSLTokenType.KEYWORD&&"null"===e.value?(this.advance(),null):e.type===a.DSLTokenType.IDENTIFIER&&"undefined"===e.value?void this.advance():e.type===a.DSLTokenType.LEFT_BRACE?this.parseObject():e.type===a.DSLTokenType.LEFT_BRACKET?this.parseArray():{isExpression:!0,value:this.parseExpression().expressionText}}peek(){return this.tokens[this.current]}peekAhead(e){return this.tokens[this.current+e]}advance(){let e=this.tokens[this.current];return this.current++,e}match(e,t){let a=this.peek();return!!a&&a.type===e&&(void 0===t||a.value===t)}expect(e,t){let a=this.peek();if(!this.match(e,t)){let r=t?`${e} (${t})`:e;throw new(0,p.DSLParserError)(`Expected ${r}`,a.location,[r],a)}return this.advance()}expectIdentifier(){let e=this.peek();return e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD?this.advance().value:this.expect(a.DSLTokenType.IDENTIFIER).value}expectDottedIdentifier(){let e=this.expectIdentifier();for(;this.match(a.DSLTokenType.DOT);)this.advance(),e+="."+this.expectIdentifier();return e}expectStepReference(){return this.expectDottedIdentifier()}unescapeJsonString(e){let t="",a=0;for(;a<e.length;)if("\\"===e[a]&&a+1<e.length)switch(e[a+1]){case"n":t+="\n",a+=2;break;case"r":t+="\r",a+=2;break;case"t":t+=" ",a+=2;break;case"b":t+="\b",a+=2;break;case"f":t+="\f",a+=2;break;case"\\":t+="\\",a+=2;break;case'"':t+='"',a+=2;break;case"/":t+="/",a+=2;break;case"u":if(a+5<e.length){let r=e.substring(a+2,a+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(parseInt(r,16)),a+=6;break}}t+=e[a],a++;break;default:t+=e[a],a++}else t+=e[a],a++;return t}}}),parcelRegister("ljJAk",function(e,t){$parcel$export(e.exports,"ASTNode",()=>parcelRequire("6o4Cv").ASTNode),$parcel$export(e.exports,"ArgumentNode",()=>parcelRequire("TP9ar").ArgumentNode),$parcel$export(e.exports,"ComplexValueNode",()=>parcelRequire("kZUxs").ComplexValueNode),$parcel$export(e.exports,"EventDeclNode",()=>parcelRequire("3WTbA").EventDeclNode),$parcel$export(e.exports,"ExpressionNode",()=>parcelRequire("jpfiN").ExpressionNode),$parcel$export(e.exports,"FunctionCallNode",()=>parcelRequire("5qcBL").FunctionCallNode),$parcel$export(e.exports,"FunctionDefNode",()=>parcelRequire("amNrQ").FunctionDefNode),$parcel$export(e.exports,"ParameterDeclNode",()=>parcelRequire("9IcXU").ParameterDeclNode),$parcel$export(e.exports,"SchemaLiteralNode",()=>parcelRequire("hsyfz").SchemaLiteralNode),$parcel$export(e.exports,"SchemaNode",()=>parcelRequire("4eaZb").SchemaNode),$parcel$export(e.exports,"StatementNode",()=>parcelRequire("jdXce").StatementNode),parcelRequire("6o4Cv"),parcelRequire("TP9ar"),parcelRequire("kZUxs"),parcelRequire("3WTbA"),parcelRequire("jpfiN"),parcelRequire("5qcBL"),parcelRequire("amNrQ"),parcelRequire("9IcXU"),parcelRequire("hsyfz"),parcelRequire("4eaZb"),parcelRequire("jdXce")}),parcelRegister("6o4Cv",function(e,t){$parcel$export(e.exports,"ASTNode",()=>a);class a{constructor(e,t){this.type=e,this.location=t}toString(){return JSON.stringify(this.toJSON(),null,2)}}}),parcelRegister("TP9ar",function(e,t){$parcel$export(e.exports,"ArgumentNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t,a){super("Argument",a),this.key=e,this.values=Array.isArray(t)?t:[t]}get value(){return this.values[0]}isMultiValue(){return this.values.length>1}toJSON(){return{type:this.type,key:this.key,values:this.values.map(e=>e.toJSON())}}}}),parcelRegister("kZUxs",function(e,t){$parcel$export(e.exports,"ComplexValueNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t){super("ComplexValue",t),this.value=e}toJSON(){return{type:this.type,value:this.value}}}}),parcelRegister("3WTbA",function(e,t){$parcel$export(e.exports,"EventDeclNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t=[],a){super("EventDecl",a),this.name=e,this.parameters=t}toJSON(){return{type:this.type,name:this.name,parameters:this.parameters.map(e=>e.toJSON())}}}}),parcelRegister("jpfiN",function(e,t){$parcel$export(e.exports,"ExpressionNode",()=>$);var a=parcelRequire("cnGWa"),r=parcelRequire("6o4Cv");class $ extends r.ASTNode{constructor(e,t){super("Expression",t),this.expressionText=e}parse(){this.parsedExpression||(this.parsedExpression=new(0,a.Expression)(this.expressionText))}toJSON(){return{type:this.type,expressionText:this.expressionText}}}}),parcelRegister("cnGWa",function(e,t){$parcel$export(e.exports,"Expression",()=>i);var a=parcelRequire("9cFuT"),r=parcelRequire("cFqdJ"),$=parcelRequire("p6HW6"),c=parcelRequire("dYhyX"),o=parcelRequire("bQb81"),s=parcelRequire("94TVm"),n=parcelRequire("79v57"),f=parcelRequire("2EScE"),d=parcelRequire("3zdm5"),b=parcelRequire("80u7R");class i extends n.ExpressionToken{static createTernary(e,t,a){let r=new i("",void 0,void 0,void 0,!0);return r.tokens.push(e),r.tokens.push(t),r.tokens.push(a),r.ops.push(d.Operation.CONDITIONAL_TERNARY_OPERATOR),r}static createLeaf(e){let t=new i("",void 0,void 0,void 0,!0);return t.expression=e,t.tokens.push(new(0,n.ExpressionToken)(e)),t}constructor(e,t,r,$,c){if(super(e||""),this.tokens=new(0,a.LinkedList),this.ops=new(0,a.LinkedList),c)return;if(void 0!==t||void 0!==r||void 0!==$){$?.getOperator()==".."&&(t?r||(r=new(0,f.ExpressionTokenValue)("","")):t=new(0,f.ExpressionTokenValue)("","")),t&&this.tokens.push(t),r&&this.tokens.push(r),$&&this.ops.push($);return}if(e&&e.trim().length>0)try{const t=e.trim(),a=new(0,b.ExpressionParser)(t).parse();this.expression=t,this.tokens=a.getTokens(),this.ops=a.getOperations(),this.cachedTokensArray=void 0,this.cachedOpsArray=void 0}catch(e){this.evaluate(),this.ops.isEmpty()||".."!=this.ops.peekLast().getOperator()||1!=this.tokens.length||this.tokens.push(new(0,n.ExpressionToken)(""))}}getTokens(){return this.tokens}getOperations(){return this.ops}getTokensArray(){return this.cachedTokensArray||(this.cachedTokensArray=this.tokens.toArray()),this.cachedTokensArray}getOperationsArray(){return this.cachedOpsArray||(this.cachedOpsArray=this.ops.toArray()),this.cachedOpsArray}evaluate(){let e,t=this.expression.length,a="",$=new(0,r.StringBuilder)(""),o=0,f=!1;for(;o<t;){switch(a=this.expression[o],e=$.toString(),a){case" ":f=this.processTokenSepearator($,e,f);break;case"(":o=this.processSubExpression(t,$,e,o,f),f=!1;break;case")":throw new(0,s.ExpressionEvaluationException)(this.expression,"Extra closing parenthesis found");case"]":throw new(0,s.ExpressionEvaluationException)(this.expression,"Extra closing square bracket found");case"'":case'"':if(f&&this.ops.peek()==d.Operation.ARRAY_OPERATOR){let e=this.process(t,$,o);o=e.getT1(),f=e.getT2()}else{let e=this.processStringLiteral(t,a,o);o=e.getT1(),f=e.getT2()}break;case"?":if(o+1<t&&"?"!=this.expression.charAt(o+1)&&0!=o&&"?"!=this.expression.charAt(o-1))o=this.processTernaryOperator(t,$,e,o,f);else{let r=this.processOthers(a,t,$,e,o,f);o=r.getT1(),(f=r.getT2())&&this.ops.peek()==d.Operation.ARRAY_OPERATOR&&(o=(r=this.process(t,$,o)).getT1(),f=r.getT2())}break;default:let r=this.processOthers(a,t,$,e,o,f);o=r.getT1(),(f=r.getT2())&&this.ops.peek()==d.Operation.ARRAY_OPERATOR&&(o=(r=this.process(t,$,o)).getT1(),f=r.getT2())}++o}if(e=$.toString(),!c.StringUtil.isNullOrBlank(e))if(d.Operation.OPERATORS.has(e))throw new(0,s.ExpressionEvaluationException)(this.expression,"Expression is ending with an operator");else this.tokens.push(new(0,n.ExpressionToken)(e))}processStringLiteral(e,t,a){let r="",$=a+1;for(;$<e;$++){let e=this.expression.charAt($);if(e==t&&"\\"!=this.expression.charAt($-1))break;r+=e}if($==e&&this.expression.charAt($-1)!=t)throw new(0,s.ExpressionEvaluationException)(this.expression,"Missing string ending marker "+t);let c=new(0,o.Tuple2)($,!1);return this.tokens.push(new(0,f.ExpressionTokenValue)(r,r)),c}process(e,t,a){let r=1;for(++a;a<e&&0!=r;){let e=this.expression.charAt(a);"]"==e?--r:"["==e&&++r,0!=r&&(t.append(e),a++)}return this.tokens.push(new i(t.toString())),t.setLength(0),new(0,o.Tuple2)(a,!1)}processOthers(e,t,a,r,$,s){let f=t-$;f=f<d.Operation.BIGGEST_OPERATOR_SIZE?f:d.Operation.BIGGEST_OPERATOR_SIZE;for(let e=f;e>0;e--){let t=this.expression.substring($,$+e);if(d.Operation.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return c.StringUtil.isNullOrBlank(r)?".."==t&&this.tokens.isEmpty()&&(this.tokens.push(new(0,n.ExpressionToken)("0")),s=!1):(this.tokens.push(new(0,n.ExpressionToken)(r)),s=!1),this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(t),s),s=!0,a.setLength(0),new(0,o.Tuple2)($+e-1,s)}return a.append(e),new(0,o.Tuple2)($,!1)}processTernaryOperator(e,t,a,r,$){if($)throw new(0,s.ExpressionEvaluationException)(this.expression,"Ternary operator is followed by an operator");""!=a.trim()&&(this.tokens.push(new i(a)),t.setLength(0));let c=1,o="",n=++r;for(;r<e&&c>0;)"?"==(o=this.expression.charAt(r))?++c:":"==o&&--c,++r;if(":"!=o)throw new(0,s.ExpressionEvaluationException)(this.expression,"':' operater is missing");if(r>=e)throw new(0,s.ExpressionEvaluationException)(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(d.Operation.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(d.Operation.UNARY_OPERATORS.has(e)){let t=this.tokens.pop();this.tokens.push(new i("",t,void 0,e))}else{let t=this.tokens.pop(),a=this.tokens.pop();this.tokens.push(new i("",a,t,e))}}this.ops.push(d.Operation.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new i(this.expression.substring(n,r-1)));let f=this.expression.substring(r);if(""===f.trim())throw new(0,s.ExpressionEvaluationException)(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new i(f)),e-1}processSubExpression(e,t,a,o,n){if(d.Operation.OPERATORS.has(a))this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(a),n),t.setLength(0);else if(!c.StringUtil.isNullOrBlank(a))throw new(0,s.ExpressionEvaluationException)(this.expression,$.StringFormatter.format("Unkown token : $ found.",a));let f=1,b=new(0,r.StringBuilder),p=this.expression.charAt(o);for(o++;o<e&&f>0;)"("==(p=this.expression.charAt(o))?f++:")"==p&&f--,0!=f&&(b.append(p),o++);if(")"!=p)throw new(0,s.ExpressionEvaluationException)(this.expression,"Missing a closed parenthesis");for(;b.length()>2&&this.hasMatchingOuterParentheses(b.toString());)b.deleteCharAt(0),b.setLength(b.length()-1);return this.tokens.push(new i(b.toString().trim())),o}processTokenSepearator(e,t,a){return c.StringUtil.isNullOrBlank(t)||(d.Operation.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(t),a),a=!0):(this.tokens.push(new(0,n.ExpressionToken)(t)),a=!1)),e.setLength(0),a}checkUnaryOperator(e,t,a,r){if(a)if(r||e.isEmpty())if(d.Operation.UNARY_OPERATORS.has(a)){let e=d.Operation.UNARY_MAP.get(a);e&&t.push(e)}else throw new(0,s.ExpressionEvaluationException)(this.expression,$.StringFormatter.format("Extra operator $ found.",a));else{for(;!t.isEmpty()&&this.hasPrecedence(a,t.peek());){let a=t.pop();if(d.Operation.UNARY_OPERATORS.has(a)){let t=e.pop();e.push(new i("",t,void 0,a))}else{let t=e.pop(),r=e.pop();e.push(new i("",r,t,a))}}t.push(a)}}hasPrecedence(e,t){let a=d.Operation.OPERATOR_PRIORITY.get(e),r=d.Operation.OPERATOR_PRIORITY.get(t);if(!a||!r)throw Error("Unknown operators provided");return r===a?t!==d.Operation.OBJECT_OPERATOR&&t!==d.Operation.ARRAY_OPERATOR&&e!==d.Operation.OBJECT_OPERATOR&&e!==d.Operation.ARRAY_OPERATOR:r<a}hasMatchingOuterParentheses(e){if(e.length<2||"("!==e.charAt(0)||")"!==e.charAt(e.length-1))return!1;let t=0;for(let a=0;a<e.length-1;a++){let r=e.charAt(a);if("("===r?t++:")"===r&&t--,0===t)return!1}return 1===t}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokenToString(this.tokens.get(0)):this.expression&&this.expression.length>0?this.expression:"Error: No tokens";let e=this.ops.get(0);return e.getOperator().startsWith("UN: ")?this.formatUnaryOperation(e):e==d.Operation.CONDITIONAL_TERNARY_OPERATOR?this.formatTernaryOperation():this.formatBinaryOperation(e)}formatUnaryOperation(e){let t=this.tokens.get(0),a=this.tokenToString(t);return"("+e.getOperator().substring(4)+a+")"}formatTernaryOperation(){let e=this.tokens.get(0),t=this.tokens.get(1),a=this.tokens.get(2);return"("+this.tokenToString(a)+"?"+this.tokenToString(t)+":"+this.tokenToString(e)+")"}formatBinaryOperation(e){if(2>this.tokens.size())return this.expression&&this.expression.length>0?this.expression:1===this.tokens.size()?this.tokenToString(this.tokens.get(0)):"Error: Invalid binary expression";let t=this.tokens.get(0),a=this.tokens.get(1);if(e==d.Operation.ARRAY_OPERATOR)return this.tokenToString(a)+"["+this.formatArrayIndex(t)+"]";if(e==d.Operation.OBJECT_OPERATOR){let e=this.tokenToString(a),r=this.tokenToString(t);if(t instanceof i){let a=t.getOperations();if(!a.isEmpty()&&a.get(0)==d.Operation.ARRAY_OPERATOR)return"("+e+".("+r+"))"}return"("+e+"."+r+")"}if(e==d.Operation.ARRAY_RANGE_INDEX_OPERATOR)return"("+this.tokenToString(a)+".."+this.tokenToString(t)+")";let r=this.tokenToString(a),$=this.tokenToString(t);return"("+r+e.getOperator()+$+")"}tokenToString(e){if(e instanceof i)return e.toString();if(e&&"function"==typeof e.getExpression&&"function"==typeof e.getTokenValue){let t=e.getExpression();if(t&&(t.startsWith('"')||t.startsWith("'")))return t}return e.toString()}formatArrayIndex(e){if(e instanceof i){if(e.getOperations().isEmpty()&&1==e.getTokens().size()){let t=e.getTokens().get(0);if(t&&"function"==typeof t.getExpression){let e=t.getExpression();if(e&&(e.startsWith('"')||e.startsWith("'")))return e}}return e.toString()}if(e&&"function"==typeof e.getExpression){let t=e.getExpression();if(t&&(t.startsWith('"')||t.startsWith("'")))return t}return e.toString()}tokenHasOperations(e){return e instanceof i&&!e.getOperations().isEmpty()}equals(e){return this.expression==e.expression}}}),parcelRegister("9cFuT",function(e,t){$parcel$export(e.exports,"LinkedList",()=>c);var a=parcelRequire("7qv9Q"),r=parcelRequire("ip0Ed"),$=parcelRequire("p6HW6");class c{constructor(e){if(this.head=void 0,this.tail=void 0,this.length=0,e?.length){for(const t of e)if(this.head){const e=new o(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new o(t);this.length=e.length}}push(e){let t=new o(e,void 0,this.head);this.head?(this.head.previous=t,this.head=t):this.tail=this.head=t,this.length++}pop(){if(!this.head)throw Error("List is empty and cannot pop further.");let e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;let t=this.head;return this.head=t.next,t.next=void 0,t.previous=void 0,this.head.previous=void 0,e}isEmpty(){return!this.length}size(){return this.length}get(e){if(e<0||e>=this.length)throw Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=t.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new(0,a.KIRuntimeException)($.StringFormatter.format("Index $ out of bound to set the value in linked list.",e));let r=this.head;for(;e>0;)r=this.head.next,--e;return r.value=t,this}toString(){let e=this.head,t="";for(;e;)t+=e.value,(e=e.next)&&(t+=", ");return`[${t}]`}toArray(){let e=[],t=this.head;for(;t;)e.push(t.value),t=t.next;return e}peek(){if(!this.head)throw Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw Error("List is empty so cannot remove");--this.length;let e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{let e=this.tail.previous;e.next=void 0,this.tail.previous=void 0,this.tail=e}return e}addAll(e){return e&&e.length&&e.forEach(this.add.bind(this)),this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new o(e,this.head),this.head.next=this.tail):(this.tail=new o(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new o(e),this}map(e,t){let a=new c,r=this.head,$=0;for(;r;)a.add(e(r.value,$)),r=r.next,++$;return a}indexOf(e){let t=this.head,a=0;for(;t;){if((0,r.deepEqual)(t.value,e))return a;t=t.next,++a}return -1}forEach(e,t){let a=this.head,r=0;for(;a;)e(a.value,r),a=a.next,++r}}class o{constructor(e,t,a){this.value=e,this.next=a,this.previous=t}toString(){return""+this.value}}}),parcelRegister("7qv9Q",function(e,t){$parcel$export(e.exports,"KIRuntimeException",()=>a);class a extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}}),parcelRegister("ip0Ed",function(e,t){$parcel$export(e.exports,"deepEqual",()=>r);var a=parcelRequire("9cFuT");function r(e,t){let r=new(0,a.LinkedList);r.push(e);let $=new(0,a.LinkedList);for($.push(t);!r.isEmpty()&&!$.isEmpty();){let e=r.pop(),t=$.pop();if(e===t)continue;let a=typeof e,c=typeof t;if("undefined"===a||"undefined"===c){if(!e&&!t)continue;return!1}if(a!==c)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let a=0;a<e.length;a++)r.push(e[a]),$.push(t[a]);continue}if("object"===a){if("object"!==c||null===e||null===t)return!1;let a=Object.entries(e),o=Object.entries(t);if(a.length!==o.length)return!1;for(let[e,c]of a)r.push(c),$.push(t[e]);continue}return!1}return!0}}),parcelRegister("p6HW6",function(e,t){$parcel$export(e.exports,"StringFormatter",()=>a);class a{static format(e,...t){if(!t||0==t.length)return e;let a="",r=0,$="",c=$,o=e.length;for(let s=0;s<o;s++)"$"==($=e.charAt(s))&&"\\"==c?a=a.substring(0,s-1)+$:"$"==$&&r<t.length?a+=t[r++]:a+=$,c=$;return a.toString()}}}),parcelRegister("cFqdJ",function(e,t){$parcel$export(e.exports,"StringBuilder",()=>r);var a=parcelRequire("7qv9Q");class r{constructor(e){this.str=e??""}append(e){return this.str+=e,this}toString(){return""+this.str}trim(){return this.str=this.str.trim(),this}setLength(e){return this.str=this.str.substring(0,e),this}length(){return this.str.length}charAt(e){return this.str.charAt(e)}deleteCharAt(e){return this.checkIndex(e),this.str=this.str.substring(0,e)+this.str.substring(e+1),this}insert(e,t){return this.str=this.str.substring(0,e)+t+this.str.substring(e),this}checkIndex(e){if(e>=this.str.length)throw new(0,a.KIRuntimeException)(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}}),parcelRegister("dYhyX",function(e,t){$parcel$export(e.exports,"StringUtil",()=>$);var a=parcelRequire("7qv9Q"),r=parcelRequire("p6HW6");class ${static nthIndex(e,t,$=0,c){if(!e)throw new(0,a.KIRuntimeException)("String cannot be null");if($<0||$>=e.length)throw new(0,a.KIRuntimeException)(r.StringFormatter.format("Cannot search from index : $",$));if(c<=0||c>e.length)throw new(0,a.KIRuntimeException)(r.StringFormatter.format("Cannot search for occurance : $",c));for(;$<e.length;){if(e.charAt($)==t&&0==--c)return $;++$}return -1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let a=e.indexOf(t);return -1==a?[e,void 0]:[e.substring(0,a),e.substring(a+1)]}static splitAtLastOccurance(e,t){if(!e)return[void 0,void 0];let a=e.lastIndexOf(t);return -1==a?[e,void 0]:[e.substring(0,a),e.substring(a+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}}),parcelRegister("bQb81",function(e,t){$parcel$export(e.exports,"Tuple2",()=>a),$parcel$export(e.exports,"Tuple3",()=>r),$parcel$export(e.exports,"Tuple4",()=>$);class a{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}}class r extends a{constructor(e,t,a){super(e,t),this.t=a}getT3(){return this.t}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}}class $ extends r{constructor(e,t,a,r){super(e,t,a),this.fr=r}getT4(){return this.fr}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}setT4(e){return this.fr=e,this}}}),parcelRegister("94TVm",function(e,t){$parcel$export(e.exports,"ExpressionEvaluationException",()=>a);class a extends Error{constructor(e,t,a){const r=Error.stackTraceLimit;Error.stackTraceLimit=0,super(),Error.stackTraceLimit=r,this._expression=e,this._msg=t,this.cause=a}get message(){return this._expression+" : "+this._msg}getCause(){return this.cause}}}),parcelRegister("79v57",function(e,t){$parcel$export(e.exports,"ExpressionToken",()=>a);class a{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}}),parcelRegister("2EScE",function(e,t){$parcel$export(e.exports,"ExpressionTokenValue",()=>$);var a=parcelRequire("p6HW6"),r=parcelRequire("79v57");class $ extends r.ExpressionToken{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return a.StringFormatter.format("$: $",this.expression,this.element)}}}),parcelRegister("3zdm5",function(e,t){$parcel$export(e.exports,"Operation",()=>a);class a{static{this.MULTIPLICATION=new a("*")}static{this.DIVISION=new a("/")}static{this.INTEGER_DIVISION=new a("//")}static{this.MOD=new a("%")}static{this.ADDITION=new a("+")}static{this.SUBTRACTION=new a("-")}static{this.NOT=new a("not",void 0,!0)}static{this.AND=new a("and",void 0,!0)}static{this.OR=new a("or",void 0,!0)}static{this.LESS_THAN=new a("<")}static{this.LESS_THAN_EQUAL=new a("<=")}static{this.GREATER_THAN=new a(">")}static{this.GREATER_THAN_EQUAL=new a(">=")}static{this.EQUAL=new a("=")}static{this.NOT_EQUAL=new a("!=")}static{this.BITWISE_AND=new a("&")}static{this.BITWISE_OR=new a("|")}static{this.BITWISE_XOR=new a("^")}static{this.BITWISE_COMPLEMENT=new a("~")}static{this.BITWISE_LEFT_SHIFT=new a("<<")}static{this.BITWISE_RIGHT_SHIFT=new a(">>")}static{this.BITWISE_UNSIGNED_RIGHT_SHIFT=new a(">>>")}static{this.UNARY_PLUS=new a("UN: +","+")}static{this.UNARY_MINUS=new a("UN: -","-")}static{this.UNARY_LOGICAL_NOT=new a("UN: not","not")}static{this.UNARY_BITWISE_COMPLEMENT=new a("UN: ~","~")}static{this.ARRAY_OPERATOR=new a("[")}static{this.ARRAY_RANGE_INDEX_OPERATOR=new a("..")}static{this.OBJECT_OPERATOR=new a(".")}static{this.NULLISH_COALESCING_OPERATOR=new a("??")}static{this.CONDITIONAL_TERNARY_OPERATOR=new a("?")}static{this.VALUE_OF=new Map([["MULTIPLICATION",a.MULTIPLICATION],["DIVISION",a.DIVISION],["INTEGER_DIVISION",a.INTEGER_DIVISION],["MOD",a.MOD],["ADDITION",a.ADDITION],["SUBTRACTION",a.SUBTRACTION],["NOT",a.NOT],["AND",a.AND],["OR",a.OR],["LESS_THAN",a.LESS_THAN],["LESS_THAN_EQUAL",a.LESS_THAN_EQUAL],["GREATER_THAN",a.GREATER_THAN],["GREATER_THAN_EQUAL",a.GREATER_THAN_EQUAL],["EQUAL",a.EQUAL],["NOT_EQUAL",a.NOT_EQUAL],["BITWISE_AND",a.BITWISE_AND],["BITWISE_OR",a.BITWISE_OR],["BITWISE_XOR",a.BITWISE_XOR],["BITWISE_COMPLEMENT",a.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",a.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",a.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",a.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",a.UNARY_PLUS],["UNARY_MINUS",a.UNARY_MINUS],["UNARY_LOGICAL_NOT",a.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",a.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",a.ARRAY_OPERATOR],["ARRAY_RANGE_INDEX_OPERATOR",a.ARRAY_RANGE_INDEX_OPERATOR],["OBJECT_OPERATOR",a.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",a.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",a.CONDITIONAL_TERNARY_OPERATOR]])}static{this.UNARY_OPERATORS=new Set([a.ADDITION,a.SUBTRACTION,a.NOT,a.BITWISE_COMPLEMENT,a.UNARY_PLUS,a.UNARY_MINUS,a.UNARY_LOGICAL_NOT,a.UNARY_BITWISE_COMPLEMENT])}static{this.ARITHMETIC_OPERATORS=new Set([a.MULTIPLICATION,a.DIVISION,a.INTEGER_DIVISION,a.MOD,a.ADDITION,a.SUBTRACTION])}static{this.LOGICAL_OPERATORS=new Set([a.NOT,a.AND,a.OR,a.LESS_THAN,a.LESS_THAN_EQUAL,a.GREATER_THAN,a.GREATER_THAN_EQUAL,a.EQUAL,a.NOT_EQUAL,a.NULLISH_COALESCING_OPERATOR])}static{this.BITWISE_OPERATORS=new Set([a.BITWISE_AND,a.BITWISE_COMPLEMENT,a.BITWISE_LEFT_SHIFT,a.BITWISE_OR,a.BITWISE_RIGHT_SHIFT,a.BITWISE_UNSIGNED_RIGHT_SHIFT,a.BITWISE_XOR])}static{this.CONDITIONAL_OPERATORS=new Set([a.CONDITIONAL_TERNARY_OPERATOR])}static{this.OPERATOR_PRIORITY=new Map([[a.UNARY_PLUS,1],[a.UNARY_MINUS,1],[a.UNARY_LOGICAL_NOT,1],[a.UNARY_BITWISE_COMPLEMENT,1],[a.ARRAY_OPERATOR,1],[a.OBJECT_OPERATOR,1],[a.ARRAY_RANGE_INDEX_OPERATOR,2],[a.MULTIPLICATION,2],[a.DIVISION,2],[a.INTEGER_DIVISION,2],[a.MOD,2],[a.ADDITION,3],[a.SUBTRACTION,3],[a.BITWISE_LEFT_SHIFT,4],[a.BITWISE_RIGHT_SHIFT,4],[a.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[a.LESS_THAN,5],[a.LESS_THAN_EQUAL,5],[a.GREATER_THAN,5],[a.GREATER_THAN_EQUAL,5],[a.EQUAL,6],[a.NOT_EQUAL,6],[a.BITWISE_AND,7],[a.BITWISE_XOR,8],[a.BITWISE_OR,9],[a.NOT,10],[a.AND,10],[a.OR,11],[a.NULLISH_COALESCING_OPERATOR,11],[a.CONDITIONAL_TERNARY_OPERATOR,12]])}static{this.OPERATORS=new Set([...Array.from(a.ARITHMETIC_OPERATORS),...Array.from(a.LOGICAL_OPERATORS),...Array.from(a.BITWISE_OPERATORS),a.ARRAY_OPERATOR,a.ARRAY_RANGE_INDEX_OPERATOR,a.OBJECT_OPERATOR,...Array.from(a.CONDITIONAL_OPERATORS)].map(e=>e.getOperator()))}static{this.OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(a.ARITHMETIC_OPERATORS),...Array.from(a.LOGICAL_OPERATORS),...Array.from(a.BITWISE_OPERATORS),a.ARRAY_OPERATOR,a.ARRAY_RANGE_INDEX_OPERATOR,a.OBJECT_OPERATOR,...Array.from(a.CONDITIONAL_OPERATORS)].filter(e=>!e.shouldBeWrappedInSpace()).map(e=>e.getOperator()))}static{this.OPERATION_VALUE_OF=new Map(Array.from(a.VALUE_OF.entries()).map(([e,t])=>[t.getOperator(),t]))}static{this.UNARY_MAP=new Map([[a.ADDITION,a.UNARY_PLUS],[a.SUBTRACTION,a.UNARY_MINUS],[a.NOT,a.UNARY_LOGICAL_NOT],[a.BITWISE_COMPLEMENT,a.UNARY_BITWISE_COMPLEMENT],[a.UNARY_PLUS,a.UNARY_PLUS],[a.UNARY_MINUS,a.UNARY_MINUS],[a.UNARY_LOGICAL_NOT,a.UNARY_LOGICAL_NOT],[a.UNARY_BITWISE_COMPLEMENT,a.UNARY_BITWISE_COMPLEMENT]])}static{this.BIGGEST_OPERATOR_SIZE=Array.from(a.VALUE_OF.values()).map(e=>e.getOperator()).filter(e=>!e.startsWith("UN: ")).map(e=>e.length).reduce((e,t)=>e>t?e:t,0)}constructor(e,t,a=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=a}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return a.VALUE_OF.get(e)}toString(){return this.operator}}}),parcelRegister("80u7R",function(e,t){$parcel$export(e.exports,"ExpressionParser",()=>n);var a=parcelRequire("94TVm"),r=parcelRequire("79v57"),$=parcelRequire("2EScE"),c=parcelRequire("cnGWa"),o=parcelRequire("3zdm5"),s=parcelRequire("bFW7H");class n{constructor(e){this.currentToken=null,this.previousTokenValue=null,this.parseDepth=0,this.originalExpression=e,this.lexer=new(0,s.ExpressionLexer)(e),this.currentToken=this.lexer.nextToken()}createParserError(e){let t=this.lexer.getPosition(),r=Math.max(0,t-20),$=Math.min(this.originalExpression.length,t+20),c=this.originalExpression.substring(r,$),o=" ".repeat(t-r)+"^";return console.error(`
4
+ ${c}`}}}),parcelRegister("jXSwJ",function(e,t){$parcel$export(e.exports,"DSLParser",()=>E);var a=parcelRequire("lnzmS");parcelRequire("ljJAk");var r=parcelRequire("TP9ar"),$=parcelRequire("kZUxs"),c=parcelRequire("3WTbA"),o=parcelRequire("jpfiN"),s=parcelRequire("5qcBL"),n=parcelRequire("amNrQ"),f=parcelRequire("9IcXU"),d=parcelRequire("hsyfz"),b=parcelRequire("4eaZb"),i=parcelRequire("jdXce"),p=parcelRequire("5kX2Z");class E{constructor(e,t=""){this.current=0,this.tokens=e,this.originalInput=t}parse(){return this.parseFunctionDefinition()}parseFunctionDefinition(){let e=this.expect(a.DSLTokenType.KEYWORD,"FUNCTION"),t=this.expectIdentifier(),r=this.parseNamespaceDecl(),$=this.parseParametersDecl(),c=this.parseEventsDecl();this.expect(a.DSLTokenType.KEYWORD,"LOGIC");let o=this.parseLogicBlock();return new(0,n.FunctionDefNode)(t,r,$,c,o,e.location)}parseNamespaceDecl(){if(this.match(a.DSLTokenType.KEYWORD,"NAMESPACE"))return this.advance(),this.expectDottedIdentifier()}parseParametersDecl(){if(!this.match(a.DSLTokenType.KEYWORD,"PARAMETERS"))return[];this.advance();let e=[];for(;!this.match(a.DSLTokenType.KEYWORD,"EVENTS")&&!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF);)e.push(this.parseParameterDecl());return e}parseParameterDecl(){let e=this.peek(),t=this.expectIdentifier();this.expect(a.DSLTokenType.KEYWORD,"AS");let r=this.parseSchemaSpec();return new(0,f.ParameterDeclNode)(t,r,e.location)}parseEventsDecl(){if(!this.match(a.DSLTokenType.KEYWORD,"EVENTS"))return[];this.advance();let e=[];for(;!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF);)e.push(this.parseEventDecl());return e}parseEventDecl(){let e=this.peek(),t=this.expectIdentifier(),r=[];for(;!this.match(a.DSLTokenType.KEYWORD,"LOGIC")&&!this.match(a.DSLTokenType.EOF)&&this.peek().type===a.DSLTokenType.IDENTIFIER;)if(this.peekAhead(1)?.is(a.DSLTokenType.KEYWORD,"AS"))r.push(this.parseParameterDecl());else break;return new(0,c.EventDeclNode)(t,r,e.location)}parseLogicBlock(){let e=[];for(;!this.match(a.DSLTokenType.EOF);)e.push(this.parseStatement());return e}parseStatement(e=0){let t,r=this.peek();this.match(a.DSLTokenType.COLON)?t=`_anonymous_${this.current}`:(t=this.expectIdentifier(),this.expect(a.DSLTokenType.COLON));let $=this.parseFunctionCall(),c=[];if(this.match(a.DSLTokenType.KEYWORD,"AFTER"))for(this.advance();;)if(c.push(this.expectStepReference()),this.match(a.DSLTokenType.COMMA))this.advance();else break;let o=[];if(this.match(a.DSLTokenType.KEYWORD,"IF"))for(this.advance();;)if(o.push(this.expectStepReference()),this.match(a.DSLTokenType.COMMA))this.advance();else break;let s="";this.match(a.DSLTokenType.COMMENT)&&(s=this.advance().value.replace(/^\/\*\s*/,"").replace(/\s*\*\/$/,"").trim());let n=this.parseNestedBlocks(e);return new(0,i.StatementNode)(t,$,c,o,n,r.location,s)}parseNestedBlocks(e=0){let t=new Map;for(;!this.match(a.DSLTokenType.EOF);){let r=this.peek(),$=r.type===a.DSLTokenType.IDENTIFIER||r.type===a.DSLTokenType.BOOLEAN||r.type===a.DSLTokenType.KEYWORD,c=this.peekAhead(1),o=c&&c.type===a.DSLTokenType.COLON,s=r.location.column;if(s<=e)break;if($&&!o){let e=this.advance().value,r=[];for(;!this.match(a.DSLTokenType.EOF);){let e=this.peek();if(e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD){let t=this.peekAhead(1);if(t&&t.type===a.DSLTokenType.COLON){if(e.location.column<=s)break}else if(e.location.column<=s)break}if(e.type===a.DSLTokenType.COLON)r.push(this.parseStatement(s));else if(e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD)r.push(this.parseStatement(s));else break}t.set(e,r)}else break}return t}parseFunctionCall(){let e=this.peek(),t=this.expectDottedIdentifier().split("."),r=t.pop(),$=t.join(".");this.expect(a.DSLTokenType.LEFT_PAREN);let c=this.parseArgumentList();return this.expect(a.DSLTokenType.RIGHT_PAREN),new(0,s.FunctionCallNode)($,r,c,e.location)}parseArgumentList(){let e=new Map;if(this.match(a.DSLTokenType.RIGHT_PAREN))return e;do{let t=this.peek(),$=this.expectIdentifier();this.expect(a.DSLTokenType.EQUALS);let c=this.parseArgumentValue(),o=e.get($);if(o?o.values.push(c):e.set($,new(0,r.ArgumentNode)($,c,t.location)),this.match(a.DSLTokenType.COMMA))this.advance();else break}while(!this.match(a.DSLTokenType.RIGHT_PAREN)&&!this.match(a.DSLTokenType.EOF))return e}parseArgumentValue(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_PAREN)){let e=this.current;try{return this.parseSchemaLiteral()}catch{this.current=e}}if(this.match(a.DSLTokenType.BACKTICK_STRING)){let e=this.advance();return new(0,o.ExpressionNode)(e.value,e.location)}if(this.match(a.DSLTokenType.STRING)){let e=this.peek();if("'"===e.value[0]){let t=this.peekAhead(1);return t&&t.type===a.DSLTokenType.OPERATOR?this.parseExpression():(this.advance(),new(0,o.ExpressionNode)(e.value,e.location))}{this.advance();let t=this.unescapeJsonString(e.value.slice(1,-1));return new(0,$.ComplexValueNode)(t,e.location)}}if(this.match(a.DSLTokenType.NUMBER)){let e=this.peekAhead(1);if(e&&(e.type===a.DSLTokenType.OPERATOR||e.type===a.DSLTokenType.EQUALS))return this.parseExpression();let t=this.advance();return new(0,$.ComplexValueNode)(parseFloat(t.value),t.location)}if(this.match(a.DSLTokenType.BOOLEAN)||this.match(a.DSLTokenType.KEYWORD)&&("true"===e.value||"false"===e.value)){let e=this.advance();return new(0,$.ComplexValueNode)("true"===e.value,e.location)}if(this.match(a.DSLTokenType.NULL)||this.match(a.DSLTokenType.KEYWORD)&&"null"===e.value){let e=this.advance();return new(0,$.ComplexValueNode)(null,e.location)}if(this.match(a.DSLTokenType.IDENTIFIER)&&"undefined"===e.value){let e=this.advance();return new(0,$.ComplexValueNode)(void 0,e.location)}if(this.match(a.DSLTokenType.LEFT_BRACE)){let e=this.peekAhead(1);if(e&&e.type!==a.DSLTokenType.LEFT_BRACE)return this.parseComplexValue()}return this.match(a.DSLTokenType.LEFT_BRACKET)?this.parseComplexValue():this.parseExpression()}parseExpression(){let e=this.peek(),t=e.location.startPos;if(e.type===a.DSLTokenType.COMMA||e.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.RIGHT_BRACE)return new(0,o.ExpressionNode)("",e.location);let r=0,$=e;for(;!this.match(a.DSLTokenType.EOF);){let e=this.peek();if(e.type===a.DSLTokenType.LEFT_PAREN||e.type===a.DSLTokenType.LEFT_BRACKET||e.type===a.DSLTokenType.LEFT_BRACE)r++;else if(e.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.RIGHT_BRACE){if(0===r)break;r--}else if(e.type===a.DSLTokenType.COMMA&&0===r)break;$=e,this.advance()}if(this.originalInput&&t>=0){let a=this.peek().location.startPos;if(a>t){let r=this.originalInput.substring(t,a);return new(0,o.ExpressionNode)(r.trimStart(),e.location)}}if(this.originalInput&&t>=0&&$.location.endPos>t){let a=this.originalInput.substring(t,$.location.endPos);return new(0,o.ExpressionNode)(a.trimStart(),e.location)}return this.reconstructExpressionFromTokens(e,$)}reconstructExpressionFromTokens(e,t){this.current;let r=0;for(let t=0;t<this.tokens.length;t++)if(this.tokens[t].location.startPos===e.location.startPos){r=t;break}let $="",c=0;for(let e=r;e<this.tokens.length;e++){let r=this.tokens[e];if(r.location.startPos>t.location.startPos)break;r.type===a.DSLTokenType.LEFT_PAREN||r.type===a.DSLTokenType.LEFT_BRACKET||r.type===a.DSLTokenType.LEFT_BRACE?c++:(r.type===a.DSLTokenType.RIGHT_PAREN||r.type===a.DSLTokenType.RIGHT_BRACKET||r.type===a.DSLTokenType.RIGHT_BRACE)&&c--,$+=r.value;let o=this.tokens[e+1];o&&o.location.startPos<=t.location.startPos&&this.needsSpaceBetween(r,o,c)&&($+=" ")}return new(0,o.ExpressionNode)($.trimStart(),e.location)}needsSpaceBetween(e,t,r){if(e.type===a.DSLTokenType.LEFT_BRACE&&t.type===a.DSLTokenType.LEFT_BRACE||e.type===a.DSLTokenType.RIGHT_BRACE&&t.type===a.DSLTokenType.RIGHT_BRACE||e.type===a.DSLTokenType.DOT||t.type===a.DSLTokenType.DOT||e.type===a.DSLTokenType.LEFT_BRACKET||t.type===a.DSLTokenType.RIGHT_BRACKET||e.type===a.DSLTokenType.LEFT_PAREN||t.type===a.DSLTokenType.RIGHT_PAREN||e.type===a.DSLTokenType.LEFT_BRACE||t.type===a.DSLTokenType.RIGHT_BRACE||e.type===a.DSLTokenType.OPERATOR&&"??"===e.value||t.type===a.DSLTokenType.OPERATOR&&"??"===t.value||e.type===a.DSLTokenType.OPERATOR&&"-"===e.value||t.type===a.DSLTokenType.OPERATOR&&"-"===t.value)return!1;if(r>0){let r=["+","*","/","%"];if(e.type===a.DSLTokenType.OPERATOR&&r.includes(e.value)||t.type===a.DSLTokenType.OPERATOR&&r.includes(t.value))return!1}let $=e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.KEYWORD||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.NUMBER,c=t.type===a.DSLTokenType.IDENTIFIER||t.type===a.DSLTokenType.KEYWORD||t.type===a.DSLTokenType.BOOLEAN||t.type===a.DSLTokenType.NUMBER;return!!$&&!!c||e.type===a.DSLTokenType.EQUALS||t.type===a.DSLTokenType.EQUALS||e.type===a.DSLTokenType.OPERATOR||t.type===a.DSLTokenType.OPERATOR}parseSchemaSpec(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_BRACE)){let t=this.parseComplexValue();return new(0,b.SchemaNode)(t.value,e.location)}let t=this.parseSimpleSchema();return new(0,b.SchemaNode)(t,e.location)}parseSimpleSchema(){if(this.match(a.DSLTokenType.KEYWORD,"ARRAY")){this.advance(),this.expect(a.DSLTokenType.KEYWORD,"OF");let e=this.parseSimpleSchema();return`ARRAY OF ${e}`}if(this.match(a.DSLTokenType.KEYWORD,"OBJECT"))return this.advance().value;let e=this.peek();if(e.type===a.DSLTokenType.KEYWORD)return this.advance().value;throw new(0,p.DSLParserError)("Expected schema type",e.location,["INTEGER","LONG","FLOAT","DOUBLE","STRING","BOOLEAN","NULL","ANY","ARRAY","OBJECT"],e)}parseSchemaLiteral(){let e,t=this.peek();this.expect(a.DSLTokenType.LEFT_PAREN);let r=this.parseSchemaSpec();return this.expect(a.DSLTokenType.RIGHT_PAREN),this.match(a.DSLTokenType.KEYWORD,"WITH")&&(this.advance(),this.expect(a.DSLTokenType.KEYWORD,"DEFAULT"),this.expect(a.DSLTokenType.KEYWORD,"VALUE"),e=this.parseExpression()),new(0,d.SchemaLiteralNode)(r,e,t.location)}parseComplexValue(){let e=this.peek();if(this.match(a.DSLTokenType.LEFT_BRACE))return new(0,$.ComplexValueNode)(this.parseObject(),e.location);if(this.match(a.DSLTokenType.LEFT_BRACKET))return new(0,$.ComplexValueNode)(this.parseArray(),e.location);throw new(0,p.DSLParserError)("Expected { or [",e.location,["{","["],e)}parseObject(){this.expect(a.DSLTokenType.LEFT_BRACE);let e={};if(this.match(a.DSLTokenType.RIGHT_BRACE))return this.advance(),e;do{let t;if(t=this.match(a.DSLTokenType.STRING)?this.advance().value.slice(1,-1):this.expectIdentifier(),this.expect(a.DSLTokenType.COLON),e[t]=this.parseJsonValue(),this.match(a.DSLTokenType.COMMA))this.advance();else break}while(!this.match(a.DSLTokenType.RIGHT_BRACE)&&!this.match(a.DSLTokenType.EOF))return this.expect(a.DSLTokenType.RIGHT_BRACE),e}parseArray(){this.expect(a.DSLTokenType.LEFT_BRACKET);let e=[];if(this.match(a.DSLTokenType.RIGHT_BRACKET))return this.advance(),e;do if(e.push(this.parseJsonValue()),this.match(a.DSLTokenType.COMMA))this.advance();else break;while(!this.match(a.DSLTokenType.RIGHT_BRACKET)&&!this.match(a.DSLTokenType.EOF))return this.expect(a.DSLTokenType.RIGHT_BRACKET),e}parseJsonValue(){let e=this.peek();if(e.type===a.DSLTokenType.STRING){let e=this.advance();return this.unescapeJsonString(e.value.slice(1,-1))}return e.type===a.DSLTokenType.NUMBER?parseFloat(this.advance().value):e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD&&("true"===e.value||"false"===e.value)?"true"===this.advance().value:e.type===a.DSLTokenType.NULL||e.type===a.DSLTokenType.KEYWORD&&"null"===e.value?(this.advance(),null):e.type===a.DSLTokenType.IDENTIFIER&&"undefined"===e.value?void this.advance():e.type===a.DSLTokenType.LEFT_BRACE?this.parseObject():e.type===a.DSLTokenType.LEFT_BRACKET?this.parseArray():{isExpression:!0,value:this.parseExpression().expressionText}}peek(){return this.tokens[this.current]}peekAhead(e){return this.tokens[this.current+e]}advance(){let e=this.tokens[this.current];return this.current++,e}match(e,t){let a=this.peek();return!!a&&a.type===e&&(void 0===t||a.value===t)}expect(e,t){let a=this.peek();if(!this.match(e,t)){let r=t?`${e} (${t})`:e;throw new(0,p.DSLParserError)(`Expected ${r}`,a.location,[r],a)}return this.advance()}expectIdentifier(){let e=this.peek();return e.type===a.DSLTokenType.IDENTIFIER||e.type===a.DSLTokenType.BOOLEAN||e.type===a.DSLTokenType.KEYWORD?this.advance().value:this.expect(a.DSLTokenType.IDENTIFIER).value}expectDottedIdentifier(){let e=this.expectIdentifier();for(;this.match(a.DSLTokenType.DOT);)this.advance(),e+="."+this.expectIdentifier();return e}expectStepReference(){return this.expectDottedIdentifier()}unescapeJsonString(e){let t="",a=0;for(;a<e.length;)if("\\"===e[a]&&a+1<e.length)switch(e[a+1]){case"n":t+="\n",a+=2;break;case"r":t+="\r",a+=2;break;case"t":t+=" ",a+=2;break;case"b":t+="\b",a+=2;break;case"f":t+="\f",a+=2;break;case"\\":t+="\\",a+=2;break;case'"':t+='"',a+=2;break;case"/":t+="/",a+=2;break;case"u":if(a+5<e.length){let r=e.substring(a+2,a+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(parseInt(r,16)),a+=6;break}}t+=e[a],a++;break;default:t+=e[a],a++}else t+=e[a],a++;return t}}}),parcelRegister("ljJAk",function(e,t){$parcel$export(e.exports,"ASTNode",()=>parcelRequire("6o4Cv").ASTNode),$parcel$export(e.exports,"ArgumentNode",()=>parcelRequire("TP9ar").ArgumentNode),$parcel$export(e.exports,"ComplexValueNode",()=>parcelRequire("kZUxs").ComplexValueNode),$parcel$export(e.exports,"EventDeclNode",()=>parcelRequire("3WTbA").EventDeclNode),$parcel$export(e.exports,"ExpressionNode",()=>parcelRequire("jpfiN").ExpressionNode),$parcel$export(e.exports,"FunctionCallNode",()=>parcelRequire("5qcBL").FunctionCallNode),$parcel$export(e.exports,"FunctionDefNode",()=>parcelRequire("amNrQ").FunctionDefNode),$parcel$export(e.exports,"ParameterDeclNode",()=>parcelRequire("9IcXU").ParameterDeclNode),$parcel$export(e.exports,"SchemaLiteralNode",()=>parcelRequire("hsyfz").SchemaLiteralNode),$parcel$export(e.exports,"SchemaNode",()=>parcelRequire("4eaZb").SchemaNode),$parcel$export(e.exports,"StatementNode",()=>parcelRequire("jdXce").StatementNode),parcelRequire("6o4Cv"),parcelRequire("TP9ar"),parcelRequire("kZUxs"),parcelRequire("3WTbA"),parcelRequire("jpfiN"),parcelRequire("5qcBL"),parcelRequire("amNrQ"),parcelRequire("9IcXU"),parcelRequire("hsyfz"),parcelRequire("4eaZb"),parcelRequire("jdXce")}),parcelRegister("6o4Cv",function(e,t){$parcel$export(e.exports,"ASTNode",()=>a);class a{constructor(e,t){this.type=e,this.location=t}toString(){return JSON.stringify(this.toJSON(),null,2)}}}),parcelRegister("TP9ar",function(e,t){$parcel$export(e.exports,"ArgumentNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t,a){super("Argument",a),this.key=e,this.values=Array.isArray(t)?t:[t]}get value(){return this.values[0]}isMultiValue(){return this.values.length>1}toJSON(){return{type:this.type,key:this.key,values:this.values.map(e=>e.toJSON())}}}}),parcelRegister("kZUxs",function(e,t){$parcel$export(e.exports,"ComplexValueNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t){super("ComplexValue",t),this.value=e}toJSON(){return{type:this.type,value:this.value}}}}),parcelRegister("3WTbA",function(e,t){$parcel$export(e.exports,"EventDeclNode",()=>r);var a=parcelRequire("6o4Cv");class r extends a.ASTNode{constructor(e,t=[],a){super("EventDecl",a),this.name=e,this.parameters=t}toJSON(){return{type:this.type,name:this.name,parameters:this.parameters.map(e=>e.toJSON())}}}}),parcelRegister("jpfiN",function(e,t){$parcel$export(e.exports,"ExpressionNode",()=>$);var a=parcelRequire("cnGWa"),r=parcelRequire("6o4Cv");class $ extends r.ASTNode{constructor(e,t){super("Expression",t),this.expressionText=e}parse(){this.parsedExpression||(this.parsedExpression=new(0,a.Expression)(this.expressionText))}toJSON(){return{type:this.type,expressionText:this.expressionText}}}}),parcelRegister("cnGWa",function(e,t){$parcel$export(e.exports,"Expression",()=>i);var a=parcelRequire("9cFuT"),r=parcelRequire("cFqdJ"),$=parcelRequire("p6HW6"),c=parcelRequire("dYhyX"),o=parcelRequire("bQb81"),s=parcelRequire("94TVm"),n=parcelRequire("79v57"),f=parcelRequire("2EScE"),d=parcelRequire("3zdm5"),b=parcelRequire("80u7R");class i extends n.ExpressionToken{static createTernary(e,t,a){let r=new i("",void 0,void 0,void 0,!0);return r.tokens.push(e),r.tokens.push(t),r.tokens.push(a),r.ops.push(d.Operation.CONDITIONAL_TERNARY_OPERATOR),r}static createLeaf(e){let t=new i("",void 0,void 0,void 0,!0);return t.expression=e,t.tokens.push(new(0,n.ExpressionToken)(e)),t}constructor(e,t,r,$,c){if(super(e||""),this.tokens=new(0,a.LinkedList),this.ops=new(0,a.LinkedList),c)return;if(void 0!==t||void 0!==r||void 0!==$){$?.getOperator()==".."&&(t?r||(r=new(0,f.ExpressionTokenValue)("","")):t=new(0,f.ExpressionTokenValue)("","")),t&&this.tokens.push(t),r&&this.tokens.push(r),$&&this.ops.push($);return}if(e&&e.trim().length>0)try{const t=e.trim(),a=new(0,b.ExpressionParser)(t).parse();this.expression=t,this.tokens=a.getTokens(),this.ops=a.getOperations(),this.cachedTokensArray=void 0,this.cachedOpsArray=void 0}catch(e){this.evaluate(),this.ops.isEmpty()||".."!=this.ops.peekLast().getOperator()||1!=this.tokens.length||this.tokens.push(new(0,n.ExpressionToken)(""))}}getTokens(){return this.tokens}getOperations(){return this.ops}getTokensArray(){return this.cachedTokensArray||(this.cachedTokensArray=this.tokens.toArray()),this.cachedTokensArray}getOperationsArray(){return this.cachedOpsArray||(this.cachedOpsArray=this.ops.toArray()),this.cachedOpsArray}evaluate(){let e,t=this.expression.length,a="",$=new(0,r.StringBuilder)(""),o=0,f=!1;for(;o<t;){switch(a=this.expression[o],e=$.toString(),a){case" ":f=this.processTokenSepearator($,e,f);break;case"(":o=this.processSubExpression(t,$,e,o,f),f=!1;break;case")":throw new(0,s.ExpressionEvaluationException)(this.expression,"Extra closing parenthesis found");case"]":throw new(0,s.ExpressionEvaluationException)(this.expression,"Extra closing square bracket found");case"'":case'"':if(f&&this.ops.peek()==d.Operation.ARRAY_OPERATOR){let e=this.process(t,$,o);o=e.getT1(),f=e.getT2()}else{let e=this.processStringLiteral(t,a,o);o=e.getT1(),f=e.getT2()}break;case"?":if(o+1<t&&"?"!=this.expression.charAt(o+1)&&0!=o&&"?"!=this.expression.charAt(o-1))o=this.processTernaryOperator(t,$,e,o,f);else{let r=this.processOthers(a,t,$,e,o,f);o=r.getT1(),(f=r.getT2())&&this.ops.peek()==d.Operation.ARRAY_OPERATOR&&(o=(r=this.process(t,$,o)).getT1(),f=r.getT2())}break;default:let r=this.processOthers(a,t,$,e,o,f);o=r.getT1(),(f=r.getT2())&&this.ops.peek()==d.Operation.ARRAY_OPERATOR&&(o=(r=this.process(t,$,o)).getT1(),f=r.getT2())}++o}if(e=$.toString(),!c.StringUtil.isNullOrBlank(e))if(d.Operation.OPERATORS.has(e))throw new(0,s.ExpressionEvaluationException)(this.expression,"Expression is ending with an operator");else this.tokens.push(new(0,n.ExpressionToken)(e))}processStringLiteral(e,t,a){let r="",$=a+1;for(;$<e;$++){let e=this.expression.charAt($);if(e==t&&"\\"!=this.expression.charAt($-1))break;r+=e}if($==e&&this.expression.charAt($-1)!=t)throw new(0,s.ExpressionEvaluationException)(this.expression,"Missing string ending marker "+t);let c=new(0,o.Tuple2)($,!1);return this.tokens.push(new(0,f.ExpressionTokenValue)(r,r)),c}process(e,t,a){let r=1;for(++a;a<e&&0!=r;){let e=this.expression.charAt(a);"]"==e?--r:"["==e&&++r,0!=r&&(t.append(e),a++)}return this.tokens.push(new i(t.toString())),t.setLength(0),new(0,o.Tuple2)(a,!1)}processOthers(e,t,a,r,$,s){let f=t-$;f=f<d.Operation.BIGGEST_OPERATOR_SIZE?f:d.Operation.BIGGEST_OPERATOR_SIZE;for(let e=f;e>0;e--){let t=this.expression.substring($,$+e);if(d.Operation.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return c.StringUtil.isNullOrBlank(r)?".."==t&&this.tokens.isEmpty()&&(this.tokens.push(new(0,n.ExpressionToken)("0")),s=!1):(this.tokens.push(new(0,n.ExpressionToken)(r)),s=!1),this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(t),s),s=!0,a.setLength(0),new(0,o.Tuple2)($+e-1,s)}return a.append(e),new(0,o.Tuple2)($,!1)}processTernaryOperator(e,t,a,r,$){if($)throw new(0,s.ExpressionEvaluationException)(this.expression,"Ternary operator is followed by an operator");""!=a.trim()&&(this.tokens.push(new i(a)),t.setLength(0));let c=1,o="",n=++r;for(;r<e&&c>0;)"?"==(o=this.expression.charAt(r))?++c:":"==o&&--c,++r;if(":"!=o)throw new(0,s.ExpressionEvaluationException)(this.expression,"':' operater is missing");if(r>=e)throw new(0,s.ExpressionEvaluationException)(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(d.Operation.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(d.Operation.UNARY_OPERATORS.has(e)){let t=this.tokens.pop();this.tokens.push(new i("",t,void 0,e))}else{let t=this.tokens.pop(),a=this.tokens.pop();this.tokens.push(new i("",a,t,e))}}this.ops.push(d.Operation.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new i(this.expression.substring(n,r-1)));let f=this.expression.substring(r);if(""===f.trim())throw new(0,s.ExpressionEvaluationException)(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new i(f)),e-1}processSubExpression(e,t,a,o,n){if(d.Operation.OPERATORS.has(a))this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(a),n),t.setLength(0);else if(!c.StringUtil.isNullOrBlank(a))throw new(0,s.ExpressionEvaluationException)(this.expression,$.StringFormatter.format("Unkown token : $ found.",a));let f=1,b=new(0,r.StringBuilder),p=this.expression.charAt(o);for(o++;o<e&&f>0;)"("==(p=this.expression.charAt(o))?f++:")"==p&&f--,0!=f&&(b.append(p),o++);if(")"!=p)throw new(0,s.ExpressionEvaluationException)(this.expression,"Missing a closed parenthesis");for(;b.length()>2&&this.hasMatchingOuterParentheses(b.toString());)b.deleteCharAt(0),b.setLength(b.length()-1);return this.tokens.push(new i(b.toString().trim())),o}processTokenSepearator(e,t,a){return c.StringUtil.isNullOrBlank(t)||(d.Operation.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,d.Operation.OPERATION_VALUE_OF.get(t),a),a=!0):(this.tokens.push(new(0,n.ExpressionToken)(t)),a=!1)),e.setLength(0),a}checkUnaryOperator(e,t,a,r){if(a)if(r||e.isEmpty())if(d.Operation.UNARY_OPERATORS.has(a)){let e=d.Operation.UNARY_MAP.get(a);e&&t.push(e)}else throw new(0,s.ExpressionEvaluationException)(this.expression,$.StringFormatter.format("Extra operator $ found.",a));else{for(;!t.isEmpty()&&this.hasPrecedence(a,t.peek());){let a=t.pop();if(d.Operation.UNARY_OPERATORS.has(a)){let t=e.pop();e.push(new i("",t,void 0,a))}else{let t=e.pop(),r=e.pop();e.push(new i("",r,t,a))}}t.push(a)}}hasPrecedence(e,t){let a=d.Operation.OPERATOR_PRIORITY.get(e),r=d.Operation.OPERATOR_PRIORITY.get(t);if(!a||!r)throw Error("Unknown operators provided");return r===a?t!==d.Operation.OBJECT_OPERATOR&&t!==d.Operation.ARRAY_OPERATOR&&e!==d.Operation.OBJECT_OPERATOR&&e!==d.Operation.ARRAY_OPERATOR:r<a}hasMatchingOuterParentheses(e){if(e.length<2||"("!==e.charAt(0)||")"!==e.charAt(e.length-1))return!1;let t=0;for(let a=0;a<e.length-1;a++){let r=e.charAt(a);if("("===r?t++:")"===r&&t--,0===t)return!1}return 1===t}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokenToString(this.tokens.get(0)):this.expression&&this.expression.length>0?this.expression:"Error: No tokens";let e=this.ops.get(0);return e.getOperator().startsWith("UN: ")?this.formatUnaryOperation(e):e==d.Operation.CONDITIONAL_TERNARY_OPERATOR?this.formatTernaryOperation():this.formatBinaryOperation(e)}formatUnaryOperation(e){let t=this.tokens.get(0),a=this.tokenToString(t);return"("+e.getOperator().substring(4)+a+")"}formatTernaryOperation(){let e=this.tokens.get(0),t=this.tokens.get(1),a=this.tokens.get(2);return"("+this.tokenToString(a)+"?"+this.tokenToString(t)+":"+this.tokenToString(e)+")"}formatBinaryOperation(e){if(2>this.tokens.size())return this.expression&&this.expression.length>0?this.expression:1===this.tokens.size()?this.tokenToString(this.tokens.get(0)):"Error: Invalid binary expression";let t=this.tokens.get(0),a=this.tokens.get(1);if(e==d.Operation.ARRAY_OPERATOR)return this.tokenToString(a)+"["+this.formatArrayIndex(t)+"]";if(e==d.Operation.OBJECT_OPERATOR){let e=this.tokenToString(a),r=this.tokenToString(t);if(t instanceof i){let a=t.getOperations();if(!a.isEmpty()&&a.get(0)==d.Operation.ARRAY_OPERATOR)return"("+e+".("+r+"))"}return"("+e+"."+r+")"}if(e==d.Operation.ARRAY_RANGE_INDEX_OPERATOR)return"("+this.tokenToString(a)+".."+this.tokenToString(t)+")";let r=this.tokenToString(a),$=this.tokenToString(t);return"("+r+e.getOperator()+$+")"}tokenToString(e){if(e instanceof i)return e.toString();if(e&&"function"==typeof e.getExpression&&"function"==typeof e.getTokenValue){let t=e.getExpression();if(t&&(t.startsWith('"')||t.startsWith("'")))return t}return e.toString()}formatArrayIndex(e){if(e instanceof i){if(e.getOperations().isEmpty()&&1==e.getTokens().size()){let t=e.getTokens().get(0);if(t&&"function"==typeof t.getExpression){let e=t.getExpression();if(e&&(e.startsWith('"')||e.startsWith("'")))return e}}return e.toString()}if(e&&"function"==typeof e.getExpression){let t=e.getExpression();if(t&&(t.startsWith('"')||t.startsWith("'")))return t}return e.toString()}tokenHasOperations(e){return e instanceof i&&!e.getOperations().isEmpty()}equals(e){return this.expression==e.expression}}}),parcelRegister("9cFuT",function(e,t){$parcel$export(e.exports,"LinkedList",()=>c);var a=parcelRequire("7qv9Q"),r=parcelRequire("ip0Ed"),$=parcelRequire("p6HW6");class c{constructor(e){if(this.head=void 0,this.tail=void 0,this.length=0,e?.length){for(const t of e)if(this.head){const e=new o(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new o(t);this.length=e.length}}push(e){let t=new o(e,void 0,this.head);this.head?(this.head.previous=t,this.head=t):this.tail=this.head=t,this.length++}pop(){if(!this.head)throw Error("List is empty and cannot pop further.");let e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;let t=this.head;return this.head=t.next,t.next=void 0,t.previous=void 0,this.head.previous=void 0,e}isEmpty(){return!this.length}size(){return this.length}get(e){if(e<0||e>=this.length)throw Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=t.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new(0,a.KIRuntimeException)($.StringFormatter.format("Index $ out of bound to set the value in linked list.",e));let r=this.head;for(;e>0;)r=r.next,--e;return r.value=t,this}toString(){let e=this.head,t="";for(;e;)t+=e.value,(e=e.next)&&(t+=", ");return`[${t}]`}toArray(){let e=[],t=this.head;for(;t;)e.push(t.value),t=t.next;return e}peek(){if(!this.head)throw Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw Error("List is empty so cannot remove");--this.length;let e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{let e=this.tail.previous;e.next=void 0,this.tail.previous=void 0,this.tail=e}return e}addAll(e){return e&&e.length&&e.forEach(this.add.bind(this)),this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new o(e,this.head),this.head.next=this.tail):(this.tail=new o(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new o(e),this}map(e,t){let a=new c,r=this.head,$=0;for(;r;)a.add(e(r.value,$)),r=r.next,++$;return a}indexOf(e){let t=this.head,a=0;for(;t;){if((0,r.deepEqual)(t.value,e))return a;t=t.next,++a}return -1}forEach(e,t){let a=this.head,r=0;for(;a;)e(a.value,r),a=a.next,++r}}class o{constructor(e,t,a){this.value=e,this.next=a,this.previous=t}toString(){return""+this.value}}}),parcelRegister("7qv9Q",function(e,t){$parcel$export(e.exports,"KIRuntimeException",()=>a);class a extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}}),parcelRegister("ip0Ed",function(e,t){$parcel$export(e.exports,"deepEqual",()=>r);var a=parcelRequire("9cFuT");function r(e,t){let r=new(0,a.LinkedList);r.push(e);let $=new(0,a.LinkedList);for($.push(t);!r.isEmpty()&&!$.isEmpty();){let e=r.pop(),t=$.pop();if(e===t)continue;let a=typeof e,c=typeof t;if("undefined"===a||"undefined"===c){if(!e&&!t)continue;return!1}if(a!==c||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let a=0;a<e.length;a++)r.push(e[a]),$.push(t[a]);continue}if("object"===a){if("object"!==c||null===e||null===t)return!1;let a=Object.keys(e);if(a.length!==Object.keys(t).length)return!1;for(let c=0;c<a.length;c++){let o=a[c];r.push(e[o]),$.push(t[o])}continue}return!1}return!0}}),parcelRegister("p6HW6",function(e,t){$parcel$export(e.exports,"StringFormatter",()=>a);class a{static format(e,...t){if(!t||0==t.length)return e;let a="",r=0,$="",c=$,o=e.length;for(let s=0;s<o;s++)"$"==($=e.charAt(s))&&"\\"==c?a=a.substring(0,s-1)+$:"$"==$&&r<t.length?a+=t[r++]:a+=$,c=$;return a.toString()}}}),parcelRegister("cFqdJ",function(e,t){$parcel$export(e.exports,"StringBuilder",()=>r);var a=parcelRequire("7qv9Q");class r{constructor(e){this.str=e??""}append(e){return this.str+=e,this}toString(){return""+this.str}trim(){return this.str=this.str.trim(),this}setLength(e){return this.str=this.str.substring(0,e),this}length(){return this.str.length}charAt(e){return this.str.charAt(e)}deleteCharAt(e){return this.checkIndex(e),this.str=this.str.substring(0,e)+this.str.substring(e+1),this}insert(e,t){return this.str=this.str.substring(0,e)+t+this.str.substring(e),this}checkIndex(e){if(e>=this.str.length)throw new(0,a.KIRuntimeException)(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}}),parcelRegister("dYhyX",function(e,t){$parcel$export(e.exports,"StringUtil",()=>$);var a=parcelRequire("7qv9Q"),r=parcelRequire("p6HW6");class ${static nthIndex(e,t,$=0,c){if(!e)throw new(0,a.KIRuntimeException)("String cannot be null");if($<0||$>=e.length)throw new(0,a.KIRuntimeException)(r.StringFormatter.format("Cannot search from index : $",$));if(c<=0||c>e.length)throw new(0,a.KIRuntimeException)(r.StringFormatter.format("Cannot search for occurance : $",c));for(;$<e.length;){if(e.charAt($)==t&&0==--c)return $;++$}return -1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let a=e.indexOf(t);return -1==a?[e,void 0]:[e.substring(0,a),e.substring(a+1)]}static splitAtLastOccurance(e,t){if(!e)return[void 0,void 0];let a=e.lastIndexOf(t);return -1==a?[e,void 0]:[e.substring(0,a),e.substring(a+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}}),parcelRegister("bQb81",function(e,t){$parcel$export(e.exports,"Tuple2",()=>a),$parcel$export(e.exports,"Tuple3",()=>r),$parcel$export(e.exports,"Tuple4",()=>$);class a{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}}class r extends a{constructor(e,t,a){super(e,t),this.t=a}getT3(){return this.t}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}}class $ extends r{constructor(e,t,a,r){super(e,t,a),this.fr=r}getT4(){return this.fr}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}setT4(e){return this.fr=e,this}}}),parcelRegister("94TVm",function(e,t){$parcel$export(e.exports,"ExpressionEvaluationException",()=>a);class a extends Error{constructor(e,t,a){const r=Error.stackTraceLimit;Error.stackTraceLimit=0,super(),Error.stackTraceLimit=r,this._expression=e,this._msg=t,this.cause=a}get message(){return this._expression+" : "+this._msg}getCause(){return this.cause}}}),parcelRegister("79v57",function(e,t){$parcel$export(e.exports,"ExpressionToken",()=>a);class a{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}}),parcelRegister("2EScE",function(e,t){$parcel$export(e.exports,"ExpressionTokenValue",()=>$);var a=parcelRequire("p6HW6"),r=parcelRequire("79v57");class $ extends r.ExpressionToken{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return a.StringFormatter.format("$: $",this.expression,this.element)}}}),parcelRegister("3zdm5",function(e,t){$parcel$export(e.exports,"Operation",()=>a);class a{static{this.MULTIPLICATION=new a("*")}static{this.DIVISION=new a("/")}static{this.INTEGER_DIVISION=new a("//")}static{this.MOD=new a("%")}static{this.ADDITION=new a("+")}static{this.SUBTRACTION=new a("-")}static{this.NOT=new a("not",void 0,!0)}static{this.AND=new a("and",void 0,!0)}static{this.OR=new a("or",void 0,!0)}static{this.LESS_THAN=new a("<")}static{this.LESS_THAN_EQUAL=new a("<=")}static{this.GREATER_THAN=new a(">")}static{this.GREATER_THAN_EQUAL=new a(">=")}static{this.EQUAL=new a("=")}static{this.NOT_EQUAL=new a("!=")}static{this.BITWISE_AND=new a("&")}static{this.BITWISE_OR=new a("|")}static{this.BITWISE_XOR=new a("^")}static{this.BITWISE_COMPLEMENT=new a("~")}static{this.BITWISE_LEFT_SHIFT=new a("<<")}static{this.BITWISE_RIGHT_SHIFT=new a(">>")}static{this.BITWISE_UNSIGNED_RIGHT_SHIFT=new a(">>>")}static{this.UNARY_PLUS=new a("UN: +","+")}static{this.UNARY_MINUS=new a("UN: -","-")}static{this.UNARY_LOGICAL_NOT=new a("UN: not","not")}static{this.UNARY_BITWISE_COMPLEMENT=new a("UN: ~","~")}static{this.ARRAY_OPERATOR=new a("[")}static{this.ARRAY_RANGE_INDEX_OPERATOR=new a("..")}static{this.OBJECT_OPERATOR=new a(".")}static{this.NULLISH_COALESCING_OPERATOR=new a("??")}static{this.CONDITIONAL_TERNARY_OPERATOR=new a("?")}static{this.VALUE_OF=new Map([["MULTIPLICATION",a.MULTIPLICATION],["DIVISION",a.DIVISION],["INTEGER_DIVISION",a.INTEGER_DIVISION],["MOD",a.MOD],["ADDITION",a.ADDITION],["SUBTRACTION",a.SUBTRACTION],["NOT",a.NOT],["AND",a.AND],["OR",a.OR],["LESS_THAN",a.LESS_THAN],["LESS_THAN_EQUAL",a.LESS_THAN_EQUAL],["GREATER_THAN",a.GREATER_THAN],["GREATER_THAN_EQUAL",a.GREATER_THAN_EQUAL],["EQUAL",a.EQUAL],["NOT_EQUAL",a.NOT_EQUAL],["BITWISE_AND",a.BITWISE_AND],["BITWISE_OR",a.BITWISE_OR],["BITWISE_XOR",a.BITWISE_XOR],["BITWISE_COMPLEMENT",a.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",a.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",a.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",a.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",a.UNARY_PLUS],["UNARY_MINUS",a.UNARY_MINUS],["UNARY_LOGICAL_NOT",a.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",a.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",a.ARRAY_OPERATOR],["ARRAY_RANGE_INDEX_OPERATOR",a.ARRAY_RANGE_INDEX_OPERATOR],["OBJECT_OPERATOR",a.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",a.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",a.CONDITIONAL_TERNARY_OPERATOR]])}static{this.UNARY_OPERATORS=new Set([a.ADDITION,a.SUBTRACTION,a.NOT,a.BITWISE_COMPLEMENT,a.UNARY_PLUS,a.UNARY_MINUS,a.UNARY_LOGICAL_NOT,a.UNARY_BITWISE_COMPLEMENT])}static{this.ARITHMETIC_OPERATORS=new Set([a.MULTIPLICATION,a.DIVISION,a.INTEGER_DIVISION,a.MOD,a.ADDITION,a.SUBTRACTION])}static{this.LOGICAL_OPERATORS=new Set([a.NOT,a.AND,a.OR,a.LESS_THAN,a.LESS_THAN_EQUAL,a.GREATER_THAN,a.GREATER_THAN_EQUAL,a.EQUAL,a.NOT_EQUAL,a.NULLISH_COALESCING_OPERATOR])}static{this.BITWISE_OPERATORS=new Set([a.BITWISE_AND,a.BITWISE_COMPLEMENT,a.BITWISE_LEFT_SHIFT,a.BITWISE_OR,a.BITWISE_RIGHT_SHIFT,a.BITWISE_UNSIGNED_RIGHT_SHIFT,a.BITWISE_XOR])}static{this.CONDITIONAL_OPERATORS=new Set([a.CONDITIONAL_TERNARY_OPERATOR])}static{this.OPERATOR_PRIORITY=new Map([[a.UNARY_PLUS,1],[a.UNARY_MINUS,1],[a.UNARY_LOGICAL_NOT,1],[a.UNARY_BITWISE_COMPLEMENT,1],[a.ARRAY_OPERATOR,1],[a.OBJECT_OPERATOR,1],[a.ARRAY_RANGE_INDEX_OPERATOR,2],[a.MULTIPLICATION,2],[a.DIVISION,2],[a.INTEGER_DIVISION,2],[a.MOD,2],[a.ADDITION,3],[a.SUBTRACTION,3],[a.BITWISE_LEFT_SHIFT,4],[a.BITWISE_RIGHT_SHIFT,4],[a.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[a.LESS_THAN,5],[a.LESS_THAN_EQUAL,5],[a.GREATER_THAN,5],[a.GREATER_THAN_EQUAL,5],[a.EQUAL,6],[a.NOT_EQUAL,6],[a.BITWISE_AND,7],[a.BITWISE_XOR,8],[a.BITWISE_OR,9],[a.NOT,10],[a.AND,10],[a.OR,11],[a.NULLISH_COALESCING_OPERATOR,11],[a.CONDITIONAL_TERNARY_OPERATOR,12]])}static{this.OPERATORS=new Set([...Array.from(a.ARITHMETIC_OPERATORS),...Array.from(a.LOGICAL_OPERATORS),...Array.from(a.BITWISE_OPERATORS),a.ARRAY_OPERATOR,a.ARRAY_RANGE_INDEX_OPERATOR,a.OBJECT_OPERATOR,...Array.from(a.CONDITIONAL_OPERATORS)].map(e=>e.getOperator()))}static{this.OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(a.ARITHMETIC_OPERATORS),...Array.from(a.LOGICAL_OPERATORS),...Array.from(a.BITWISE_OPERATORS),a.ARRAY_OPERATOR,a.ARRAY_RANGE_INDEX_OPERATOR,a.OBJECT_OPERATOR,...Array.from(a.CONDITIONAL_OPERATORS)].filter(e=>!e.shouldBeWrappedInSpace()).map(e=>e.getOperator()))}static{this.OPERATION_VALUE_OF=new Map(Array.from(a.VALUE_OF.entries()).map(([e,t])=>[t.getOperator(),t]))}static{this.UNARY_MAP=new Map([[a.ADDITION,a.UNARY_PLUS],[a.SUBTRACTION,a.UNARY_MINUS],[a.NOT,a.UNARY_LOGICAL_NOT],[a.BITWISE_COMPLEMENT,a.UNARY_BITWISE_COMPLEMENT],[a.UNARY_PLUS,a.UNARY_PLUS],[a.UNARY_MINUS,a.UNARY_MINUS],[a.UNARY_LOGICAL_NOT,a.UNARY_LOGICAL_NOT],[a.UNARY_BITWISE_COMPLEMENT,a.UNARY_BITWISE_COMPLEMENT]])}static{this.BIGGEST_OPERATOR_SIZE=Array.from(a.VALUE_OF.values()).map(e=>e.getOperator()).filter(e=>!e.startsWith("UN: ")).map(e=>e.length).reduce((e,t)=>e>t?e:t,0)}constructor(e,t,a=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=a}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return a.VALUE_OF.get(e)}toString(){return this.operator}}}),parcelRegister("80u7R",function(e,t){$parcel$export(e.exports,"ExpressionParser",()=>n);var a=parcelRequire("94TVm"),r=parcelRequire("79v57"),$=parcelRequire("2EScE"),c=parcelRequire("cnGWa"),o=parcelRequire("3zdm5"),s=parcelRequire("bFW7H");class n{constructor(e){this.currentToken=null,this.previousTokenValue=null,this.parseDepth=0,this.originalExpression=e,this.lexer=new(0,s.ExpressionLexer)(e),this.currentToken=this.lexer.nextToken()}createParserError(e){let t=this.lexer.getPosition(),r=Math.max(0,t-20),$=Math.min(this.originalExpression.length,t+20),c=this.originalExpression.substring(r,$),o=" ".repeat(t-r)+"^";return console.error(`
5
5
  Parser Error: ${e}
6
6
  Expression: ${this.originalExpression}
7
7
  Position: ${t}