@fincity/kirun-js 1.4.6 → 1.4.8
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.
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
LogicalGreaterThanEqualOperator,
|
|
3
|
+
LogicalGreaterThanOperator,
|
|
4
|
+
LogicalLessThanOperator,
|
|
5
|
+
LogicalLessThanEqualOperator,
|
|
6
|
+
LogicalNotOperator,
|
|
7
|
+
} from '../../../../../../src';
|
|
2
8
|
|
|
3
9
|
test('Logical Not Test', () => {
|
|
4
10
|
expect(new LogicalNotOperator().apply(null)).toBeTruthy();
|
|
@@ -15,3 +21,10 @@ test('Logical Not Test', () => {
|
|
|
15
21
|
expect(new LogicalNotOperator().apply('')).toBeFalsy();
|
|
16
22
|
expect(new LogicalNotOperator().apply('TRUE')).toBeFalsy();
|
|
17
23
|
});
|
|
24
|
+
|
|
25
|
+
test('Logical Greate than', () => {
|
|
26
|
+
expect(new LogicalGreaterThanOperator().apply(0, 4)).toBeFalsy();
|
|
27
|
+
expect(new LogicalLessThanOperator().apply(0, 4)).toBeTruthy();
|
|
28
|
+
expect(new LogicalGreaterThanEqualOperator().apply(0, 0)).toBeTruthy();
|
|
29
|
+
expect(new LogicalLessThanEqualOperator().apply(0, 0)).toBeTruthy();
|
|
30
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){return Object.keys(t).forEach((function(r){"default"===r||"__esModule"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e}function t(e,t,r,s){Object.defineProperty(e,t,{get:r,set:s,enumerable:!0,configurable:!0})}var r={};t(r,"KIRunSchemaRepository",(()=>_));var s={};t(s,"AdditionalPropertiesType",(()=>O)),t(s,"Schema",(()=>S));var n={};t(n,"Namespaces",(()=>a));class a{static SYSTEM="System";static SYSTEM_CTX="System.Context";static SYSTEM_LOOP="System.Loop";static SYSTEM_ARRAY="System.Array";static MATH="System.Math";static STRING="System.String";constructor(){}}var i={};t(i,"ArraySchemaType",(()=>p));var o={};function u(e){return null==e}t(o,"isNullValue",(()=>u));class p{constructor(e){e&&(this.singleSchema=e.singleSchema?new S(e.singleSchema):void 0,this.tupleSchema=e.tupleSchema?e.tupleSchema.map((e=>new S(e))):void 0)}setSingleSchema(e){return this.singleSchema=e,this}setTupleSchema(e){return this.tupleSchema=e,this}getSingleSchema(){return this.singleSchema}getTupleSchema(){return this.tupleSchema}isSingleType(){return!u(this.singleSchema)}static of(...e){return 1==e.length?(new p).setSingleSchema(e[0]):(new p).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&p.of(...S.fromListOfSchemas(e));let t=S.from(e);return t?p.of(t):void 0}}var l={};let h;var m;t(l,"SchemaType",(()=>h)),(m=h||(h={})).INTEGER="Integer",m.LONG="Long",m.FLOAT="Float",m.DOUBLE="Double",m.STRING="String",m.OBJECT="Object",m.ARRAY="Array",m.BOOLEAN="Boolean",m.NULL="Null";var c={};t(c,"TypeUtil",(()=>w));var g={};t(g,"MultipleType",(()=>T));var f={};t(f,"Type",(()=>E));class E{}class T extends E{constructor(e){super(),this.type=e instanceof T?new Set(Array.from(e.type)):new Set(Array.from(e))}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}var d={};t(d,"SingleType",(()=>A));class A extends E{constructor(e){super(),this.type=e instanceof A?e.type:e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class w{static of(...e){return 1==e.length?new A(e[0]):new T(new Set(e))}static from(e){return"string"==typeof e?new A(h[e]):Array.isArray(e)?new T(new Set(e.map((e=>e)).map((e=>h[e])))):void 0}}class O{constructor(e){e&&(this.booleanValue=e.booleanValue,e.schemaValue&&(this.schemaValue=new S(e.schemaValue)))}getBooleanValue(){return this.booleanValue}getSchemaValue(){return this.schemaValue}setBooleanValue(e){return this.booleanValue=e,this}setSchemaValue(e){return this.schemaValue=e,this}static from(e){if(!e)return;const t=new O;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}class S{static NULL=(new S).setNamespace(a.SYSTEM).setName("Null").setType(w.of(h.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new S).setType(w.of(h.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new S).setNamespace(a.SYSTEM).setName("Schema").setType(w.of(h.OBJECT)).setProperties(new Map([["namespace",S.of("namespace",h.STRING).setDefaultValue("_")],["name",S.ofString("name")],["version",S.of("version",h.INTEGER).setDefaultValue(1)],["ref",S.ofString("ref")],["type",(new S).setAnyOf([S.TYPE_SCHEMA,S.ofArray("type",S.TYPE_SCHEMA)])],["anyOf",S.ofArray("anyOf",S.ofRef("#/"))],["allOf",S.ofArray("allOf",S.ofRef("#/"))],["oneOf",S.ofArray("oneOf",S.ofRef("#/"))],["not",S.ofRef("#/")],["title",S.ofString("title")],["description",S.ofString("description")],["id",S.ofString("id")],["examples",S.ofAny("examples")],["defaultValue",S.ofAny("defaultValue")],["comment",S.ofString("comment")],["enums",S.ofArray("enums",S.ofString("enums"))],["constant",S.ofAny("constant")],["pattern",S.ofString("pattern")],["format",S.of("format",h.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",S.ofInteger("minLength")],["maxLength",S.ofInteger("maxLength")],["multipleOf",S.ofLong("multipleOf")],["minimum",S.ofNumber("minimum")],["maximum",S.ofNumber("maximum")],["exclusiveMinimum",S.ofNumber("exclusiveMinimum")],["exclusiveMaximum",S.ofNumber("exclusiveMaximum")],["properties",S.of("properties",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["additionalProperties",(new S).setName("additionalProperty").setNamespace(a.SYSTEM).setAnyOf([S.ofBoolean("additionalProperty"),S.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",S.ofArray("required",S.ofString("required")).setDefaultValue([])],["propertyNames",S.ofRef("#/")],["minProperties",S.ofInteger("minProperties")],["maxProperties",S.ofInteger("maxProperties")],["patternProperties",S.of("patternProperties",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["items",(new S).setName("items").setAnyOf([S.ofRef("#/").setName("item"),S.ofArray("tuple",S.ofRef("#/"))])],["contains",S.ofRef("#/")],["minItems",S.ofInteger("minItems")],["maxItems",S.ofInteger("maxItems")],["uniqueItems",S.ofBoolean("uniqueItems")],["$defs",S.of("$defs",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["permission",S.ofString("permission")]])).setRequired([]);static ofString(e){return(new S).setType(w.of(h.STRING)).setName(e)}static ofInteger(e){return(new S).setType(w.of(h.INTEGER)).setName(e)}static ofFloat(e){return(new S).setType(w.of(h.FLOAT)).setName(e)}static ofLong(e){return(new S).setType(w.of(h.LONG)).setName(e)}static ofDouble(e){return(new S).setType(w.of(h.DOUBLE)).setName(e)}static ofAny(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE,h.STRING,h.BOOLEAN,h.ARRAY,h.NULL,h.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE,h.STRING,h.BOOLEAN,h.ARRAY,h.OBJECT)).setName(e)}static ofNumber(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)).setName(e)}static ofBoolean(e){return(new S).setType(w.of(h.BOOLEAN)).setName(e)}static of(e,...t){return(new S).setType(w.of(...t)).setName(e)}static ofObject(e){return(new S).setType(w.of(h.OBJECT)).setName(e)}static ofRef(e){return(new S).setRef(e)}static ofArray(e,...t){return(new S).setType(w.of(h.ARRAY)).setName(e).setItems(p.of(...t))}static fromListOfSchemas(e){if(u(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=S.from(r);e&&t.push(e)}return t}static fromMapOfSchemas(e){if(u(e))return;const t=new Map;return Object.entries(e).forEach((([e,r])=>{let s=S.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(u(e))return;let r=new S;return r.namespace=e.namespace??"_",r.name=e.name,r.version=e.version??1,r.ref=e.ref,r.type=t?new A(h.STRING):w.from(e.type),r.anyOf=S.fromListOfSchemas(e.anyOf),r.allOf=S.fromListOfSchemas(e.allOf),r.oneOf=S.fromListOfSchemas(e.oneOf),r.not=S.from(e.not),r.description=e.description,r.examples=e.examples?[...e.examples]:void 0,r.defaultValue=e.defaultValue,r.comment=e.comment,r.enums=e.enums?[...e.enums]:void 0,r.constant=e.constant,r.pattern=e.pattern,r.format=e.format,r.minLength=e.minLength,r.maxLength=e.maxLength,r.multipleOf=e.multipleOf,r.minimum=e.minimum,r.maximum=e.maximum,r.exclusiveMinimum=e.exclusiveMinimum,r.exclusiveMaximum=e.exclusiveMaximum,r.properties=S.fromMapOfSchemas(e.properties),r.additionalProperties=O.from(e.additionalProperties),r.required=e.required,r.propertyNames=S.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=S.fromMapOfSchemas(e.patternProperties),r.items=p.from(e.items),r.contains=S.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=S.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;constructor(e){e&&(this.namespace=e.namespace,this.name=e.name,this.version=e.version,this.ref=e.ref,this.type=e.type instanceof A?new A(e.type):new T(e.type),this.anyOf=e.anyOf?.map((e=>new S(e))),this.allOf=e.allOf?.map((e=>new S(e))),this.oneOf=e.oneOf?.map((e=>new S(e))),this.not=this.not?new S(this.not):void 0,this.description=e.description,this.examples=e.examples?JSON.parse(JSON.stringify(e.examples)):void 0,this.defaultValue=e.defaultValue?JSON.parse(JSON.stringify(e.defaultValue)):void 0,this.comment=e.comment,this.enums=e.enums?[...e.enums]:void 0,this.constant=e.constant?JSON.parse(JSON.stringify(e.constant)):void 0,this.pattern=e.pattern,this.format=e.format,this.minLength=e.minLength,this.maxLength=e.maxLength,this.multipleOf=e.multipleOf,this.minimum=e.minimum,this.maximum=e.maximum,this.exclusiveMinimum=e.exclusiveMinimum,this.exclusiveMaximum=e.exclusiveMaximum,this.properties=e.properties?new Map(Array.from(e.properties.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.additionalProperties=e.additionalProperties?new O(e.additionalProperties):void 0,this.required=e.required?[...e.required]:void 0,this.propertyNames=e.propertyNames?new S(e.propertyNames):void 0,this.minProperties=e.minProperties,this.maxProperties=e.maxProperties,this.patternProperties=e.patternProperties?new Map(Array.from(e.patternProperties.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.items=e.items?new p(e.items):void 0,this.contains=e.contains?new S(this.contains):void 0,this.minItems=e.minItems,this.maxItems=e.maxItems,this.uniqueItems=e.uniqueItems,this.$defs=e.$defs?new Map(Array.from(e.$defs.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.permission=e.permission)}getTitle(){return this.getFullName()}getFullName(){return this.namespace&&"_"!=this.namespace?this.namespace+"."+this.name:this.name}get$defs(){return this.$defs}set$defs(e){return this.$defs=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getVersion(){return this.version}setVersion(e){return this.version=e,this}getRef(){return this.ref}setRef(e){return this.ref=e,this}getType(){return this.type}setType(e){return this.type=e,this}getAnyOf(){return this.anyOf}setAnyOf(e){return this.anyOf=e,this}getAllOf(){return this.allOf}setAllOf(e){return this.allOf=e,this}getOneOf(){return this.oneOf}setOneOf(e){return this.oneOf=e,this}getNot(){return this.not}setNot(e){return this.not=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getExamples(){return this.examples}setExamples(e){return this.examples=e,this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}getComment(){return this.comment}setComment(e){return this.comment=e,this}getEnums(){return this.enums}setEnums(e){return this.enums=e,this}getConstant(){return this.constant}setConstant(e){return this.constant=e,this}getPattern(){return this.pattern}setPattern(e){return this.pattern=e,this}getFormat(){return this.format}setFormat(e){return this.format=e,this}getMinLength(){return this.minLength}setMinLength(e){return this.minLength=e,this}getMaxLength(){return this.maxLength}setMaxLength(e){return this.maxLength=e,this}getMultipleOf(){return this.multipleOf}setMultipleOf(e){return this.multipleOf=e,this}getMinimum(){return this.minimum}setMinimum(e){return this.minimum=e,this}getMaximum(){return this.maximum}setMaximum(e){return this.maximum=e,this}getExclusiveMinimum(){return this.exclusiveMinimum}setExclusiveMinimum(e){return this.exclusiveMinimum=e,this}getExclusiveMaximum(){return this.exclusiveMaximum}setExclusiveMaximum(e){return this.exclusiveMaximum=e,this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}getAdditionalProperties(){return this.additionalProperties}setAdditionalProperties(e){return this.additionalProperties=e,this}getRequired(){return this.required}setRequired(e){return this.required=e,this}getPropertyNames(){return this.propertyNames}setPropertyNames(e){return this.propertyNames=e,this.propertyNames.type=new A(h.STRING),this}getMinProperties(){return this.minProperties}setMinProperties(e){return this.minProperties=e,this}getMaxProperties(){return this.maxProperties}setMaxProperties(e){return this.maxProperties=e,this}getPatternProperties(){return this.patternProperties}setPatternProperties(e){return this.patternProperties=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}getContains(){return this.contains}setContains(e){return this.contains=e,this}getMinItems(){return this.minItems}setMinItems(e){return this.minItems=e,this}getMaxItems(){return this.maxItems}setMaxItems(e){return this.maxItems=e,this}getUniqueItems(){return this.uniqueItems}setUniqueItems(e){return this.uniqueItems=e,this}getPermission(){return this.permission}setPermission(e){return this.permission=e,this}}var N={};t(N,"Parameter",(()=>M));var R={};t(R,"SchemaReferenceException",(()=>x));class x extends Error{constructor(e,t,r){super(e.trim()?e+"-"+t:t),this.schemaPath=e,this.cause=r}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}var y={};let v;var I;t(y,"ParameterType",(()=>v)),(I=v||(v={})).CONSTANT="CONSTANT",I.EXPRESSION="EXPRESSION";class M{static SCHEMA_NAME="Parameter";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(M.SCHEMA_NAME).setProperties(new Map([["schema",S.SCHEMA],["parameterName",S.ofString("parameterName")],["variableArgument",S.of("variableArgument",h.BOOLEAN).setDefaultValue(!1)],["type",S.ofString("type").setEnums(["EXPRESSION","CONSTANT"])]]));static EXPRESSION=(new S).setNamespace(a.SYSTEM).setName("ParameterExpression").setType(w.of(h.OBJECT)).setProperties(new Map([["isExpression",S.ofBoolean("isExpression").setDefaultValue(!0)],["value",S.ofAny("value")]]));variableArgument=!1;type=v.EXPRESSION;constructor(e,t){if(e instanceof M)this.schema=new S(e.schema),this.parameterName=e.parameterName,this.variableArgument=e.variableArgument,this.type=e.type;else{if(!t)throw new Error("Unknown constructor signature");this.schema=t,this.parameterName=e}}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getParameterName(){return this.parameterName}setParameterName(e){return this.parameterName=e,this}isVariableArgument(){return this.variableArgument}setVariableArgument(e){return this.variableArgument=e,this}getType(){return this.type}setType(e){return this.type=e,this}static ofEntry(e,t,r=!1,s=v.EXPRESSION){return[e,new M(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=v.EXPRESSION){return new M(e,t).setType(s).setVariableArgument(r)}static from(e){const t=S.from(e.schema);if(!t)throw new x("","Parameter requires Schema");return new M(e.parameterName,t).setVariableArgument(!!e.variableArguments).setType(e.type??v.EXPRESSION)}}const P=new Map([["any",S.ofAny("any").setNamespace(a.SYSTEM)],["boolean",S.ofBoolean("boolean").setNamespace(a.SYSTEM)],["double",S.ofDouble("double").setNamespace(a.SYSTEM)],["float",S.ofFloat("float").setNamespace(a.SYSTEM)],["integer",S.ofInteger("integer").setNamespace(a.SYSTEM)],["long",S.ofLong("long").setNamespace(a.SYSTEM)],["number",S.ofNumber("number").setNamespace(a.SYSTEM)],["string",S.ofString("string").setNamespace(a.SYSTEM)],[M.EXPRESSION.getName(),M.EXPRESSION]]);class _{find(e,t){if(a.SYSTEM==e)return P.get(t)}}var L={};t(L,"KIRunFunctionRepository",(()=>_r));var C={};t(C,"KIRuntimeException",(()=>b));class b extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var U={};let V;var B;t(U,"StringFormat",(()=>V)),(B=V||(V={})).DATETIME="DATETIME",B.TIME="TIME",B.DATE="DATE",B.EMAIL="EMAIL",B.REGEX="REGEX";var D={};t(D,"Event",(()=>k));class k{static OUTPUT="output";static ERROR="error";static ITERATION="iteration";static TRUE="true";static FALSE="false";static SCHEMA_NAME="Event";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(k.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["name",S.ofString("name")],["parameters",S.ofObject("parameter").setAdditionalProperties((new O).setSchemaValue(S.SCHEMA))]]));constructor(e,t){if(e instanceof k)this.name=e.name,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new S(e[1])])));else{if(this.name=e,!t)throw new Error("Unknown constructor format");this.parameters=t}}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}static outputEventMapEntry(e){return k.eventMapEntry(k.OUTPUT,e)}static eventMapEntry(e,t){return[e,new k(e,t)]}static from(e){return new k(e.name,new Map(Object.entries(e.parameters??{}).map((e=>{const t=S.from(e[1]);if(!t)throw new x("","Event expects a schema");return[e[0],t]}))))}}var G={};t(G,"EventResult",(()=>$));class ${constructor(e,t){this.name=e,this.result=t}getName(){return this.name}setName(e){return this.name=e,this}getResult(){return this.result}setResult(e){return this.result=e,this}static outputOf(e){return $.of(k.OUTPUT,e)}static of(e,t){return new $(e,t)}}var F={};t(F,"FunctionOutput",(()=>H));class H{index=0;constructor(e){if(u(e))throw new b("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof $?this.fo=e:(this.fo=[],this.generator=e)}next(){if(!this.generator)return this.index<this.fo.length?this.fo[this.index++]:void 0;const e=this.generator.next();return e&&this.fo.push(e),e}allResults(){return this.fo}}var Y={};t(Y,"FunctionSignature",(()=>W));class W{static SCHEMA_NAME="FunctionSignature";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(W.SCHEMA_NAME).setProperties(new Map([["name",S.ofString("name")],["namespace",S.ofString("namespace")],["parameters",S.ofObject("parameters").setAdditionalProperties((new O).setSchemaValue(M.SCHEMA))],["events",S.ofObject("events").setAdditionalProperties((new O).setSchemaValue(k.SCHEMA))]]));namespace="_";parameters=new Map;events=new Map;constructor(e){e instanceof W?(this.name=e.name,this.namespace=e.namespace,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new M(e[1])]))),this.events=new Map(Array.from(e.events.entries()).map((e=>[e[0],new k(e[1])])))):this.name=e}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}getEvents(){return this.events}setEvents(e){return this.events=e,this}}var j={};t(j,"ContextElement",(()=>X));class X{static NULL=new X(S.NULL,void 0);constructor(e,t){this.schema=e,this.element=t}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getElement(){return this.element}setElement(e){return this.element=e,this}}var q={};t(q,"StringFormatter",(()=>J));class J{static format(e,...t){if(!t||0==t.length)return e;let r="",s=0,n="",a=n,i=e.length;for(let o=0;o<i;o++)n=e.charAt(o),"$"==n&&"\\"==a?r=r.substring(0,o-1)+n:"$"==n&&s<t.length?r+=t[s++]:r+=n,a=n;return r.toString()}constructor(){}}var Q={};t(Q,"AbstractFunction",(()=>xe));var K={};t(K,"SchemaValidator",(()=>Re));var z={};t(z,"StringUtil",(()=>Z));class Z{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new b("String cannot be null");if(r<0||r>=e.length)throw new b(J.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new b(J.format("Cannot search for occurance : $",s));for(;r<e.length;){if(e.charAt(r)==t&&0==--s)return r;++r}return-1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let r=e.indexOf(t);return-1==r?[e,void 0]:[e.substring(0,r),e.substring(r+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}var ee={};t(ee,"SchemaUtil",(()=>oe));var te={};t(te,"Tuple2",(()=>re)),t(te,"Tuple3",(()=>se)),t(te,"Tuple4",(()=>ne));class re{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 se extends re{constructor(e,t,r){super(e,t),this.t=r}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 ne extends se{constructor(e,t,r,s){super(e,t,r),this.fr=s}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}}var ae={};t(ae,"SchemaValidationException",(()=>ie));class ie extends Error{constructor(e,t,r=[],s){super(t+(r?r.map((e=>e.message)).reduce(((e,t)=>e+"\n"+t),""):"")),this.schemaPath=e,this.cause=s}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}class oe{static UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH="Unable to retrive schema from referenced path";static CYCLIC_REFERENCE_LIMIT_COUNTER=20;static getDefaultValue(e,t){if(e)return e.getConstant()?e.getConstant():e.getDefaultValue()?e.getDefaultValue():oe.getDefaultValue(oe.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==oe.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new ie(r??"","Schema has a cyclic reference");if(!e||!r||Z.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=oe.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let a=r.split("/");return 1===a.length?e:oe.resolveInternalSchema(e,t,r,s,a,1)}static resolveInternalSchema(e,t,r,s,n,a){let i=e;if(a!==n.length){for(;a<n.length;){if("$defs"===n[a]){if(++a>=n.length||!i.get$defs())throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);i=i.get$defs()?.get(n[a])}else{if(i&&(!i.getType()?.contains(h.OBJECT)||!i.getProperties()))throw new x(r,"Cannot retrievie schema from non Object type schemas");i=i.getProperties()?.get(n[a])}if(a++,!i)throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!Z.isNullOrBlank(i.getRef())&&(i=oe.getSchemaFromRef(i,t,i.getRef(),s),!i))throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return i}}static resolveExternalSchema(e,t,r){if(!t)return;let s=Z.splitAtFirstOccurance(r??"","/");if(!s[0])return;let n=Z.splitAtFirstOccurance(s[0],".");if(!n[0]||!n[1])return;let a=t.find(n[0],n[1]);if(a){if(!s[1]||""===s[1])return new re(a,r);if(r="#/"+s[1],!a)throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new re(a,r)}}constructor(){}}var ue={};t(ue,"AnyOfAllOfOneOfValidator",(()=>pe));class pe{static validate(e,t,r,s){let n=[];return t.getOneOf()&&!t.getOneOf()?pe.oneOf(e,t,r,s,n):t.getAllOf()&&!t.getAllOf()?pe.allOf(e,t,r,s,n):t.getAnyOf()&&!t.getAnyOf()&&pe.anyOf(e,t,r,s,n),s}static anyOf(e,t,r,s,n){let a=!1;for(let i of t.getAnyOf()??[])try{pe.validate(e,i,r,s),a=!0;break}catch(e){a=!1,n.push(e)}if(!a)throw new ie(Re.path(e),"The value don't satisfy any of the schemas.",n)}static allOf(e,t,r,s,n){let a=0;for(let i of t.getAllOf()??[])try{pe.validate(e,i,r,s),a++}catch(e){n.push(e)}if(a!==t.getAllOf()?.length)throw new ie(Re.path(e),"The value doesn't satisfy some of the schemas.",n)}static oneOf(e,t,r,s,n){let a=0;for(let i of t.getOneOf()??[])try{pe.validate(e,i,r,s),a++}catch(e){n.push(e)}if(1!=a)throw new ie(Re.path(e),0==a?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}var le={};t(le,"TypeValidator",(()=>Ne));var he={};t(he,"ArrayValidator",(()=>me));class me{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new ie(Re.path(e),s.toString()+" is not an Array");let n=s;return me.checkMinMaxItems(e,t,n),me.checkItems(e,t,r,n),me.checkUniqueItems(e,t,n),me.checkContains(e,t,r,n),s}static checkContains(e,t,r,s){if(!t.getContains())return;let n=!1;for(let a=0;a<s.length;a++){let i=e?[...e]:[];try{Re.validate(i,t.getContains(),r,s[a]),n=!0;break}catch(e){n=!1}}if(!n)throw new ie(Re.path(e),"None of the items are of type contains schema")}static checkUniqueItems(e,t,r){if(t.getUniqueItems()&&t.getUniqueItems()){if(new Set(r).size!==r.length)throw new ie(Re.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new ie(Re.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new ie(Re.path(e),"Array can have maximum of "+t.getMaxItems()+" elements")}static checkItems(e,t,r,s){if(!t.getItems())return;let n=t.getItems();if(n.getSingleSchema())for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=Re.validate(a,n.getSingleSchema(),r,s[t]);s[t]=i}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new ie(Re.path(e),"Expected an array with only "+n.getTupleSchema().length+" but found "+s.length);for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=Re.validate(a,n.getTupleSchema()[t],r,s[t]);s[t]=i}}}constructor(){}}var ce={};t(ce,"BooleanValidator",(()=>ge));class ge{static validate(e,t,r){if(u(r))throw new ie(Re.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new ie(Re.path(e),r.toString()+" is not a boolean");return r}constructor(){}}var fe={};t(fe,"NullValidator",(()=>Ee));class Ee{static validate(e,t,r){if(r)throw new ie(Re.path(e),"Expected a null but found "+r);return r}constructor(){}}var Te={};t(Te,"NumberValidator",(()=>de));class de{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(t),"Expected a number but found null");if("number"!=typeof s)throw new ie(Re.path(t),s.toString()+" is not a "+e);let n=de.extractNumber(e,t,r,s);return de.checkRange(t,r,s,n),de.checkMultipleOf(t,r,s,n),s}static extractNumber(e,t,r,s){let n=s;try{e!=h.LONG&&e!=h.INTEGER||(n=Math.round(n))}catch(r){throw new ie(Re.path(t),s+" is not a number of type "+e,r)}if(u(n)||(e==h.LONG||e==h.INTEGER)&&n!=s)throw new ie(Re.path(t),s.toString()+" is not a number of type "+e);return n}static checkMultipleOf(e,t,r,s){if(t.getMultipleOf()){if(s%t.getMultipleOf()!=0)throw new ie(Re.path(e),r.toString()+" is not multiple of "+t.getMultipleOf())}}static checkRange(e,t,r,s){if(t.getMinimum()&&de.numberCompare(s,t.getMinimum())<0)throw new ie(Re.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&de.numberCompare(s,t.getMaximum())>0)throw new ie(Re.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&de.numberCompare(s,t.getExclusiveMinimum())<=0)throw new ie(Re.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&de.numberCompare(s,t.getExclusiveMaximum())>0)throw new ie(Re.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}var Ae={};t(Ae,"ObjectValidator",(()=>we));class we{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new ie(Re.path(e),s.toString()+" is not an Object");let n=s,a=new Set(Object.keys(n));we.checkMinMaxProperties(e,t,a),t.getPropertyNames()&&we.checkPropertyNameSchema(e,t,r,a),t.getRequired()&&we.checkRequired(e,t,n),t.getProperties()&&we.checkProperties(e,t,r,n,a),t.getPatternProperties()&&we.checkPatternProperties(e,t,r,n,a),t.getAdditionalProperties()&&we.checkAddtionalProperties(e,t,r,n,a)}static checkPropertyNameSchema(e,t,r,s){for(let n of Array.from(s.values()))try{Re.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new ie(Re.path(e),"Property name '"+n+"' does not fit the property schema")}}static checkRequired(e,t,r){for(const s of t.getRequired()??[])if(u(r[s]))throw new ie(Re.path(e),s+" is mandatory")}static checkAddtionalProperties(e,t,r,s,n){let a=t.getAdditionalProperties();if(a.getSchemaValue())for(let t of Array.from(n.values())){let n=e?[...e]:[],i=Re.validate(n,a.getSchemaValue(),r,s[t]);s[t]=i}else if(!1===a.getBooleanValue()&&n.size)throw new ie(Re.path(e),n.toString()+" are additional properties which are not allowed.")}static checkPatternProperties(e,t,r,s,n){const a=new Map;for(const e of Array.from(t.getPatternProperties().keys()))a.set(e,new RegExp(e));for(const i of Array.from(n.values())){const o=e?[...e]:[];for(const e of Array.from(a.entries()))if(e[1].test(i)){const a=Re.validate(o,t.getPatternProperties().get(e[0]),r,s[i]);s[i]=a,n.delete(i);break}}}static checkProperties(e,t,r,s,n){for(const a of Array.from(t.getProperties())){let t=s[a[0]];if(u(t))continue;let i=e?[...e]:[],o=Re.validate(i,a[1],r,t);s[a[0]]=o,n.delete(a[0])}}static checkMinMaxProperties(e,t,r){if(t.getMinProperties()&&r.size<t.getMinProperties())throw new ie(Re.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new ie(Re.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}var Oe={};t(Oe,"StringValidator",(()=>Se));class Se{static TIME=/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static DATE=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])$/;static DATETIME=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])T([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static EMAIL=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;static validate(e,t,r){if(u(r))throw new ie(Re.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new ie(Re.path(e),r.toString()+" is not String");t.getFormat()==V.TIME?Se.patternMatcher(e,t,r,Se.TIME,"time pattern"):t.getFormat()==V.DATE?Se.patternMatcher(e,t,r,Se.DATE,"date pattern"):t.getFormat()==V.DATETIME?Se.patternMatcher(e,t,r,Se.DATETIME,"date time pattern"):t.getFormat()==V.EMAIL?Se.patternMatcher(e,t,r,Se.EMAIL,"email pattern"):t.getPattern()&&Se.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new ie(Re.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMaxLength())throw new ie(Re.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new ie(Re.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class Ne{static validate(e,t,r,s,n){if(t==h.STRING)Se.validate(e,r,n);else if(t==h.LONG||t==h.INTEGER||t==h.DOUBLE||t==h.FLOAT)de.validate(t,e,r,n);else if(t==h.BOOLEAN)ge.validate(e,r,n);else if(t==h.OBJECT)we.validate(e,r,s,n);else if(t==h.ARRAY)me.validate(e,r,s,n);else{if(t!=h.NULL)throw new ie(Re.path(e),t+" is not a valid type.");Ee.validate(e,r,n)}return n}constructor(){}}class Re{static path(e){return e?e.map((e=>e.getTitle()??"")).filter((e=>!!e)).reduce(((e,t,r)=>e+(0===r?"":".")+t),""):""}static validate(e,t,r,s){if(!t)throw new ie(Re.path(e),"No schema found to validate");if(e||(e=new Array),e.push(t),u(s)&&!u(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return Re.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return Re.enumCheck(e,t,s);if(t.getType()&&Re.typeValidation(e,t,r,s),!Z.isNullOrBlank(t.getRef()))return Re.validate(e,oe.getSchemaFromRef(e[0],r,t.getRef()),r,s);if((t.getOneOf()||t.getAllOf()||t.getAnyOf())&&pe.validate(e,t,r,s),t.getNot()){let n=!1;try{Re.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new ie(Re.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new ie(Re.path(e),"Expecting a constant value : "+r);return r}static enumCheck(e,t,r){let s=!1;for(let e of t.getEnums()??[])if(e===r){s=!0;break}if(s)return r;throw new ie(Re.path(e),"Value is not one of "+t.getEnums())}static typeValidation(e,t,r,s){let n=!1,a=[];for(const i of Array.from(t.getType()?.getAllowedSchemaTypes()?.values()??[]))try{Ne.validate(e,i,t,r,s),n=!0;break}catch(e){n=!1,a.push(e)}if(!n)throw new ie(Re.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",a)}constructor(){}}class xe{validateArguments(e,t,r){return Array.from(this.getSignature().getParameters().entries()).map((s=>{let n=s[1];try{return this.validateArgument(e,t,s,n)}catch(e){const t=this.getSignature();throw new b(`Error while executing the function ${t.getNamespace()}.${t.getName()}'s parameter ${n.getParameterName()} with step name '${r?.getStatement().getStatementName()??"Unknown Step"}' with error : ${e?.message}`)}})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}validateArgument(e,t,r,s){let n,a=r[0],i=e.get(r[0]);if(u(i)&&!s.isVariableArgument())return new re(a,Re.validate(void 0,s.getSchema(),t,void 0));if(!s?.isVariableArgument())return new re(a,Re.validate(void 0,s.getSchema(),t,i));Array.isArray(i)?n=i:(n=[],u(i)?u(s.getSchema().getDefaultValue())||n.push(s.getSchema().getDefaultValue()):n.push(i));for(let e=0;e<n.length;e++)n[e]=Re.validate(void 0,s.getSchema(),t,n[e]);return new re(a,n)}async execute(e){e.setArguments(this.validateArguments(e.getArguments()??new Map,e.getSchemaRepository(),e.getStatementExecution()));try{return this.internalExecute(e)}catch(t){const r=this.getSignature();throw new b(`Error while executing the function ${r.getNamespace()}.${r.getName()} with step name '${e.getStatementExecution()?.getStatement().getStatementName()??"Unknown Step"}' with error : ${t?.message}`)}}getProbableEventSignature(e){return this.getSignature().getEvents()}}const ye=new W("Create").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1).setFormat(V.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,v.CONSTANT),M.ofEntry("schema",S.SCHEMA,!1,v.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const ve=new W("Get").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1).setFormat(V.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,v.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofAny("value")]]))]));var Ie={};t(Ie,"ExecutionException",(()=>Me));class Me extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var Pe={};t(Pe,"Expression",(()=>je));var _e={};t(_e,"LinkedList",(()=>be));var Le={};function Ce(e,t){let r=new be;r.push(e);let s=new be;for(s.push(t);!r.isEmpty()&&!s.isEmpty();){const e=r.pop(),t=s.pop();if(e===t)continue;const n=typeof e,a=typeof t;if("undefined"===n||"undefined"===a){if(!e&&!t)continue;return!1}if(n!==a)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let n=0;n<e.length;n++)r.push(e[n]),s.push(t[n])}else{if("object"!==n)return!1;{const n=Object.entries(e),a=Object.entries(t);if(n.length!==a.length)return!1;for(const[e,a]of n)r.push(a),s.push(t[e])}}}return!0}t(Le,"deepEqual",(()=>Ce));class be{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new Ue(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new Ue(t);this.length=e.length}}push(e){const t=new Ue(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.");const e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;const 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 new Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=this.head.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new b(J.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,e&&(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 new Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw new Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw new Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw new Error("List is empty so cannot remove");--this.length;const e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{const 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):this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new Ue(e,this.head),this.head.next=this.tail):(this.tail=new Ue(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new Ue(e),this}map(e,t){let r=new be,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}indexOf(e){let t=this.head,r=0;for(;t;){if(Ce(t.value,e))return r;t=t.next,++r}return-1}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class Ue{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}var Ve={};t(Ve,"StringBuilder",(()=>Be));class Be{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 b(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}var De={};t(De,"ExpressionEvaluationException",(()=>ke));class ke extends Error{constructor(e,t,r){super(J.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}var Ge={};t(Ge,"ExpressionToken",(()=>$e));class $e{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}var Fe={};t(Fe,"ExpressionTokenValue",(()=>He));class He extends $e{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return J.format("$: $",this.expression,this.element)}}var Ye={};t(Ye,"Operation",(()=>We));class We{static MULTIPLICATION=new We("*");static DIVISION=new We("/");static INTEGER_DIVISION=new We("//");static MOD=new We("%");static ADDITION=new We("+");static SUBTRACTION=new We("-");static NOT=new We("not",void 0,!0);static AND=new We("and",void 0,!0);static OR=new We("or",void 0,!0);static LESS_THAN=new We("<");static LESS_THAN_EQUAL=new We("<=");static GREATER_THAN=new We(">");static GREATER_THAN_EQUAL=new We(">=");static EQUAL=new We("=");static NOT_EQUAL=new We("!=");static BITWISE_AND=new We("&");static BITWISE_OR=new We("|");static BITWISE_XOR=new We("^");static BITWISE_COMPLEMENT=new We("~");static BITWISE_LEFT_SHIFT=new We("<<");static BITWISE_RIGHT_SHIFT=new We(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new We(">>>");static UNARY_PLUS=new We("UN: +","+");static UNARY_MINUS=new We("UN: -","-");static UNARY_LOGICAL_NOT=new We("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new We("UN: ~","~");static ARRAY_OPERATOR=new We("[");static OBJECT_OPERATOR=new We(".");static NULLISH_COALESCING_OPERATOR=new We("??");static CONDITIONAL_TERNARY_OPERATOR=new We("?");static VALUE_OF=new Map([["MULTIPLICATION",We.MULTIPLICATION],["DIVISION",We.DIVISION],["INTEGER_DIVISON",We.INTEGER_DIVISION],["MOD",We.MOD],["ADDITION",We.ADDITION],["SUBTRACTION",We.SUBTRACTION],["NOT",We.NOT],["AND",We.AND],["OR",We.OR],["LESS_THAN",We.LESS_THAN],["LESS_THAN_EQUAL",We.LESS_THAN_EQUAL],["GREATER_THAN",We.GREATER_THAN],["GREATER_THAN_EQUAL",We.GREATER_THAN_EQUAL],["EQUAL",We.EQUAL],["NOT_EQUAL",We.NOT_EQUAL],["BITWISE_AND",We.BITWISE_AND],["BITWISE_OR",We.BITWISE_OR],["BITWISE_XOR",We.BITWISE_XOR],["BITWISE_COMPLEMENT",We.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",We.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",We.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",We.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",We.UNARY_PLUS],["UNARY_MINUS",We.UNARY_MINUS],["UNARY_LOGICAL_NOT",We.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",We.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",We.ARRAY_OPERATOR],["OBJECT_OPERATOR",We.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",We.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",We.CONDITIONAL_TERNARY_OPERATOR]]);static UNARY_OPERATORS=new Set([We.ADDITION,We.SUBTRACTION,We.NOT,We.BITWISE_COMPLEMENT,We.UNARY_PLUS,We.UNARY_MINUS,We.UNARY_LOGICAL_NOT,We.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([We.MULTIPLICATION,We.DIVISION,We.INTEGER_DIVISION,We.MOD,We.ADDITION,We.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([We.NOT,We.AND,We.OR,We.LESS_THAN,We.LESS_THAN_EQUAL,We.GREATER_THAN,We.GREATER_THAN_EQUAL,We.EQUAL,We.NOT_EQUAL,We.NULLISH_COALESCING_OPERATOR]);static BITWISE_OPERATORS=new Set([We.BITWISE_AND,We.BITWISE_COMPLEMENT,We.BITWISE_LEFT_SHIFT,We.BITWISE_OR,We.BITWISE_RIGHT_SHIFT,We.BITWISE_UNSIGNED_RIGHT_SHIFT,We.BITWISE_XOR]);static CONDITIONAL_OPERATORS=new Set([We.CONDITIONAL_TERNARY_OPERATOR]);static OPERATOR_PRIORITY=new Map([[We.UNARY_PLUS,1],[We.UNARY_MINUS,1],[We.UNARY_LOGICAL_NOT,1],[We.UNARY_BITWISE_COMPLEMENT,1],[We.ARRAY_OPERATOR,1],[We.OBJECT_OPERATOR,1],[We.MULTIPLICATION,2],[We.DIVISION,2],[We.INTEGER_DIVISION,2],[We.MOD,2],[We.ADDITION,3],[We.SUBTRACTION,3],[We.BITWISE_LEFT_SHIFT,4],[We.BITWISE_RIGHT_SHIFT,4],[We.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[We.LESS_THAN,5],[We.LESS_THAN_EQUAL,5],[We.GREATER_THAN,5],[We.GREATER_THAN_EQUAL,5],[We.EQUAL,6],[We.NOT_EQUAL,6],[We.BITWISE_AND,7],[We.BITWISE_XOR,8],[We.BITWISE_OR,9],[We.AND,10],[We.OR,11],[We.NULLISH_COALESCING_OPERATOR,11],[We.CONDITIONAL_TERNARY_OPERATOR,12]]);static OPERATORS=new Set([...Array.from(We.ARITHMETIC_OPERATORS),...Array.from(We.LOGICAL_OPERATORS),...Array.from(We.BITWISE_OPERATORS),We.ARRAY_OPERATOR,We.OBJECT_OPERATOR,...Array.from(We.CONDITIONAL_OPERATORS)].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(We.ARITHMETIC_OPERATORS),...Array.from(We.LOGICAL_OPERATORS),...Array.from(We.BITWISE_OPERATORS),We.ARRAY_OPERATOR,We.OBJECT_OPERATOR,...Array.from(We.CONDITIONAL_OPERATORS)].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(We.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[We.ADDITION,We.UNARY_PLUS],[We.SUBTRACTION,We.UNARY_MINUS],[We.NOT,We.UNARY_LOGICAL_NOT],[We.BITWISE_COMPLEMENT,We.UNARY_BITWISE_COMPLEMENT],[We.UNARY_PLUS,We.UNARY_PLUS],[We.UNARY_MINUS,We.UNARY_MINUS],[We.UNARY_LOGICAL_NOT,We.UNARY_LOGICAL_NOT],[We.UNARY_BITWISE_COMPLEMENT,We.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(We.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,r=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=r}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return We.VALUE_OF.get(e)}toString(){return this.operator}}class je extends $e{tokens=new be;ops=new be;constructor(e,t,r,s){super(e||""),t&&this.tokens.push(t),r&&this.tokens.push(r),s&&this.ops.push(s),this.evaluate()}getTokens(){return this.tokens}getOperations(){return this.ops}evaluate(){const e=this.expression.length;let t,r="",s=new Be(""),n=0,a=!1;for(;n<e;){switch(r=this.expression[n],t=s.toString(),r){case" ":a=this.processTokenSepearator(s,t,a);break;case"(":n=this.processSubExpression(e,s,t,n,a),a=!1;break;case")":throw new ke(this.expression,"Extra closing parenthesis found");case"]":throw new ke(this.expression,"Extra closing square bracket found");case"'":case'"':{let t=this.processStringLiteral(e,r,n);n=t.getT1(),a=t.getT2();break}case"?":if(n+1<e&&"?"!=this.expression.charAt(n+1)&&0!=n&&"?"!=this.expression.charAt(n-1))n=this.processTernaryOperator(e,s,t,n,a);else{let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==We.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}break;default:let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==We.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}++n}if(t=s.toString(),!Z.isNullOrBlank(t)){if(We.OPERATORS.has(t))throw new ke(this.expression,"Expression is ending with an operator");this.tokens.push(new $e(t))}}processStringLiteral(e,t,r){let s="",n=r+1;for(;n<e;n++){let e=this.expression.charAt(n);if(e==t&&"\\"!=this.expression.charAt(n-1))break;s+=e}if(n==e&&this.expression.charAt(n-1)!=t)throw new ke(this.expression,"Missing string ending marker "+t);let a=new re(n,!1);return this.tokens.push(new He(s,s)),a}process(e,t,r){let s=1;for(++r;r<e&&0!=s;){let e=this.expression.charAt(r);"]"==e?--s:"["==e&&++s,0!=s&&(t.append(e),r++)}return this.tokens.push(new je(t.toString())),t.setLength(0),new re(r,!1)}processOthers(e,t,r,s,n,a){let i=t-n;i=i<We.BIGGEST_OPERATOR_SIZE?i:We.BIGGEST_OPERATOR_SIZE;for(let e=i;e>0;e--){let t=this.expression.substring(n,n+e);if(We.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return Z.isNullOrBlank(s)||(this.tokens.push(new $e(s)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new re(n+e-1,a)}return r.append(e),new re(n,!1)}processTernaryOperator(e,t,r,s,n){if(n)throw new ke(this.expression,"Ternary operator is followed by an operator");""!=r.trim()&&(this.tokens.push(new je(r)),t.setLength(0));let a=1,i="";const o=++s;for(;s<e&&a>0;)i=this.expression.charAt(s),"?"==i?++a:":"==i&&--a,++s;if(":"!=i)throw new ke(this.expression,"':' operater is missing");if(s>=e)throw new ke(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(We.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(We.UNARY_OPERATORS.has(e)){const t=this.tokens.pop();this.tokens.push(new je("",t,void 0,e))}else{let t=this.tokens.pop(),r=this.tokens.pop();this.tokens.push(new je("",r,t,e))}}this.ops.push(We.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new je(this.expression.substring(o,s-1)));const u=this.expression.substring(s);if(""===u.trim())throw new ke(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new je(u)),e-1}processSubExpression(e,t,r,s,n){if(We.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!Z.isNullOrBlank(r))throw new ke(this.expression,J.format("Unkown token : $ found.",r));let a=1;const i=new Be;let o=this.expression.charAt(s);for(s++;s<e&&a>0;)o=this.expression.charAt(s),"("==o?a++:")"==o&&a--,0!=a&&(i.append(o),s++);if(")"!=o)throw new ke(this.expression,"Missing a closed parenthesis");for(;i.length()>2&&"("==i.charAt(0)&&")"==i.charAt(i.length()-1);)i.deleteCharAt(0),i.setLength(i.length()-1);return this.tokens.push(new je(i.toString().trim())),s}processTokenSepearator(e,t,r){return Z.isNullOrBlank(t)||(We.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new $e(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!We.UNARY_OPERATORS.has(r))throw new ke(this.expression,J.format("Extra operator $ found.",r));{const e=We.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(We.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new je("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new je("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=We.OPERATOR_PRIORITY.get(e),s=We.OPERATOR_PRIORITY.get(t);if(!r||!s)throw new Error("Unknown operators provided");return s<r}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokens.get(0).toString():"Error: No tokens";let e=new Be,t=0;const r=this.ops.toArray(),s=this.tokens.toArray();for(let n=0;n<r.length;n++)if(r[n].getOperator().startsWith("UN: "))e.append("(").append(r[n].getOperator().substring(4)).append(s[t]instanceof je?s[t].toString():s[t]).append(")"),t++;else if(r[n]==We.CONDITIONAL_TERNARY_OPERATOR){let r=s[t++];e.insert(0,r.toString()),e.insert(0,":"),r=s[t++],e.insert(0,r.toString()),e.insert(0,"?"),r=s[t++],e.insert(0,r.toString()).append(")"),e.insert(0,"(")}else{if(0==t){const r=s[t++];e.insert(0,r.toString())}const a=s[t++];e.insert(0,r[n].getOperator()).insert(0,a.toString()).insert(0,"(").append(")")}return e.toString()}equals(e){return this.expression==e.expression}}var Xe={};t(Xe,"ExpressionEvaluator",(()=>pr));var qe={};t(qe,"LogicalNullishCoalescingOperator",(()=>Ke));var Je={};t(Je,"BinaryOperator",(()=>Qe));class Qe{nullCheck(e,t,r){if(u(e)||u(t))throw new Me(J.format("$ cannot be applied to a null value",r.getOperatorName()))}}class Ke extends Qe{apply(e,t){return u(e)?t:e}}var ze={};t(ze,"ArithmeticAdditionOperator",(()=>Ze));class Ze extends Qe{apply(e,t){return this.nullCheck(e,t,We.ADDITION),e+t}}var et={};t(et,"ArithmeticDivisionOperator",(()=>tt));class tt extends Qe{apply(e,t){return this.nullCheck(e,t,We.DIVISION),e/t}}var rt={};t(rt,"ArithmeticIntegerDivisionOperator",(()=>st));class st extends Qe{apply(e,t){return this.nullCheck(e,t,We.DIVISION),Math.floor(e/t)}}var nt={};t(nt,"ArithmeticModulusOperator",(()=>at));class at extends Qe{apply(e,t){return this.nullCheck(e,t,We.MOD),e%t}}var it={};t(it,"ArithmeticMultiplicationOperator",(()=>ot));class ot extends Qe{apply(e,t){this.nullCheck(e,t,We.MULTIPLICATION);const r="string"==typeof e;if(r||"string"===typeof t){let s=r?e:t,n=r?t:e,a="",i=n<0;n=Math.abs(n);let o=Math.floor(n);for(;o-- >0;)a+=s;let u=Math.floor(s.length*(n-Math.floor(n)));if(u<0&&(u=-u),0!=u&&(a+=s.substring(0,u)),i){let e="";for(let t=a.length-1;t>=0;t--)e+=a[t];return e}return a}return e*t}}var ut={};t(ut,"ArithmeticSubtractionOperator",(()=>pt));class pt extends Qe{apply(e,t){return this.nullCheck(e,t,We.SUBTRACTION),e-t}}var lt={};t(lt,"ArrayOperator",(()=>ht));class ht extends Qe{apply(e,t){if(!e)throw new Me("Cannot apply array operator on a null value");if(!t)throw new Me("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new Me(J.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new Me(J.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var mt={};t(mt,"BitwiseAndOperator",(()=>ct));class ct extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_AND),e&t}}var gt={};t(gt,"BitwiseLeftShiftOperator",(()=>ft));class ft extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_LEFT_SHIFT),e<<t}}var Et={};t(Et,"BitwiseOrOperator",(()=>Tt));class Tt extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_OR),e|t}}var dt={};t(dt,"BitwiseRightShiftOperator",(()=>At));class At extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_RIGHT_SHIFT),e>>t}}var wt={};t(wt,"BitwiseUnsignedRightShiftOperator",(()=>Ot));class Ot extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var St={};t(St,"BitwiseXorOperator",(()=>Nt));class Nt extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_XOR),e^t}}var Rt={};t(Rt,"LogicalAndOperator",(()=>vt));var xt={};t(xt,"PrimitiveUtil",(()=>yt));class yt{static findPrimitiveNullAsBoolean(e){if(!e)return new re(h.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new Me(J.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new re(h.BOOLEAN,r):"string"===t?new re(h.STRING,r):yt.findPrimitiveNumberType(r)}static findPrimitive(e){if(u(e))return new re(h.NULL,void 0);let t=typeof e;if("object"===t)throw new Me(J.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new re(h.BOOLEAN,r):"string"===t?new re(h.STRING,r):yt.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(u(e)||Array.isArray(e)||"object"==typeof e)throw new Me(J.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new re(h.LONG,e):new re(h.DOUBLE,e)}catch(e){throw new Me(J.format("Unable to convert $ to a number.",t),e)}}static compare(e,t){if(e==t)return 0;if(u(e)||u(t))return u(e)?-1:1;if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return e.length-t.length;for(let r=0;r<e.length;r++){let s=this.compare(e[r],t[r]);if(0!=s)return s}return 0}return Array.isArray(e)?-1:1}const r=typeof e,s=typeof t;return"object"===r||"object"===s?("object"===r&&"object"===s&&Object.keys(e).forEach((r=>{let s=this.compare(e[r],t[r]);if(0!=s)return s})),"object"===r?-1:1):this.comparePrimitive(e,t)}static comparePrimitive(e,t){return u(e)||u(t)?u(e)&&u(t)?0:u(e)?-1:1:e==t?0:"boolean"==typeof e||"boolean"==typeof t?e?-1:1:"string"==typeof e||"string"==typeof t?e+""<t+""?-1:1:"number"==typeof e||"number"==typeof t?e-t:0}static baseNumberType(e){return Number.isInteger(e)?h.LONG:h.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class vt extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var It={};t(It,"LogicalEqualOperator",(()=>Mt));class Mt extends Qe{apply(e,t){return Ce(e,t)}}var Pt={};t(Pt,"LogicalGreaterThanEqualOperator",(()=>_t));class _t extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var Lt={};t(Lt,"LogicalGreaterThanOperator",(()=>Ct));class Ct extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var bt={};t(bt,"LogicalLessThanEqualOperator",(()=>Ut));class Ut extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var Vt={};t(Vt,"LogicalLessThanOperator",(()=>Bt));class Bt extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var Dt={};t(Dt,"LogicalNotEqualOperator",(()=>kt));class kt extends Qe{apply(e,t){return!Ce(e,t)}}var Gt={};t(Gt,"LogicalOrOperator",(()=>$t));class $t extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var Ft={};t(Ft,"ObjectOperator",(()=>Ht));class Ht extends Qe{apply(e,t){if(!e)throw new Me("Cannot apply array operator on a null value");if(!t)throw new Me("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new Me(J.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var Yt={};t(Yt,"ArithmeticUnaryMinusOperator",(()=>Xt));var Wt={};t(Wt,"UnaryOperator",(()=>jt));class jt{nullCheck(e,t){if(u(e))throw new Me(J.format("$ cannot be applied to a null value",t.getOperatorName()))}}class Xt extends jt{apply(e){return this.nullCheck(e,We.UNARY_MINUS),yt.findPrimitiveNumberType(e),-e}}var qt={};t(qt,"ArithmeticUnaryPlusOperator",(()=>Jt));class Jt extends jt{apply(e){return this.nullCheck(e,We.UNARY_PLUS),yt.findPrimitiveNumberType(e),e}}var Qt={};t(Qt,"BitwiseComplementOperator",(()=>Kt));class Kt extends jt{apply(e){this.nullCheck(e,We.UNARY_BITWISE_COMPLEMENT);let t=yt.findPrimitiveNumberType(e);if(t.getT1()!=h.INTEGER&&t.getT1()!=h.LONG)throw new Me(J.format("Unable to apply bitwise operator on $",e));return~e}}var zt={};t(zt,"LogicalNotOperator",(()=>Zt));class Zt extends jt{apply(e){return!e&&""!==e}}var er={};t(er,"LiteralTokenValueExtractor",(()=>nr));var tr={};t(tr,"TokenValueExtractor",(()=>rr));class rr{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new b(J.format("Token $ doesn't start with $",e,t));return this.getValueInternal(e)}retrieveElementFrom(e,t,r,s){if(u(s))return;if(t.length==r)return s;let n=t[r].split(rr.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!Z.isNullOrBlank(e))).reduce(((s,n,a)=>this.resolveForEachPartOfTokenWithBrackets(e,t,r,n,s,a)),s);return this.retrieveElementFrom(e,t,r+1,n)}resolveForEachPartOfTokenWithBrackets(e,t,r,s,n,a){if(!u(n)){if(0===a){if(Array.isArray(n)){if("length"===s)return n.length;try{let e=parseInt(s);if(isNaN(e))throw new Error(J.format("$ is not a number",e));if(e>=n.length)return;return n[e]}catch(t){throw new ke(e,J.format("$ couldn't be parsed into integer in $",s,e),t)}}return this.checkIfObject(e,t,r,n),n[s]}if(s?.startsWith('"')){if(!s.endsWith('"')||1==s.length||2==s.length)throw new ke(e,J.format("$ is missing a double quote or empty key found",e));return this.checkIfObject(e,t,r,n),n[s.substring(1,s.length-1)]}try{let t=parseInt(s);if(isNaN(t))throw new Error(J.format("$ is not a number",t));if(!Array.isArray(n))throw new ke(e,J.format("Expecting an array with index $ while processing the expression",t,e));if(t>=n.length)return;return n[t]}catch(t){throw new ke(e,J.format("$ couldn't be parsed into integer in $",s,e),t)}}}checkIfObject(e,t,r,s){if("object"!=typeof s||Array.isArray(s))throw new ke(e,J.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const sr=new Map([["true",!0],["false",!1],["null",void 0]]);class nr extends rr{static INSTANCE=new nr;getValueInternal(e){if(!Z.isNullOrBlank(e))return e=e.trim(),sr.has(e)?sr.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t=Number(e);if(isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new ke(e,J.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new ke(e,J.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}var ar={},ir={};t(ir,"ConditionalTernaryOperator",(()=>or));class or extends class{nullCheck(e,t,r,s){if(u(e)||u(t)||u(r))throw new Me(J.format("$ cannot be applied to a null value",s.getOperatorName()))}}{apply(e,t,r){return e?t:r}}e(ar,ir);class ur extends rr{static PREFIX="_internal.";values=new Map;addValue(e,t){this.values.set(e,t)}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.values.get(r))}getPrefix(){return ur.PREFIX}}class pr{static UNARY_OPERATORS_MAP=new Map([[We.UNARY_BITWISE_COMPLEMENT,new Kt],[We.UNARY_LOGICAL_NOT,new Zt],[We.UNARY_MINUS,new Xt],[We.UNARY_PLUS,new Jt]]);static TERNARY_OPERATORS_MAP=new Map([[We.CONDITIONAL_TERNARY_OPERATOR,new or]]);static BINARY_OPERATORS_MAP=new Map([[We.ADDITION,new Ze],[We.DIVISION,new tt],[We.INTEGER_DIVISION,new st],[We.MOD,new at],[We.MULTIPLICATION,new ot],[We.SUBTRACTION,new pt],[We.BITWISE_AND,new ct],[We.BITWISE_LEFT_SHIFT,new ft],[We.BITWISE_OR,new Tt],[We.BITWISE_RIGHT_SHIFT,new At],[We.BITWISE_UNSIGNED_RIGHT_SHIFT,new Ot],[We.BITWISE_XOR,new Nt],[We.AND,new vt],[We.EQUAL,new Mt],[We.GREATER_THAN,new Ct],[We.GREATER_THAN_EQUAL,new _t],[We.LESS_THAN,new Bt],[We.LESS_THAN_EQUAL,new Ut],[We.OR,new $t],[We.NOT_EQUAL,new kt],[We.NULLISH_COALESCING_OPERATOR,new Ke],[We.ARRAY_OPERATOR,new ht],[We.OBJECT_OPERATOR,new Ht]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(pr.UNARY_OPERATORS_MAP.keys());internalTokenValueExtractor=new ur;constructor(e){e instanceof je?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){const t=this.processNestingExpression(this.expression,e);return this.expression=t.getT1(),this.exp=t.getT2(),(e=new Map(e.entries())).set(this.internalTokenValueExtractor.getPrefix(),this.internalTokenValueExtractor),this.evaluateExpression(this.exp,e)}processNestingExpression(e,t){let r=0,s=0;const n=new be;for(;s<e.length-1;){if("{"==e.charAt(s)&&"{"==e.charAt(s+1))0==r&&n.push(new re(s+2,-1)),r++,s++;else if("}"==e.charAt(s)&&"}"==e.charAt(s+1)){if(r--,r<0)throw new ke(e,"Expecting {{ nesting path operator to be started before closing");0==r&&n.push(n.pop().setT2(s)),s++}s++}let a=this.replaceNestingExpression(e,t,n);return new re(a,new je(a))}replaceNestingExpression(e,t,r){let s=e;for(var n of r.toArray()){if(-1==n.getT2())throw new ke(e,"Expecting }} nesting path operator to be closed");let r=new pr(s.substring(n.getT1(),n.getT2())).evaluate(t);s=s.substring(0,n.getT1()-2)+r+s.substring(n.getT2()+2)}return s}getExpression(){return this.exp||(this.exp=new je(this.expression)),this.exp}getExpressionString(){return this.expression}evaluateExpression(e,t){let r=e.getOperations(),s=e.getTokens();for(;!r.isEmpty();){let e=r.pop(),o=s.pop();if(pr.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,o)));else if(e==We.OBJECT_OPERATOR||e==We.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,o);else if(e==We.CONDITIONAL_TERNARY_OPERATOR){const r=s.pop(),u=s.pop();var n=this.getValueFromToken(t,u),a=this.getValueFromToken(t,r),i=this.getValueFromToken(t,o);s.push(this.applyTernaryOperation(e,n,a,i))}else{const r=s.pop();n=this.getValueFromToken(t,r),a=this.getValueFromToken(t,o);s.push(this.applyBinaryOperation(e,n,a))}}if(s.isEmpty())throw new Me(J.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new Me(J.format("Expression : $ evaluated multiple values $",e,s));const o=s.get(0);if(o instanceof He)return o.getElement();if(!(o instanceof je))return this.getValueFromToken(t,o);throw new Me(J.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const a=new be,i=new be;if(!s||!n)return;do{i.push(s),n instanceof je?a.push(new He(n.toString(),this.evaluateExpression(n,e))):n&&a.push(n),n=r.isEmpty()?void 0:r.pop(),s=t.isEmpty()?void 0:t.pop()}while(s==We.OBJECT_OPERATOR||s==We.ARRAY_OPERATOR);n&&(n instanceof je?a.push(new He(n.toString(),this.evaluateExpression(n,e))):a.push(n)),s&&t.push(s);let o=a.pop();if(o instanceof He&&"object"==typeof o.getTokenValue()){const e=(new Date).getTime()+""+Math.round(1e3*Math.random());this.internalTokenValueExtractor.addValue(e,o.getTokenValue()),o=new $e(ur.PREFIX+e)}let u=new Be(o instanceof He?o.getTokenValue():o.toString());for(;!a.isEmpty();)o=a.pop(),s=i.pop(),u.append(s.getOperator()).append(o instanceof He?o.getTokenValue():o.toString()),s==We.ARRAY_OPERATOR&&u.append("]");let p=u.toString(),l=p.substring(0,p.indexOf(".")+1);if(l.length>2&&e.has(l))r.push(new He(p,this.getValue(p,e)));else{let e;try{e=nr.INSTANCE.getValue(p)}catch(t){e=p}r.push(new He(p,e))}}applyTernaryOperation(e,t,r,s){let n=pr.TERNARY_OPERATORS_MAP.get(e);if(!n)throw new ke(this.expression,J.format("No operator found to evaluate $",this.getExpression()));return new He(e.toString(),n.apply(t,r,s))}applyBinaryOperation(e,t,r){let s=typeof t,n=typeof r,a=pr.BINARY_OPERATORS_MAP.get(e);if(("object"===s||"object"===n)&&e!==We.EQUAL&&e!==We.NOT_EQUAL&&e!==We.NULLISH_COALESCING_OPERATOR)throw new ke(this.expression,J.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));if(!a)throw new ke(this.expression,J.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new He(e.toString(),a.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new ke(this.expression,J.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=pr.UNARY_OPERATORS_MAP.get(e);if(!r)throw new ke(this.expression,J.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new He(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof je?this.evaluateExpression(t,e):t instanceof He?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return nr.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??nr.INSTANCE).getValue(e)}}const lr=new W("Set").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1),!1,v.CONSTANT),M.ofEntry("value",S.ofAny("value"))])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const hr=new W("GenerateEvent").setNamespace(a.SYSTEM).setParameters(new Map([M.ofEntry("eventName",S.ofString("eventName").setDefaultValue("output")),M.ofEntry("results",S.ofObject("results").setProperties(new Map([["name",S.ofString("name")],["value",M.EXPRESSION]])),!0)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));class mr extends xe{static CONDITION="condition";static SIGNATURE=new W("If").setNamespace(a.SYSTEM).setParameters(new Map([M.ofEntry(mr.CONDITION,S.of(mr.CONDITION,h.BOOLEAN))])).setEvents(new Map([k.eventMapEntry(k.TRUE,new Map),k.eventMapEntry(k.FALSE,new Map),k.outputEventMapEntry(new Map)]));getSignature(){return mr.SIGNATURE}async internalExecute(e){var t=e.getArguments()?.get(mr.CONDITION);return new H([$.of(t?k.TRUE:k.FALSE,new Map),$.outputOf(new Map)])}}const cr=new W("CountLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([M.ofEntry("count",S.of("count",h.INTEGER).setDefaultValue(1))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",S.of("index",h.INTEGER)]])),k.outputEventMapEntry(new Map([["value",S.of("value",h.INTEGER)]]))]));const gr=new W("RangeLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([M.ofEntry("from",S.of("from",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(0)),M.ofEntry("to",S.of("to",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(1)),M.ofEntry("step",S.of("step",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(1).setNot((new S).setConstant(0)))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",S.of("index",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)]])),k.outputEventMapEntry(new Map([["value",S.of("value",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)]]))]));const fr=new W("Add").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));const Er=[()=>new Map([["value",new M("value",S.ofNumber("value"))]]),()=>new Map([["value1",new M("value1",S.ofNumber("value1"))],["value2",new M("value2",S.ofNumber("value2"))]])];class Tr extends xe{constructor(e,t,r=1,...s){super(),s&&s.length||(s=[h.DOUBLE]),this.parametersNumber=r,this.mathFunction=t,this.signature=new W(e).setNamespace(a.MATH).setParameters(Er[r-1]()).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new S).setType(w.of(...s)).setName("value")]]))]))}getSignature(){return this.signature}async internalExecute(e){let t,r=yt.findPrimitiveNumberType(e.getArguments()?.get(1==this.parametersNumber?"value":"value1")).getT2();return 2==this.parametersNumber&&(t=yt.findPrimitiveNumberType(e.getArguments()?.get("value2")).getT2()),new H([$.outputOf(new Map([["value",this.mathFunction.call(this,r,t)]]))])}}class dr extends xe{static SIGNATURE=new W("Hypotenuse").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new S).setType(w.of(h.DOUBLE)).setName("value")]]))]));constructor(){super()}getSignature(){return dr.SIGNATURE}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>e+t*t),0))]]))])}}const Ar=new W("Maximum").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));const wr=new W("Minimum").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));var Or={};t(Or,"MapUtil",(()=>Sr)),t(Or,"MapEntry",(()=>Nr));class Sr{static of(e,t,r,s,n,a,i,o,p,l,h,m,c,g,f,E,T,d,A,w){const O=new Map;return u(e)||u(t)||O.set(e,t),u(r)||u(s)||O.set(r,s),u(n)||u(a)||O.set(n,a),u(i)||u(o)||O.set(i,o),u(p)||u(l)||O.set(p,l),u(h)||u(m)||O.set(h,m),u(c)||u(g)||O.set(c,g),u(f)||u(E)||O.set(f,E),u(T)||u(d)||O.set(T,d),u(A)||u(w)||O.set(A,w),O}static ofArrayEntries(...e){const t=new Map;for(const[r,s]of e)t.set(r,s);return t}static entry(e,t){return new Nr(e,t)}static ofEntries(...e){const t=new Map;for(const r of e)t.set(r.k,r.v);return t}static ofEntriesArray(...e){const t=new Map;for(let r=0;r<e.length;r++)t.set(e[r][0],e[r][1]);return t}constructor(){}}class Nr{constructor(e,t){this.k=e,this.v=t}}class Rr extends xe{static SIGNATURE=new W("Random").setNamespace(a.MATH).setEvents(new Map([k.outputEventMapEntry(Sr.of("value",S.ofDouble("value")))]));getSignature(){return Rr.SIGNATURE}async internalExecute(e){return new H([$.outputOf(new Map([["value",Math.random()]]))])}}const xr={Absolute:new Tr("Absolute",(e=>Math.abs(e)),1,h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE),ACosine:new Tr("ArcCosine",(e=>Math.acos(e))),ASine:new Tr("ArcSine",(e=>Math.asin(e))),ATangent:new Tr("ArcTangent",(e=>Math.atan(e))),Ceiling:new Tr("Ceiling",(e=>Math.ceil(e))),Cosine:new Tr("Cosine",(e=>Math.cos(e))),CosineH:new Tr("HyperbolicCosine",(e=>Math.cosh(e))),CubeRoot:new Tr("CubeRoot",(e=>Math.cbrt(e))),Exponential:new Tr("Exponential",(e=>Math.exp(e))),Expm1:new Tr("ExponentialMinus1",(e=>Math.expm1(e))),Floor:new Tr("Floor",(e=>Math.floor(e))),Log:new Tr("LogNatural",(e=>Math.log(e))),Log10:new Tr("Log10",(e=>Math.log10(e))),Round:new Tr("Round",(e=>Math.round(e)),1,h.INTEGER,h.LONG),Sine:new Tr("Sine",(e=>Math.sin(e))),SineH:new Tr("HyperbolicSine",(e=>Math.sinh(e))),Tangent:new Tr("Tangent",(e=>Math.tan(e))),TangentH:new Tr("HyperbolicTangent",(e=>Math.tanh(e))),ToDegrees:new Tr("ToDegrees",(e=>e*(Math.PI/180))),ToRadians:new Tr("ToRadians",(e=>e*(180/Math.PI))),SquareRoot:new Tr("SquareRoot",(e=>Math.sqrt(e))),ArcTangent:new Tr("ArcTangent2",((e,t)=>Math.atan2(e,t)),2),Power:new Tr("Power",((e,t)=>Math.pow(e,t)),2),Add:new class extends xe{getSignature(){return fr}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>e+t),0)]]))])}},Hypotenuse:new dr,Maximum:new class extends xe{getSignature(){return Ar}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t>e?t:e))]]))])}},Minimum:new class extends xe{getSignature(){return wr}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t<e?t:e))]]))])}},Random:new Rr};class yr{find(e,t){if(e==a.MATH)return xr[t]}}var vr={};t(vr,"HybridRepository",(()=>Ir));class Ir{constructor(...e){this.repos=e}find(e,t){for(let r of this.repos){let s=r.find(e,t);if(s)return s}}}function Mr(e){return[e.getSignature().getName(),e]}const Pr=new Map([[a.SYSTEM_CTX,new Map([Mr(new class extends xe{getSignature(){return ye}async internalExecute(e){const t=e?.getArguments()?.get("name");if(e?.getContext()?.has(t))throw new b(J.format("Context already has an element for '$' ",t));let r=S.from(e?.getArguments()?.get("schema"));if(!r)throw new b("Schema is not supplied.");return e.getContext().set(t,new X(r,u(r.getDefaultValue())?void 0:r.getDefaultValue())),new H([$.outputOf(new Map)])}}),Mr(new class extends xe{getSignature(){return ve}async internalExecute(e){const t=e?.getArguments()?.get("name");if(!e.getContext()?.has(t))throw new b(J.format("Context don't have an element for '$' ",t));return new H([$.outputOf(new Map(["value",e.getContext()?.get(t)?.getElement()]))])}}),Mr(new class extends xe{getSignature(){return lr}async internalExecute(e){let t=e?.getArguments()?.get("name");if(Z.isNullOrBlank(t))throw new b("Empty string is not a valid name for the context element");let r=e?.getArguments()?.get("value");const s=new je(t),n=s.getTokens().peekLast();if(!n.getExpression().startsWith("Context")||n instanceof je||n instanceof He&&!n.getElement().toString().startsWith("Context"))throw new Me(J.format("The context path $ is not a valid path in context",t));for(const e of s.getOperations().toArray())if(e!=We.ARRAY_OPERATOR&&e!=We.OBJECT_OPERATOR)throw new Me(J.format("Expected a reference to the context location, but found an expression $",t));for(let r=0;r<s.getTokens().size();r++){let n=s.getTokens().get(r);n instanceof je&&s.getTokens().set(r,new He(t,new pr(n).evaluate(e.getValuesMap())))}return this.modifyContext(e,t,r,s)}modifyContext(e,t,r,s){const n=s.getTokens();n.removeLast();const a=s.getOperations();a.removeLast();let i=e.getContext()?.get(n.removeLast().getExpression());if(u(i))throw new b(J.format("Context doesn't have any element with name '$' ",t));if(a.isEmpty())return i.setElement(r),new H([$.outputOf(new Map)]);let o=i.getElement(),p=a.removeLast(),l=n.removeLast(),h=l instanceof He?l.getElement():l.getExpression();for(u(o)&&(o=p==We.OBJECT_OPERATOR?{}:[],i.setElement(o));!a.isEmpty();)o=p==We.OBJECT_OPERATOR?this.getDataFromObject(o,h,a.peekLast()):this.getDataFromArray(o,h,a.peekLast()),p=a.removeLast(),l=n.removeLast(),h=l instanceof He?l.getElement():l.getExpression();return p==We.OBJECT_OPERATOR?this.putDataInObject(o,h,r):this.putDataInArray(o,h,r),new H([$.outputOf(new Map)])}getDataFromArray(e,t,r){if(!Array.isArray(e))throw new b(J.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new b(J.format("Expected an array index but found $",t));if(s<0)throw new b(J.format("Array index is out of bound - $",t));let n=e[s];return u(n)&&(n=r==We.OBJECT_OPERATOR?{}:[],e[s]=n),n}getDataFromObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new b(J.format("Expected an object but found $",e));let s=e[t];return u(s)&&(s=r==We.OBJECT_OPERATOR?{}:[],e[t]=s),s}putDataInArray(e,t,r){if(!Array.isArray(e))throw new b(J.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new b(J.format("Expected an array index but found $",t));if(s<0)throw new b(J.format("Array index is out of bound - $",t));e[s]=r}putDataInObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new b(J.format("Expected an object but found $",e));e[t]=r}})])],[a.SYSTEM_LOOP,new Map([Mr(new class extends xe{getSignature(){return gr}async internalExecute(e){let t=e.getArguments()?.get("from"),r=e.getArguments()?.get("to"),s=e.getArguments()?.get("step");const n=s>0;let a=t,i=!1;return new H({next(){if(i)return;if(n&&a>=r||!n&&a<=r)return i=!0,$.outputOf(new Map([["value",a]]));const e=$.of(k.ITERATION,new Map([["index",a]]));return a+=s,e}})}}),Mr(new class extends xe{getSignature(){return cr}async internalExecute(e){let t=e.getArguments()?.get("count"),r=0;return new H({next(){if(r>=t)return $.outputOf(new Map([["value",r]]));const e=$.of(k.ITERATION,new Map([["index",r]]));return++r,e}})}})])],[a.SYSTEM,new Map([Mr(new mr),Mr(new class extends xe{getSignature(){return hr}async internalExecute(e){const t=e.getEvents(),r=e.getArguments()?.get("eventName"),s=e?.getArguments()?.get("results").map((t=>{let r=t.value;if(u(r))throw new b("Expect a value object");let s=r.value;return r.isExpression&&(s=new pr(s).evaluate(e.getValuesMap())),[t.name,s]})).reduce(((e,t)=>(e.set(t[0],t[1]),e)),new Map);return t?.has(r)||t?.set(r,[]),t?.get(r)?.push(s),new H([$.outputOf(new Map)])}})])]]);class _r extends Ir{constructor(){super({find:(e,t)=>Pr.get(e)?.get(t)},new yr)}}var Lr={};t(Lr,"ArrayUtil",(()=>Cr));class Cr{static removeAListFrom(e,t){if(!(t&&e&&e.length&&t.length))return;const r=new Set(t);for(let t=0;t<e.length;t++)r.has(e[t])&&(e.splice(t,1),t--)}static of(...e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r];return t}constructor(){}}var br={};t(br,"StatementExecution",(()=>Br));var Ur={};t(Ur,"StatementMessage",(()=>Vr));class Vr{constructor(e,t){this.message=t,this.messageType=e}getMessageType(){return this.messageType}setMessageType(e){return this.messageType=e,this}getMessage(){return this.message}setMessage(e){return this.message=e,this}toString(){return`${this.messageType} : ${this.message}`}}class Br{messages=new Array;dependencies=new Set;constructor(e){this.statement=e}getStatement(){return this.statement}setStatement(e){return this.statement=e,this}getMessages(){return this.messages}setMessages(e){return this.messages=e,this}getDependencies(){return this.dependencies}setDependencies(e){return this.dependencies=e,this}getUniqueKey(){return this.statement.getStatementName()}addMessage(e,t){this.messages.push(new Vr(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof Br))return!1;return e.statement.equals(this.statement)}}var Dr={};t(Dr,"ContextTokenValueExtractor",(()=>kr));class kr extends rr{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.context.get(r)?.getElement())}getPrefix(){return kr.PREFIX}}var Gr={};t(Gr,"OutputMapTokenValueExtractor",(()=>$r));class $r extends rr{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=1,s=this.output.get(t[r++]);if(!s||r>=t.length)return;let n=s.get(t[r++]);if(!n||r>=t.length)return;let a=n.get(t[r++]);return this.retrieveElementFrom(e,t,r,a)}getPrefix(){return $r.PREFIX}}var Fr={};t(Fr,"ArgumentsTokenValueExtractor",(()=>Hr));class Hr extends rr{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.args.get(r))}getPrefix(){return Hr.PREFIX}}var Yr={};t(Yr,"GraphVertex",(()=>Xr));var Wr={};t(Wr,"ExecutionGraph",(()=>jr));class jr{nodeMap=new Map;constructor(e=!1){this.isSubGrph=e}getVerticesData(){return Array.from(this.nodeMap.values()).map((e=>e.getData()))}addVertex(e){if(!this.nodeMap.has(e.getUniqueKey())){let t=new Xr(this,e);this.nodeMap.set(e.getUniqueKey(),t)}return this.nodeMap.get(e.getUniqueKey())}getVertex(e){return this.nodeMap.get(e)}getVertexData(e){if(this.nodeMap.has(e))return this.nodeMap.get(e).getData()}getVerticesWithNoIncomingEdges(){return Array.from(this.nodeMap.values()).filter((e=>!e.hasIncomingEdges()))}isCyclic(){let e,t=new be(this.getVerticesWithNoIncomingEdges()),r=new Set;for(;!t.isEmpty();){if(r.has(t.getFirst().getKey()))return!0;e=t.removeFirst(),r.add(e.getKey()),e.hasOutgoingEdges()&&t.addAll(Array.from(e.getOutVertices().values()).flatMap((e=>Array.from(e))))}return!1}addVertices(e){for(const t of e)this.addVertex(t)}getNodeMap(){return this.nodeMap}isSubGraph(){return this.isSubGrph}toString(){return"Execution Graph : \n"+Array.from(this.nodeMap.values()).map((e=>e.toString())).join("\n")}}class Xr{outVertices=new Map;inVertices=new Set;constructor(e,t){this.data=t,this.graph=e}getData(){return this.data}setData(e){return this.data=e,this}getOutVertices(){return this.outVertices}setOutVertices(e){return this.outVertices=e,this}getInVertices(){return this.inVertices}setInVertices(e){return this.inVertices=e,this}getGraph(){return this.graph}setGraph(e){return this.graph=e,this}getKey(){return this.data.getUniqueKey()}addOutEdgeTo(e,t){return this.outVertices.has(e)||this.outVertices.set(e,new Set),this.outVertices.get(e).add(t),t.inVertices.add(new re(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new re(e,t)),e.outVertices.has(t)||e.outVertices.set(t,new Set),e.outVertices.get(t).add(this),e}hasIncomingEdges(){return!!this.inVertices.size}hasOutgoingEdges(){return!!this.outVertices.size}getSubGraphOfType(e){let t=new jr(!0);var r=new be(Array.from(this.outVertices.get(e)??[]));for(r.map((e=>e.getData())).forEach((e=>t.addVertex(e)));!r.isEmpty();){var s=r.pop();Array.from(s.outVertices.values()).flatMap((e=>Array.from(e))).forEach((e=>{t.addVertex(e.getData()),r.add(e)}))}return t}toString(){var e=Array.from(this.getInVertices()).map((e=>e.getT1().getKey()+"("+e.getT2()+")")).join(", "),t=Array.from(this.outVertices.entries()).map((([e,t])=>e+": "+Array.from(t).map((e=>e.getKey())).join(","))).join("\n\t\t");return this.getKey()+":\n\tIn: "+e+"\n\tOut: \n\t\t"+t}}var qr={};t(qr,"KIRuntime",(()=>is));var Jr={};t(Jr,"JsonExpression",(()=>Qr));class Qr{constructor(e){this.expression=e}getExpression(){return this.expression}}var Kr={};let zr;var Zr;t(Kr,"ParameterReferenceType",(()=>zr)),(Zr=zr||(zr={})).VALUE="VALUE",Zr.EXPRESSION="EXPRESSION";var es={};function ts(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}t(es,"FunctionExecutionParameters",(()=>rs));class rs{count=0;valueExtractors=new Map;constructor(e,t,r){this.functionRepository=e,this.schemaRepository=t,this.executionId=r??ts()}getExecutionId(){return this.executionId}getContext(){return this.context}setContext(e){this.context=e;let t=new kr(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new Hr(e);return this.valueExtractors.set(t.getPrefix(),t),this}getEvents(){return this.events}setEvents(e){return this.events=e,this}getStatementExecution(){return this.statementExecution}setStatementExecution(e){return this.statementExecution=e,this}getSteps(){return this.steps}setSteps(e){this.steps=e;let t=new $r(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}getFunctionRepository(){return this.functionRepository}setFunctionRepository(e){return this.functionRepository=e,this}getSchemaRepository(){return this.schemaRepository}setSchemaRepository(e){return this.schemaRepository=e,this}addTokenValueExtractor(...e){for(const t of e)this.valueExtractors.set(t.getPrefix(),t);return this}setValuesMap(e){for(const[t,r]of e.entries())this.valueExtractors.set(t,r);return this}}var ss={};let ns;var as;t(ss,"StatementMessageType",(()=>ns)),(as=ns||(ns={})).ERROR="ERROR",as.WARNING="WARNING",as.MESSAGE="MESSAGE";class is extends xe{static PARAMETER_NEEDS_A_VALUE='Parameter "$" needs a value';static STEP_REGEX_PATTERN=new RegExp("Steps\\.([a-zA-Z0-9\\\\-]{1,})\\.([a-zA-Z0-9\\\\-]{1,})","g");static VERSION=1;static MAX_EXECUTION_ITERATIONS=1e7;debugMode=!1;constructor(e,t=!1){if(super(),this.debugMode=t,this.fd=e,this.fd.getVersion()>is.VERSION)throw new b("Runtime is at a lower version "+is.VERSION+" and trying to run code from version "+this.fd.getVersion()+".")}getSignature(){return this.fd}async getExecutionPlan(e){let t=new jr;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(r,e.getFunctionRepository(),e.getSchemaRepository()));return new re(this.makeEdges(t),t)}async internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map),this.debugMode&&(console.log(`Executing: ${this.fd.getNamespace()}.${this.fd.getName()}`),console.log("Parameters: ",e));let t=await this.getExecutionPlan(e);this.debugMode&&console.log(t.getT2()?.toString());let r=t.getT1();if(this.debugMode&&r.length&&(console.log("Unresolved Dependencies: "),console.log(r.map((e=>J.format("Steps.$.$",e.getT1(),e.getT2()))))),r.length)throw new b(J.format("Found these unresolved dependencies : $ ",r.map((e=>J.format("Steps.$.$",e.getT1(),e.getT2())))));let s=t.getT2().getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(s?.length)throw new b("Please fix the errors in the function definition before execution : \n"+s.join(",\n"));return await this.executeGraph(t.getT2(),e)}async executeGraph(e,t){let r=new be;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new be;for(;!(r.isEmpty()&&s.isEmpty()||t.getEvents()?.has(k.OUTPUT));)if(await this.processBranchQue(t,r,s),await this.processExecutionQue(t,r,s),t.setCount(t.getCount()+1),t.getCount()==is.MAX_EXECUTION_ITERATIONS)throw new b("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new b("No events raised");return new H(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>$.of(e[0],t))))))}async processExecutionQue(e,t,r){if(!t.isEmpty()){let s=t.pop();await this.allDependenciesResolvedVertex(s,e.getSteps())?await this.executeVertex(s,e,r,t,e.getFunctionRepository()):t.add(s)}}async processBranchQue(e,t,r){if(r.length){let s=r.pop();await this.allDependenciesResolvedTuples(s.getT2(),e.getSteps())?await this.executeBranch(e,t,s):r.add(s)}}async executeBranch(e,t,r){let s,n=r.getT4();do{if(await this.executeGraph(r.getT1(),e),s=r.getT3().next(),s&&(e.getSteps()?.has(n.getData().getStatement().getStatementName())||e.getSteps()?.set(n.getData().getStatement().getStatementName(),new Map),e.getSteps()?.get(n.getData().getStatement().getStatementName())?.set(s.getName(),this.resolveInternalExpressions(s.getResult(),e)),this.debugMode)){const t=n.getData().getStatement();console.log(`Step : ${t.getStatementName()} => ${t.getNamespace()}.${t.getName()}`),console.log(`Event : ${s.getName()} : `,e.getSteps().get(t.getStatementName()).get(s.getName()))}}while(s&&s.getName()!=k.OUTPUT);s?.getName()==k.OUTPUT&&n.getOutVertices().has(k.OUTPUT)&&(n?.getOutVertices()?.get(k.OUTPUT)??[]).forEach((async r=>{await this.allDependenciesResolvedVertex(r,e.getSteps())&&t.add(r)}))}async executeVertex(e,t,r,s,n){let a=e.getData().getStatement(),i=n.find(a.getNamespace(),a.getName());if(!i)throw new b(J.format("$.$ function is not found.",a.getNamespace(),a.getName()));let o=i?.getSignature().getParameters(),u=this.getArgumentsFromParametersMap(t,a,o??new Map);this.debugMode&&(console.log(`Step : ${a.getStatementName()} => ${a.getNamespace()}.${a.getName()}`),console.log("Arguments : ",u));let p=t.getContext(),l=await i.execute(new rs(t.getFunctionRepository(),t.getSchemaRepository(),t.getExecutionId()).setValuesMap(t.getValuesMap()).setContext(p).setArguments(u).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),h=l.next();if(!h)throw new b(J.format("Executing $ returned no events",a.getStatementName()));let m=h.getName()==k.OUTPUT;if(t.getSteps()?.has(a.getStatementName())||t.getSteps().set(a.getStatementName(),new Map),t.getSteps().get(a.getStatementName()).set(h.getName(),this.resolveInternalExpressions(h.getResult(),t)),this.debugMode&&(console.log(`Step : ${a.getStatementName()} => ${a.getNamespace()}.${a.getName()}`),console.log(`Event : ${h.getName()} : `,t.getSteps().get(a.getStatementName()).get(h.getName()))),m){let r=e.getOutVertices().get(k.OUTPUT);r&&r.forEach((async e=>{await this.allDependenciesResolvedVertex(e,t.getSteps())&&s.add(e)}))}else{let t=e.getSubGraphOfType(h.getName()),s=this.makeEdges(t);r.push(new ne(t,s,l,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new re(e[0],this.resolveInternalExpression(e[1],t)))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map):e}resolveInternalExpression(e,t){if(u(e)||"object"!=typeof e)return e;if(e instanceof Qr){return new pr(e.getExpression()).evaluate(t.getValuesMap())}if(Array.isArray(e)){let r=[];for(let s of e)r.push(this.resolveInternalExpression(s,t));return r}if("object"==typeof e){let r={};for(let s of Object.entries(e))r[s[0]]=this.resolveInternalExpression(s[1],t);return r}}allDependenciesResolvedTuples(e,t){for(let r of e){if(!t.has(r.getT1()))return!1;if(!t.get(r.getT1())?.get(r.getT2()))return!1}return!0}allDependenciesResolvedVertex(e,t){return!e.getInVertices().size||0==Array.from(e.getInVertices()).filter((e=>{let r=e.getT1().getData().getStatement().getStatementName(),s=e.getT2();return!(t.has(r)&&t.get(r)?.has(s))})).length}getArgumentsFromParametersMap(e,t,r){return Array.from(t.getParameterMap().entries()).map((t=>{let s,n=Array.from(t[1]?.values()??[]);if(!n?.length)return new re(t[0],s);let a=r.get(t[0]);return a?(s=a.isVariableArgument()?n.map((t=>this.parameterReferenceEvaluation(e,t))).flatMap((e=>Array.isArray(e)?e:[e])):this.parameterReferenceEvaluation(e,n[0]),new re(t[0],s)):new re(t[0],void 0)})).filter((e=>!u(e.getT2()))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}parameterReferenceEvaluation(e,t){let r;if(t.getType()==zr.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==zr.EXPRESSION&&!Z.isNullOrBlank(t.getExpression())){r=new pr(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t,r){let s=new Br(e),n=t.find(e.getNamespace(),e.getName());if(!n)throw new b(J.format("$.$ was not available",e.getNamespace(),e.getName()));let a=new Map(n.getSignature().getParameters());for(let t of Array.from(e.getParameterMap().entries())){let e=a.get(t[0]);if(!e)continue;let n=Array.from(t[1]?.values()??[]);if(n.length||e.isVariableArgument()){if(e.isVariableArgument())for(let t of n)this.parameterReferenceValidation(s,e,t,r);else if(n.length){let t=n[0];this.parameterReferenceValidation(s,e,t,r)}a.delete(e.getParameterName())}else u(oe.getDefaultValue(e.getSchema(),r))&&s.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,e.getParameterName())),a.delete(e.getParameterName())}if(!u(s.getStatement().getDependentStatements()))for(let e of s.getStatement().getDependentStatements().entries())e[1]&&s.addDependency(e[0]);if(a.size)for(let e of Array.from(a.values()))e.isVariableArgument()||u(oe.getDefaultValue(e.getSchema(),r))&&s.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return s}parameterReferenceValidation(e,t,r,s){if(r){if(r.getType()==zr.VALUE){u(r.getValue())&&u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));let n=new be;for(n.push(new re(t.getSchema(),r.getValue()));!n.isEmpty();){let t=n.pop();if(t.getT2()instanceof Qr)this.addDependencies(e,t.getT2().getExpression());else{if(u(t.getT1())||u(t.getT1().getType()))continue;if(t.getT1().getType()?.contains(h.ARRAY)&&Array.isArray(t.getT2())){let e=t.getT1().getItems();if(!e)continue;if(e.isSingleType())for(let r of t.getT2())n.push(new re(e.getSingleSchema(),r));else{let r=t.getT2();for(let t=0;t<r.length;t++)n.push(new re(e.getTupleSchema()[t],r[t]))}}else if(t.getT1().getType()?.contains(h.OBJECT)&&"object"==typeof t.getT2()){let r=t.getT1();if(r.getName()===M.EXPRESSION.getName()&&r.getNamespace()===M.EXPRESSION.getNamespace()){let r=t.getT2();r.isExpression&&this.addDependencies(e,r.value)}else if(r.getProperties())for(let e of Object.entries(t.getT2()))r.getProperties().has(e[0])&&n.push(new re(r.getProperties().get(e[0]),e[1]))}}}}else if(r.getType()==zr.EXPRESSION)if(Z.isNullOrBlank(r.getExpression()))u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));else try{this.addDependencies(e,r.getExpression())}catch(t){e.addMessage(ns.ERROR,J.format("Error evaluating $ : $",r.getExpression(),t))}}else u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(is.STEP_REGEX_PATTERN)??[]).forEach((t=>e.addDependency(t)))}makeEdges(e){let t=e.getNodeMap().values(),r=[];for(let s of Array.from(t))for(let t of s.getData().getDependencies()){let n=t.indexOf(".",6),a=t.substring(6,n),i=t.indexOf(".",n+1),o=-1==i?t.substring(n+1):t.substring(n+1,i);e.getNodeMap().has(a)||r.push(new re(a,o));let u=e.getNodeMap().get(a);u&&s.addInEdgeTo(u,o)}return r}}var os={};t(os,"KIRunConstants",(()=>us));class us{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}var ps={};t(ps,"Position",(()=>ls));class ls{static SCHEMA_NAME="Position";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(ls.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["left",S.ofFloat("left")],["top",S.ofFloat("top")]]));constructor(e,t){this.left=e,this.top=t}getLeft(){return this.left}setLeft(e){return this.left=e,this}getTop(){return this.top}setTop(e){return this.top=e,this}static from(e){return e?new ls(e.left,e.top):new ls(-1,-1)}}var hs={};t(hs,"FunctionDefinition",(()=>Os));var ms={};t(ms,"Statement",(()=>Ts));var cs={};t(cs,"AbstractStatement",(()=>gs));class gs{override=!1;constructor(e){e&&(this.comment=e.comment,this.description=e.description,this.position=e.position?new ls(e.position.getLeft(),e.position.getTop()):void 0,this.override=e.override)}getComment(){return this.comment}setComment(e){return this.comment=e,this}isOverride(){return this.override}setOverride(e){return this.override=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getPosition(){return this.position}setPosition(e){return this.position=e,this}}var fs={};t(fs,"ParameterReference",(()=>Es));class Es{static SCHEMA_NAME="ParameterReference";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(Es.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["key",S.ofString("key")],["value",S.ofAny("value")],["expression",S.ofString("expression")],["type",S.ofString("type").setEnums(["EXPRESSION","VALUE"])]]));constructor(e){if(e instanceof Es){let t=e;this.key=t.key,this.type=t.type,this.value=u(t.value)?void 0:JSON.parse(JSON.stringify(t.value)),this.expression=t.expression}else this.type=e,this.key=ts()}getType(){return this.type}setType(e){return this.type=e,this}getKey(){return this.key}setKey(e){return this.key=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}getExpression(){return this.expression}setExpression(e){return this.expression=e,this}static ofExpression(e){const t=new Es(zr.EXPRESSION).setExpression(e);return[t.getKey(),t]}static ofValue(e){const t=new Es(zr.VALUE).setValue(e);return[t.getKey(),t]}static from(e){return new Es(e.type).setValue(e.value).setExpression(e.expression).setKey(e.key)}}class Ts extends gs{static SCHEMA_NAME="Statement";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(Ts.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["statementName",S.ofString("statementName")],["comment",S.ofString("comment")],["description",S.ofString("description")],["namespace",S.ofString("namespace")],["name",S.ofString("name")],["dependentStatements",S.ofObject("dependentstatement").setAdditionalProperties((new O).setSchemaValue(S.ofBoolean("exists")))],["parameterMap",(new S).setName("parameterMap").setAdditionalProperties((new O).setSchemaValue(S.ofObject("parameterReference").setAdditionalProperties((new O).setSchemaValue(Es.SCHEMA))))],["position",ls.SCHEMA]]));constructor(e,t,r){if(super(e instanceof Ts?e:void 0),e instanceof Ts){let t=e;this.statementName=t.statementName,this.name=t.name,this.namespace=t.namespace,t.parameterMap&&(this.parameterMap=new Map(Array.from(t.parameterMap.entries()).map((e=>[e[0],new Map(Array.from(e[1].entries()).map((e=>[e[0],new Es(e[1])])))])))),t.dependentStatements&&(this.dependentStatements=new Map(Array.from(t.dependentStatements.entries())))}else{if(this.statementName=e,!r||!t)throw new Error("Unknown constructor");this.namespace=t,this.name=r}}getStatementName(){return this.statementName}setStatementName(e){return this.statementName=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameterMap(){return this.parameterMap||(this.parameterMap=new Map),this.parameterMap}setParameterMap(e){return this.parameterMap=e,this}getDependentStatements(){return this.dependentStatements??new Map}setDependentStatements(e){return this.dependentStatements=e,this}equals(e){if(!(e instanceof Ts))return!1;return e.statementName==this.statementName}static ofEntry(e){return[e.statementName,e]}static from(e){return new Ts(e.statementName,e.namespace,e.name).setParameterMap(new Map(Object.entries(e.parameterMap??{}).map((([e,t])=>[e,new Map(Object.entries(t??{}).map((([e,t])=>Es.from(t))).map((e=>[e.getKey(),e])))])))).setDependentStatements(new Map(Object.entries(e.dependentStatements??{}))).setPosition(ls.from(e.position)).setComment(e.comment).setDescription(e.description)}}var ds={};t(ds,"StatementGroup",(()=>As));class As extends gs{static SCHEMA_NAME="StatementGroup";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(As.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["statementGroupName",S.ofString("statementGroupName")],["comment",S.ofString("comment")],["description",S.ofString("description")],["position",ls.SCHEMA]]));constructor(e,t=new Map){super(),this.statementGroupName=e,this.statements=t}getStatementGroupName(){return this.statementGroupName}setStatementGroupName(e){return this.statementGroupName=e,this}getStatements(){return this.statements}setStatements(e){return this.statements=e,this}static from(e){return new As(e.statementGroupName,new Map(Object.entries(e.statements||{}).map((([e,t])=>[e,"true"==(""+t)?.toLowerCase()])))).setPosition(ls.from(e.position)).setComment(e.comment).setDescription(e.description)}}const ws=(new S).setNamespace(a.SYSTEM).setName("FunctionDefinition").setProperties(new Map([["name",S.ofString("name")],["namespace",S.ofString("namespace")],["parameters",S.ofArray("parameters",M.SCHEMA)],["events",S.ofObject("events").setAdditionalProperties((new O).setSchemaValue(k.SCHEMA))],["steps",S.ofObject("steps").setAdditionalProperties((new O).setSchemaValue(Ts.SCHEMA))]]));ws.getProperties()?.set("parts",S.ofArray("parts",ws));class Os extends W{static SCHEMA=ws;version=1;constructor(e){super(e)}getVersion(){return this.version}setVersion(e){return this.version=e,this}getSteps(){return this.steps??new Map}setSteps(e){return this.steps=e,this}getStepGroups(){return this.stepGroups}setStepGroups(e){return this.stepGroups=e,this}getParts(){return this.parts}setParts(e){return this.parts=e,this}static from(e){return e?new Os(e.name).setSteps(new Map(Object.values(e.steps??{}).filter((e=>!!e)).map((e=>[e.statementName,Ts.from(e)])))).setStepGroups(new Map(Object.values(e.stepGroups??{}).filter((e=>!!e)).map((e=>[e.statementGroupName,As.from(e)])))).setParts(Array.from(e.parts??[]).filter((e=>!!e)).map((e=>Os.from(e)))).setVersion(e.version??1).setEvents(new Map(Object.values(e.events??{}).filter((e=>!!e)).map((e=>[e.name,k.from(e)])))).setParameters(new Map(Object.values(e.parameters??{}).filter((e=>!!e)).map((e=>[e.parameterName,M.from(e)])))):new Os("unknown")}}var Ss={};t(Ss,"Argument",(()=>Ns));class Ns{argumentIndex=0;constructor(e,t,r){this.argumentIndex=e,this.name=t,this.value=r}getArgumentIndex(){return this.argumentIndex}setArgumentIndex(e){return this.argumentIndex=e,this}getName(){return this.name}setName(e){return this.name=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}static of(e,t){return new Ns(0,e,t)}}var Rs={};e(Rs,Yt),e(Rs,qt),e(Rs,Qt),e(Rs,zt),e(Rs,Wt);var xs={};e(xs,ze),e(xs,et),e(xs,rt),e(xs,nt),e(xs,it),e(xs,ut),e(xs,lt),e(xs,Je),e(xs,mt),e(xs,gt),e(xs,Et),e(xs,dt),e(xs,wt),e(xs,St),e(xs,Rt),e(xs,It),e(xs,Pt),e(xs,Lt),e(xs,bt),e(xs,Dt),e(xs,Vt),e(xs,Gt),e(xs,Ft),e(xs,qe),e(module.exports,r),e(module.exports,L),e(module.exports,{}),e(module.exports,xt),e(module.exports,Or),e(module.exports,o),e(module.exports,_e),e(module.exports,Ve),e(module.exports,q),e(module.exports,z),e(module.exports,te),e(module.exports,Lr),e(module.exports,Le),e(module.exports,br),e(module.exports,Ur),e(module.exports,j),e(module.exports,Dr),e(module.exports,Gr),e(module.exports,Fr),e(module.exports,Yr),e(module.exports,{}),e(module.exports,Wr),e(module.exports,qr),e(module.exports,ss),e(module.exports,es),e(module.exports,Pe),e(module.exports,tr),e(module.exports,er),e(module.exports,Xe),e(module.exports,Ye),e(module.exports,Ge),e(module.exports,De),e(module.exports,Fe),e(module.exports,{}),e(module.exports,Q),e(module.exports,n),e(module.exports,Jr),e(module.exports,s),e(module.exports,Te),e(module.exports,ce),e(module.exports,fe),e(module.exports,he),e(module.exports,ue),e(module.exports,Oe),e(module.exports,Ae),e(module.exports,K),e(module.exports,ae),e(module.exports,R),e(module.exports,le),e(module.exports,i),e(module.exports,d),e(module.exports,c),e(module.exports,g),e(module.exports,f),e(module.exports,l),e(module.exports,ee),e(module.exports,U),e(module.exports,vr),e(module.exports,os),e(module.exports,N),e(module.exports,F),e(module.exports,ps),e(module.exports,hs),e(module.exports,Kr),e(module.exports,G),e(module.exports,cs),e(module.exports,ms),e(module.exports,{}),e(module.exports,ds),e(module.exports,Y),e(module.exports,D),e(module.exports,y),e(module.exports,Ss),e(module.exports,fs),e(module.exports,Ie),e(module.exports,C),e(module.exports,Rs),e(module.exports,xs),e(module.exports,ar);
|
|
1
|
+
function e(e,t){return Object.keys(t).forEach((function(r){"default"===r||"__esModule"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e}function t(e,t,r,s){Object.defineProperty(e,t,{get:r,set:s,enumerable:!0,configurable:!0})}var r={};t(r,"KIRunSchemaRepository",(()=>_));var s={};t(s,"AdditionalPropertiesType",(()=>O)),t(s,"Schema",(()=>S));var n={};t(n,"Namespaces",(()=>a));class a{static SYSTEM="System";static SYSTEM_CTX="System.Context";static SYSTEM_LOOP="System.Loop";static SYSTEM_ARRAY="System.Array";static MATH="System.Math";static STRING="System.String";constructor(){}}var i={};t(i,"ArraySchemaType",(()=>p));var o={};function u(e){return null==e}t(o,"isNullValue",(()=>u));class p{constructor(e){e&&(this.singleSchema=e.singleSchema?new S(e.singleSchema):void 0,this.tupleSchema=e.tupleSchema?e.tupleSchema.map((e=>new S(e))):void 0)}setSingleSchema(e){return this.singleSchema=e,this}setTupleSchema(e){return this.tupleSchema=e,this}getSingleSchema(){return this.singleSchema}getTupleSchema(){return this.tupleSchema}isSingleType(){return!u(this.singleSchema)}static of(...e){return 1==e.length?(new p).setSingleSchema(e[0]):(new p).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&p.of(...S.fromListOfSchemas(e));let t=S.from(e);return t?p.of(t):void 0}}var l={};let h;var m;t(l,"SchemaType",(()=>h)),(m=h||(h={})).INTEGER="Integer",m.LONG="Long",m.FLOAT="Float",m.DOUBLE="Double",m.STRING="String",m.OBJECT="Object",m.ARRAY="Array",m.BOOLEAN="Boolean",m.NULL="Null";var c={};t(c,"TypeUtil",(()=>w));var g={};t(g,"MultipleType",(()=>T));var f={};t(f,"Type",(()=>E));class E{}class T extends E{constructor(e){super(),this.type=e instanceof T?new Set(Array.from(e.type)):new Set(Array.from(e))}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}var d={};t(d,"SingleType",(()=>A));class A extends E{constructor(e){super(),this.type=e instanceof A?e.type:e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class w{static of(...e){return 1==e.length?new A(e[0]):new T(new Set(e))}static from(e){return"string"==typeof e?new A(h[e]):Array.isArray(e)?new T(new Set(e.map((e=>e)).map((e=>h[e])))):void 0}}class O{constructor(e){e&&(this.booleanValue=e.booleanValue,e.schemaValue&&(this.schemaValue=new S(e.schemaValue)))}getBooleanValue(){return this.booleanValue}getSchemaValue(){return this.schemaValue}setBooleanValue(e){return this.booleanValue=e,this}setSchemaValue(e){return this.schemaValue=e,this}static from(e){if(!e)return;const t=new O;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}class S{static NULL=(new S).setNamespace(a.SYSTEM).setName("Null").setType(w.of(h.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new S).setType(w.of(h.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new S).setNamespace(a.SYSTEM).setName("Schema").setType(w.of(h.OBJECT)).setProperties(new Map([["namespace",S.of("namespace",h.STRING).setDefaultValue("_")],["name",S.ofString("name")],["version",S.of("version",h.INTEGER).setDefaultValue(1)],["ref",S.ofString("ref")],["type",(new S).setAnyOf([S.TYPE_SCHEMA,S.ofArray("type",S.TYPE_SCHEMA)])],["anyOf",S.ofArray("anyOf",S.ofRef("#/"))],["allOf",S.ofArray("allOf",S.ofRef("#/"))],["oneOf",S.ofArray("oneOf",S.ofRef("#/"))],["not",S.ofRef("#/")],["title",S.ofString("title")],["description",S.ofString("description")],["id",S.ofString("id")],["examples",S.ofAny("examples")],["defaultValue",S.ofAny("defaultValue")],["comment",S.ofString("comment")],["enums",S.ofArray("enums",S.ofString("enums"))],["constant",S.ofAny("constant")],["pattern",S.ofString("pattern")],["format",S.of("format",h.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",S.ofInteger("minLength")],["maxLength",S.ofInteger("maxLength")],["multipleOf",S.ofLong("multipleOf")],["minimum",S.ofNumber("minimum")],["maximum",S.ofNumber("maximum")],["exclusiveMinimum",S.ofNumber("exclusiveMinimum")],["exclusiveMaximum",S.ofNumber("exclusiveMaximum")],["properties",S.of("properties",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["additionalProperties",(new S).setName("additionalProperty").setNamespace(a.SYSTEM).setAnyOf([S.ofBoolean("additionalProperty"),S.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",S.ofArray("required",S.ofString("required")).setDefaultValue([])],["propertyNames",S.ofRef("#/")],["minProperties",S.ofInteger("minProperties")],["maxProperties",S.ofInteger("maxProperties")],["patternProperties",S.of("patternProperties",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["items",(new S).setName("items").setAnyOf([S.ofRef("#/").setName("item"),S.ofArray("tuple",S.ofRef("#/"))])],["contains",S.ofRef("#/")],["minItems",S.ofInteger("minItems")],["maxItems",S.ofInteger("maxItems")],["uniqueItems",S.ofBoolean("uniqueItems")],["$defs",S.of("$defs",h.OBJECT).setAdditionalProperties((new O).setSchemaValue(S.ofRef("#/")))],["permission",S.ofString("permission")]])).setRequired([]);static ofString(e){return(new S).setType(w.of(h.STRING)).setName(e)}static ofInteger(e){return(new S).setType(w.of(h.INTEGER)).setName(e)}static ofFloat(e){return(new S).setType(w.of(h.FLOAT)).setName(e)}static ofLong(e){return(new S).setType(w.of(h.LONG)).setName(e)}static ofDouble(e){return(new S).setType(w.of(h.DOUBLE)).setName(e)}static ofAny(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE,h.STRING,h.BOOLEAN,h.ARRAY,h.NULL,h.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE,h.STRING,h.BOOLEAN,h.ARRAY,h.OBJECT)).setName(e)}static ofNumber(e){return(new S).setType(w.of(h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)).setName(e)}static ofBoolean(e){return(new S).setType(w.of(h.BOOLEAN)).setName(e)}static of(e,...t){return(new S).setType(w.of(...t)).setName(e)}static ofObject(e){return(new S).setType(w.of(h.OBJECT)).setName(e)}static ofRef(e){return(new S).setRef(e)}static ofArray(e,...t){return(new S).setType(w.of(h.ARRAY)).setName(e).setItems(p.of(...t))}static fromListOfSchemas(e){if(u(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=S.from(r);e&&t.push(e)}return t}static fromMapOfSchemas(e){if(u(e))return;const t=new Map;return Object.entries(e).forEach((([e,r])=>{let s=S.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(u(e))return;let r=new S;return r.namespace=e.namespace??"_",r.name=e.name,r.version=e.version??1,r.ref=e.ref,r.type=t?new A(h.STRING):w.from(e.type),r.anyOf=S.fromListOfSchemas(e.anyOf),r.allOf=S.fromListOfSchemas(e.allOf),r.oneOf=S.fromListOfSchemas(e.oneOf),r.not=S.from(e.not),r.description=e.description,r.examples=e.examples?[...e.examples]:void 0,r.defaultValue=e.defaultValue,r.comment=e.comment,r.enums=e.enums?[...e.enums]:void 0,r.constant=e.constant,r.pattern=e.pattern,r.format=e.format,r.minLength=e.minLength,r.maxLength=e.maxLength,r.multipleOf=e.multipleOf,r.minimum=e.minimum,r.maximum=e.maximum,r.exclusiveMinimum=e.exclusiveMinimum,r.exclusiveMaximum=e.exclusiveMaximum,r.properties=S.fromMapOfSchemas(e.properties),r.additionalProperties=O.from(e.additionalProperties),r.required=e.required,r.propertyNames=S.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=S.fromMapOfSchemas(e.patternProperties),r.items=p.from(e.items),r.contains=S.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=S.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;constructor(e){e&&(this.namespace=e.namespace,this.name=e.name,this.version=e.version,this.ref=e.ref,this.type=e.type instanceof A?new A(e.type):new T(e.type),this.anyOf=e.anyOf?.map((e=>new S(e))),this.allOf=e.allOf?.map((e=>new S(e))),this.oneOf=e.oneOf?.map((e=>new S(e))),this.not=this.not?new S(this.not):void 0,this.description=e.description,this.examples=e.examples?JSON.parse(JSON.stringify(e.examples)):void 0,this.defaultValue=e.defaultValue?JSON.parse(JSON.stringify(e.defaultValue)):void 0,this.comment=e.comment,this.enums=e.enums?[...e.enums]:void 0,this.constant=e.constant?JSON.parse(JSON.stringify(e.constant)):void 0,this.pattern=e.pattern,this.format=e.format,this.minLength=e.minLength,this.maxLength=e.maxLength,this.multipleOf=e.multipleOf,this.minimum=e.minimum,this.maximum=e.maximum,this.exclusiveMinimum=e.exclusiveMinimum,this.exclusiveMaximum=e.exclusiveMaximum,this.properties=e.properties?new Map(Array.from(e.properties.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.additionalProperties=e.additionalProperties?new O(e.additionalProperties):void 0,this.required=e.required?[...e.required]:void 0,this.propertyNames=e.propertyNames?new S(e.propertyNames):void 0,this.minProperties=e.minProperties,this.maxProperties=e.maxProperties,this.patternProperties=e.patternProperties?new Map(Array.from(e.patternProperties.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.items=e.items?new p(e.items):void 0,this.contains=e.contains?new S(this.contains):void 0,this.minItems=e.minItems,this.maxItems=e.maxItems,this.uniqueItems=e.uniqueItems,this.$defs=e.$defs?new Map(Array.from(e.$defs.entries()).map((e=>[e[0],new S(e[1])]))):void 0,this.permission=e.permission)}getTitle(){return this.getFullName()}getFullName(){return this.namespace&&"_"!=this.namespace?this.namespace+"."+this.name:this.name}get$defs(){return this.$defs}set$defs(e){return this.$defs=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getVersion(){return this.version}setVersion(e){return this.version=e,this}getRef(){return this.ref}setRef(e){return this.ref=e,this}getType(){return this.type}setType(e){return this.type=e,this}getAnyOf(){return this.anyOf}setAnyOf(e){return this.anyOf=e,this}getAllOf(){return this.allOf}setAllOf(e){return this.allOf=e,this}getOneOf(){return this.oneOf}setOneOf(e){return this.oneOf=e,this}getNot(){return this.not}setNot(e){return this.not=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getExamples(){return this.examples}setExamples(e){return this.examples=e,this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}getComment(){return this.comment}setComment(e){return this.comment=e,this}getEnums(){return this.enums}setEnums(e){return this.enums=e,this}getConstant(){return this.constant}setConstant(e){return this.constant=e,this}getPattern(){return this.pattern}setPattern(e){return this.pattern=e,this}getFormat(){return this.format}setFormat(e){return this.format=e,this}getMinLength(){return this.minLength}setMinLength(e){return this.minLength=e,this}getMaxLength(){return this.maxLength}setMaxLength(e){return this.maxLength=e,this}getMultipleOf(){return this.multipleOf}setMultipleOf(e){return this.multipleOf=e,this}getMinimum(){return this.minimum}setMinimum(e){return this.minimum=e,this}getMaximum(){return this.maximum}setMaximum(e){return this.maximum=e,this}getExclusiveMinimum(){return this.exclusiveMinimum}setExclusiveMinimum(e){return this.exclusiveMinimum=e,this}getExclusiveMaximum(){return this.exclusiveMaximum}setExclusiveMaximum(e){return this.exclusiveMaximum=e,this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}getAdditionalProperties(){return this.additionalProperties}setAdditionalProperties(e){return this.additionalProperties=e,this}getRequired(){return this.required}setRequired(e){return this.required=e,this}getPropertyNames(){return this.propertyNames}setPropertyNames(e){return this.propertyNames=e,this.propertyNames.type=new A(h.STRING),this}getMinProperties(){return this.minProperties}setMinProperties(e){return this.minProperties=e,this}getMaxProperties(){return this.maxProperties}setMaxProperties(e){return this.maxProperties=e,this}getPatternProperties(){return this.patternProperties}setPatternProperties(e){return this.patternProperties=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}getContains(){return this.contains}setContains(e){return this.contains=e,this}getMinItems(){return this.minItems}setMinItems(e){return this.minItems=e,this}getMaxItems(){return this.maxItems}setMaxItems(e){return this.maxItems=e,this}getUniqueItems(){return this.uniqueItems}setUniqueItems(e){return this.uniqueItems=e,this}getPermission(){return this.permission}setPermission(e){return this.permission=e,this}}var N={};t(N,"Parameter",(()=>M));var R={};t(R,"SchemaReferenceException",(()=>x));class x extends Error{constructor(e,t,r){super(e.trim()?e+"-"+t:t),this.schemaPath=e,this.cause=r}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}var y={};let v;var I;t(y,"ParameterType",(()=>v)),(I=v||(v={})).CONSTANT="CONSTANT",I.EXPRESSION="EXPRESSION";class M{static SCHEMA_NAME="Parameter";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(M.SCHEMA_NAME).setProperties(new Map([["schema",S.SCHEMA],["parameterName",S.ofString("parameterName")],["variableArgument",S.of("variableArgument",h.BOOLEAN).setDefaultValue(!1)],["type",S.ofString("type").setEnums(["EXPRESSION","CONSTANT"])]]));static EXPRESSION=(new S).setNamespace(a.SYSTEM).setName("ParameterExpression").setType(w.of(h.OBJECT)).setProperties(new Map([["isExpression",S.ofBoolean("isExpression").setDefaultValue(!0)],["value",S.ofAny("value")]]));variableArgument=!1;type=v.EXPRESSION;constructor(e,t){if(e instanceof M)this.schema=new S(e.schema),this.parameterName=e.parameterName,this.variableArgument=e.variableArgument,this.type=e.type;else{if(!t)throw new Error("Unknown constructor signature");this.schema=t,this.parameterName=e}}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getParameterName(){return this.parameterName}setParameterName(e){return this.parameterName=e,this}isVariableArgument(){return this.variableArgument}setVariableArgument(e){return this.variableArgument=e,this}getType(){return this.type}setType(e){return this.type=e,this}static ofEntry(e,t,r=!1,s=v.EXPRESSION){return[e,new M(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=v.EXPRESSION){return new M(e,t).setType(s).setVariableArgument(r)}static from(e){const t=S.from(e.schema);if(!t)throw new x("","Parameter requires Schema");return new M(e.parameterName,t).setVariableArgument(!!e.variableArguments).setType(e.type??v.EXPRESSION)}}const P=new Map([["any",S.ofAny("any").setNamespace(a.SYSTEM)],["boolean",S.ofBoolean("boolean").setNamespace(a.SYSTEM)],["double",S.ofDouble("double").setNamespace(a.SYSTEM)],["float",S.ofFloat("float").setNamespace(a.SYSTEM)],["integer",S.ofInteger("integer").setNamespace(a.SYSTEM)],["long",S.ofLong("long").setNamespace(a.SYSTEM)],["number",S.ofNumber("number").setNamespace(a.SYSTEM)],["string",S.ofString("string").setNamespace(a.SYSTEM)],[M.EXPRESSION.getName(),M.EXPRESSION]]);class _{find(e,t){if(a.SYSTEM==e)return P.get(t)}}var L={};t(L,"KIRunFunctionRepository",(()=>_r));var C={};t(C,"KIRuntimeException",(()=>b));class b extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var U={};let V;var B;t(U,"StringFormat",(()=>V)),(B=V||(V={})).DATETIME="DATETIME",B.TIME="TIME",B.DATE="DATE",B.EMAIL="EMAIL",B.REGEX="REGEX";var D={};t(D,"Event",(()=>k));class k{static OUTPUT="output";static ERROR="error";static ITERATION="iteration";static TRUE="true";static FALSE="false";static SCHEMA_NAME="Event";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(k.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["name",S.ofString("name")],["parameters",S.ofObject("parameter").setAdditionalProperties((new O).setSchemaValue(S.SCHEMA))]]));constructor(e,t){if(e instanceof k)this.name=e.name,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new S(e[1])])));else{if(this.name=e,!t)throw new Error("Unknown constructor format");this.parameters=t}}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}static outputEventMapEntry(e){return k.eventMapEntry(k.OUTPUT,e)}static eventMapEntry(e,t){return[e,new k(e,t)]}static from(e){return new k(e.name,new Map(Object.entries(e.parameters??{}).map((e=>{const t=S.from(e[1]);if(!t)throw new x("","Event expects a schema");return[e[0],t]}))))}}var G={};t(G,"EventResult",(()=>$));class ${constructor(e,t){this.name=e,this.result=t}getName(){return this.name}setName(e){return this.name=e,this}getResult(){return this.result}setResult(e){return this.result=e,this}static outputOf(e){return $.of(k.OUTPUT,e)}static of(e,t){return new $(e,t)}}var F={};t(F,"FunctionOutput",(()=>H));class H{index=0;constructor(e){if(u(e))throw new b("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof $?this.fo=e:(this.fo=[],this.generator=e)}next(){if(!this.generator)return this.index<this.fo.length?this.fo[this.index++]:void 0;const e=this.generator.next();return e&&this.fo.push(e),e}allResults(){return this.fo}}var Y={};t(Y,"FunctionSignature",(()=>W));class W{static SCHEMA_NAME="FunctionSignature";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(W.SCHEMA_NAME).setProperties(new Map([["name",S.ofString("name")],["namespace",S.ofString("namespace")],["parameters",S.ofObject("parameters").setAdditionalProperties((new O).setSchemaValue(M.SCHEMA))],["events",S.ofObject("events").setAdditionalProperties((new O).setSchemaValue(k.SCHEMA))]]));namespace="_";parameters=new Map;events=new Map;constructor(e){e instanceof W?(this.name=e.name,this.namespace=e.namespace,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new M(e[1])]))),this.events=new Map(Array.from(e.events.entries()).map((e=>[e[0],new k(e[1])])))):this.name=e}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}getEvents(){return this.events}setEvents(e){return this.events=e,this}}var j={};t(j,"ContextElement",(()=>X));class X{static NULL=new X(S.NULL,void 0);constructor(e,t){this.schema=e,this.element=t}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getElement(){return this.element}setElement(e){return this.element=e,this}}var q={};t(q,"StringFormatter",(()=>J));class J{static format(e,...t){if(!t||0==t.length)return e;let r="",s=0,n="",a=n,i=e.length;for(let o=0;o<i;o++)n=e.charAt(o),"$"==n&&"\\"==a?r=r.substring(0,o-1)+n:"$"==n&&s<t.length?r+=t[s++]:r+=n,a=n;return r.toString()}constructor(){}}var Q={};t(Q,"AbstractFunction",(()=>xe));var K={};t(K,"SchemaValidator",(()=>Re));var z={};t(z,"StringUtil",(()=>Z));class Z{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new b("String cannot be null");if(r<0||r>=e.length)throw new b(J.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new b(J.format("Cannot search for occurance : $",s));for(;r<e.length;){if(e.charAt(r)==t&&0==--s)return r;++r}return-1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let r=e.indexOf(t);return-1==r?[e,void 0]:[e.substring(0,r),e.substring(r+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}var ee={};t(ee,"SchemaUtil",(()=>oe));var te={};t(te,"Tuple2",(()=>re)),t(te,"Tuple3",(()=>se)),t(te,"Tuple4",(()=>ne));class re{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 se extends re{constructor(e,t,r){super(e,t),this.t=r}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 ne extends se{constructor(e,t,r,s){super(e,t,r),this.fr=s}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}}var ae={};t(ae,"SchemaValidationException",(()=>ie));class ie extends Error{constructor(e,t,r=[],s){super(t+(r?r.map((e=>e.message)).reduce(((e,t)=>e+"\n"+t),""):"")),this.schemaPath=e,this.cause=s}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}class oe{static UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH="Unable to retrive schema from referenced path";static CYCLIC_REFERENCE_LIMIT_COUNTER=20;static getDefaultValue(e,t){if(e)return e.getConstant()?e.getConstant():e.getDefaultValue()?e.getDefaultValue():oe.getDefaultValue(oe.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==oe.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new ie(r??"","Schema has a cyclic reference");if(!e||!r||Z.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=oe.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let a=r.split("/");return 1===a.length?e:oe.resolveInternalSchema(e,t,r,s,a,1)}static resolveInternalSchema(e,t,r,s,n,a){let i=e;if(a!==n.length){for(;a<n.length;){if("$defs"===n[a]){if(++a>=n.length||!i.get$defs())throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);i=i.get$defs()?.get(n[a])}else{if(i&&(!i.getType()?.contains(h.OBJECT)||!i.getProperties()))throw new x(r,"Cannot retrievie schema from non Object type schemas");i=i.getProperties()?.get(n[a])}if(a++,!i)throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!Z.isNullOrBlank(i.getRef())&&(i=oe.getSchemaFromRef(i,t,i.getRef(),s),!i))throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return i}}static resolveExternalSchema(e,t,r){if(!t)return;let s=Z.splitAtFirstOccurance(r??"","/");if(!s[0])return;let n=Z.splitAtFirstOccurance(s[0],".");if(!n[0]||!n[1])return;let a=t.find(n[0],n[1]);if(a){if(!s[1]||""===s[1])return new re(a,r);if(r="#/"+s[1],!a)throw new x(r,oe.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new re(a,r)}}constructor(){}}var ue={};t(ue,"AnyOfAllOfOneOfValidator",(()=>pe));class pe{static validate(e,t,r,s){let n=[];return t.getOneOf()&&!t.getOneOf()?pe.oneOf(e,t,r,s,n):t.getAllOf()&&!t.getAllOf()?pe.allOf(e,t,r,s,n):t.getAnyOf()&&!t.getAnyOf()&&pe.anyOf(e,t,r,s,n),s}static anyOf(e,t,r,s,n){let a=!1;for(let i of t.getAnyOf()??[])try{pe.validate(e,i,r,s),a=!0;break}catch(e){a=!1,n.push(e)}if(!a)throw new ie(Re.path(e),"The value don't satisfy any of the schemas.",n)}static allOf(e,t,r,s,n){let a=0;for(let i of t.getAllOf()??[])try{pe.validate(e,i,r,s),a++}catch(e){n.push(e)}if(a!==t.getAllOf()?.length)throw new ie(Re.path(e),"The value doesn't satisfy some of the schemas.",n)}static oneOf(e,t,r,s,n){let a=0;for(let i of t.getOneOf()??[])try{pe.validate(e,i,r,s),a++}catch(e){n.push(e)}if(1!=a)throw new ie(Re.path(e),0==a?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}var le={};t(le,"TypeValidator",(()=>Ne));var he={};t(he,"ArrayValidator",(()=>me));class me{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new ie(Re.path(e),s.toString()+" is not an Array");let n=s;return me.checkMinMaxItems(e,t,n),me.checkItems(e,t,r,n),me.checkUniqueItems(e,t,n),me.checkContains(e,t,r,n),s}static checkContains(e,t,r,s){if(!t.getContains())return;let n=!1;for(let a=0;a<s.length;a++){let i=e?[...e]:[];try{Re.validate(i,t.getContains(),r,s[a]),n=!0;break}catch(e){n=!1}}if(!n)throw new ie(Re.path(e),"None of the items are of type contains schema")}static checkUniqueItems(e,t,r){if(t.getUniqueItems()&&t.getUniqueItems()){if(new Set(r).size!==r.length)throw new ie(Re.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new ie(Re.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new ie(Re.path(e),"Array can have maximum of "+t.getMaxItems()+" elements")}static checkItems(e,t,r,s){if(!t.getItems())return;let n=t.getItems();if(n.getSingleSchema())for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=Re.validate(a,n.getSingleSchema(),r,s[t]);s[t]=i}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new ie(Re.path(e),"Expected an array with only "+n.getTupleSchema().length+" but found "+s.length);for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=Re.validate(a,n.getTupleSchema()[t],r,s[t]);s[t]=i}}}constructor(){}}var ce={};t(ce,"BooleanValidator",(()=>ge));class ge{static validate(e,t,r){if(u(r))throw new ie(Re.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new ie(Re.path(e),r.toString()+" is not a boolean");return r}constructor(){}}var fe={};t(fe,"NullValidator",(()=>Ee));class Ee{static validate(e,t,r){if(r)throw new ie(Re.path(e),"Expected a null but found "+r);return r}constructor(){}}var Te={};t(Te,"NumberValidator",(()=>de));class de{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(t),"Expected a number but found null");if("number"!=typeof s)throw new ie(Re.path(t),s.toString()+" is not a "+e);let n=de.extractNumber(e,t,r,s);return de.checkRange(t,r,s,n),de.checkMultipleOf(t,r,s,n),s}static extractNumber(e,t,r,s){let n=s;try{e!=h.LONG&&e!=h.INTEGER||(n=Math.round(n))}catch(r){throw new ie(Re.path(t),s+" is not a number of type "+e,r)}if(u(n)||(e==h.LONG||e==h.INTEGER)&&n!=s)throw new ie(Re.path(t),s.toString()+" is not a number of type "+e);return n}static checkMultipleOf(e,t,r,s){if(t.getMultipleOf()){if(s%t.getMultipleOf()!=0)throw new ie(Re.path(e),r.toString()+" is not multiple of "+t.getMultipleOf())}}static checkRange(e,t,r,s){if(t.getMinimum()&&de.numberCompare(s,t.getMinimum())<0)throw new ie(Re.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&de.numberCompare(s,t.getMaximum())>0)throw new ie(Re.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&de.numberCompare(s,t.getExclusiveMinimum())<=0)throw new ie(Re.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&de.numberCompare(s,t.getExclusiveMaximum())>0)throw new ie(Re.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}var Ae={};t(Ae,"ObjectValidator",(()=>we));class we{static validate(e,t,r,s){if(u(s))throw new ie(Re.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new ie(Re.path(e),s.toString()+" is not an Object");let n=s,a=new Set(Object.keys(n));we.checkMinMaxProperties(e,t,a),t.getPropertyNames()&&we.checkPropertyNameSchema(e,t,r,a),t.getRequired()&&we.checkRequired(e,t,n),t.getProperties()&&we.checkProperties(e,t,r,n,a),t.getPatternProperties()&&we.checkPatternProperties(e,t,r,n,a),t.getAdditionalProperties()&&we.checkAddtionalProperties(e,t,r,n,a)}static checkPropertyNameSchema(e,t,r,s){for(let n of Array.from(s.values()))try{Re.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new ie(Re.path(e),"Property name '"+n+"' does not fit the property schema")}}static checkRequired(e,t,r){for(const s of t.getRequired()??[])if(u(r[s]))throw new ie(Re.path(e),s+" is mandatory")}static checkAddtionalProperties(e,t,r,s,n){let a=t.getAdditionalProperties();if(a.getSchemaValue())for(let t of Array.from(n.values())){let n=e?[...e]:[],i=Re.validate(n,a.getSchemaValue(),r,s[t]);s[t]=i}else if(!1===a.getBooleanValue()&&n.size)throw new ie(Re.path(e),n.toString()+" are additional properties which are not allowed.")}static checkPatternProperties(e,t,r,s,n){const a=new Map;for(const e of Array.from(t.getPatternProperties().keys()))a.set(e,new RegExp(e));for(const i of Array.from(n.values())){const o=e?[...e]:[];for(const e of Array.from(a.entries()))if(e[1].test(i)){const a=Re.validate(o,t.getPatternProperties().get(e[0]),r,s[i]);s[i]=a,n.delete(i);break}}}static checkProperties(e,t,r,s,n){for(const a of Array.from(t.getProperties())){let t=s[a[0]];if(u(t))continue;let i=e?[...e]:[],o=Re.validate(i,a[1],r,t);s[a[0]]=o,n.delete(a[0])}}static checkMinMaxProperties(e,t,r){if(t.getMinProperties()&&r.size<t.getMinProperties())throw new ie(Re.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new ie(Re.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}var Oe={};t(Oe,"StringValidator",(()=>Se));class Se{static TIME=/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static DATE=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])$/;static DATETIME=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])T([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static EMAIL=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;static validate(e,t,r){if(u(r))throw new ie(Re.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new ie(Re.path(e),r.toString()+" is not String");t.getFormat()==V.TIME?Se.patternMatcher(e,t,r,Se.TIME,"time pattern"):t.getFormat()==V.DATE?Se.patternMatcher(e,t,r,Se.DATE,"date pattern"):t.getFormat()==V.DATETIME?Se.patternMatcher(e,t,r,Se.DATETIME,"date time pattern"):t.getFormat()==V.EMAIL?Se.patternMatcher(e,t,r,Se.EMAIL,"email pattern"):t.getPattern()&&Se.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new ie(Re.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMaxLength())throw new ie(Re.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new ie(Re.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class Ne{static validate(e,t,r,s,n){if(t==h.STRING)Se.validate(e,r,n);else if(t==h.LONG||t==h.INTEGER||t==h.DOUBLE||t==h.FLOAT)de.validate(t,e,r,n);else if(t==h.BOOLEAN)ge.validate(e,r,n);else if(t==h.OBJECT)we.validate(e,r,s,n);else if(t==h.ARRAY)me.validate(e,r,s,n);else{if(t!=h.NULL)throw new ie(Re.path(e),t+" is not a valid type.");Ee.validate(e,r,n)}return n}constructor(){}}class Re{static path(e){return e?e.map((e=>e.getTitle()??"")).filter((e=>!!e)).reduce(((e,t,r)=>e+(0===r?"":".")+t),""):""}static validate(e,t,r,s){if(!t)throw new ie(Re.path(e),"No schema found to validate");if(e||(e=new Array),e.push(t),u(s)&&!u(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return Re.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return Re.enumCheck(e,t,s);if(t.getType()&&Re.typeValidation(e,t,r,s),!Z.isNullOrBlank(t.getRef()))return Re.validate(e,oe.getSchemaFromRef(e[0],r,t.getRef()),r,s);if((t.getOneOf()||t.getAllOf()||t.getAnyOf())&&pe.validate(e,t,r,s),t.getNot()){let n=!1;try{Re.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new ie(Re.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new ie(Re.path(e),"Expecting a constant value : "+r);return r}static enumCheck(e,t,r){let s=!1;for(let e of t.getEnums()??[])if(e===r){s=!0;break}if(s)return r;throw new ie(Re.path(e),"Value is not one of "+t.getEnums())}static typeValidation(e,t,r,s){let n=!1,a=[];for(const i of Array.from(t.getType()?.getAllowedSchemaTypes()?.values()??[]))try{Ne.validate(e,i,t,r,s),n=!0;break}catch(e){n=!1,a.push(e)}if(!n)throw new ie(Re.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",a)}constructor(){}}class xe{validateArguments(e,t,r){return Array.from(this.getSignature().getParameters().entries()).map((s=>{let n=s[1];try{return this.validateArgument(e,t,s,n)}catch(e){const t=this.getSignature();throw new b(`Error while executing the function ${t.getNamespace()}.${t.getName()}'s parameter ${n.getParameterName()} with step name '${r?.getStatement().getStatementName()??"Unknown Step"}' with error : ${e?.message}`)}})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}validateArgument(e,t,r,s){let n,a=r[0],i=e.get(r[0]);if(u(i)&&!s.isVariableArgument())return new re(a,Re.validate(void 0,s.getSchema(),t,void 0));if(!s?.isVariableArgument())return new re(a,Re.validate(void 0,s.getSchema(),t,i));Array.isArray(i)?n=i:(n=[],u(i)?u(s.getSchema().getDefaultValue())||n.push(s.getSchema().getDefaultValue()):n.push(i));for(let e=0;e<n.length;e++)n[e]=Re.validate(void 0,s.getSchema(),t,n[e]);return new re(a,n)}async execute(e){e.setArguments(this.validateArguments(e.getArguments()??new Map,e.getSchemaRepository(),e.getStatementExecution()));try{return this.internalExecute(e)}catch(t){const r=this.getSignature();throw new b(`Error while executing the function ${r.getNamespace()}.${r.getName()} with step name '${e.getStatementExecution()?.getStatement().getStatementName()??"Unknown Step"}' with error : ${t?.message}`)}}getProbableEventSignature(e){return this.getSignature().getEvents()}}const ye=new W("Create").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1).setFormat(V.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,v.CONSTANT),M.ofEntry("schema",S.SCHEMA,!1,v.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const ve=new W("Get").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1).setFormat(V.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,v.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofAny("value")]]))]));var Ie={};t(Ie,"ExecutionException",(()=>Me));class Me extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var Pe={};t(Pe,"Expression",(()=>je));var _e={};t(_e,"LinkedList",(()=>be));var Le={};function Ce(e,t){let r=new be;r.push(e);let s=new be;for(s.push(t);!r.isEmpty()&&!s.isEmpty();){const e=r.pop(),t=s.pop();if(e===t)continue;const n=typeof e,a=typeof t;if("undefined"===n||"undefined"===a){if(!e&&!t)continue;return!1}if(n!==a)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let n=0;n<e.length;n++)r.push(e[n]),s.push(t[n])}else{if("object"!==n)return!1;{const n=Object.entries(e),a=Object.entries(t);if(n.length!==a.length)return!1;for(const[e,a]of n)r.push(a),s.push(t[e])}}}return!0}t(Le,"deepEqual",(()=>Ce));class be{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new Ue(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new Ue(t);this.length=e.length}}push(e){const t=new Ue(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.");const e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;const 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 new Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=this.head.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new b(J.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,e&&(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 new Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw new Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw new Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw new Error("List is empty so cannot remove");--this.length;const e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{const 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):this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new Ue(e,this.head),this.head.next=this.tail):(this.tail=new Ue(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new Ue(e),this}map(e,t){let r=new be,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}indexOf(e){let t=this.head,r=0;for(;t;){if(Ce(t.value,e))return r;t=t.next,++r}return-1}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class Ue{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}var Ve={};t(Ve,"StringBuilder",(()=>Be));class Be{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 b(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}var De={};t(De,"ExpressionEvaluationException",(()=>ke));class ke extends Error{constructor(e,t,r){super(J.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}var Ge={};t(Ge,"ExpressionToken",(()=>$e));class $e{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}var Fe={};t(Fe,"ExpressionTokenValue",(()=>He));class He extends $e{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return J.format("$: $",this.expression,this.element)}}var Ye={};t(Ye,"Operation",(()=>We));class We{static MULTIPLICATION=new We("*");static DIVISION=new We("/");static INTEGER_DIVISION=new We("//");static MOD=new We("%");static ADDITION=new We("+");static SUBTRACTION=new We("-");static NOT=new We("not",void 0,!0);static AND=new We("and",void 0,!0);static OR=new We("or",void 0,!0);static LESS_THAN=new We("<");static LESS_THAN_EQUAL=new We("<=");static GREATER_THAN=new We(">");static GREATER_THAN_EQUAL=new We(">=");static EQUAL=new We("=");static NOT_EQUAL=new We("!=");static BITWISE_AND=new We("&");static BITWISE_OR=new We("|");static BITWISE_XOR=new We("^");static BITWISE_COMPLEMENT=new We("~");static BITWISE_LEFT_SHIFT=new We("<<");static BITWISE_RIGHT_SHIFT=new We(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new We(">>>");static UNARY_PLUS=new We("UN: +","+");static UNARY_MINUS=new We("UN: -","-");static UNARY_LOGICAL_NOT=new We("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new We("UN: ~","~");static ARRAY_OPERATOR=new We("[");static OBJECT_OPERATOR=new We(".");static NULLISH_COALESCING_OPERATOR=new We("??");static CONDITIONAL_TERNARY_OPERATOR=new We("?");static VALUE_OF=new Map([["MULTIPLICATION",We.MULTIPLICATION],["DIVISION",We.DIVISION],["INTEGER_DIVISON",We.INTEGER_DIVISION],["MOD",We.MOD],["ADDITION",We.ADDITION],["SUBTRACTION",We.SUBTRACTION],["NOT",We.NOT],["AND",We.AND],["OR",We.OR],["LESS_THAN",We.LESS_THAN],["LESS_THAN_EQUAL",We.LESS_THAN_EQUAL],["GREATER_THAN",We.GREATER_THAN],["GREATER_THAN_EQUAL",We.GREATER_THAN_EQUAL],["EQUAL",We.EQUAL],["NOT_EQUAL",We.NOT_EQUAL],["BITWISE_AND",We.BITWISE_AND],["BITWISE_OR",We.BITWISE_OR],["BITWISE_XOR",We.BITWISE_XOR],["BITWISE_COMPLEMENT",We.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",We.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",We.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",We.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",We.UNARY_PLUS],["UNARY_MINUS",We.UNARY_MINUS],["UNARY_LOGICAL_NOT",We.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",We.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",We.ARRAY_OPERATOR],["OBJECT_OPERATOR",We.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",We.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",We.CONDITIONAL_TERNARY_OPERATOR]]);static UNARY_OPERATORS=new Set([We.ADDITION,We.SUBTRACTION,We.NOT,We.BITWISE_COMPLEMENT,We.UNARY_PLUS,We.UNARY_MINUS,We.UNARY_LOGICAL_NOT,We.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([We.MULTIPLICATION,We.DIVISION,We.INTEGER_DIVISION,We.MOD,We.ADDITION,We.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([We.NOT,We.AND,We.OR,We.LESS_THAN,We.LESS_THAN_EQUAL,We.GREATER_THAN,We.GREATER_THAN_EQUAL,We.EQUAL,We.NOT_EQUAL,We.NULLISH_COALESCING_OPERATOR]);static BITWISE_OPERATORS=new Set([We.BITWISE_AND,We.BITWISE_COMPLEMENT,We.BITWISE_LEFT_SHIFT,We.BITWISE_OR,We.BITWISE_RIGHT_SHIFT,We.BITWISE_UNSIGNED_RIGHT_SHIFT,We.BITWISE_XOR]);static CONDITIONAL_OPERATORS=new Set([We.CONDITIONAL_TERNARY_OPERATOR]);static OPERATOR_PRIORITY=new Map([[We.UNARY_PLUS,1],[We.UNARY_MINUS,1],[We.UNARY_LOGICAL_NOT,1],[We.UNARY_BITWISE_COMPLEMENT,1],[We.ARRAY_OPERATOR,1],[We.OBJECT_OPERATOR,1],[We.MULTIPLICATION,2],[We.DIVISION,2],[We.INTEGER_DIVISION,2],[We.MOD,2],[We.ADDITION,3],[We.SUBTRACTION,3],[We.BITWISE_LEFT_SHIFT,4],[We.BITWISE_RIGHT_SHIFT,4],[We.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[We.LESS_THAN,5],[We.LESS_THAN_EQUAL,5],[We.GREATER_THAN,5],[We.GREATER_THAN_EQUAL,5],[We.EQUAL,6],[We.NOT_EQUAL,6],[We.BITWISE_AND,7],[We.BITWISE_XOR,8],[We.BITWISE_OR,9],[We.AND,10],[We.OR,11],[We.NULLISH_COALESCING_OPERATOR,11],[We.CONDITIONAL_TERNARY_OPERATOR,12]]);static OPERATORS=new Set([...Array.from(We.ARITHMETIC_OPERATORS),...Array.from(We.LOGICAL_OPERATORS),...Array.from(We.BITWISE_OPERATORS),We.ARRAY_OPERATOR,We.OBJECT_OPERATOR,...Array.from(We.CONDITIONAL_OPERATORS)].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(We.ARITHMETIC_OPERATORS),...Array.from(We.LOGICAL_OPERATORS),...Array.from(We.BITWISE_OPERATORS),We.ARRAY_OPERATOR,We.OBJECT_OPERATOR,...Array.from(We.CONDITIONAL_OPERATORS)].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(We.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[We.ADDITION,We.UNARY_PLUS],[We.SUBTRACTION,We.UNARY_MINUS],[We.NOT,We.UNARY_LOGICAL_NOT],[We.BITWISE_COMPLEMENT,We.UNARY_BITWISE_COMPLEMENT],[We.UNARY_PLUS,We.UNARY_PLUS],[We.UNARY_MINUS,We.UNARY_MINUS],[We.UNARY_LOGICAL_NOT,We.UNARY_LOGICAL_NOT],[We.UNARY_BITWISE_COMPLEMENT,We.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(We.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,r=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=r}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return We.VALUE_OF.get(e)}toString(){return this.operator}}class je extends $e{tokens=new be;ops=new be;constructor(e,t,r,s){super(e||""),t&&this.tokens.push(t),r&&this.tokens.push(r),s&&this.ops.push(s),this.evaluate()}getTokens(){return this.tokens}getOperations(){return this.ops}evaluate(){const e=this.expression.length;let t,r="",s=new Be(""),n=0,a=!1;for(;n<e;){switch(r=this.expression[n],t=s.toString(),r){case" ":a=this.processTokenSepearator(s,t,a);break;case"(":n=this.processSubExpression(e,s,t,n,a),a=!1;break;case")":throw new ke(this.expression,"Extra closing parenthesis found");case"]":throw new ke(this.expression,"Extra closing square bracket found");case"'":case'"':{let t=this.processStringLiteral(e,r,n);n=t.getT1(),a=t.getT2();break}case"?":if(n+1<e&&"?"!=this.expression.charAt(n+1)&&0!=n&&"?"!=this.expression.charAt(n-1))n=this.processTernaryOperator(e,s,t,n,a);else{let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==We.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}break;default:let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==We.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}++n}if(t=s.toString(),!Z.isNullOrBlank(t)){if(We.OPERATORS.has(t))throw new ke(this.expression,"Expression is ending with an operator");this.tokens.push(new $e(t))}}processStringLiteral(e,t,r){let s="",n=r+1;for(;n<e;n++){let e=this.expression.charAt(n);if(e==t&&"\\"!=this.expression.charAt(n-1))break;s+=e}if(n==e&&this.expression.charAt(n-1)!=t)throw new ke(this.expression,"Missing string ending marker "+t);let a=new re(n,!1);return this.tokens.push(new He(s,s)),a}process(e,t,r){let s=1;for(++r;r<e&&0!=s;){let e=this.expression.charAt(r);"]"==e?--s:"["==e&&++s,0!=s&&(t.append(e),r++)}return this.tokens.push(new je(t.toString())),t.setLength(0),new re(r,!1)}processOthers(e,t,r,s,n,a){let i=t-n;i=i<We.BIGGEST_OPERATOR_SIZE?i:We.BIGGEST_OPERATOR_SIZE;for(let e=i;e>0;e--){let t=this.expression.substring(n,n+e);if(We.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return Z.isNullOrBlank(s)||(this.tokens.push(new $e(s)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new re(n+e-1,a)}return r.append(e),new re(n,!1)}processTernaryOperator(e,t,r,s,n){if(n)throw new ke(this.expression,"Ternary operator is followed by an operator");""!=r.trim()&&(this.tokens.push(new je(r)),t.setLength(0));let a=1,i="";const o=++s;for(;s<e&&a>0;)i=this.expression.charAt(s),"?"==i?++a:":"==i&&--a,++s;if(":"!=i)throw new ke(this.expression,"':' operater is missing");if(s>=e)throw new ke(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(We.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(We.UNARY_OPERATORS.has(e)){const t=this.tokens.pop();this.tokens.push(new je("",t,void 0,e))}else{let t=this.tokens.pop(),r=this.tokens.pop();this.tokens.push(new je("",r,t,e))}}this.ops.push(We.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new je(this.expression.substring(o,s-1)));const u=this.expression.substring(s);if(""===u.trim())throw new ke(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new je(u)),e-1}processSubExpression(e,t,r,s,n){if(We.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!Z.isNullOrBlank(r))throw new ke(this.expression,J.format("Unkown token : $ found.",r));let a=1;const i=new Be;let o=this.expression.charAt(s);for(s++;s<e&&a>0;)o=this.expression.charAt(s),"("==o?a++:")"==o&&a--,0!=a&&(i.append(o),s++);if(")"!=o)throw new ke(this.expression,"Missing a closed parenthesis");for(;i.length()>2&&"("==i.charAt(0)&&")"==i.charAt(i.length()-1);)i.deleteCharAt(0),i.setLength(i.length()-1);return this.tokens.push(new je(i.toString().trim())),s}processTokenSepearator(e,t,r){return Z.isNullOrBlank(t)||(We.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,We.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new $e(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!We.UNARY_OPERATORS.has(r))throw new ke(this.expression,J.format("Extra operator $ found.",r));{const e=We.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(We.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new je("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new je("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=We.OPERATOR_PRIORITY.get(e),s=We.OPERATOR_PRIORITY.get(t);if(!r||!s)throw new Error("Unknown operators provided");return s<r}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokens.get(0).toString():"Error: No tokens";let e=new Be,t=0;const r=this.ops.toArray(),s=this.tokens.toArray();for(let n=0;n<r.length;n++)if(r[n].getOperator().startsWith("UN: "))e.append("(").append(r[n].getOperator().substring(4)).append(s[t]instanceof je?s[t].toString():s[t]).append(")"),t++;else if(r[n]==We.CONDITIONAL_TERNARY_OPERATOR){let r=s[t++];e.insert(0,r.toString()),e.insert(0,":"),r=s[t++],e.insert(0,r.toString()),e.insert(0,"?"),r=s[t++],e.insert(0,r.toString()).append(")"),e.insert(0,"(")}else{if(0==t){const r=s[t++];e.insert(0,r.toString())}const a=s[t++];e.insert(0,r[n].getOperator()).insert(0,a.toString()).insert(0,"(").append(")")}return e.toString()}equals(e){return this.expression==e.expression}}var Xe={};t(Xe,"ExpressionEvaluator",(()=>pr));var qe={};t(qe,"LogicalNullishCoalescingOperator",(()=>Ke));var Je={};t(Je,"BinaryOperator",(()=>Qe));class Qe{nullCheck(e,t,r){if(u(e)||u(t))throw new Me(J.format("$ cannot be applied to a null value",r.getOperatorName()))}}class Ke extends Qe{apply(e,t){return u(e)?t:e}}var ze={};t(ze,"ArithmeticAdditionOperator",(()=>Ze));class Ze extends Qe{apply(e,t){return this.nullCheck(e,t,We.ADDITION),e+t}}var et={};t(et,"ArithmeticDivisionOperator",(()=>tt));class tt extends Qe{apply(e,t){return this.nullCheck(e,t,We.DIVISION),e/t}}var rt={};t(rt,"ArithmeticIntegerDivisionOperator",(()=>st));class st extends Qe{apply(e,t){return this.nullCheck(e,t,We.DIVISION),Math.floor(e/t)}}var nt={};t(nt,"ArithmeticModulusOperator",(()=>at));class at extends Qe{apply(e,t){return this.nullCheck(e,t,We.MOD),e%t}}var it={};t(it,"ArithmeticMultiplicationOperator",(()=>ot));class ot extends Qe{apply(e,t){this.nullCheck(e,t,We.MULTIPLICATION);const r="string"==typeof e;if(r||"string"===typeof t){let s=r?e:t,n=r?t:e,a="",i=n<0;n=Math.abs(n);let o=Math.floor(n);for(;o-- >0;)a+=s;let u=Math.floor(s.length*(n-Math.floor(n)));if(u<0&&(u=-u),0!=u&&(a+=s.substring(0,u)),i){let e="";for(let t=a.length-1;t>=0;t--)e+=a[t];return e}return a}return e*t}}var ut={};t(ut,"ArithmeticSubtractionOperator",(()=>pt));class pt extends Qe{apply(e,t){return this.nullCheck(e,t,We.SUBTRACTION),e-t}}var lt={};t(lt,"ArrayOperator",(()=>ht));class ht extends Qe{apply(e,t){if(!e)throw new Me("Cannot apply array operator on a null value");if(!t)throw new Me("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new Me(J.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new Me(J.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var mt={};t(mt,"BitwiseAndOperator",(()=>ct));class ct extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_AND),e&t}}var gt={};t(gt,"BitwiseLeftShiftOperator",(()=>ft));class ft extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_LEFT_SHIFT),e<<t}}var Et={};t(Et,"BitwiseOrOperator",(()=>Tt));class Tt extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_OR),e|t}}var dt={};t(dt,"BitwiseRightShiftOperator",(()=>At));class At extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_RIGHT_SHIFT),e>>t}}var wt={};t(wt,"BitwiseUnsignedRightShiftOperator",(()=>Ot));class Ot extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var St={};t(St,"BitwiseXorOperator",(()=>Nt));class Nt extends Qe{apply(e,t){return this.nullCheck(e,t,We.BITWISE_XOR),e^t}}var Rt={};t(Rt,"LogicalAndOperator",(()=>vt));var xt={};t(xt,"PrimitiveUtil",(()=>yt));class yt{static findPrimitiveNullAsBoolean(e){if(u(e))return new re(h.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new Me(J.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new re(h.BOOLEAN,r):"string"===t?new re(h.STRING,r):yt.findPrimitiveNumberType(r)}static findPrimitive(e){if(u(e))return new re(h.NULL,void 0);let t=typeof e;if("object"===t)throw new Me(J.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new re(h.BOOLEAN,r):"string"===t?new re(h.STRING,r):yt.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(u(e)||Array.isArray(e)||"object"==typeof e)throw new Me(J.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new re(h.LONG,e):new re(h.DOUBLE,e)}catch(e){throw new Me(J.format("Unable to convert $ to a number.",t),e)}}static compare(e,t){if(e==t)return 0;if(u(e)||u(t))return u(e)?-1:1;if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return e.length-t.length;for(let r=0;r<e.length;r++){let s=this.compare(e[r],t[r]);if(0!=s)return s}return 0}return Array.isArray(e)?-1:1}const r=typeof e,s=typeof t;return"object"===r||"object"===s?("object"===r&&"object"===s&&Object.keys(e).forEach((r=>{let s=this.compare(e[r],t[r]);if(0!=s)return s})),"object"===r?-1:1):this.comparePrimitive(e,t)}static comparePrimitive(e,t){return u(e)||u(t)?u(e)&&u(t)?0:u(e)?-1:1:e==t?0:"boolean"==typeof e||"boolean"==typeof t?e?-1:1:"string"==typeof e||"string"==typeof t?e+""<t+""?-1:1:"number"==typeof e||"number"==typeof t?e-t:0}static baseNumberType(e){return Number.isInteger(e)?h.LONG:h.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class vt extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var It={};t(It,"LogicalEqualOperator",(()=>Mt));class Mt extends Qe{apply(e,t){return Ce(e,t)}}var Pt={};t(Pt,"LogicalGreaterThanEqualOperator",(()=>_t));class _t extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var Lt={};t(Lt,"LogicalGreaterThanOperator",(()=>Ct));class Ct extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var bt={};t(bt,"LogicalLessThanEqualOperator",(()=>Ut));class Ut extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var Vt={};t(Vt,"LogicalLessThanOperator",(()=>Bt));class Bt extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()==h.BOOLEAN||s.getT1()==h.BOOLEAN)throw new Me(J.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var Dt={};t(Dt,"LogicalNotEqualOperator",(()=>kt));class kt extends Qe{apply(e,t){return!Ce(e,t)}}var Gt={};t(Gt,"LogicalOrOperator",(()=>$t));class $t extends Qe{apply(e,t){const r=yt.findPrimitiveNullAsBoolean(e),s=yt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=h.BOOLEAN)throw new Me(J.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var Ft={};t(Ft,"ObjectOperator",(()=>Ht));class Ht extends Qe{apply(e,t){if(!e)throw new Me("Cannot apply array operator on a null value");if(!t)throw new Me("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new Me(J.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var Yt={};t(Yt,"ArithmeticUnaryMinusOperator",(()=>Xt));var Wt={};t(Wt,"UnaryOperator",(()=>jt));class jt{nullCheck(e,t){if(u(e))throw new Me(J.format("$ cannot be applied to a null value",t.getOperatorName()))}}class Xt extends jt{apply(e){return this.nullCheck(e,We.UNARY_MINUS),yt.findPrimitiveNumberType(e),-e}}var qt={};t(qt,"ArithmeticUnaryPlusOperator",(()=>Jt));class Jt extends jt{apply(e){return this.nullCheck(e,We.UNARY_PLUS),yt.findPrimitiveNumberType(e),e}}var Qt={};t(Qt,"BitwiseComplementOperator",(()=>Kt));class Kt extends jt{apply(e){this.nullCheck(e,We.UNARY_BITWISE_COMPLEMENT);let t=yt.findPrimitiveNumberType(e);if(t.getT1()!=h.INTEGER&&t.getT1()!=h.LONG)throw new Me(J.format("Unable to apply bitwise operator on $",e));return~e}}var zt={};t(zt,"LogicalNotOperator",(()=>Zt));class Zt extends jt{apply(e){return!e&&""!==e}}var er={};t(er,"LiteralTokenValueExtractor",(()=>nr));var tr={};t(tr,"TokenValueExtractor",(()=>rr));class rr{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new b(J.format("Token $ doesn't start with $",e,t));return this.getValueInternal(e)}retrieveElementFrom(e,t,r,s){if(u(s))return;if(t.length==r)return s;let n=t[r].split(rr.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!Z.isNullOrBlank(e))).reduce(((s,n,a)=>this.resolveForEachPartOfTokenWithBrackets(e,t,r,n,s,a)),s);return this.retrieveElementFrom(e,t,r+1,n)}resolveForEachPartOfTokenWithBrackets(e,t,r,s,n,a){if(!u(n)){if(0===a){if(Array.isArray(n)){if("length"===s)return n.length;try{let e=parseInt(s);if(isNaN(e))throw new Error(J.format("$ is not a number",e));if(e>=n.length)return;return n[e]}catch(t){throw new ke(e,J.format("$ couldn't be parsed into integer in $",s,e),t)}}return this.checkIfObject(e,t,r,n),n[s]}if(s?.startsWith('"')){if(!s.endsWith('"')||1==s.length||2==s.length)throw new ke(e,J.format("$ is missing a double quote or empty key found",e));return this.checkIfObject(e,t,r,n),n[s.substring(1,s.length-1)]}try{let t=parseInt(s);if(isNaN(t))throw new Error(J.format("$ is not a number",t));if(!Array.isArray(n))throw new ke(e,J.format("Expecting an array with index $ while processing the expression",t,e));if(t>=n.length)return;return n[t]}catch(t){throw new ke(e,J.format("$ couldn't be parsed into integer in $",s,e),t)}}}checkIfObject(e,t,r,s){if("object"!=typeof s||Array.isArray(s))throw new ke(e,J.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const sr=new Map([["true",!0],["false",!1],["null",void 0]]);class nr extends rr{static INSTANCE=new nr;getValueInternal(e){if(!Z.isNullOrBlank(e))return e=e.trim(),sr.has(e)?sr.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t=Number(e);if(isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new ke(e,J.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new ke(e,J.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}var ar={},ir={};t(ir,"ConditionalTernaryOperator",(()=>or));class or extends class{nullCheck(e,t,r,s){if(u(e)||u(t)||u(r))throw new Me(J.format("$ cannot be applied to a null value",s.getOperatorName()))}}{apply(e,t,r){return e?t:r}}e(ar,ir);class ur extends rr{static PREFIX="_internal.";values=new Map;addValue(e,t){this.values.set(e,t)}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.values.get(r))}getPrefix(){return ur.PREFIX}}class pr{static UNARY_OPERATORS_MAP=new Map([[We.UNARY_BITWISE_COMPLEMENT,new Kt],[We.UNARY_LOGICAL_NOT,new Zt],[We.UNARY_MINUS,new Xt],[We.UNARY_PLUS,new Jt]]);static TERNARY_OPERATORS_MAP=new Map([[We.CONDITIONAL_TERNARY_OPERATOR,new or]]);static BINARY_OPERATORS_MAP=new Map([[We.ADDITION,new Ze],[We.DIVISION,new tt],[We.INTEGER_DIVISION,new st],[We.MOD,new at],[We.MULTIPLICATION,new ot],[We.SUBTRACTION,new pt],[We.BITWISE_AND,new ct],[We.BITWISE_LEFT_SHIFT,new ft],[We.BITWISE_OR,new Tt],[We.BITWISE_RIGHT_SHIFT,new At],[We.BITWISE_UNSIGNED_RIGHT_SHIFT,new Ot],[We.BITWISE_XOR,new Nt],[We.AND,new vt],[We.EQUAL,new Mt],[We.GREATER_THAN,new Ct],[We.GREATER_THAN_EQUAL,new _t],[We.LESS_THAN,new Bt],[We.LESS_THAN_EQUAL,new Ut],[We.OR,new $t],[We.NOT_EQUAL,new kt],[We.NULLISH_COALESCING_OPERATOR,new Ke],[We.ARRAY_OPERATOR,new ht],[We.OBJECT_OPERATOR,new Ht]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(pr.UNARY_OPERATORS_MAP.keys());internalTokenValueExtractor=new ur;constructor(e){e instanceof je?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){const t=this.processNestingExpression(this.expression,e);return this.expression=t.getT1(),this.exp=t.getT2(),(e=new Map(e.entries())).set(this.internalTokenValueExtractor.getPrefix(),this.internalTokenValueExtractor),this.evaluateExpression(this.exp,e)}processNestingExpression(e,t){let r=0,s=0;const n=new be;for(;s<e.length-1;){if("{"==e.charAt(s)&&"{"==e.charAt(s+1))0==r&&n.push(new re(s+2,-1)),r++,s++;else if("}"==e.charAt(s)&&"}"==e.charAt(s+1)){if(r--,r<0)throw new ke(e,"Expecting {{ nesting path operator to be started before closing");0==r&&n.push(n.pop().setT2(s)),s++}s++}let a=this.replaceNestingExpression(e,t,n);return new re(a,new je(a))}replaceNestingExpression(e,t,r){let s=e;for(var n of r.toArray()){if(-1==n.getT2())throw new ke(e,"Expecting }} nesting path operator to be closed");let r=new pr(s.substring(n.getT1(),n.getT2())).evaluate(t);s=s.substring(0,n.getT1()-2)+r+s.substring(n.getT2()+2)}return s}getExpression(){return this.exp||(this.exp=new je(this.expression)),this.exp}getExpressionString(){return this.expression}evaluateExpression(e,t){let r=e.getOperations(),s=e.getTokens();for(;!r.isEmpty();){let e=r.pop(),o=s.pop();if(pr.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,o)));else if(e==We.OBJECT_OPERATOR||e==We.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,o);else if(e==We.CONDITIONAL_TERNARY_OPERATOR){const r=s.pop(),u=s.pop();var n=this.getValueFromToken(t,u),a=this.getValueFromToken(t,r),i=this.getValueFromToken(t,o);s.push(this.applyTernaryOperation(e,n,a,i))}else{const r=s.pop();n=this.getValueFromToken(t,r),a=this.getValueFromToken(t,o);s.push(this.applyBinaryOperation(e,n,a))}}if(s.isEmpty())throw new Me(J.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new Me(J.format("Expression : $ evaluated multiple values $",e,s));const o=s.get(0);if(o instanceof He)return o.getElement();if(!(o instanceof je))return this.getValueFromToken(t,o);throw new Me(J.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const a=new be,i=new be;if(!s||!n)return;do{i.push(s),n instanceof je?a.push(new He(n.toString(),this.evaluateExpression(n,e))):n&&a.push(n),n=r.isEmpty()?void 0:r.pop(),s=t.isEmpty()?void 0:t.pop()}while(s==We.OBJECT_OPERATOR||s==We.ARRAY_OPERATOR);n&&(n instanceof je?a.push(new He(n.toString(),this.evaluateExpression(n,e))):a.push(n)),s&&t.push(s);let o=a.pop();if(o instanceof He&&"object"==typeof o.getTokenValue()){const e=(new Date).getTime()+""+Math.round(1e3*Math.random());this.internalTokenValueExtractor.addValue(e,o.getTokenValue()),o=new $e(ur.PREFIX+e)}let u=new Be(o instanceof He?o.getTokenValue():o.toString());for(;!a.isEmpty();)o=a.pop(),s=i.pop(),u.append(s.getOperator()).append(o instanceof He?o.getTokenValue():o.toString()),s==We.ARRAY_OPERATOR&&u.append("]");let p=u.toString(),l=p.substring(0,p.indexOf(".")+1);if(l.length>2&&e.has(l))r.push(new He(p,this.getValue(p,e)));else{let e;try{e=nr.INSTANCE.getValue(p)}catch(t){e=p}r.push(new He(p,e))}}applyTernaryOperation(e,t,r,s){let n=pr.TERNARY_OPERATORS_MAP.get(e);if(!n)throw new ke(this.expression,J.format("No operator found to evaluate $",this.getExpression()));return new He(e.toString(),n.apply(t,r,s))}applyBinaryOperation(e,t,r){let s=typeof t,n=typeof r,a=pr.BINARY_OPERATORS_MAP.get(e);if(("object"===s||"object"===n)&&e!==We.EQUAL&&e!==We.NOT_EQUAL&&e!==We.NULLISH_COALESCING_OPERATOR)throw new ke(this.expression,J.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));if(!a)throw new ke(this.expression,J.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new He(e.toString(),a.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new ke(this.expression,J.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=pr.UNARY_OPERATORS_MAP.get(e);if(!r)throw new ke(this.expression,J.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new He(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof je?this.evaluateExpression(t,e):t instanceof He?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return nr.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??nr.INSTANCE).getValue(e)}}const lr=new W("Set").setNamespace(a.SYSTEM_CTX).setParameters(new Map([M.ofEntry("name",(new S).setName("name").setType(w.of(h.STRING)).setMinLength(1),!1,v.CONSTANT),M.ofEntry("value",S.ofAny("value"))])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const hr=new W("GenerateEvent").setNamespace(a.SYSTEM).setParameters(new Map([M.ofEntry("eventName",S.ofString("eventName").setDefaultValue("output")),M.ofEntry("results",S.ofObject("results").setProperties(new Map([["name",S.ofString("name")],["value",M.EXPRESSION]])),!0)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));class mr extends xe{static CONDITION="condition";static SIGNATURE=new W("If").setNamespace(a.SYSTEM).setParameters(new Map([M.ofEntry(mr.CONDITION,S.of(mr.CONDITION,h.BOOLEAN))])).setEvents(new Map([k.eventMapEntry(k.TRUE,new Map),k.eventMapEntry(k.FALSE,new Map),k.outputEventMapEntry(new Map)]));getSignature(){return mr.SIGNATURE}async internalExecute(e){var t=e.getArguments()?.get(mr.CONDITION);return new H([$.of(t?k.TRUE:k.FALSE,new Map),$.outputOf(new Map)])}}const cr=new W("CountLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([M.ofEntry("count",S.of("count",h.INTEGER).setDefaultValue(1))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",S.of("index",h.INTEGER)]])),k.outputEventMapEntry(new Map([["value",S.of("value",h.INTEGER)]]))]));const gr=new W("RangeLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([M.ofEntry("from",S.of("from",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(0)),M.ofEntry("to",S.of("to",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(1)),M.ofEntry("step",S.of("step",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE).setDefaultValue(1).setNot((new S).setConstant(0)))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",S.of("index",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)]])),k.outputEventMapEntry(new Map([["value",S.of("value",h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE)]]))]));const fr=new W("Add").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));const Er=[()=>new Map([["value",new M("value",S.ofNumber("value"))]]),()=>new Map([["value1",new M("value1",S.ofNumber("value1"))],["value2",new M("value2",S.ofNumber("value2"))]])];class Tr extends xe{constructor(e,t,r=1,...s){super(),s&&s.length||(s=[h.DOUBLE]),this.parametersNumber=r,this.mathFunction=t,this.signature=new W(e).setNamespace(a.MATH).setParameters(Er[r-1]()).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new S).setType(w.of(...s)).setName("value")]]))]))}getSignature(){return this.signature}async internalExecute(e){let t,r=yt.findPrimitiveNumberType(e.getArguments()?.get(1==this.parametersNumber?"value":"value1")).getT2();return 2==this.parametersNumber&&(t=yt.findPrimitiveNumberType(e.getArguments()?.get("value2")).getT2()),new H([$.outputOf(new Map([["value",this.mathFunction.call(this,r,t)]]))])}}class dr extends xe{static SIGNATURE=new W("Hypotenuse").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new S).setType(w.of(h.DOUBLE)).setName("value")]]))]));constructor(){super()}getSignature(){return dr.SIGNATURE}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>e+t*t),0))]]))])}}const Ar=new W("Maximum").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));const wr=new W("Minimum").setNamespace(a.MATH).setParameters(new Map([["value",new M("value",S.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",S.ofNumber("value")]]))]));var Or={};t(Or,"MapUtil",(()=>Sr)),t(Or,"MapEntry",(()=>Nr));class Sr{static of(e,t,r,s,n,a,i,o,p,l,h,m,c,g,f,E,T,d,A,w){const O=new Map;return u(e)||u(t)||O.set(e,t),u(r)||u(s)||O.set(r,s),u(n)||u(a)||O.set(n,a),u(i)||u(o)||O.set(i,o),u(p)||u(l)||O.set(p,l),u(h)||u(m)||O.set(h,m),u(c)||u(g)||O.set(c,g),u(f)||u(E)||O.set(f,E),u(T)||u(d)||O.set(T,d),u(A)||u(w)||O.set(A,w),O}static ofArrayEntries(...e){const t=new Map;for(const[r,s]of e)t.set(r,s);return t}static entry(e,t){return new Nr(e,t)}static ofEntries(...e){const t=new Map;for(const r of e)t.set(r.k,r.v);return t}static ofEntriesArray(...e){const t=new Map;for(let r=0;r<e.length;r++)t.set(e[r][0],e[r][1]);return t}constructor(){}}class Nr{constructor(e,t){this.k=e,this.v=t}}class Rr extends xe{static SIGNATURE=new W("Random").setNamespace(a.MATH).setEvents(new Map([k.outputEventMapEntry(Sr.of("value",S.ofDouble("value")))]));getSignature(){return Rr.SIGNATURE}async internalExecute(e){return new H([$.outputOf(new Map([["value",Math.random()]]))])}}const xr={Absolute:new Tr("Absolute",(e=>Math.abs(e)),1,h.INTEGER,h.LONG,h.FLOAT,h.DOUBLE),ACosine:new Tr("ArcCosine",(e=>Math.acos(e))),ASine:new Tr("ArcSine",(e=>Math.asin(e))),ATangent:new Tr("ArcTangent",(e=>Math.atan(e))),Ceiling:new Tr("Ceiling",(e=>Math.ceil(e))),Cosine:new Tr("Cosine",(e=>Math.cos(e))),CosineH:new Tr("HyperbolicCosine",(e=>Math.cosh(e))),CubeRoot:new Tr("CubeRoot",(e=>Math.cbrt(e))),Exponential:new Tr("Exponential",(e=>Math.exp(e))),Expm1:new Tr("ExponentialMinus1",(e=>Math.expm1(e))),Floor:new Tr("Floor",(e=>Math.floor(e))),Log:new Tr("LogNatural",(e=>Math.log(e))),Log10:new Tr("Log10",(e=>Math.log10(e))),Round:new Tr("Round",(e=>Math.round(e)),1,h.INTEGER,h.LONG),Sine:new Tr("Sine",(e=>Math.sin(e))),SineH:new Tr("HyperbolicSine",(e=>Math.sinh(e))),Tangent:new Tr("Tangent",(e=>Math.tan(e))),TangentH:new Tr("HyperbolicTangent",(e=>Math.tanh(e))),ToDegrees:new Tr("ToDegrees",(e=>e*(Math.PI/180))),ToRadians:new Tr("ToRadians",(e=>e*(180/Math.PI))),SquareRoot:new Tr("SquareRoot",(e=>Math.sqrt(e))),ArcTangent:new Tr("ArcTangent2",((e,t)=>Math.atan2(e,t)),2),Power:new Tr("Power",((e,t)=>Math.pow(e,t)),2),Add:new class extends xe{getSignature(){return fr}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>e+t),0)]]))])}},Hypotenuse:new dr,Maximum:new class extends xe{getSignature(){return Ar}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t>e?t:e))]]))])}},Minimum:new class extends xe{getSignature(){return wr}async internalExecute(e){let t=e.getArguments()?.get("value");return new H([$.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t<e?t:e))]]))])}},Random:new Rr};class yr{find(e,t){if(e==a.MATH)return xr[t]}}var vr={};t(vr,"HybridRepository",(()=>Ir));class Ir{constructor(...e){this.repos=e}find(e,t){for(let r of this.repos){let s=r.find(e,t);if(s)return s}}}function Mr(e){return[e.getSignature().getName(),e]}const Pr=new Map([[a.SYSTEM_CTX,new Map([Mr(new class extends xe{getSignature(){return ye}async internalExecute(e){const t=e?.getArguments()?.get("name");if(e?.getContext()?.has(t))throw new b(J.format("Context already has an element for '$' ",t));let r=S.from(e?.getArguments()?.get("schema"));if(!r)throw new b("Schema is not supplied.");return e.getContext().set(t,new X(r,u(r.getDefaultValue())?void 0:r.getDefaultValue())),new H([$.outputOf(new Map)])}}),Mr(new class extends xe{getSignature(){return ve}async internalExecute(e){const t=e?.getArguments()?.get("name");if(!e.getContext()?.has(t))throw new b(J.format("Context don't have an element for '$' ",t));return new H([$.outputOf(new Map(["value",e.getContext()?.get(t)?.getElement()]))])}}),Mr(new class extends xe{getSignature(){return lr}async internalExecute(e){let t=e?.getArguments()?.get("name");if(Z.isNullOrBlank(t))throw new b("Empty string is not a valid name for the context element");let r=e?.getArguments()?.get("value");const s=new je(t),n=s.getTokens().peekLast();if(!n.getExpression().startsWith("Context")||n instanceof je||n instanceof He&&!n.getElement().toString().startsWith("Context"))throw new Me(J.format("The context path $ is not a valid path in context",t));for(const e of s.getOperations().toArray())if(e!=We.ARRAY_OPERATOR&&e!=We.OBJECT_OPERATOR)throw new Me(J.format("Expected a reference to the context location, but found an expression $",t));for(let r=0;r<s.getTokens().size();r++){let n=s.getTokens().get(r);n instanceof je&&s.getTokens().set(r,new He(t,new pr(n).evaluate(e.getValuesMap())))}return this.modifyContext(e,t,r,s)}modifyContext(e,t,r,s){const n=s.getTokens();n.removeLast();const a=s.getOperations();a.removeLast();let i=e.getContext()?.get(n.removeLast().getExpression());if(u(i))throw new b(J.format("Context doesn't have any element with name '$' ",t));if(a.isEmpty())return i.setElement(r),new H([$.outputOf(new Map)]);let o=i.getElement(),p=a.removeLast(),l=n.removeLast(),h=l instanceof He?l.getElement():l.getExpression();for(u(o)&&(o=p==We.OBJECT_OPERATOR?{}:[],i.setElement(o));!a.isEmpty();)o=p==We.OBJECT_OPERATOR?this.getDataFromObject(o,h,a.peekLast()):this.getDataFromArray(o,h,a.peekLast()),p=a.removeLast(),l=n.removeLast(),h=l instanceof He?l.getElement():l.getExpression();return p==We.OBJECT_OPERATOR?this.putDataInObject(o,h,r):this.putDataInArray(o,h,r),new H([$.outputOf(new Map)])}getDataFromArray(e,t,r){if(!Array.isArray(e))throw new b(J.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new b(J.format("Expected an array index but found $",t));if(s<0)throw new b(J.format("Array index is out of bound - $",t));let n=e[s];return u(n)&&(n=r==We.OBJECT_OPERATOR?{}:[],e[s]=n),n}getDataFromObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new b(J.format("Expected an object but found $",e));let s=e[t];return u(s)&&(s=r==We.OBJECT_OPERATOR?{}:[],e[t]=s),s}putDataInArray(e,t,r){if(!Array.isArray(e))throw new b(J.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new b(J.format("Expected an array index but found $",t));if(s<0)throw new b(J.format("Array index is out of bound - $",t));e[s]=r}putDataInObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new b(J.format("Expected an object but found $",e));e[t]=r}})])],[a.SYSTEM_LOOP,new Map([Mr(new class extends xe{getSignature(){return gr}async internalExecute(e){let t=e.getArguments()?.get("from"),r=e.getArguments()?.get("to"),s=e.getArguments()?.get("step");const n=s>0;let a=t,i=!1;return new H({next(){if(i)return;if(n&&a>=r||!n&&a<=r)return i=!0,$.outputOf(new Map([["value",a]]));const e=$.of(k.ITERATION,new Map([["index",a]]));return a+=s,e}})}}),Mr(new class extends xe{getSignature(){return cr}async internalExecute(e){let t=e.getArguments()?.get("count"),r=0;return new H({next(){if(r>=t)return $.outputOf(new Map([["value",r]]));const e=$.of(k.ITERATION,new Map([["index",r]]));return++r,e}})}})])],[a.SYSTEM,new Map([Mr(new mr),Mr(new class extends xe{getSignature(){return hr}async internalExecute(e){const t=e.getEvents(),r=e.getArguments()?.get("eventName"),s=e?.getArguments()?.get("results").map((t=>{let r=t.value;if(u(r))throw new b("Expect a value object");let s=r.value;return r.isExpression&&(s=new pr(s).evaluate(e.getValuesMap())),[t.name,s]})).reduce(((e,t)=>(e.set(t[0],t[1]),e)),new Map);return t?.has(r)||t?.set(r,[]),t?.get(r)?.push(s),new H([$.outputOf(new Map)])}})])]]);class _r extends Ir{constructor(){super({find:(e,t)=>Pr.get(e)?.get(t)},new yr)}}var Lr={};t(Lr,"ArrayUtil",(()=>Cr));class Cr{static removeAListFrom(e,t){if(!(t&&e&&e.length&&t.length))return;const r=new Set(t);for(let t=0;t<e.length;t++)r.has(e[t])&&(e.splice(t,1),t--)}static of(...e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r];return t}constructor(){}}var br={};t(br,"StatementExecution",(()=>Br));var Ur={};t(Ur,"StatementMessage",(()=>Vr));class Vr{constructor(e,t){this.message=t,this.messageType=e}getMessageType(){return this.messageType}setMessageType(e){return this.messageType=e,this}getMessage(){return this.message}setMessage(e){return this.message=e,this}toString(){return`${this.messageType} : ${this.message}`}}class Br{messages=new Array;dependencies=new Set;constructor(e){this.statement=e}getStatement(){return this.statement}setStatement(e){return this.statement=e,this}getMessages(){return this.messages}setMessages(e){return this.messages=e,this}getDependencies(){return this.dependencies}setDependencies(e){return this.dependencies=e,this}getUniqueKey(){return this.statement.getStatementName()}addMessage(e,t){this.messages.push(new Vr(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof Br))return!1;return e.statement.equals(this.statement)}}var Dr={};t(Dr,"ContextTokenValueExtractor",(()=>kr));class kr extends rr{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.context.get(r)?.getElement())}getPrefix(){return kr.PREFIX}}var Gr={};t(Gr,"OutputMapTokenValueExtractor",(()=>$r));class $r extends rr{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=1,s=this.output.get(t[r++]);if(!s||r>=t.length)return;let n=s.get(t[r++]);if(!n||r>=t.length)return;let a=n.get(t[r++]);return this.retrieveElementFrom(e,t,r,a)}getPrefix(){return $r.PREFIX}}var Fr={};t(Fr,"ArgumentsTokenValueExtractor",(()=>Hr));class Hr extends rr{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(rr.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.args.get(r))}getPrefix(){return Hr.PREFIX}}var Yr={};t(Yr,"GraphVertex",(()=>Xr));var Wr={};t(Wr,"ExecutionGraph",(()=>jr));class jr{nodeMap=new Map;constructor(e=!1){this.isSubGrph=e}getVerticesData(){return Array.from(this.nodeMap.values()).map((e=>e.getData()))}addVertex(e){if(!this.nodeMap.has(e.getUniqueKey())){let t=new Xr(this,e);this.nodeMap.set(e.getUniqueKey(),t)}return this.nodeMap.get(e.getUniqueKey())}getVertex(e){return this.nodeMap.get(e)}getVertexData(e){if(this.nodeMap.has(e))return this.nodeMap.get(e).getData()}getVerticesWithNoIncomingEdges(){return Array.from(this.nodeMap.values()).filter((e=>!e.hasIncomingEdges()))}isCyclic(){let e,t=new be(this.getVerticesWithNoIncomingEdges()),r=new Set;for(;!t.isEmpty();){if(r.has(t.getFirst().getKey()))return!0;e=t.removeFirst(),r.add(e.getKey()),e.hasOutgoingEdges()&&t.addAll(Array.from(e.getOutVertices().values()).flatMap((e=>Array.from(e))))}return!1}addVertices(e){for(const t of e)this.addVertex(t)}getNodeMap(){return this.nodeMap}isSubGraph(){return this.isSubGrph}toString(){return"Execution Graph : \n"+Array.from(this.nodeMap.values()).map((e=>e.toString())).join("\n")}}class Xr{outVertices=new Map;inVertices=new Set;constructor(e,t){this.data=t,this.graph=e}getData(){return this.data}setData(e){return this.data=e,this}getOutVertices(){return this.outVertices}setOutVertices(e){return this.outVertices=e,this}getInVertices(){return this.inVertices}setInVertices(e){return this.inVertices=e,this}getGraph(){return this.graph}setGraph(e){return this.graph=e,this}getKey(){return this.data.getUniqueKey()}addOutEdgeTo(e,t){return this.outVertices.has(e)||this.outVertices.set(e,new Set),this.outVertices.get(e).add(t),t.inVertices.add(new re(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new re(e,t)),e.outVertices.has(t)||e.outVertices.set(t,new Set),e.outVertices.get(t).add(this),e}hasIncomingEdges(){return!!this.inVertices.size}hasOutgoingEdges(){return!!this.outVertices.size}getSubGraphOfType(e){let t=new jr(!0);var r=new be(Array.from(this.outVertices.get(e)??[]));for(r.map((e=>e.getData())).forEach((e=>t.addVertex(e)));!r.isEmpty();){var s=r.pop();Array.from(s.outVertices.values()).flatMap((e=>Array.from(e))).forEach((e=>{t.addVertex(e.getData()),r.add(e)}))}return t}toString(){var e=Array.from(this.getInVertices()).map((e=>e.getT1().getKey()+"("+e.getT2()+")")).join(", "),t=Array.from(this.outVertices.entries()).map((([e,t])=>e+": "+Array.from(t).map((e=>e.getKey())).join(","))).join("\n\t\t");return this.getKey()+":\n\tIn: "+e+"\n\tOut: \n\t\t"+t}}var qr={};t(qr,"KIRuntime",(()=>is));var Jr={};t(Jr,"JsonExpression",(()=>Qr));class Qr{constructor(e){this.expression=e}getExpression(){return this.expression}}var Kr={};let zr;var Zr;t(Kr,"ParameterReferenceType",(()=>zr)),(Zr=zr||(zr={})).VALUE="VALUE",Zr.EXPRESSION="EXPRESSION";var es={};function ts(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}t(es,"FunctionExecutionParameters",(()=>rs));class rs{count=0;valueExtractors=new Map;constructor(e,t,r){this.functionRepository=e,this.schemaRepository=t,this.executionId=r??ts()}getExecutionId(){return this.executionId}getContext(){return this.context}setContext(e){this.context=e;let t=new kr(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new Hr(e);return this.valueExtractors.set(t.getPrefix(),t),this}getEvents(){return this.events}setEvents(e){return this.events=e,this}getStatementExecution(){return this.statementExecution}setStatementExecution(e){return this.statementExecution=e,this}getSteps(){return this.steps}setSteps(e){this.steps=e;let t=new $r(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}getFunctionRepository(){return this.functionRepository}setFunctionRepository(e){return this.functionRepository=e,this}getSchemaRepository(){return this.schemaRepository}setSchemaRepository(e){return this.schemaRepository=e,this}addTokenValueExtractor(...e){for(const t of e)this.valueExtractors.set(t.getPrefix(),t);return this}setValuesMap(e){for(const[t,r]of e.entries())this.valueExtractors.set(t,r);return this}}var ss={};let ns;var as;t(ss,"StatementMessageType",(()=>ns)),(as=ns||(ns={})).ERROR="ERROR",as.WARNING="WARNING",as.MESSAGE="MESSAGE";class is extends xe{static PARAMETER_NEEDS_A_VALUE='Parameter "$" needs a value';static STEP_REGEX_PATTERN=new RegExp("Steps\\.([a-zA-Z0-9\\\\-]{1,})\\.([a-zA-Z0-9\\\\-]{1,})","g");static VERSION=1;static MAX_EXECUTION_ITERATIONS=1e7;debugMode=!1;constructor(e,t=!1){if(super(),this.debugMode=t,this.fd=e,this.fd.getVersion()>is.VERSION)throw new b("Runtime is at a lower version "+is.VERSION+" and trying to run code from version "+this.fd.getVersion()+".")}getSignature(){return this.fd}async getExecutionPlan(e){let t=new jr;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(r,e.getFunctionRepository(),e.getSchemaRepository()));return new re(this.makeEdges(t),t)}async internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map),this.debugMode&&(console.log(`Executing: ${this.fd.getNamespace()}.${this.fd.getName()}`),console.log("Parameters: ",e));let t=await this.getExecutionPlan(e);this.debugMode&&console.log(t.getT2()?.toString());let r=t.getT1();if(this.debugMode&&r.length&&(console.log("Unresolved Dependencies: "),console.log(r.map((e=>J.format("Steps.$.$",e.getT1(),e.getT2()))))),r.length)throw new b(J.format("Found these unresolved dependencies : $ ",r.map((e=>J.format("Steps.$.$",e.getT1(),e.getT2())))));let s=t.getT2().getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(s?.length)throw new b("Please fix the errors in the function definition before execution : \n"+s.join(",\n"));return await this.executeGraph(t.getT2(),e)}async executeGraph(e,t){let r=new be;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new be;for(;!(r.isEmpty()&&s.isEmpty()||t.getEvents()?.has(k.OUTPUT));)if(await this.processBranchQue(t,r,s),await this.processExecutionQue(t,r,s),t.setCount(t.getCount()+1),t.getCount()==is.MAX_EXECUTION_ITERATIONS)throw new b("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new b("No events raised");return new H(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>$.of(e[0],t))))))}async processExecutionQue(e,t,r){if(!t.isEmpty()){let s=t.pop();await this.allDependenciesResolvedVertex(s,e.getSteps())?await this.executeVertex(s,e,r,t,e.getFunctionRepository()):t.add(s)}}async processBranchQue(e,t,r){if(r.length){let s=r.pop();await this.allDependenciesResolvedTuples(s.getT2(),e.getSteps())?await this.executeBranch(e,t,s):r.add(s)}}async executeBranch(e,t,r){let s,n=r.getT4();do{if(await this.executeGraph(r.getT1(),e),s=r.getT3().next(),s&&(e.getSteps()?.has(n.getData().getStatement().getStatementName())||e.getSteps()?.set(n.getData().getStatement().getStatementName(),new Map),e.getSteps()?.get(n.getData().getStatement().getStatementName())?.set(s.getName(),this.resolveInternalExpressions(s.getResult(),e)),this.debugMode)){const t=n.getData().getStatement();console.log(`Step : ${t.getStatementName()} => ${t.getNamespace()}.${t.getName()}`),console.log(`Event : ${s.getName()} : `,e.getSteps().get(t.getStatementName()).get(s.getName()))}}while(s&&s.getName()!=k.OUTPUT);s?.getName()==k.OUTPUT&&n.getOutVertices().has(k.OUTPUT)&&(n?.getOutVertices()?.get(k.OUTPUT)??[]).forEach((async r=>{await this.allDependenciesResolvedVertex(r,e.getSteps())&&t.add(r)}))}async executeVertex(e,t,r,s,n){let a=e.getData().getStatement(),i=n.find(a.getNamespace(),a.getName());if(!i)throw new b(J.format("$.$ function is not found.",a.getNamespace(),a.getName()));let o=i?.getSignature().getParameters(),u=this.getArgumentsFromParametersMap(t,a,o??new Map);this.debugMode&&(console.log(`Step : ${a.getStatementName()} => ${a.getNamespace()}.${a.getName()}`),console.log("Arguments : ",u));let p=t.getContext(),l=await i.execute(new rs(t.getFunctionRepository(),t.getSchemaRepository(),t.getExecutionId()).setValuesMap(t.getValuesMap()).setContext(p).setArguments(u).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),h=l.next();if(!h)throw new b(J.format("Executing $ returned no events",a.getStatementName()));let m=h.getName()==k.OUTPUT;if(t.getSteps()?.has(a.getStatementName())||t.getSteps().set(a.getStatementName(),new Map),t.getSteps().get(a.getStatementName()).set(h.getName(),this.resolveInternalExpressions(h.getResult(),t)),this.debugMode&&(console.log(`Step : ${a.getStatementName()} => ${a.getNamespace()}.${a.getName()}`),console.log(`Event : ${h.getName()} : `,t.getSteps().get(a.getStatementName()).get(h.getName()))),m){let r=e.getOutVertices().get(k.OUTPUT);r&&r.forEach((async e=>{await this.allDependenciesResolvedVertex(e,t.getSteps())&&s.add(e)}))}else{let t=e.getSubGraphOfType(h.getName()),s=this.makeEdges(t);r.push(new ne(t,s,l,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new re(e[0],this.resolveInternalExpression(e[1],t)))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map):e}resolveInternalExpression(e,t){if(u(e)||"object"!=typeof e)return e;if(e instanceof Qr){return new pr(e.getExpression()).evaluate(t.getValuesMap())}if(Array.isArray(e)){let r=[];for(let s of e)r.push(this.resolveInternalExpression(s,t));return r}if("object"==typeof e){let r={};for(let s of Object.entries(e))r[s[0]]=this.resolveInternalExpression(s[1],t);return r}}allDependenciesResolvedTuples(e,t){for(let r of e){if(!t.has(r.getT1()))return!1;if(!t.get(r.getT1())?.get(r.getT2()))return!1}return!0}allDependenciesResolvedVertex(e,t){return!e.getInVertices().size||0==Array.from(e.getInVertices()).filter((e=>{let r=e.getT1().getData().getStatement().getStatementName(),s=e.getT2();return!(t.has(r)&&t.get(r)?.has(s))})).length}getArgumentsFromParametersMap(e,t,r){return Array.from(t.getParameterMap().entries()).map((t=>{let s,n=Array.from(t[1]?.values()??[]);if(!n?.length)return new re(t[0],s);let a=r.get(t[0]);return a?(s=a.isVariableArgument()?n.map((t=>this.parameterReferenceEvaluation(e,t))).flatMap((e=>Array.isArray(e)?e:[e])):this.parameterReferenceEvaluation(e,n[0]),new re(t[0],s)):new re(t[0],void 0)})).filter((e=>!u(e.getT2()))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}parameterReferenceEvaluation(e,t){let r;if(t.getType()==zr.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==zr.EXPRESSION&&!Z.isNullOrBlank(t.getExpression())){r=new pr(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t,r){let s=new Br(e),n=t.find(e.getNamespace(),e.getName());if(!n)throw new b(J.format("$.$ was not available",e.getNamespace(),e.getName()));let a=new Map(n.getSignature().getParameters());for(let t of Array.from(e.getParameterMap().entries())){let e=a.get(t[0]);if(!e)continue;let n=Array.from(t[1]?.values()??[]);if(n.length||e.isVariableArgument()){if(e.isVariableArgument())for(let t of n)this.parameterReferenceValidation(s,e,t,r);else if(n.length){let t=n[0];this.parameterReferenceValidation(s,e,t,r)}a.delete(e.getParameterName())}else u(oe.getDefaultValue(e.getSchema(),r))&&s.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,e.getParameterName())),a.delete(e.getParameterName())}if(!u(s.getStatement().getDependentStatements()))for(let e of s.getStatement().getDependentStatements().entries())e[1]&&s.addDependency(e[0]);if(a.size)for(let e of Array.from(a.values()))e.isVariableArgument()||u(oe.getDefaultValue(e.getSchema(),r))&&s.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return s}parameterReferenceValidation(e,t,r,s){if(r){if(r.getType()==zr.VALUE){u(r.getValue())&&u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));let n=new be;for(n.push(new re(t.getSchema(),r.getValue()));!n.isEmpty();){let t=n.pop();if(t.getT2()instanceof Qr)this.addDependencies(e,t.getT2().getExpression());else{if(u(t.getT1())||u(t.getT1().getType()))continue;if(t.getT1().getType()?.contains(h.ARRAY)&&Array.isArray(t.getT2())){let e=t.getT1().getItems();if(!e)continue;if(e.isSingleType())for(let r of t.getT2())n.push(new re(e.getSingleSchema(),r));else{let r=t.getT2();for(let t=0;t<r.length;t++)n.push(new re(e.getTupleSchema()[t],r[t]))}}else if(t.getT1().getType()?.contains(h.OBJECT)&&"object"==typeof t.getT2()){let r=t.getT1();if(r.getName()===M.EXPRESSION.getName()&&r.getNamespace()===M.EXPRESSION.getNamespace()){let r=t.getT2();r.isExpression&&this.addDependencies(e,r.value)}else if(r.getProperties())for(let e of Object.entries(t.getT2()))r.getProperties().has(e[0])&&n.push(new re(r.getProperties().get(e[0]),e[1]))}}}}else if(r.getType()==zr.EXPRESSION)if(Z.isNullOrBlank(r.getExpression()))u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));else try{this.addDependencies(e,r.getExpression())}catch(t){e.addMessage(ns.ERROR,J.format("Error evaluating $ : $",r.getExpression(),t))}}else u(oe.getDefaultValue(t.getSchema(),s))&&e.addMessage(ns.ERROR,J.format(is.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(is.STEP_REGEX_PATTERN)??[]).forEach((t=>e.addDependency(t)))}makeEdges(e){let t=e.getNodeMap().values(),r=[];for(let s of Array.from(t))for(let t of s.getData().getDependencies()){let n=t.indexOf(".",6),a=t.substring(6,n),i=t.indexOf(".",n+1),o=-1==i?t.substring(n+1):t.substring(n+1,i);e.getNodeMap().has(a)||r.push(new re(a,o));let u=e.getNodeMap().get(a);u&&s.addInEdgeTo(u,o)}return r}}var os={};t(os,"KIRunConstants",(()=>us));class us{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}var ps={};t(ps,"Position",(()=>ls));class ls{static SCHEMA_NAME="Position";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(ls.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["left",S.ofFloat("left")],["top",S.ofFloat("top")]]));constructor(e,t){this.left=e,this.top=t}getLeft(){return this.left}setLeft(e){return this.left=e,this}getTop(){return this.top}setTop(e){return this.top=e,this}static from(e){return e?new ls(e.left,e.top):new ls(-1,-1)}}var hs={};t(hs,"FunctionDefinition",(()=>Os));var ms={};t(ms,"Statement",(()=>Ts));var cs={};t(cs,"AbstractStatement",(()=>gs));class gs{override=!1;constructor(e){e&&(this.comment=e.comment,this.description=e.description,this.position=e.position?new ls(e.position.getLeft(),e.position.getTop()):void 0,this.override=e.override)}getComment(){return this.comment}setComment(e){return this.comment=e,this}isOverride(){return this.override}setOverride(e){return this.override=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getPosition(){return this.position}setPosition(e){return this.position=e,this}}var fs={};t(fs,"ParameterReference",(()=>Es));class Es{static SCHEMA_NAME="ParameterReference";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(Es.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["key",S.ofString("key")],["value",S.ofAny("value")],["expression",S.ofString("expression")],["type",S.ofString("type").setEnums(["EXPRESSION","VALUE"])]]));constructor(e){if(e instanceof Es){let t=e;this.key=t.key,this.type=t.type,this.value=u(t.value)?void 0:JSON.parse(JSON.stringify(t.value)),this.expression=t.expression}else this.type=e,this.key=ts()}getType(){return this.type}setType(e){return this.type=e,this}getKey(){return this.key}setKey(e){return this.key=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}getExpression(){return this.expression}setExpression(e){return this.expression=e,this}static ofExpression(e){const t=new Es(zr.EXPRESSION).setExpression(e);return[t.getKey(),t]}static ofValue(e){const t=new Es(zr.VALUE).setValue(e);return[t.getKey(),t]}static from(e){return new Es(e.type).setValue(e.value).setExpression(e.expression).setKey(e.key)}}class Ts extends gs{static SCHEMA_NAME="Statement";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(Ts.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["statementName",S.ofString("statementName")],["comment",S.ofString("comment")],["description",S.ofString("description")],["namespace",S.ofString("namespace")],["name",S.ofString("name")],["dependentStatements",S.ofObject("dependentstatement").setAdditionalProperties((new O).setSchemaValue(S.ofBoolean("exists")))],["parameterMap",(new S).setName("parameterMap").setAdditionalProperties((new O).setSchemaValue(S.ofObject("parameterReference").setAdditionalProperties((new O).setSchemaValue(Es.SCHEMA))))],["position",ls.SCHEMA]]));constructor(e,t,r){if(super(e instanceof Ts?e:void 0),e instanceof Ts){let t=e;this.statementName=t.statementName,this.name=t.name,this.namespace=t.namespace,t.parameterMap&&(this.parameterMap=new Map(Array.from(t.parameterMap.entries()).map((e=>[e[0],new Map(Array.from(e[1].entries()).map((e=>[e[0],new Es(e[1])])))])))),t.dependentStatements&&(this.dependentStatements=new Map(Array.from(t.dependentStatements.entries())))}else{if(this.statementName=e,!r||!t)throw new Error("Unknown constructor");this.namespace=t,this.name=r}}getStatementName(){return this.statementName}setStatementName(e){return this.statementName=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameterMap(){return this.parameterMap||(this.parameterMap=new Map),this.parameterMap}setParameterMap(e){return this.parameterMap=e,this}getDependentStatements(){return this.dependentStatements??new Map}setDependentStatements(e){return this.dependentStatements=e,this}equals(e){if(!(e instanceof Ts))return!1;return e.statementName==this.statementName}static ofEntry(e){return[e.statementName,e]}static from(e){return new Ts(e.statementName,e.namespace,e.name).setParameterMap(new Map(Object.entries(e.parameterMap??{}).map((([e,t])=>[e,new Map(Object.entries(t??{}).map((([e,t])=>Es.from(t))).map((e=>[e.getKey(),e])))])))).setDependentStatements(new Map(Object.entries(e.dependentStatements??{}))).setPosition(ls.from(e.position)).setComment(e.comment).setDescription(e.description)}}var ds={};t(ds,"StatementGroup",(()=>As));class As extends gs{static SCHEMA_NAME="StatementGroup";static SCHEMA=(new S).setNamespace(a.SYSTEM).setName(As.SCHEMA_NAME).setType(w.of(h.OBJECT)).setProperties(new Map([["statementGroupName",S.ofString("statementGroupName")],["comment",S.ofString("comment")],["description",S.ofString("description")],["position",ls.SCHEMA]]));constructor(e,t=new Map){super(),this.statementGroupName=e,this.statements=t}getStatementGroupName(){return this.statementGroupName}setStatementGroupName(e){return this.statementGroupName=e,this}getStatements(){return this.statements}setStatements(e){return this.statements=e,this}static from(e){return new As(e.statementGroupName,new Map(Object.entries(e.statements||{}).map((([e,t])=>[e,"true"==(""+t)?.toLowerCase()])))).setPosition(ls.from(e.position)).setComment(e.comment).setDescription(e.description)}}const ws=(new S).setNamespace(a.SYSTEM).setName("FunctionDefinition").setProperties(new Map([["name",S.ofString("name")],["namespace",S.ofString("namespace")],["parameters",S.ofArray("parameters",M.SCHEMA)],["events",S.ofObject("events").setAdditionalProperties((new O).setSchemaValue(k.SCHEMA))],["steps",S.ofObject("steps").setAdditionalProperties((new O).setSchemaValue(Ts.SCHEMA))]]));ws.getProperties()?.set("parts",S.ofArray("parts",ws));class Os extends W{static SCHEMA=ws;version=1;constructor(e){super(e)}getVersion(){return this.version}setVersion(e){return this.version=e,this}getSteps(){return this.steps??new Map}setSteps(e){return this.steps=e,this}getStepGroups(){return this.stepGroups}setStepGroups(e){return this.stepGroups=e,this}getParts(){return this.parts}setParts(e){return this.parts=e,this}static from(e){return e?new Os(e.name).setSteps(new Map(Object.values(e.steps??{}).filter((e=>!!e)).map((e=>[e.statementName,Ts.from(e)])))).setStepGroups(new Map(Object.values(e.stepGroups??{}).filter((e=>!!e)).map((e=>[e.statementGroupName,As.from(e)])))).setParts(Array.from(e.parts??[]).filter((e=>!!e)).map((e=>Os.from(e)))).setVersion(e.version??1).setEvents(new Map(Object.values(e.events??{}).filter((e=>!!e)).map((e=>[e.name,k.from(e)])))).setParameters(new Map(Object.values(e.parameters??{}).filter((e=>!!e)).map((e=>[e.parameterName,M.from(e)])))):new Os("unknown")}}var Ss={};t(Ss,"Argument",(()=>Ns));class Ns{argumentIndex=0;constructor(e,t,r){this.argumentIndex=e,this.name=t,this.value=r}getArgumentIndex(){return this.argumentIndex}setArgumentIndex(e){return this.argumentIndex=e,this}getName(){return this.name}setName(e){return this.name=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}static of(e,t){return new Ns(0,e,t)}}var Rs={};e(Rs,Yt),e(Rs,qt),e(Rs,Qt),e(Rs,zt),e(Rs,Wt);var xs={};e(xs,ze),e(xs,et),e(xs,rt),e(xs,nt),e(xs,it),e(xs,ut),e(xs,lt),e(xs,Je),e(xs,mt),e(xs,gt),e(xs,Et),e(xs,dt),e(xs,wt),e(xs,St),e(xs,Rt),e(xs,It),e(xs,Pt),e(xs,Lt),e(xs,bt),e(xs,Dt),e(xs,Vt),e(xs,Gt),e(xs,Ft),e(xs,qe),e(module.exports,r),e(module.exports,L),e(module.exports,{}),e(module.exports,xt),e(module.exports,Or),e(module.exports,o),e(module.exports,_e),e(module.exports,Ve),e(module.exports,q),e(module.exports,z),e(module.exports,te),e(module.exports,Lr),e(module.exports,Le),e(module.exports,br),e(module.exports,Ur),e(module.exports,j),e(module.exports,Dr),e(module.exports,Gr),e(module.exports,Fr),e(module.exports,Yr),e(module.exports,{}),e(module.exports,Wr),e(module.exports,qr),e(module.exports,ss),e(module.exports,es),e(module.exports,Pe),e(module.exports,tr),e(module.exports,er),e(module.exports,Xe),e(module.exports,Ye),e(module.exports,Ge),e(module.exports,De),e(module.exports,Fe),e(module.exports,{}),e(module.exports,Q),e(module.exports,n),e(module.exports,Jr),e(module.exports,s),e(module.exports,Te),e(module.exports,ce),e(module.exports,fe),e(module.exports,he),e(module.exports,ue),e(module.exports,Oe),e(module.exports,Ae),e(module.exports,K),e(module.exports,ae),e(module.exports,R),e(module.exports,le),e(module.exports,i),e(module.exports,d),e(module.exports,c),e(module.exports,g),e(module.exports,f),e(module.exports,l),e(module.exports,ee),e(module.exports,U),e(module.exports,vr),e(module.exports,os),e(module.exports,N),e(module.exports,F),e(module.exports,ps),e(module.exports,hs),e(module.exports,Kr),e(module.exports,G),e(module.exports,cs),e(module.exports,ms),e(module.exports,{}),e(module.exports,ds),e(module.exports,Y),e(module.exports,D),e(module.exports,y),e(module.exports,Ss),e(module.exports,fs),e(module.exports,Ie),e(module.exports,C),e(module.exports,Rs),e(module.exports,xs),e(module.exports,ar);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|