@fincity/kirun-js 1.0.5 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/engine/function/system/array/AddFirstTest.ts +13 -12
- package/__tests__/engine/function/system/array/AddTest.ts +11 -11
- package/__tests__/engine/function/system/array/BinarySearchTest.ts +29 -14
- package/__tests__/engine/function/system/array/CompareTest.ts +3 -3
- package/__tests__/engine/function/system/array/CopyTest.ts +5 -5
- package/__tests__/engine/function/system/array/DeleteFirstTest.ts +10 -10
- package/__tests__/engine/function/system/array/DeleteFromTest.ts +8 -8
- package/__tests__/engine/function/system/array/DeleteLastTest.ts +10 -10
- package/__tests__/engine/function/system/array/DeleteTest.ts +60 -25
- package/__tests__/engine/function/system/array/DisjointTest.ts +6 -7
- package/__tests__/engine/function/system/array/Equals.ts +5 -5
- package/__tests__/engine/function/system/array/FillTest.ts +5 -5
- package/__tests__/engine/function/system/array/FrequencyTest.ts +11 -11
- package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +14 -20
- package/__tests__/engine/function/system/array/IndexOfTest.ts +26 -14
- package/__tests__/engine/function/system/array/InsertTest.ts +12 -12
- package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +9 -12
- package/__tests__/engine/function/system/array/LastIndexOfTest.ts +16 -16
- package/__tests__/engine/function/system/array/MaxTest.ts +18 -18
- package/__tests__/engine/function/system/array/MinTest.ts +18 -18
- package/__tests__/engine/function/system/array/MisMatchTest.ts +8 -11
- package/__tests__/engine/function/system/array/ReverseTest.ts +12 -12
- package/__tests__/engine/function/system/array/RotateTest.ts +6 -6
- package/__tests__/engine/function/system/array/ShuffleTest.ts +7 -4
- package/__tests__/engine/function/system/array/SortTest.ts +10 -10
- package/__tests__/engine/function/system/array/SubArrayTest.ts +19 -10
- package/__tests__/engine/function/system/context/SetFunctionTest.ts +24 -5
- package/__tests__/engine/function/system/math/AddTest.ts +2 -2
- package/__tests__/engine/function/system/math/RandomIntTest.ts +46 -0
- package/__tests__/engine/function/system/string/ConcatenateTest.ts +4 -4
- package/__tests__/engine/function/system/string/DeleteForGivenLengthTest.ts +8 -4
- package/__tests__/engine/function/system/string/InsertAtGivenPositionTest.ts +6 -6
- package/__tests__/engine/function/system/string/PostPadTest.ts +6 -6
- package/__tests__/engine/function/system/string/PrePadTest.ts +8 -8
- package/__tests__/engine/function/system/string/RegionMatchesTest.ts +15 -6
- package/__tests__/engine/function/system/string/ReverseTest.ts +6 -6
- package/__tests__/engine/function/system/string/SplitTest.ts +8 -4
- package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +35 -11
- package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +14 -5
- package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +40 -16
- package/__tests__/engine/function/system/string/ToStringTest.ts +6 -6
- package/__tests__/engine/function/system/string/TrimToTest.ts +8 -6
- package/__tests__/engine/runtime/KIRuntimeTest.ts +148 -155
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +89 -0
- package/__tests__/engine/util/LinkedListTest.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +267 -109
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/AbstractFunction.ts +5 -3
- package/src/engine/function/Function.ts +1 -1
- package/src/engine/function/system/GenerateEvent.ts +1 -1
- package/src/engine/function/system/If.ts +1 -1
- package/src/engine/function/system/array/AbstractArrayFunction.ts +5 -0
- package/src/engine/function/system/array/Add.ts +1 -1
- package/src/engine/function/system/array/AddFirst.ts +1 -1
- package/src/engine/function/system/array/BinarySearch.ts +1 -1
- package/src/engine/function/system/array/Compare.ts +1 -1
- package/src/engine/function/system/array/Copy.ts +1 -1
- package/src/engine/function/system/array/Delete.ts +24 -32
- package/src/engine/function/system/array/DeleteFirst.ts +1 -1
- package/src/engine/function/system/array/DeleteFrom.ts +1 -1
- package/src/engine/function/system/array/DeleteLast.ts +1 -1
- package/src/engine/function/system/array/Disjoint.ts +1 -1
- package/src/engine/function/system/array/Equals.ts +2 -2
- package/src/engine/function/system/array/Fill.ts +1 -1
- package/src/engine/function/system/array/Frequency.ts +1 -1
- package/src/engine/function/system/array/IndexOf.ts +1 -1
- package/src/engine/function/system/array/IndexOfArray.ts +1 -1
- package/src/engine/function/system/array/Insert.ts +1 -1
- package/src/engine/function/system/array/LastIndexOf.ts +1 -1
- package/src/engine/function/system/array/LastIndexOfArray.ts +1 -1
- package/src/engine/function/system/array/Max.ts +1 -1
- package/src/engine/function/system/array/Min.ts +1 -1
- package/src/engine/function/system/array/MisMatch.ts +1 -1
- package/src/engine/function/system/array/Reverse.ts +1 -1
- package/src/engine/function/system/array/Rotate.ts +1 -1
- package/src/engine/function/system/array/Shuffle.ts +1 -1
- package/src/engine/function/system/array/Sort.ts +1 -1
- package/src/engine/function/system/array/SubArray.ts +1 -1
- package/src/engine/function/system/context/Create.ts +1 -1
- package/src/engine/function/system/context/Get.ts +1 -1
- package/src/engine/function/system/context/SetFunction.ts +1 -1
- package/src/engine/function/system/loop/CountLoop.ts +1 -1
- package/src/engine/function/system/loop/RangeLoop.ts +1 -1
- package/src/engine/function/system/math/Add.ts +2 -4
- package/src/engine/function/system/math/GenericMathFunction.ts +2 -4
- package/src/engine/function/system/math/Hypotenuse.ts +2 -6
- package/src/engine/function/system/math/Maximum.ts +2 -4
- package/src/engine/function/system/math/Minimum.ts +2 -4
- package/src/engine/function/system/math/Random.ts +1 -1
- package/src/engine/function/system/math/RandomFloat.ts +56 -0
- package/src/engine/function/system/math/RandomInt.ts +56 -0
- package/src/engine/function/system/string/AbstractStringFunction.ts +24 -8
- package/src/engine/function/system/string/Concatenate.ts +2 -2
- package/src/engine/function/system/string/DeleteForGivenLength.ts +25 -15
- package/src/engine/function/system/string/InsertAtGivenPosition.ts +17 -7
- package/src/engine/function/system/string/PostPad.ts +20 -10
- package/src/engine/function/system/string/PrePad.ts +17 -7
- package/src/engine/function/system/string/RegionMatches.ts +40 -22
- package/src/engine/function/system/string/ReplaceAtGivenPosition.ts +26 -13
- package/src/engine/function/system/string/Reverse.ts +4 -3
- package/src/engine/function/system/string/Split.ts +13 -4
- package/src/engine/function/system/string/ToString.ts +9 -5
- package/src/engine/function/system/string/TrimTo.ts +13 -6
- package/src/engine/json/schema/Schema.ts +1 -0
- package/src/engine/model/Event.ts +15 -0
- package/src/engine/model/FunctionDefinition.ts +76 -29
- package/src/engine/model/Parameter.ts +11 -0
- package/src/engine/model/ParameterReference.ts +8 -1
- package/src/engine/model/Position.ts +5 -0
- package/src/engine/model/Statement.ts +16 -0
- package/src/engine/model/StatementGroup.ts +7 -0
- package/src/engine/runtime/KIRuntime.ts +26 -24
- package/src/index.ts +71 -20
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,"Tuple2",(()=>s)),t(r,"Tuple3",(()=>n)),t(r,"Tuple4",(()=>i));class s{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}}class n extends s{constructor(e,t,r){super(e,t),this.t=r}getT3(){return this.t}}class i extends n{constructor(e,t,r,s){super(e,t,r),this.fr=s}getT4(){return this.fr}}var a={};t(a,"HybridRepository",(()=>o));class o{constructor(...e){this.repos=e}find(e,t){for(let r of this.repos){let s=r.find(e,t);if(s)return s}}}var h={};t(h,"Schema",(()=>N));var u={};t(u,"Namespaces",(()=>l));class l{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 p={};function c(e){return null==e}t(p,"isNullValue",(()=>c));class m{setSingleSchema(e){return this.singleSchema=e,this}setTupleSchema(e){return this.tupleSchema=e,this}getSingleSchema(){return this.singleSchema}getTupleSchema(){return this.tupleSchema}isSingleType(){return!c(this.singleSchema)}static of(...e){return 1==e.length?(new m).setSingleSchema(e[0]):(new m).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&m.of(...N.fromListOfSchemas(e));let t=N.from(e);return t?m.of(t):void 0}}class g{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 g;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}var f={};let E;var T;t(f,"SchemaType",(()=>E)),(T=E||(E={})).INTEGER="Integer",T.LONG="Long",T.FLOAT="Float",T.DOUBLE="Double",T.STRING="String",T.OBJECT="Object",T.ARRAY="Array",T.BOOLEAN="Boolean",T.NULL="Null";class A{}class d extends A{constructor(e){super(),this.type=e}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}class O extends A{constructor(e){super(),this.type=e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class S{static of(...e){return 1==e.length?new O(e[0]):new d(new Set(e))}static from(e){return"string"==typeof e?S.of(e):Array.isArray(e)?S.of(...Array.of(e).map((e=>e)).map((e=>e))):void 0}}class N{static NULL=(new N).setNamespace(l.SYSTEM).setName("Null").setType(S.of(E.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new N).setType(S.of(E.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new N).setNamespace(l.SYSTEM).setName("Schema").setType(S.of(E.OBJECT)).setProperties(new Map([["namespace",N.of("namespace",E.STRING).setDefaultValue("_")],["name",N.ofString("name")],["version",N.of("version",E.INTEGER).setDefaultValue(1)],["ref",N.ofString("ref")],["type",(new N).setAnyOf([N.TYPE_SCHEMA,N.ofArray("type",N.TYPE_SCHEMA)])],["anyOf",N.ofArray("anyOf",N.ofRef("#/"))],["allOf",N.ofArray("allOf",N.ofRef("#/"))],["oneOf",N.ofArray("oneOf",N.ofRef("#/"))],["not",N.ofRef("#/")],["title",N.ofString("title")],["description",N.ofString("description")],["id",N.ofString("id")],["examples",N.ofAny("examples")],["defaultValue",N.ofAny("defaultValue")],["comment",N.ofString("comment")],["enums",N.ofArray("enums",N.ofString("enums"))],["constant",N.ofAny("constant")],["pattern",N.ofString("pattern")],["format",N.of("format",E.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",N.ofInteger("minLength")],["maxLength",N.ofInteger("maxLength")],["multipleOf",N.ofLong("multipleOf")],["minimum",N.ofNumber("minimum")],["maximum",N.ofNumber("maximum")],["exclusiveMinimum",N.ofNumber("exclusiveMinimum")],["exclusiveMaximum",N.ofNumber("exclusiveMaximum")],["properties",N.of("properties",E.OBJECT).setAdditionalProperties((new g).setSchemaValue(N.ofRef("#/")))],["additionalProperties",(new N).setName("additionalProperty").setNamespace(l.SYSTEM).setAnyOf([N.ofBoolean("additionalProperty"),N.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",N.ofArray("required",N.ofString("required")).setDefaultValue([])],["propertyNames",N.ofRef("#/")],["minProperties",N.ofInteger("minProperties")],["maxProperties",N.ofInteger("maxProperties")],["patternProperties",N.of("patternProperties",E.OBJECT).setAdditionalProperties((new g).setSchemaValue(N.ofRef("#/")))],["items",(new N).setName("items").setAnyOf([N.ofRef("#/").setName("item"),N.ofArray("tuple",N.ofRef("#/"))])],["contains",N.ofRef("#/")],["minItems",N.ofInteger("minItems")],["maxItems",N.ofInteger("maxItems")],["uniqueItems",N.ofBoolean("uniqueItems")],["$defs",N.of("$defs",E.OBJECT).setAdditionalProperties((new g).setSchemaValue(N.ofRef("#/")))],["permission",N.ofString("permission")]])).setRequired([]);static ofString(e){return(new N).setType(S.of(E.STRING)).setName(e)}static ofInteger(e){return(new N).setType(S.of(E.INTEGER)).setName(e)}static ofFloat(e){return(new N).setType(S.of(E.FLOAT)).setName(e)}static ofLong(e){return(new N).setType(S.of(E.LONG)).setName(e)}static ofDouble(e){return(new N).setType(S.of(E.DOUBLE)).setName(e)}static ofAny(e){return(new N).setType(S.of(E.INTEGER,E.LONG,E.FLOAT,E.DOUBLE,E.STRING,E.BOOLEAN,E.ARRAY,E.NULL,E.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new N).setType(S.of(E.INTEGER,E.LONG,E.FLOAT,E.DOUBLE,E.STRING,E.BOOLEAN,E.ARRAY,E.OBJECT)).setName(e)}static ofNumber(e){return(new N).setType(S.of(E.INTEGER,E.LONG,E.FLOAT,E.DOUBLE)).setName(e)}static ofBoolean(e){return(new N).setType(S.of(E.BOOLEAN)).setName(e)}static of(e,...t){return(new N).setType(S.of(...t)).setName(e)}static ofObject(e){return(new N).setType(S.of(E.OBJECT)).setName(e)}static ofRef(e){return(new N).setRef(e)}static ofArray(e,...t){return(new N).setType(S.of(E.ARRAY)).setName(e).setItems(m.of(...t))}static fromListOfSchemas(e){if(c(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=N.from(r);e&&t.push(e)}return t}static fromMapOfSchemas(e){if(c(e))return;const t=new Map;return Object.entries(e).forEach((([e,r])=>{let s=N.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(c(e))return;let r=new N;return r.namespace=e.namespace,r.name=e.name,r.version=e.version,r.ref=e.ref,r.type=t?new O(E.STRING):S.from(r.type),r.anyOf=N.fromListOfSchemas(e.anyOf),r.allOf=N.fromListOfSchemas(e.allOf),r.oneOf=N.fromListOfSchemas(e.oneOf),r.not=N.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=N.fromMapOfSchemas(e.properties),r.additionalProperties=g.from(e.additionalProperties),r.required=e.required,r.propertyNames=N.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=N.fromMapOfSchemas(e.patternProperties),r.items=m.from(e.items),r.contains=N.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=N.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;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 O(E.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 I={};t(I,"SchemaValidator",(()=>F));var R={};t(R,"StringUtil",(()=>_));var w={};t(w,"KIRuntimeException",(()=>y));class y extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var x={};t(x,"StringFormatter",(()=>v));class v{static format(e,...t){if(!t||0==t.length)return e;let r="",s=0,n="",i=n,a=e.length;for(let o=0;o<a;o++)n=e.charAt(o),"$"==n&&"\\"==i?r=r.substring(0,o-1)+n:"$"==n&&s<t.length?r+=t[s++]:r+=n,i=n;return r.toString()}constructor(){}}class _{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new y("String cannot be null");if(r<0||r>=e.length)throw new y(v.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new y(v.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()}}class P 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}}class M 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 L{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():L.getDefaultValue(L.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==L.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new M(r??"","Schema has a cyclic reference");if(!e||!r||_.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=L.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let i=r.split("/");return e=L.resolveInternalSchema(e,t,r,s,i,1)}static resolveInternalSchema(e,t,r,s,n,i){let a=e;for(;i<n.length;){if("$defs"===n[i]){if(++i>=n.length||!a.get$defs())throw new P(r,L.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);a=a.get$defs()?.get(n[i])}else{if(a&&(!a.getType()?.contains(E.OBJECT)||!a.getProperties()))throw new P(r,"Cannot retrievie schema from non Object type schemas");a=a.getProperties()?.get(n[i])}if(i++,!a)throw new P(r,L.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!_.isNullOrBlank(a.getRef())&&(a=L.getSchemaFromRef(a,t,a.getRef(),s),!a))throw new P(r,L.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return a}static resolveExternalSchema(e,t,r){if(!t)return;let n=_.splitAtFirstOccurance(e?.getRef()??"","/");if(!n[0])return;let i=_.splitAtFirstOccurance(n[0],".");if(!i[0]||!i[1])return;let a=t.find(i[0],i[1]);if(a){if(!n[1]||""===n[1])return new s(a,r);if(r="#/"+n[1],!a)throw new P(r,L.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new s(a,r)}}constructor(){}}class U{static validate(e,t,r,s){let n=[];return t.getOneOf()&&!t.getOneOf()?U.oneOf(e,t,r,s,n):t.getAllOf()&&!t.getAllOf()?U.allOf(e,t,r,s,n):t.getAnyOf()&&!t.getAnyOf()&&U.anyOf(e,t,r,s,n),s}static anyOf(e,t,r,s,n){let i=!1;for(let a of t.getAnyOf()??[])try{U.validate(e,a,r,s),i=!0;break}catch(e){i=!1,n.push(e)}if(!i)throw new M(F.path(e),"The value don't satisfy any of the schemas.",n)}static allOf(e,t,r,s,n){let i=0;for(let a of t.getAllOf()??[])try{U.validate(e,a,r,s),i++}catch(e){n.push(e)}if(i!==t.getAllOf()?.length)throw new M(F.path(e),"The value doesn't satisfy some of the schemas.",n)}static oneOf(e,t,r,s,n){let i=0;for(let a of t.getOneOf()??[])try{U.validate(e,a,r,s),i++}catch(e){n.push(e)}if(1!=i)throw new M(F.path(e),0==i?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}class B{static validate(e,t,r,s){if(c(s))throw new M(F.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new M(F.path(e),s.toString()+" is not an Array");let n=s;return B.checkMinMaxItems(e,t,n),B.checkItems(e,t,r,n),B.checkUniqueItems(e,t,n),B.checkContains(e,t,r,n),s}static checkContains(e,t,r,s){if(!t.getContains())return;let n=!1;for(let i=0;i<s.length;i++){let a=e?[...e]:[];try{F.validate(a,t.getContains(),r,s[i]),n=!0;break}catch(e){n=!1}}if(!n)throw new M(F.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 M(F.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new M(F.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new M(F.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 i=e?[...e]:[],a=F.validate(i,n.getSingleSchema(),r,s[t]);s[t]=a}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new M(F.path(e),"Expected an array with only "+n.getTupleSchema().length+" but found "+s.length);for(let t=0;t<s.length;t++){let i=e?[...e]:[],a=F.validate(i,n.getTupleSchema()[t],r,s[t]);s[t]=a}}}constructor(){}}class C{static validate(e,t,r,s){if(c(s))throw new M(F.path(t),"Expected a number but found null");if("number"!=typeof s)throw new M(F.path(t),s.toString()+" is not a "+e);let n=C.extractNumber(e,t,r,s);return C.checkRange(t,r,s,n),C.checkMultipleOf(t,r,s,n),s}static extractNumber(e,t,r,s){let n=s;try{e!=E.LONG&&e!=E.INTEGER||(n=Math.round(n))}catch(r){throw new M(F.path(t),s+" is not a number of type "+e,r)}if(c(n)||(e==E.LONG||e==E.INTEGER)&&n!=s)throw new M(F.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 M(F.path(e),r.toString()+" is not multiple of "+t.getMultipleOf())}}static checkRange(e,t,r,s){if(t.getMinimum()&&C.numberCompare(s,t.getMinimum())<0)throw new M(F.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&C.numberCompare(s,t.getMaximum())>0)throw new M(F.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&C.numberCompare(s,t.getExclusiveMinimum())<=0)throw new M(F.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&C.numberCompare(s,t.getExclusiveMaximum())>0)throw new M(F.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}class b{static validate(e,t,r,s){if(c(s))throw new M(F.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new M(F.path(e),s.toString()+" is not an Object");let n=s,i=new Set(Object.keys(n));b.checkMinMaxProperties(e,t,i),t.getPropertyNames()&&b.checkPropertyNameSchema(e,t,r,i),t.getRequired()&&b.checkRequired(e,t,n),t.getProperties()&&b.checkProperties(e,t,r,n,i),t.getPatternProperties()&&b.checkPatternProperties(e,t,r,n,i),t.getAdditionalProperties()&&b.checkAddtionalProperties(e,t,r,n,i)}static checkPropertyNameSchema(e,t,r,s){for(let n of Array.from(s.values()))try{F.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new M(F.path(e),"Property name '"+n+"' does not fit the property schema")}}static checkRequired(e,t,r){for(const s of t.getRequired()??[])if(c(r[s]))throw new M(F.path(e),s+" is mandatory")}static checkAddtionalProperties(e,t,r,s,n){let i=t.getAdditionalProperties();if(i.getSchemaValue())for(let t of Array.from(n.values())){let n=e?[...e]:[],a=F.validate(n,i.getSchemaValue(),r,s.get(t));s[t]=a}else if(!1===i.getBooleanValue()&&n.size)throw new M(F.path(e),n.toString()+" are additional properties which are not allowed.")}static checkPatternProperties(e,t,r,s,n){const i=new Map;for(const e of Array.from(t.getPatternProperties().keys()))i.set(e,new RegExp(e));for(const a of Array.from(n.values())){const o=e?[...e]:[];for(const e of Array.from(i.entries()))if(e[1].test(a)){const i=F.validate(o,t.getPatternProperties().get(e[0]),r,s[a]);s[a]=i,n.delete(a);break}}}static checkProperties(e,t,r,s,n){for(const i of Array.from(t.getProperties())){let t=s[i[0]];if(c(t))continue;let a=e?[...e]:[],o=F.validate(a,i[1],r,t);s[i[0]]=o,n.delete(i[0])}}static checkMinMaxProperties(e,t,r){if(t.getMinProperties()&&r.size<t.getMinProperties())throw new M(F.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new M(F.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}let V;var D;(D=V||(V={})).DATETIME="DATETIME",D.TIME="TIME",D.DATE="DATE",D.EMAIL="EMAIL",D.REGEX="REGEX";class k{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 validate(e,t,r){if(c(r))throw new M(F.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new M(F.path(e),r.toString()+" is not String");t.getFormat()==V.TIME?k.patternMatcher(e,t,r,k.TIME,"time pattern"):t.getFormat()==V.DATE?k.patternMatcher(e,t,r,k.DATE,"date pattern"):t.getFormat()==V.DATETIME?k.patternMatcher(e,t,r,k.DATETIME,"date time pattern"):t.getPattern()&&k.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new M(F.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMinLength())throw new M(F.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new M(F.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class G{static validate(e,t,r,s,n){if(t==E.STRING)k.validate(e,r,n);else if(t==E.LONG||t==E.INTEGER||t==E.DOUBLE||t==E.FLOAT)C.validate(t,e,r,n);else if(t==E.BOOLEAN)(class{static validate(e,t,r){if(c(r))throw new M(F.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new M(F.path(e),r.toString()+" is not a boolean");return r}constructor(){}}).validate(e,r,n);else if(t==E.OBJECT)b.validate(e,r,s,n);else if(t==E.ARRAY)B.validate(e,r,s,n);else{if(t!=E.NULL)throw new M(F.path(e),t+" is not a valid type.");(class{static validate(e,t,r){if(r)throw new M(F.path(e),"Expected a null but found "+r);return r}constructor(){}}).validate(e,r,n)}return n}constructor(){}}class F{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)return s;if(e||(e=new Array),e.push(t),c(s)&&!c(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return F.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return F.enumCheck(e,t,s);if(t.getType()&&F.typeValidation(e,t,r,s),!_.isNullOrBlank(t.getRef()))return F.validate(e,L.getSchemaFromRef(e[0],r,t.getRef()),r,s);if((t.getOneOf()||t.getAllOf()||t.getAnyOf())&&U.validate(e,t,r,s),t.getNot()){let n=!1;try{F.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new M(F.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new M(F.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 M(F.path(e),"Value is not one of "+t.getEnums())}static typeValidation(e,t,r,s){let n=!1,i=[];for(const a of Array.from(t.getType()?.getAllowedSchemaTypes()?.values()??[]))try{G.validate(e,a,t,r,s),n=!0;break}catch(e){n=!1,i.push(e)}if(!n)throw new M(F.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",i)}constructor(){}}var $={};t($,"KIRunConstants",(()=>Y));class Y{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}var H={};t(H,"ExecutionException",(()=>W));class W extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var j={};t(j,"AbstractFunction",(()=>q));class q{validateArguments(e){return Array.from(this.getSignature().getParameters().entries()).map((t=>{let r,n=t[0],i=t[1],a=e.get(t[0]);if(c(a))return new s(n,F.validate(void 0,i.getSchema(),void 0,void 0));if(!i?.isVariableArgument())return new s(n,F.validate(void 0,i.getSchema(),void 0,a));Array.isArray(a)?r=a:(r=[],r.push(a));for(const e of r)F.validate(void 0,i.getSchema(),void 0,e);return new s(n,a)})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}execute(e){return e.setArguments(this.validateArguments(e.getArguments()??new Map)),this.internalExecute(e)}getProbableEventSignature(e){return this.getSignature().getEvents()}}var X={};t(X,"KIRuntime",(()=>Vt));class Q{constructor(e){this.expression=e}getExpression(){return this.expression}}class J{static OUTPUT="output";static ERROR="error";static ITERATION="iteration";static TRUE="true";static FALSE="false";static SCHEMA_NAME="Event";static SCHEMA=(new N).setNamespace(l.SYSTEM).setName(J.SCHEMA_NAME).setType(S.of(E.OBJECT)).setProperties(new Map([["name",N.ofString("name")],["parameters",N.ofObject("parameter").setAdditionalProperties((new g).setSchemaValue(N.SCHEMA))]]));constructor(e,t){this.name=e,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 J.eventMapEntry(J.OUTPUT,e)}static eventMapEntry(e,t){return[e,new J(e,t)]}}class K{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 K.of(J.OUTPUT,e)}static of(e,t){return new K(e,t)}}class z{index=0;constructor(e){if(c(e))throw new y("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof K?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}}let Z;var ee;(ee=Z||(Z={})).CONSTANT="CONSTANT",ee.EXPRESSION="EXPRESSION";class te{static SCHEMA_NAME="Parameter";static SCHEMA=(new N).setNamespace(l.SYSTEM).setName(te.SCHEMA_NAME).setProperties(new Map([["schema",N.SCHEMA],["parameterName",N.ofString("parameterName")],["variableArgument",N.of("variableArgument",E.BOOLEAN).setDefaultValue(!1)]]));static EXPRESSION=(new N).setNamespace(l.SYSTEM).setName("ParameterExpression").setType(S.of(E.OBJECT)).setProperties(new Map([["isExpression",N.ofBoolean("isExpression").setDefaultValue(!0)],["value",N.ofAny("value")]]));variableArgument=!1;type=Z.EXPRESSION;constructor(e,t){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=Z.EXPRESSION){return[e,new te(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=Z.EXPRESSION){return new te(e,t).setType(s).setVariableArgument(r)}}let re;var se;(se=re||(re={})).VALUE="VALUE",se.EXPRESSION="EXPRESSION";var ne={};t(ne,"LinkedList",(()=>ie));class ie{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new ae(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new ae(t);this.length=e.length}}push(e){const t=new ae(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 y(v.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 ae(e,this.head),this.head.next=this.tail):(this.tail=new ae(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new ae(e),this}map(e,t){let r=new ie,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class ae{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}var oe={};t(oe,"ExpressionEvaluator",(()=>yt));class he{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 y(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}var ue={};t(ue,"ExpressionEvaluationException",(()=>le));class le extends Error{constructor(e,t,r){super(v.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}var pe={};t(pe,"Expression",(()=>Ee));var ce={};t(ce,"ExpressionToken",(()=>me));class me{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}var ge={};t(ge,"Operation",(()=>fe));class fe{static MULTIPLICATION=new fe("*");static DIVISION=new fe("/");static INTEGER_DIVISION=new fe("//");static MOD=new fe("%");static ADDITION=new fe("+");static SUBTRACTION=new fe("-");static NOT=new fe("not",void 0,!0);static AND=new fe("and",void 0,!0);static OR=new fe("or",void 0,!0);static LESS_THAN=new fe("<");static LESS_THAN_EQUAL=new fe("<=");static GREATER_THAN=new fe(">");static GREATER_THAN_EQUAL=new fe(">=");static EQUAL=new fe("=");static NOT_EQUAL=new fe("!=");static BITWISE_AND=new fe("&");static BITWISE_OR=new fe("|");static BITWISE_XOR=new fe("^");static BITWISE_COMPLEMENT=new fe("~");static BITWISE_LEFT_SHIFT=new fe("<<");static BITWISE_RIGHT_SHIFT=new fe(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new fe(">>>");static UNARY_PLUS=new fe("UN: +","+");static UNARY_MINUS=new fe("UN: -","-");static UNARY_LOGICAL_NOT=new fe("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new fe("UN: ~","~");static ARRAY_OPERATOR=new fe("[");static OBJECT_OPERATOR=new fe(".");static VALUE_OF=new Map([["MULTIPLICATION",fe.MULTIPLICATION],["DIVISION",fe.DIVISION],["INTEGER_DIVISON",fe.INTEGER_DIVISION],["MOD",fe.MOD],["ADDITION",fe.ADDITION],["SUBTRACTION",fe.SUBTRACTION],["NOT",fe.NOT],["AND",fe.AND],["OR",fe.OR],["LESS_THAN",fe.LESS_THAN],["LESS_THAN_EQUAL",fe.LESS_THAN_EQUAL],["GREATER_THAN",fe.GREATER_THAN],["GREATER_THAN_EQUAL",fe.GREATER_THAN_EQUAL],["EQUAL",fe.EQUAL],["NOT_EQUAL",fe.NOT_EQUAL],["BITWISE_AND",fe.BITWISE_AND],["BITWISE_OR",fe.BITWISE_OR],["BITWISE_XOR",fe.BITWISE_XOR],["BITWISE_COMPLEMENT",fe.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",fe.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",fe.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",fe.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",fe.UNARY_PLUS],["UNARY_MINUS",fe.UNARY_MINUS],["UNARY_LOGICAL_NOT",fe.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",fe.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",fe.ARRAY_OPERATOR],["OBJECT_OPERATOR",fe.OBJECT_OPERATOR]]);static UNARY_OPERATORS=new Set([fe.ADDITION,fe.SUBTRACTION,fe.NOT,fe.BITWISE_COMPLEMENT,fe.UNARY_PLUS,fe.UNARY_MINUS,fe.UNARY_LOGICAL_NOT,fe.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([fe.MULTIPLICATION,fe.DIVISION,fe.INTEGER_DIVISION,fe.MOD,fe.ADDITION,fe.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([fe.NOT,fe.AND,fe.OR,fe.LESS_THAN,fe.LESS_THAN_EQUAL,fe.GREATER_THAN,fe.GREATER_THAN_EQUAL,fe.EQUAL,fe.NOT_EQUAL]);static BITWISE_OPERATORS=new Set([fe.BITWISE_AND,fe.BITWISE_COMPLEMENT,fe.BITWISE_LEFT_SHIFT,fe.BITWISE_OR,fe.BITWISE_RIGHT_SHIFT,fe.BITWISE_UNSIGNED_RIGHT_SHIFT,fe.BITWISE_XOR]);static OPERATOR_PRIORITY=new Map([[fe.UNARY_PLUS,1],[fe.UNARY_MINUS,1],[fe.UNARY_LOGICAL_NOT,1],[fe.UNARY_BITWISE_COMPLEMENT,1],[fe.ARRAY_OPERATOR,1],[fe.OBJECT_OPERATOR,1],[fe.MULTIPLICATION,2],[fe.DIVISION,2],[fe.INTEGER_DIVISION,2],[fe.MOD,2],[fe.ADDITION,3],[fe.SUBTRACTION,3],[fe.BITWISE_LEFT_SHIFT,4],[fe.BITWISE_RIGHT_SHIFT,4],[fe.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[fe.LESS_THAN,5],[fe.LESS_THAN_EQUAL,5],[fe.GREATER_THAN,5],[fe.GREATER_THAN_EQUAL,5],[fe.EQUAL,6],[fe.NOT_EQUAL,6],[fe.BITWISE_AND,7],[fe.BITWISE_XOR,8],[fe.BITWISE_OR,9],[fe.AND,10],[fe.OR,11]]);static OPERATORS=new Set([...Array.from(fe.ARITHMETIC_OPERATORS),...Array.from(fe.LOGICAL_OPERATORS),...Array.from(fe.BITWISE_OPERATORS),fe.ARRAY_OPERATOR,fe.OBJECT_OPERATOR].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(fe.ARITHMETIC_OPERATORS),...Array.from(fe.LOGICAL_OPERATORS),...Array.from(fe.BITWISE_OPERATORS),fe.ARRAY_OPERATOR,fe.OBJECT_OPERATOR].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(fe.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[fe.ADDITION,fe.UNARY_PLUS],[fe.SUBTRACTION,fe.UNARY_MINUS],[fe.NOT,fe.UNARY_LOGICAL_NOT],[fe.BITWISE_COMPLEMENT,fe.UNARY_BITWISE_COMPLEMENT],[fe.UNARY_PLUS,fe.UNARY_PLUS],[fe.UNARY_MINUS,fe.UNARY_MINUS],[fe.UNARY_LOGICAL_NOT,fe.UNARY_LOGICAL_NOT],[fe.UNARY_BITWISE_COMPLEMENT,fe.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(fe.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 fe.VALUE_OF.get(e)}toString(){return this.operator}}class Ee extends me{tokens=new ie;ops=new ie;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 he(""),n=0,i=!1;for(;n<e;){switch(r=this.expression[n],t=s.toString(),r){case" ":i=this.processTokenSepearator(s,t,i);break;case"(":n=this.processSubExpression(e,s,t,n,i),i=!1;break;case")":throw new le(this.expression,"Extra closing parenthesis found");case"]":throw new le(this.expression,"Extra closing square bracket found");default:let a=this.processOthers(r,e,s,t,n,i);n=a.getT1(),i=a.getT2(),i&&this.ops.peek()==fe.ARRAY_OPERATOR&&(a=this.process(e,s,n),n=a.getT1(),i=a.getT2())}++n}if(t=s.toString(),!_.isNullOrBlank(t)){if(fe.OPERATORS.has(t))throw new le(this.expression,"Expression is ending with an operator");this.tokens.push(new me(t))}}process(e,t,r){let n=1;for(++r;r<e&&0!=n;){let e=this.expression.charAt(r);"]"==e?--n:"["==e&&++n,0!=n&&(t.append(e),r++)}return this.tokens.push(new Ee(t.toString())),t.setLength(0),new s(r,!1)}processOthers(e,t,r,n,i,a){let o=t-i;o=o<fe.BIGGEST_OPERATOR_SIZE?o:fe.BIGGEST_OPERATOR_SIZE;for(let e=o;e>0;e--){let t=this.expression.substring(i,i+e);if(fe.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return _.isNullOrBlank(n)||(this.tokens.push(new me(n)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,fe.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new s(i+e-1,a)}return r.append(e),new s(i,!1)}processSubExpression(e,t,r,s,n){if(fe.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,fe.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!_.isNullOrBlank(r))throw new le(this.expression,v.format("Unkown token : $ found.",r));let i=1;const a=new he;let o=this.expression.charAt(s);for(s++;s<e&&i>0;)o=this.expression.charAt(s),"("==o?i++:")"==o&&i--,0!=i&&(a.append(o),s++);if(")"!=o)throw new le(this.expression,"Missing a closed parenthesis");for(;a.length()>2&&"("==a.charAt(0)&&")"==a.charAt(a.length()-1);)a.deleteCharAt(0),a.setLength(a.length()-1);return this.tokens.push(new Ee(a.toString().trim())),s}processTokenSepearator(e,t,r){return _.isNullOrBlank(t)||(fe.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,fe.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new me(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!fe.UNARY_OPERATORS.has(r))throw new le(this.expression,v.format("Extra operator $ found.",r));{const e=fe.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(fe.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new Ee("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new Ee("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=fe.OPERATOR_PRIORITY.get(e),s=fe.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 he,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 Ee?s[t].toString():s[t]).append(")"),t++;else{if(0==t){const r=s[t++];e.insert(0,r.toString())}const i=s[t++];e.insert(0,r[n].getOperator()).insert(0,i.toString()).insert(0,"(").append(")")}return e.toString()}equals(e){return this.expression==e.expression}}var Te={};t(Te,"ExpressionTokenValue",(()=>Ae));class Ae extends me{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return v.format("$: $",this.expression,this.element)}}var de={};t(de,"ArithmeticAdditionOperator",(()=>Ne));var Oe={};t(Oe,"BinaryOperator",(()=>Se));class Se{nullCheck(e,t,r){if(c(e)||c(t))throw new W(v.format("$ cannot be applied to a null value",r.getOperatorName()))}}class Ne extends Se{apply(e,t){return this.nullCheck(e,t,fe.ADDITION),e+t}}var Ie={};t(Ie,"ArithmeticDivisionOperator",(()=>Re));class Re extends Se{apply(e,t){return this.nullCheck(e,t,fe.DIVISION),e/t}}var we={};t(we,"ArithmeticIntegerDivisionOperator",(()=>ye));class ye extends Se{apply(e,t){return this.nullCheck(e,t,fe.DIVISION),Math.floor(e/t)}}var xe={};t(xe,"ArithmeticModulusOperator",(()=>ve));class ve extends Se{apply(e,t){return this.nullCheck(e,t,fe.MOD),e%t}}var _e={};t(_e,"ArithmeticMultiplicationOperator",(()=>Pe));class Pe extends Se{apply(e,t){return this.nullCheck(e,t,fe.MULTIPLICATION),e*t}}var Me={};t(Me,"ArithmeticSubtractionOperator",(()=>Le));class Le extends Se{apply(e,t){return this.nullCheck(e,t,fe.SUBTRACTION),e-t}}var Ue={};t(Ue,"ArrayOperator",(()=>Be));class Be extends Se{apply(e,t){if(!e)throw new W("Cannot apply array operator on a null value");if(!t)throw new W("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new W(v.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new W(v.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var Ce={};t(Ce,"BitwiseAndOperator",(()=>be));class be extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_AND),e&t}}var Ve={};t(Ve,"BitwiseLeftShiftOperator",(()=>De));class De extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_LEFT_SHIFT),e<<t}}var ke={};t(ke,"BitwiseOrOperator",(()=>Ge));class Ge extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_OR),e|t}}var Fe={};t(Fe,"BitwiseRightShiftOperator",(()=>$e));class $e extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_RIGHT_SHIFT),e>>t}}var Ye={};t(Ye,"BitwiseUnsignedRightShiftOperator",(()=>He));class He extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var We={};t(We,"BitwiseXorOperator",(()=>je));class je extends Se{apply(e,t){return this.nullCheck(e,t,fe.BITWISE_XOR),e^t}}var qe={};t(qe,"LogicalAndOperator",(()=>Qe));class Xe{static findPrimitiveNullAsBoolean(e){if(!e)return new s(E.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new W(v.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new s(E.BOOLEAN,r):"string"===t?new s(E.STRING,r):Xe.findPrimitiveNumberType(r)}static findPrimitive(e){if(c(e))return new s(E.NULL,void 0);let t=typeof e;if("object"===t)throw new W(v.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new s(E.BOOLEAN,r):"string"===t?new s(E.STRING,r):Xe.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(c(e)||Array.isArray(e)||"object"==typeof e)throw new W(v.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new s(E.LONG,e):new s(E.DOUBLE,e)}catch(e){throw new W(v.format("Unable to convert $ to a number.",t),e)}}static compare(e,t){if(e==t)return 0;if(c(e)||c(t))return c(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 c(e)||c(t)?c(e)&&c(t)?0:c(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)?E.LONG:E.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class Qe extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()!=E.BOOLEAN)throw new W(v.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=E.BOOLEAN)throw new W(v.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var Je={};t(Je,"LogicalEqualOperator",(()=>Ke));class Ke extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);return r.getT2()==s.getT2()}}var ze={};t(ze,"LogicalGreaterThanEqualOperator",(()=>Ze));class Ze extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()==E.BOOLEAN||s.getT1()==E.BOOLEAN)throw new W(v.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var et={};t(et,"LogicalGreaterThanOperator",(()=>tt));class tt extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()==E.BOOLEAN||s.getT1()==E.BOOLEAN)throw new W(v.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var rt={};t(rt,"LogicalLessThanEqualOperator",(()=>st));class st extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()==E.BOOLEAN||s.getT1()==E.BOOLEAN)throw new W(v.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var nt={};t(nt,"LogicalLessThanOperator",(()=>it));class it extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()==E.BOOLEAN||s.getT1()==E.BOOLEAN)throw new W(v.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var at={};t(at,"LogicalNotEqualOperator",(()=>ot));class ot extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);return r.getT2()!=s.getT2()}}var ht={};t(ht,"LogicalOrOperator",(()=>ut));class ut extends Se{apply(e,t){const r=Xe.findPrimitiveNullAsBoolean(e),s=Xe.findPrimitiveNullAsBoolean(t);if(r.getT1()!=E.BOOLEAN)throw new W(v.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=E.BOOLEAN)throw new W(v.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var lt={};t(lt,"ObjectOperator",(()=>pt));class pt extends Se{apply(e,t){if(!e)throw new W("Cannot apply array operator on a null value");if(!t)throw new W("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new W(v.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var ct={};t(ct,"ArithmeticUnaryMinusOperator",(()=>ft));var mt={};t(mt,"UnaryOperator",(()=>gt));class gt{nullCheck(e,t){if(c(e))throw new W(v.format("$ cannot be applied to a null value",t.getOperatorName()))}}class ft extends gt{apply(e){return this.nullCheck(e,fe.UNARY_MINUS),Xe.findPrimitiveNumberType(e),-e}}var Et={};t(Et,"ArithmeticUnaryPlusOperator",(()=>Tt));class Tt extends gt{apply(e){return this.nullCheck(e,fe.UNARY_PLUS),Xe.findPrimitiveNumberType(e),e}}var At={};t(At,"BitwiseComplementOperator",(()=>dt));class dt extends gt{apply(e){this.nullCheck(e,fe.UNARY_BITWISE_COMPLEMENT);let t=Xe.findPrimitiveNumberType(e);if(t.getT1()!=E.INTEGER&&t.getT1()!=E.LONG)throw new W(v.format("Unable to apply bitwise operator on $",e));return~e}}var Ot={};t(Ot,"LogicalNotOperator",(()=>St));class St extends gt{apply(e){if(this.nullCheck(e,fe.UNARY_LOGICAL_NOT),Xe.findPrimitiveNumberType(e).getT1()!=E.BOOLEAN)throw new W(v.format("Unable to apply bitwise operator on $",e));return!e}}var Nt={};t(Nt,"TokenValueExtractor",(()=>It));class It{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new y(v.format("Token $ doesn't start with $",e,t));return this.getValueInternal(e)}retrieveElementFrom(e,t,r,s){if(c(s))return;if(t.length==r)return s;let n=t[r].split(It.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!_.isNullOrBlank(e))).reduce(((s,n,i)=>this.resolveForEachPartOfTokenWithBrackets(e,t,r,n,s,i)),s);return this.retrieveElementFrom(e,t,r+1,n)}resolveForEachPartOfTokenWithBrackets(e,t,r,s,n,i){if(!c(n)){if(0===i){if(Array.isArray(n)){if("length"===s)return n.length;try{let e=parseInt(s);if(isNaN(e))throw new Error(v.format("$ is not a number",e));if(e>=n.length)return;return n[e]}catch(t){throw new le(e,v.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 le(e,v.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(v.format("$ is not a number",t));if(!Array.isArray(n))throw new le(e,v.format("Expecting an array with index $ while processing the expression",t,e));if(t>=n.length)return;return n[t]}catch(t){throw new le(e,v.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 le(e,v.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const Rt=new Map([["true",!0],["false",!1],["null",void 0]]);class wt extends It{static INSTANCE=new wt;getValueInternal(e){if(!_.isNullOrBlank(e))return e=e.trim(),Rt.has(e)?Rt.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t;if(t=-1==e.indexOf(".")?parseInt(e):parseFloat(e),isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new le(e,v.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new le(e,v.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}class yt{static UNARY_OPERATORS_MAP=new Map([[fe.UNARY_BITWISE_COMPLEMENT,new dt],[fe.UNARY_LOGICAL_NOT,new St],[fe.UNARY_MINUS,new ft],[fe.UNARY_PLUS,new Tt]]);static BINARY_OPERATORS_MAP=new Map([[fe.ADDITION,new Ne],[fe.DIVISION,new Re],[fe.INTEGER_DIVISION,new ye],[fe.MOD,new ve],[fe.MULTIPLICATION,new Pe],[fe.SUBTRACTION,new Le],[fe.BITWISE_AND,new be],[fe.BITWISE_LEFT_SHIFT,new De],[fe.BITWISE_OR,new Ge],[fe.BITWISE_RIGHT_SHIFT,new $e],[fe.BITWISE_UNSIGNED_RIGHT_SHIFT,new He],[fe.BITWISE_XOR,new je],[fe.AND,new Qe],[fe.EQUAL,new Ke],[fe.GREATER_THAN,new tt],[fe.GREATER_THAN_EQUAL,new Ze],[fe.LESS_THAN,new it],[fe.LESS_THAN_EQUAL,new st],[fe.OR,new ut],[fe.NOT_EQUAL,new ot],[fe.ARRAY_OPERATOR,new Be],[fe.OBJECT_OPERATOR,new pt]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(yt.UNARY_OPERATORS_MAP.keys());constructor(e){e instanceof Ee?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){return this.exp||(this.exp=new Ee(this.expression)),this.evaluateExpression(this.exp,e)}getExpression(){return this.exp||(this.exp=new Ee(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(),a=s.pop();if(yt.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,a)));else if(e==fe.OBJECT_OPERATOR||e==fe.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,a);else{const r=s.pop();var n=this.getValueFromToken(t,r),i=this.getValueFromToken(t,a);s.push(this.applyBinaryOperation(e,n,i))}}if(s.isEmpty())throw new W(v.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new W(v.format("Expression : $ evaluated multiple values $",e,s));const a=s.get(0);if(a instanceof Ae)return a.getElement();if(!(a instanceof Ee))return this.getValueFromToken(t,a);throw new W(v.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const i=new ie,a=new ie;if(!s||!n)return;do{a.push(s),n instanceof Ee?i.push(new Ae(n.toString(),this.evaluateExpression(n,e))):n&&i.push(n),n=r.isEmpty()?void 0:r.pop(),s=t.isEmpty()?void 0:t.pop()}while(s==fe.OBJECT_OPERATOR||s==fe.ARRAY_OPERATOR);n&&(n instanceof Ee?i.push(new Ae(n.toString(),this.evaluateExpression(n,e))):i.push(n)),s&&t.push(s);let o=i.pop(),h=new he(o instanceof Ae?o.getTokenValue():o.toString());for(;!i.isEmpty();)o=i.pop(),s=a.pop(),h.append(s.getOperator()).append(o instanceof Ae?o.getTokenValue():o.toString()),s==fe.ARRAY_OPERATOR&&h.append("]");let u=h.toString(),l=u.substring(0,u.indexOf(".")+1);if(l.length>2&&e.has(l))r.push(new Ae(u,this.getValue(u,e)));else{let e;try{e=wt.INSTANCE.getValue(u)}catch(t){e=u}r.push(new Ae(u,e))}}applyBinaryOperation(e,t,r){if("object"===typeof t||"object"===typeof r||Array.isArray(t)||Array.isArray(r))throw new le(this.expression,v.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));let s=yt.BINARY_OPERATORS_MAP.get(e);if(!s)throw new le(this.expression,v.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new Ae(e.toString(),s.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new le(this.expression,v.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=yt.UNARY_OPERATORS_MAP.get(e);if(!r)throw new le(this.expression,v.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new Ae(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof Ee?this.evaluateExpression(t,e):t instanceof Ae?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return wt.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??wt.INSTANCE).getValue(e)}}class xt extends It{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(It.REGEX_DOT);return this.retrieveElementFrom(e,t,2,this.args.get(t[1]))}getPrefix(){return xt.PREFIX}}class vt extends It{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(It.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 vt.PREFIX}}class _t extends It{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(It.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 i=n.get(t[r++]);return this.retrieveElementFrom(e,t,r,i)}getPrefix(){return _t.PREFIX}}class Pt{count=0;valueExtractors=new Map;getContext(){return this.context}setContext(e){this.context=e;let t=new vt(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new xt(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 _t(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}}class Mt{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 s(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new s(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 Lt(!0);var r=new ie(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}}class Lt{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 Mt(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 ie(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 Ut{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 Bt{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 Ut(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof Bt))return!1;return e.statement.equals(this.statement)}}let Ct;var bt;(bt=Ct||(Ct={})).ERROR="ERROR",bt.WARNING="WARNING",bt.MESSAGE="MESSAGE";class Vt extends q{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;constructor(e,t,r){if(super(),this.fd=e,this.fd.getVersion()>Vt.VERSION)throw new y("Runtime is at a lower version "+Vt.VERSION+" and trying to run code from version "+this.fd.getVersion()+".");this.fRepo=t,this.sRepo=r}getSignature(){return this.fd}getExecutionPlan(e){let t=new Lt;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(e,r));let r=this.makeEdges(t);if(r.length)throw new y(v.format("Found these unresolved dependencies : $ ",r.map((e=>v.format("Steps.$.$",e.getT1(),e.getT2())))));return t}internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map);let t=this.getExecutionPlan(e.getContext()),r=t.getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(r?.length)throw new y("Please fix the errors in the function definition before execution : \n"+r.join(",\n"));return this.executeGraph(t,e)}executeGraph(e,t){let r=new ie;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new ie;for(;!(r.isEmpty()&&s.isEmpty()||t.getEvents()?.has(J.OUTPUT));)if(this.processBranchQue(t,r,s),this.processExecutionQue(t,r,s),t.setCount(t.getCount()+1),t.getCount()==Vt.MAX_EXECUTION_ITERATIONS)throw new y("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new y("No events raised");return new z(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>K.of(e[0],t))))))}processExecutionQue(e,t,r){if(!t.isEmpty()){let s=t.pop();this.allDependenciesResolvedVertex(s,e.getSteps())?this.executeVertex(s,e,r,t):t.add(s)}}processBranchQue(e,t,r){if(r.length){let s=r.pop();this.allDependenciesResolvedTuples(s.getT2(),e.getSteps())?this.executeBranch(e,t,s):r.add(s)}}executeBranch(e,t,r){let s,n=r.getT4();do{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)))}while(s&&s.getName()!=J.OUTPUT);s?.getName()==J.OUTPUT&&n.getOutVertices().has(J.OUTPUT)&&(n?.getOutVertices()?.get(J.OUTPUT)??[]).forEach((e=>t.add(e)))}executeVertex(e,t,r,s){let n=e.getData().getStatement(),a=this.fRepo.find(n.getNamespace(),n.getName());if(!a)throw new y(v.format("$.$ function is not found.",n.getNamespace(),n.getName()));let o=a?.getSignature().getParameters(),h=this.getArgumentsFromParametersMap(t,n,o??new Map),u=t.getContext(),l=a.execute((new Pt).setContext(u).setArguments(h).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),p=l.next();if(!p)throw new y(v.format("Executing $ returned no events",n.getStatementName()));let c=p.getName()==J.OUTPUT;if(t.getSteps()?.has(n.getStatementName())||t.getSteps().set(n.getStatementName(),new Map),t.getSteps().get(n.getStatementName()).set(p.getName(),this.resolveInternalExpressions(p.getResult(),t)),c){let t=e.getOutVertices().get(J.OUTPUT);t&&t.forEach((e=>s.add(e)))}else{let t=e.getSubGraphOfType(p.getName()),s=this.makeEdges(t);r.push(new i(t,s,l,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new s(e[0],this.resolveInternalExpression(e[1],t)))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map):e}resolveInternalExpression(e,t){if(c(e)||"object"!=typeof e)return e;if(e instanceof Q){return new yt(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 n,i=t[1];if(!i?.length)return new s(t[0],n);let a=r.get(t[0]);return a?(n=a.isVariableArgument()?i.map((t=>this.parameterReferenceEvaluation(e,t))).flatMap((e=>Array.isArray(e)?e:[e])):this.parameterReferenceEvaluation(e,i[0]),new s(t[0],n)):new s(t[0],void 0)})).filter((e=>!c(e.getT2()))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}parameterReferenceEvaluation(e,t){let r;if(t.getType()==re.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==re.EXPRESSION&&!_.isNullOrBlank(t.getExpression())){r=new yt(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t){let r=new Bt(t),s=this.fRepo.find(t.getNamespace(),t.getName());if(!s)throw new y(v.format("$.$ was not available",t.getNamespace(),t.getName()));let n=new Map(s.getSignature().getParameters());for(let s of Array.from(t.getParameterMap().entries())){let t=n.get(s[0]);if(!t)continue;let i=s[1];if(i.length){if(t.isVariableArgument())for(let s of i)this.parameterReferenceValidation(e,r,t,s);else{let s=i[0];this.parameterReferenceValidation(e,r,t,s)}n.delete(t.getParameterName())}else c(L.getDefaultValue(t.getSchema(),this.sRepo))&&r.addMessage(Ct.ERROR,v.format(Vt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}if(!c(r.getStatement().getDependentStatements()))for(let e of r.getStatement().getDependentStatements())r.addDependency(e);if(n.size)for(let e of Array.from(n.values()))c(L.getDefaultValue(e.getSchema(),this.sRepo))&&r.addMessage(Ct.ERROR,v.format(Vt.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return r}parameterReferenceValidation(e,t,r,n){if(n){if(n.getType()==re.VALUE){c(n.getValue())&&c(L.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Ct.ERROR,v.format(Vt.PARAMETER_NEEDS_A_VALUE,r.getParameterName()));let e=new ie;for(e.push(new s(r.getSchema(),n.getValue()));!e.isEmpty();){let r=e.pop();if(r.getT2()instanceof Q)this.addDependencies(t,r.getT2().getExpression());else{if(c(r.getT1())||c(r.getT1().getType()))continue;if(r.getT1().getType()?.contains(E.ARRAY)&&Array.isArray(r.getT2())){let t=r.getT1().getItems();if(!t)continue;if(t.isSingleType())for(let n of r.getT2())e.push(new s(t.getSingleSchema(),n));else{let n=r.getT2();for(let r=0;r<n.length;r++)e.push(new s(t.getTupleSchema()[r],n[r]))}}else if(r.getT1().getType()?.contains(E.OBJECT)&&"object"==typeof r.getT2()){let n=r.getT1();if(n.getName()===te.EXPRESSION.getName()&&n.getNamespace()===te.EXPRESSION.getNamespace()){let e=r.getT2();e.isExpression&&this.addDependencies(t,e.value)}else if(n.getProperties())for(let t of Object.entries(r.getT2()))n.getProperties().has(t[0])&&e.push(new s(n.getProperties().get(t[0]),t[1]))}}}}else if(n.getType()==re.EXPRESSION)if(_.isNullOrBlank(n.getExpression()))c(L.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Ct.ERROR,v.format(Vt.PARAMETER_NEEDS_A_VALUE,r.getParameterName()));else try{this.addDependencies(t,n.getExpression())}catch(e){t.addMessage(Ct.ERROR,v.format("Error evaluating $ : $",n.getExpression(),e))}}else c(L.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Ct.ERROR,v.format(Vt.PARAMETER_NEEDS_A_VALUE,r.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(Vt.STEP_REGEX_PATTERN)??[]).forEach((t=>e.addDependency(t)))}makeEdges(e){let t=e.getNodeMap().values(),r=[];for(let n of Array.from(t))for(let t of n.getData().getDependencies()){let i=t.indexOf(".",6),a=t.substring(6,i),o=t.indexOf(".",i+1),h=-1==o?t.substring(i+1):t.substring(i+1,o);e.getNodeMap().has(a)||r.push(new s(a,h));let u=e.getNodeMap().get(a);u&&n.addInEdgeTo(u,h)}return r}}var Dt={};e(Dt,de),e(Dt,Ie),e(Dt,we),e(Dt,xe),e(Dt,_e),e(Dt,Me),e(Dt,Ue),e(Dt,Oe),e(Dt,Ce),e(Dt,Ve),e(Dt,ke),e(Dt,Fe),e(Dt,Ye),e(Dt,We),e(Dt,qe),e(Dt,Je),e(Dt,ze),e(Dt,et),e(Dt,rt),e(Dt,at),e(Dt,nt),e(Dt,ht),e(Dt,lt);var kt={};e(kt,ct),e(kt,Et),e(kt,At),e(kt,Ot),e(kt,mt),e(module.exports,r),e(module.exports,{}),e(module.exports,a),e(module.exports,h),e(module.exports,f),e(module.exports,I),e(module.exports,$),e(module.exports,H),e(module.exports,w),e(module.exports,{}),e(module.exports,j),e(module.exports,u),e(module.exports,X),e(module.exports,pe),e(module.exports,oe),e(module.exports,Nt),e(module.exports,ue),e(module.exports,ce),e(module.exports,Te),e(module.exports,ge),e(module.exports,ne),e(module.exports,p),e(module.exports,x),e(module.exports,R),e(module.exports,Dt),e(module.exports,kt);
|
|
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",(()=>L));var s={};t(s,"Schema",(()=>N));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",(()=>l));var o={};function u(e){return null==e}t(o,"isNullValue",(()=>u));class l{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 l).setSingleSchema(e[0]):(new l).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&l.of(...N.fromListOfSchemas(e));let t=N.from(e);return t?l.of(t):void 0}}var p={};t(p,"AdditionalPropertiesType",(()=>h));class h{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 h;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}var m={};let c;var g;t(m,"SchemaType",(()=>c)),(g=c||(c={})).INTEGER="Integer",g.LONG="Long",g.FLOAT="Float",g.DOUBLE="Double",g.STRING="String",g.OBJECT="Object",g.ARRAY="Array",g.BOOLEAN="Boolean",g.NULL="Null";var f={};t(f,"TypeUtil",(()=>O));var E={};t(E,"MultipleType",(()=>d));var T={};t(T,"Type",(()=>A));class A{}class d extends A{constructor(e){super(),this.type=e}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}var S={};t(S,"SingleType",(()=>w));class w extends A{constructor(e){super(),this.type=e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class O{static of(...e){return 1==e.length?new w(e[0]):new d(new Set(e))}static from(e){return"string"==typeof e?O.of(e):Array.isArray(e)?O.of(...Array.of(e).map((e=>e)).map((e=>e))):void 0}}class N{static NULL=(new N).setNamespace(a.SYSTEM).setName("Null").setType(O.of(c.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new N).setType(O.of(c.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new N).setNamespace(a.SYSTEM).setName("Schema").setType(O.of(c.OBJECT)).setProperties(new Map([["namespace",N.of("namespace",c.STRING).setDefaultValue("_")],["name",N.ofString("name")],["version",N.of("version",c.INTEGER).setDefaultValue(1)],["ref",N.ofString("ref")],["type",(new N).setAnyOf([N.TYPE_SCHEMA,N.ofArray("type",N.TYPE_SCHEMA)])],["anyOf",N.ofArray("anyOf",N.ofRef("#/"))],["allOf",N.ofArray("allOf",N.ofRef("#/"))],["oneOf",N.ofArray("oneOf",N.ofRef("#/"))],["not",N.ofRef("#/")],["title",N.ofString("title")],["description",N.ofString("description")],["id",N.ofString("id")],["examples",N.ofAny("examples")],["defaultValue",N.ofAny("defaultValue")],["comment",N.ofString("comment")],["enums",N.ofArray("enums",N.ofString("enums"))],["constant",N.ofAny("constant")],["pattern",N.ofString("pattern")],["format",N.of("format",c.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",N.ofInteger("minLength")],["maxLength",N.ofInteger("maxLength")],["multipleOf",N.ofLong("multipleOf")],["minimum",N.ofNumber("minimum")],["maximum",N.ofNumber("maximum")],["exclusiveMinimum",N.ofNumber("exclusiveMinimum")],["exclusiveMaximum",N.ofNumber("exclusiveMaximum")],["properties",N.of("properties",c.OBJECT).setAdditionalProperties((new h).setSchemaValue(N.ofRef("#/")))],["additionalProperties",(new N).setName("additionalProperty").setNamespace(a.SYSTEM).setAnyOf([N.ofBoolean("additionalProperty"),N.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",N.ofArray("required",N.ofString("required")).setDefaultValue([])],["propertyNames",N.ofRef("#/")],["minProperties",N.ofInteger("minProperties")],["maxProperties",N.ofInteger("maxProperties")],["patternProperties",N.of("patternProperties",c.OBJECT).setAdditionalProperties((new h).setSchemaValue(N.ofRef("#/")))],["items",(new N).setName("items").setAnyOf([N.ofRef("#/").setName("item"),N.ofArray("tuple",N.ofRef("#/"))])],["contains",N.ofRef("#/")],["minItems",N.ofInteger("minItems")],["maxItems",N.ofInteger("maxItems")],["uniqueItems",N.ofBoolean("uniqueItems")],["$defs",N.of("$defs",c.OBJECT).setAdditionalProperties((new h).setSchemaValue(N.ofRef("#/")))],["permission",N.ofString("permission")]])).setRequired([]);static ofString(e){return(new N).setType(O.of(c.STRING)).setName(e)}static ofInteger(e){return(new N).setType(O.of(c.INTEGER)).setName(e)}static ofFloat(e){return(new N).setType(O.of(c.FLOAT)).setName(e)}static ofLong(e){return(new N).setType(O.of(c.LONG)).setName(e)}static ofDouble(e){return(new N).setType(O.of(c.DOUBLE)).setName(e)}static ofAny(e){return(new N).setType(O.of(c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE,c.STRING,c.BOOLEAN,c.ARRAY,c.NULL,c.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new N).setType(O.of(c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE,c.STRING,c.BOOLEAN,c.ARRAY,c.OBJECT)).setName(e)}static ofNumber(e){return(new N).setType(O.of(c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE)).setName(e)}static ofBoolean(e){return(new N).setType(O.of(c.BOOLEAN)).setName(e)}static of(e,...t){return(new N).setType(O.of(...t)).setName(e)}static ofObject(e){return(new N).setType(O.of(c.OBJECT)).setName(e)}static ofRef(e){return(new N).setRef(e)}static ofArray(e,...t){return(new N).setType(O.of(c.ARRAY)).setName(e).setItems(l.of(...t))}static fromListOfSchemas(e){if(u(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=N.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=N.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(u(e))return;let r=new N;return r.namespace=e.namespace,r.name=e.name,r.version=e.version,r.ref=e.ref,r.type=t?new w(c.STRING):O.from(r.type),r.anyOf=N.fromListOfSchemas(e.anyOf),r.allOf=N.fromListOfSchemas(e.allOf),r.oneOf=N.fromListOfSchemas(e.oneOf),r.not=N.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=N.fromMapOfSchemas(e.properties),r.additionalProperties=h.from(e.additionalProperties),r.required=e.required,r.propertyNames=N.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=N.fromMapOfSchemas(e.patternProperties),r.items=l.from(e.items),r.contains=N.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=N.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;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 w(c.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 R={};t(R,"Parameter",(()=>P));var v={};t(v,"SchemaReferenceException",(()=>I));class I 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 x;var M;t(y,"ParameterType",(()=>x)),(M=x||(x={})).CONSTANT="CONSTANT",M.EXPRESSION="EXPRESSION";class P{static SCHEMA_NAME="Parameter";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(P.SCHEMA_NAME).setProperties(new Map([["schema",N.SCHEMA],["parameterName",N.ofString("parameterName")],["variableArgument",N.of("variableArgument",c.BOOLEAN).setDefaultValue(!1)],["type",N.ofString("type").setEnums(["EXPRESSION","CONSTANT"])]]));static EXPRESSION=(new N).setNamespace(a.SYSTEM).setName("ParameterExpression").setType(O.of(c.OBJECT)).setProperties(new Map([["isExpression",N.ofBoolean("isExpression").setDefaultValue(!0)],["value",N.ofAny("value")]]));variableArgument=!1;type=x.EXPRESSION;constructor(e,t){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=x.EXPRESSION){return[e,new P(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=x.EXPRESSION){return new P(e,t).setType(s).setVariableArgument(r)}static from(e){const t=N.from(e.schema);if(!t)throw new I("","Parameter requires Schema");return new P(e.parameterName,t).setVariableArgument(!!e.variableArguments).setType(e.type??x.EXPRESSION)}}const _=new Map([["any",N.ofAny("any").setNamespace(a.SYSTEM)],["boolean",N.ofBoolean("boolean").setNamespace(a.SYSTEM)],["double",N.ofDouble("double").setNamespace(a.SYSTEM)],["float",N.ofFloat("float").setNamespace(a.SYSTEM)],["integer",N.ofInteger("integer").setNamespace(a.SYSTEM)],["long",N.ofLong("long").setNamespace(a.SYSTEM)],["number",N.ofNumber("number").setNamespace(a.SYSTEM)],["string",N.ofString("string").setNamespace(a.SYSTEM)],[P.EXPRESSION.getName(),P.EXPRESSION]]);class L{find(e,t){if(a.SYSTEM==e)return _.get(t)}}var C={};t(C,"KIRunFunctionRepository",(()=>Rr));var b={};t(b,"KIRuntimeException",(()=>U));class U extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var V={};let B;var D;t(V,"StringFormat",(()=>B)),(D=B||(B={})).DATETIME="DATETIME",D.TIME="TIME",D.DATE="DATE",D.EMAIL="EMAIL",D.REGEX="REGEX";var G={};t(G,"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 N).setNamespace(a.SYSTEM).setName(k.SCHEMA_NAME).setType(O.of(c.OBJECT)).setProperties(new Map([["name",N.ofString("name")],["parameters",N.ofObject("parameter").setAdditionalProperties((new h).setSchemaValue(N.SCHEMA))]]));constructor(e,t){this.name=e,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=N.from(e[1]);if(!t)throw new I("","Event expects a schema");return[e[0],t]}))))}}var F={};t(F,"EventResult",(()=>H));class H{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 H.of(k.OUTPUT,e)}static of(e,t){return new H(e,t)}}var Y={};t(Y,"FunctionOutput",(()=>$));class ${index=0;constructor(e){if(u(e))throw new U("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof H?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 W={};t(W,"FunctionSignature",(()=>j));class j{static SCHEMA_NAME="FunctionSignature";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(j.SCHEMA_NAME).setProperties(new Map([["name",N.ofString("name")],["namespace",N.ofString("namespace")],["parameters",N.ofObject("parameters").setAdditionalProperties((new h).setSchemaValue(P.SCHEMA))],["events",N.ofObject("events").setAdditionalProperties((new h).setSchemaValue(k.SCHEMA))]]));namespace="_";parameters=new Map;events=new Map;constructor(e){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 X={};t(X,"ContextElement",(()=>q));class q{static NULL=new q(N.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 J={};t(J,"StringFormatter",(()=>Q));class Q{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 K={};t(K,"AbstractFunction",(()=>Ie));var z={};t(z,"SchemaValidator",(()=>ve));var Z={};t(Z,"StringUtil",(()=>ee));class ee{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new U("String cannot be null");if(r<0||r>=e.length)throw new U(Q.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new U(Q.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 te={};t(te,"SchemaUtil",(()=>ue));var re={};t(re,"Tuple2",(()=>se)),t(re,"Tuple3",(()=>ne)),t(re,"Tuple4",(()=>ae));class se{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}}class ne extends se{constructor(e,t,r){super(e,t),this.t=r}getT3(){return this.t}}class ae extends ne{constructor(e,t,r,s){super(e,t,r),this.fr=s}getT4(){return this.fr}}var ie={};t(ie,"SchemaValidationException",(()=>oe));class oe 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 ue{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():ue.getDefaultValue(ue.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==ue.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new oe(r??"","Schema has a cyclic reference");if(!e||!r||ee.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=ue.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let a=r.split("/");return e=ue.resolveInternalSchema(e,t,r,s,a,1)}static resolveInternalSchema(e,t,r,s,n,a){let i=e;for(;a<n.length;){if("$defs"===n[a]){if(++a>=n.length||!i.get$defs())throw new I(r,ue.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);i=i.get$defs()?.get(n[a])}else{if(i&&(!i.getType()?.contains(c.OBJECT)||!i.getProperties()))throw new I(r,"Cannot retrievie schema from non Object type schemas");i=i.getProperties()?.get(n[a])}if(a++,!i)throw new I(r,ue.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!ee.isNullOrBlank(i.getRef())&&(i=ue.getSchemaFromRef(i,t,i.getRef(),s),!i))throw new I(r,ue.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return i}static resolveExternalSchema(e,t,r){if(!t)return;let s=ee.splitAtFirstOccurance(e?.getRef()??"","/");if(!s[0])return;let n=ee.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 se(a,r);if(r="#/"+s[1],!a)throw new I(r,ue.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new se(a,r)}}constructor(){}}var le={};t(le,"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 oe(ve.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 oe(ve.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 oe(ve.path(e),0==a?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}var he={};t(he,"TypeValidator",(()=>Re));var me={};t(me,"ArrayValidator",(()=>ce));class ce{static validate(e,t,r,s){if(u(s))throw new oe(ve.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new oe(ve.path(e),s.toString()+" is not an Array");let n=s;return ce.checkMinMaxItems(e,t,n),ce.checkItems(e,t,r,n),ce.checkUniqueItems(e,t,n),ce.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{ve.validate(i,t.getContains(),r,s[a]),n=!0;break}catch(e){n=!1}}if(!n)throw new oe(ve.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 oe(ve.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new oe(ve.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new oe(ve.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=ve.validate(a,n.getSingleSchema(),r,s[t]);s[t]=i}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new oe(ve.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=ve.validate(a,n.getTupleSchema()[t],r,s[t]);s[t]=i}}}constructor(){}}var ge={};t(ge,"BooleanValidator",(()=>fe));class fe{static validate(e,t,r){if(u(r))throw new oe(ve.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new oe(ve.path(e),r.toString()+" is not a boolean");return r}constructor(){}}var Ee={};t(Ee,"NullValidator",(()=>Te));class Te{static validate(e,t,r){if(r)throw new oe(ve.path(e),"Expected a null but found "+r);return r}constructor(){}}var Ae={};t(Ae,"NumberValidator",(()=>de));class de{static validate(e,t,r,s){if(u(s))throw new oe(ve.path(t),"Expected a number but found null");if("number"!=typeof s)throw new oe(ve.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!=c.LONG&&e!=c.INTEGER||(n=Math.round(n))}catch(r){throw new oe(ve.path(t),s+" is not a number of type "+e,r)}if(u(n)||(e==c.LONG||e==c.INTEGER)&&n!=s)throw new oe(ve.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 oe(ve.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 oe(ve.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&de.numberCompare(s,t.getMaximum())>0)throw new oe(ve.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&de.numberCompare(s,t.getExclusiveMinimum())<=0)throw new oe(ve.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&de.numberCompare(s,t.getExclusiveMaximum())>0)throw new oe(ve.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}var Se={};t(Se,"ObjectValidator",(()=>we));class we{static validate(e,t,r,s){if(u(s))throw new oe(ve.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new oe(ve.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{ve.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new oe(ve.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 oe(ve.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=ve.validate(n,a.getSchemaValue(),r,s.get(t));s[t]=i}else if(!1===a.getBooleanValue()&&n.size)throw new oe(ve.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=ve.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=ve.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 oe(ve.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new oe(ve.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}var Oe={};t(Oe,"StringValidator",(()=>Ne));class Ne{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 validate(e,t,r){if(u(r))throw new oe(ve.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new oe(ve.path(e),r.toString()+" is not String");t.getFormat()==B.TIME?Ne.patternMatcher(e,t,r,Ne.TIME,"time pattern"):t.getFormat()==B.DATE?Ne.patternMatcher(e,t,r,Ne.DATE,"date pattern"):t.getFormat()==B.DATETIME?Ne.patternMatcher(e,t,r,Ne.DATETIME,"date time pattern"):t.getPattern()&&Ne.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new oe(ve.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMinLength())throw new oe(ve.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new oe(ve.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class Re{static validate(e,t,r,s,n){if(t==c.STRING)Ne.validate(e,r,n);else if(t==c.LONG||t==c.INTEGER||t==c.DOUBLE||t==c.FLOAT)de.validate(t,e,r,n);else if(t==c.BOOLEAN)fe.validate(e,r,n);else if(t==c.OBJECT)we.validate(e,r,s,n);else if(t==c.ARRAY)ce.validate(e,r,s,n);else{if(t!=c.NULL)throw new oe(ve.path(e),t+" is not a valid type.");Te.validate(e,r,n)}return n}constructor(){}}class ve{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)return s;if(e||(e=new Array),e.push(t),u(s)&&!u(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return ve.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return ve.enumCheck(e,t,s);if(t.getType()&&ve.typeValidation(e,t,r,s),!ee.isNullOrBlank(t.getRef()))return ve.validate(e,ue.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{ve.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new oe(ve.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new oe(ve.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 oe(ve.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{Re.validate(e,i,t,r,s),n=!0;break}catch(e){n=!1,a.push(e)}if(!n)throw new oe(ve.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",a)}constructor(){}}class Ie{validateArguments(e){return Array.from(this.getSignature().getParameters().entries()).map((t=>{let r,s=t[0],n=t[1],a=e.get(t[0]);if(u(a))return new se(s,ve.validate(void 0,n.getSchema(),void 0,void 0));if(!n?.isVariableArgument())return new se(s,ve.validate(void 0,n.getSchema(),void 0,a));Array.isArray(a)?r=a:(r=[],r.push(a));for(const e of r)ve.validate(void 0,n.getSchema(),void 0,e);return new se(s,a)})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}async execute(e){return e.setArguments(this.validateArguments(e.getArguments()??new Map)),this.internalExecute(e)}getProbableEventSignature(e){return this.getSignature().getEvents()}}const ye=new j("Create").setNamespace(a.SYSTEM_CTX).setParameters(new Map([P.ofEntry("name",(new N).setName("name").setType(O.of(c.STRING)).setMinLength(1).setFormat(B.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,x.CONSTANT),P.ofEntry("schema",N.SCHEMA,!1,x.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const xe=new j("Get").setNamespace(a.SYSTEM_CTX).setParameters(new Map([P.ofEntry("name",(new N).setName("name").setType(O.of(c.STRING)).setMinLength(1).setFormat(B.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,x.CONSTANT)])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",N.ofAny("value")]]))]));var Me={};t(Me,"ExecutionException",(()=>Pe));class Pe extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}var _e={};t(_e,"Expression",(()=>Ye));var Le={};t(Le,"LinkedList",(()=>Ce));class Ce{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new be(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new be(t);this.length=e.length}}push(e){const t=new be(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 U(Q.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 be(e,this.head),this.head.next=this.tail):(this.tail=new be(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new be(e),this}map(e,t){let r=new Ce,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class be{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}var Ue={};t(Ue,"StringBuilder",(()=>Ve));class Ve{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 U(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}var Be={};t(Be,"ExpressionEvaluationException",(()=>De));class De extends Error{constructor(e,t,r){super(Q.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}var Ge={};t(Ge,"ExpressionToken",(()=>ke));class ke{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}var Fe={};t(Fe,"Operation",(()=>He));class He{static MULTIPLICATION=new He("*");static DIVISION=new He("/");static INTEGER_DIVISION=new He("//");static MOD=new He("%");static ADDITION=new He("+");static SUBTRACTION=new He("-");static NOT=new He("not",void 0,!0);static AND=new He("and",void 0,!0);static OR=new He("or",void 0,!0);static LESS_THAN=new He("<");static LESS_THAN_EQUAL=new He("<=");static GREATER_THAN=new He(">");static GREATER_THAN_EQUAL=new He(">=");static EQUAL=new He("=");static NOT_EQUAL=new He("!=");static BITWISE_AND=new He("&");static BITWISE_OR=new He("|");static BITWISE_XOR=new He("^");static BITWISE_COMPLEMENT=new He("~");static BITWISE_LEFT_SHIFT=new He("<<");static BITWISE_RIGHT_SHIFT=new He(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new He(">>>");static UNARY_PLUS=new He("UN: +","+");static UNARY_MINUS=new He("UN: -","-");static UNARY_LOGICAL_NOT=new He("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new He("UN: ~","~");static ARRAY_OPERATOR=new He("[");static OBJECT_OPERATOR=new He(".");static VALUE_OF=new Map([["MULTIPLICATION",He.MULTIPLICATION],["DIVISION",He.DIVISION],["INTEGER_DIVISON",He.INTEGER_DIVISION],["MOD",He.MOD],["ADDITION",He.ADDITION],["SUBTRACTION",He.SUBTRACTION],["NOT",He.NOT],["AND",He.AND],["OR",He.OR],["LESS_THAN",He.LESS_THAN],["LESS_THAN_EQUAL",He.LESS_THAN_EQUAL],["GREATER_THAN",He.GREATER_THAN],["GREATER_THAN_EQUAL",He.GREATER_THAN_EQUAL],["EQUAL",He.EQUAL],["NOT_EQUAL",He.NOT_EQUAL],["BITWISE_AND",He.BITWISE_AND],["BITWISE_OR",He.BITWISE_OR],["BITWISE_XOR",He.BITWISE_XOR],["BITWISE_COMPLEMENT",He.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",He.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",He.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",He.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",He.UNARY_PLUS],["UNARY_MINUS",He.UNARY_MINUS],["UNARY_LOGICAL_NOT",He.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",He.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",He.ARRAY_OPERATOR],["OBJECT_OPERATOR",He.OBJECT_OPERATOR]]);static UNARY_OPERATORS=new Set([He.ADDITION,He.SUBTRACTION,He.NOT,He.BITWISE_COMPLEMENT,He.UNARY_PLUS,He.UNARY_MINUS,He.UNARY_LOGICAL_NOT,He.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([He.MULTIPLICATION,He.DIVISION,He.INTEGER_DIVISION,He.MOD,He.ADDITION,He.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([He.NOT,He.AND,He.OR,He.LESS_THAN,He.LESS_THAN_EQUAL,He.GREATER_THAN,He.GREATER_THAN_EQUAL,He.EQUAL,He.NOT_EQUAL]);static BITWISE_OPERATORS=new Set([He.BITWISE_AND,He.BITWISE_COMPLEMENT,He.BITWISE_LEFT_SHIFT,He.BITWISE_OR,He.BITWISE_RIGHT_SHIFT,He.BITWISE_UNSIGNED_RIGHT_SHIFT,He.BITWISE_XOR]);static OPERATOR_PRIORITY=new Map([[He.UNARY_PLUS,1],[He.UNARY_MINUS,1],[He.UNARY_LOGICAL_NOT,1],[He.UNARY_BITWISE_COMPLEMENT,1],[He.ARRAY_OPERATOR,1],[He.OBJECT_OPERATOR,1],[He.MULTIPLICATION,2],[He.DIVISION,2],[He.INTEGER_DIVISION,2],[He.MOD,2],[He.ADDITION,3],[He.SUBTRACTION,3],[He.BITWISE_LEFT_SHIFT,4],[He.BITWISE_RIGHT_SHIFT,4],[He.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[He.LESS_THAN,5],[He.LESS_THAN_EQUAL,5],[He.GREATER_THAN,5],[He.GREATER_THAN_EQUAL,5],[He.EQUAL,6],[He.NOT_EQUAL,6],[He.BITWISE_AND,7],[He.BITWISE_XOR,8],[He.BITWISE_OR,9],[He.AND,10],[He.OR,11]]);static OPERATORS=new Set([...Array.from(He.ARITHMETIC_OPERATORS),...Array.from(He.LOGICAL_OPERATORS),...Array.from(He.BITWISE_OPERATORS),He.ARRAY_OPERATOR,He.OBJECT_OPERATOR].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(He.ARITHMETIC_OPERATORS),...Array.from(He.LOGICAL_OPERATORS),...Array.from(He.BITWISE_OPERATORS),He.ARRAY_OPERATOR,He.OBJECT_OPERATOR].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(He.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[He.ADDITION,He.UNARY_PLUS],[He.SUBTRACTION,He.UNARY_MINUS],[He.NOT,He.UNARY_LOGICAL_NOT],[He.BITWISE_COMPLEMENT,He.UNARY_BITWISE_COMPLEMENT],[He.UNARY_PLUS,He.UNARY_PLUS],[He.UNARY_MINUS,He.UNARY_MINUS],[He.UNARY_LOGICAL_NOT,He.UNARY_LOGICAL_NOT],[He.UNARY_BITWISE_COMPLEMENT,He.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(He.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 He.VALUE_OF.get(e)}toString(){return this.operator}}class Ye extends ke{tokens=new Ce;ops=new Ce;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 Ve(""),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 De(this.expression,"Extra closing parenthesis found");case"]":throw new De(this.expression,"Extra closing square bracket found");default:let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==He.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}++n}if(t=s.toString(),!ee.isNullOrBlank(t)){if(He.OPERATORS.has(t))throw new De(this.expression,"Expression is ending with an operator");this.tokens.push(new ke(t))}}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 Ye(t.toString())),t.setLength(0),new se(r,!1)}processOthers(e,t,r,s,n,a){let i=t-n;i=i<He.BIGGEST_OPERATOR_SIZE?i:He.BIGGEST_OPERATOR_SIZE;for(let e=i;e>0;e--){let t=this.expression.substring(n,n+e);if(He.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return ee.isNullOrBlank(s)||(this.tokens.push(new ke(s)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,He.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new se(n+e-1,a)}return r.append(e),new se(n,!1)}processSubExpression(e,t,r,s,n){if(He.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,He.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!ee.isNullOrBlank(r))throw new De(this.expression,Q.format("Unkown token : $ found.",r));let a=1;const i=new Ve;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 De(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 Ye(i.toString().trim())),s}processTokenSepearator(e,t,r){return ee.isNullOrBlank(t)||(He.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,He.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new ke(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!He.UNARY_OPERATORS.has(r))throw new De(this.expression,Q.format("Extra operator $ found.",r));{const e=He.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(He.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new Ye("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new Ye("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=He.OPERATOR_PRIORITY.get(e),s=He.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 Ve,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 Ye?s[t].toString():s[t]).append(")"),t++;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 $e={};t($e,"ExpressionEvaluator",(()=>rr));var We={};t(We,"ExpressionTokenValue",(()=>je));class je extends ke{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return Q.format("$: $",this.expression,this.element)}}var Xe={};t(Xe,"ArithmeticAdditionOperator",(()=>Qe));var qe={};t(qe,"BinaryOperator",(()=>Je));class Je{nullCheck(e,t,r){if(u(e)||u(t))throw new Pe(Q.format("$ cannot be applied to a null value",r.getOperatorName()))}}class Qe extends Je{apply(e,t){return this.nullCheck(e,t,He.ADDITION),e+t}}var Ke={};t(Ke,"ArithmeticDivisionOperator",(()=>ze));class ze extends Je{apply(e,t){return this.nullCheck(e,t,He.DIVISION),e/t}}var Ze={};t(Ze,"ArithmeticIntegerDivisionOperator",(()=>et));class et extends Je{apply(e,t){return this.nullCheck(e,t,He.DIVISION),Math.floor(e/t)}}var tt={};t(tt,"ArithmeticModulusOperator",(()=>rt));class rt extends Je{apply(e,t){return this.nullCheck(e,t,He.MOD),e%t}}var st={};t(st,"ArithmeticMultiplicationOperator",(()=>nt));class nt extends Je{apply(e,t){return this.nullCheck(e,t,He.MULTIPLICATION),e*t}}var at={};t(at,"ArithmeticSubtractionOperator",(()=>it));class it extends Je{apply(e,t){return this.nullCheck(e,t,He.SUBTRACTION),e-t}}var ot={};t(ot,"ArrayOperator",(()=>ut));class ut extends Je{apply(e,t){if(!e)throw new Pe("Cannot apply array operator on a null value");if(!t)throw new Pe("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new Pe(Q.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new Pe(Q.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var lt={};t(lt,"BitwiseAndOperator",(()=>pt));class pt extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_AND),e&t}}var ht={};t(ht,"BitwiseLeftShiftOperator",(()=>mt));class mt extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_LEFT_SHIFT),e<<t}}var ct={};t(ct,"BitwiseOrOperator",(()=>gt));class gt extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_OR),e|t}}var ft={};t(ft,"BitwiseRightShiftOperator",(()=>Et));class Et extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_RIGHT_SHIFT),e>>t}}var Tt={};t(Tt,"BitwiseUnsignedRightShiftOperator",(()=>At));class At extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var dt={};t(dt,"BitwiseXorOperator",(()=>St));class St extends Je{apply(e,t){return this.nullCheck(e,t,He.BITWISE_XOR),e^t}}var wt={};t(wt,"LogicalAndOperator",(()=>Rt));var Ot={};t(Ot,"PrimitiveUtil",(()=>Nt));class Nt{static findPrimitiveNullAsBoolean(e){if(!e)return new se(c.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new Pe(Q.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new se(c.BOOLEAN,r):"string"===t?new se(c.STRING,r):Nt.findPrimitiveNumberType(r)}static findPrimitive(e){if(u(e))return new se(c.NULL,void 0);let t=typeof e;if("object"===t)throw new Pe(Q.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new se(c.BOOLEAN,r):"string"===t?new se(c.STRING,r):Nt.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(u(e)||Array.isArray(e)||"object"==typeof e)throw new Pe(Q.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new se(c.LONG,e):new se(c.DOUBLE,e)}catch(e){throw new Pe(Q.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)?c.LONG:c.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class Rt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=c.BOOLEAN)throw new Pe(Q.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=c.BOOLEAN)throw new Pe(Q.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var vt={};t(vt,"LogicalEqualOperator",(()=>It));class It extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);return r.getT2()==s.getT2()}}var yt={};t(yt,"LogicalGreaterThanEqualOperator",(()=>xt));class xt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()==c.BOOLEAN||s.getT1()==c.BOOLEAN)throw new Pe(Q.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var Mt={};t(Mt,"LogicalGreaterThanOperator",(()=>Pt));class Pt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()==c.BOOLEAN||s.getT1()==c.BOOLEAN)throw new Pe(Q.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var _t={};t(_t,"LogicalLessThanEqualOperator",(()=>Lt));class Lt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()==c.BOOLEAN||s.getT1()==c.BOOLEAN)throw new Pe(Q.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var Ct={};t(Ct,"LogicalLessThanOperator",(()=>bt));class bt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()==c.BOOLEAN||s.getT1()==c.BOOLEAN)throw new Pe(Q.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var Ut={};t(Ut,"LogicalNotEqualOperator",(()=>Vt));class Vt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);return r.getT2()!=s.getT2()}}var Bt={};t(Bt,"LogicalOrOperator",(()=>Dt));class Dt extends Je{apply(e,t){const r=Nt.findPrimitiveNullAsBoolean(e),s=Nt.findPrimitiveNullAsBoolean(t);if(r.getT1()!=c.BOOLEAN)throw new Pe(Q.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=c.BOOLEAN)throw new Pe(Q.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var Gt={};t(Gt,"ObjectOperator",(()=>kt));class kt extends Je{apply(e,t){if(!e)throw new Pe("Cannot apply array operator on a null value");if(!t)throw new Pe("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new Pe(Q.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var Ft={};t(Ft,"ArithmeticUnaryMinusOperator",(()=>$t));var Ht={};t(Ht,"UnaryOperator",(()=>Yt));class Yt{nullCheck(e,t){if(u(e))throw new Pe(Q.format("$ cannot be applied to a null value",t.getOperatorName()))}}class $t extends Yt{apply(e){return this.nullCheck(e,He.UNARY_MINUS),Nt.findPrimitiveNumberType(e),-e}}var Wt={};t(Wt,"ArithmeticUnaryPlusOperator",(()=>jt));class jt extends Yt{apply(e){return this.nullCheck(e,He.UNARY_PLUS),Nt.findPrimitiveNumberType(e),e}}var Xt={};t(Xt,"BitwiseComplementOperator",(()=>qt));class qt extends Yt{apply(e){this.nullCheck(e,He.UNARY_BITWISE_COMPLEMENT);let t=Nt.findPrimitiveNumberType(e);if(t.getT1()!=c.INTEGER&&t.getT1()!=c.LONG)throw new Pe(Q.format("Unable to apply bitwise operator on $",e));return~e}}var Jt={};t(Jt,"LogicalNotOperator",(()=>Qt));class Qt extends Yt{apply(e){if(this.nullCheck(e,He.UNARY_LOGICAL_NOT),Nt.findPrimitiveNumberType(e).getT1()!=c.BOOLEAN)throw new Pe(Q.format("Unable to apply bitwise operator on $",e));return!e}}var Kt={};t(Kt,"LiteralTokenValueExtractor",(()=>tr));var zt={};t(zt,"TokenValueExtractor",(()=>Zt));class Zt{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new U(Q.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(Zt.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!ee.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(Q.format("$ is not a number",e));if(e>=n.length)return;return n[e]}catch(t){throw new De(e,Q.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 De(e,Q.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(Q.format("$ is not a number",t));if(!Array.isArray(n))throw new De(e,Q.format("Expecting an array with index $ while processing the expression",t,e));if(t>=n.length)return;return n[t]}catch(t){throw new De(e,Q.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 De(e,Q.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const er=new Map([["true",!0],["false",!1],["null",void 0]]);class tr extends Zt{static INSTANCE=new tr;getValueInternal(e){if(!ee.isNullOrBlank(e))return e=e.trim(),er.has(e)?er.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t;if(t=-1==e.indexOf(".")?parseInt(e):parseFloat(e),isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new De(e,Q.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new De(e,Q.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}class rr{static UNARY_OPERATORS_MAP=new Map([[He.UNARY_BITWISE_COMPLEMENT,new qt],[He.UNARY_LOGICAL_NOT,new Qt],[He.UNARY_MINUS,new $t],[He.UNARY_PLUS,new jt]]);static BINARY_OPERATORS_MAP=new Map([[He.ADDITION,new Qe],[He.DIVISION,new ze],[He.INTEGER_DIVISION,new et],[He.MOD,new rt],[He.MULTIPLICATION,new nt],[He.SUBTRACTION,new it],[He.BITWISE_AND,new pt],[He.BITWISE_LEFT_SHIFT,new mt],[He.BITWISE_OR,new gt],[He.BITWISE_RIGHT_SHIFT,new Et],[He.BITWISE_UNSIGNED_RIGHT_SHIFT,new At],[He.BITWISE_XOR,new St],[He.AND,new Rt],[He.EQUAL,new It],[He.GREATER_THAN,new Pt],[He.GREATER_THAN_EQUAL,new xt],[He.LESS_THAN,new bt],[He.LESS_THAN_EQUAL,new Lt],[He.OR,new Dt],[He.NOT_EQUAL,new Vt],[He.ARRAY_OPERATOR,new ut],[He.OBJECT_OPERATOR,new kt]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(rr.UNARY_OPERATORS_MAP.keys());constructor(e){e instanceof Ye?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){return this.exp||(this.exp=new Ye(this.expression)),this.evaluateExpression(this.exp,e)}getExpression(){return this.exp||(this.exp=new Ye(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(),i=s.pop();if(rr.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,i)));else if(e==He.OBJECT_OPERATOR||e==He.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,i);else{const r=s.pop();var n=this.getValueFromToken(t,r),a=this.getValueFromToken(t,i);s.push(this.applyBinaryOperation(e,n,a))}}if(s.isEmpty())throw new Pe(Q.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new Pe(Q.format("Expression : $ evaluated multiple values $",e,s));const i=s.get(0);if(i instanceof je)return i.getElement();if(!(i instanceof Ye))return this.getValueFromToken(t,i);throw new Pe(Q.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const a=new Ce,i=new Ce;if(!s||!n)return;do{i.push(s),n instanceof Ye?a.push(new je(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==He.OBJECT_OPERATOR||s==He.ARRAY_OPERATOR);n&&(n instanceof Ye?a.push(new je(n.toString(),this.evaluateExpression(n,e))):a.push(n)),s&&t.push(s);let o=a.pop(),u=new Ve(o instanceof je?o.getTokenValue():o.toString());for(;!a.isEmpty();)o=a.pop(),s=i.pop(),u.append(s.getOperator()).append(o instanceof je?o.getTokenValue():o.toString()),s==He.ARRAY_OPERATOR&&u.append("]");let l=u.toString(),p=l.substring(0,l.indexOf(".")+1);if(p.length>2&&e.has(p))r.push(new je(l,this.getValue(l,e)));else{let e;try{e=tr.INSTANCE.getValue(l)}catch(t){e=l}r.push(new je(l,e))}}applyBinaryOperation(e,t,r){if("object"===typeof t||"object"===typeof r||Array.isArray(t)||Array.isArray(r))throw new De(this.expression,Q.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));let s=rr.BINARY_OPERATORS_MAP.get(e);if(!s)throw new De(this.expression,Q.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new je(e.toString(),s.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new De(this.expression,Q.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=rr.UNARY_OPERATORS_MAP.get(e);if(!r)throw new De(this.expression,Q.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new je(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof Ye?this.evaluateExpression(t,e):t instanceof je?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return tr.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??tr.INSTANCE).getValue(e)}}const sr=new j("Set").setNamespace(a.SYSTEM_CTX).setParameters(new Map([P.ofEntry("name",(new N).setName("name").setType(O.of(c.STRING)).setMinLength(1),!1,x.CONSTANT),P.ofEntry("value",N.ofAny("value"))])).setEvents(new Map([k.outputEventMapEntry(new Map)]));const nr=new j("GenerateEvent").setNamespace(a.SYSTEM).setParameters(new Map([P.ofEntry("eventName",N.ofString("eventName")),P.ofEntry("results",N.ofObject("results").setProperties(new Map([["name",N.ofString("name")],["value",P.EXPRESSION]])),!0)])).setEvents(new Map([k.outputEventMapEntry(new Map)]));class ar extends Ie{static CONDITION="condition";static SIGNATURE=new j("If").setNamespace(a.SYSTEM).setParameters(new Map([P.ofEntry(ar.CONDITION,N.of(ar.CONDITION,c.BOOLEAN))])).setEvents(new Map([k.eventMapEntry(k.TRUE,new Map),k.eventMapEntry(k.FALSE,new Map),k.outputEventMapEntry(new Map)]));getSignature(){return ar.SIGNATURE}async internalExecute(e){var t=e.getArguments()?.get(ar.CONDITION);return new $([H.of(t?k.TRUE:k.FALSE,new Map),H.outputOf(new Map)])}}const ir=new j("CountLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([P.ofEntry("count",N.of("count",c.INTEGER).setDefaultValue(1))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",N.of("index",c.INTEGER)]])),k.outputEventMapEntry(new Map([["value",N.of("value",c.INTEGER)]]))]));const or=new j("RangeLoop").setNamespace(a.SYSTEM_LOOP).setParameters(new Map([P.ofEntry("from",N.of("from",c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE).setDefaultValue(0)),P.ofEntry("to",N.of("to",c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE).setDefaultValue(1)),P.ofEntry("step",N.of("step",c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE).setDefaultValue(1).setNot((new N).setConstant(0)))])).setEvents(new Map([k.eventMapEntry(k.ITERATION,new Map([["index",N.of("index",c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE)]])),k.outputEventMapEntry(new Map([["value",N.of("value",c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE)]]))]));const ur=new j("Add").setNamespace(a.MATH).setParameters(new Map([["value",new P("value",N.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",N.ofNumber("value")]]))]));const lr=[()=>new Map([["value",new P("value",N.ofNumber("value"))]]),()=>new Map([["value1",new P("value1",N.ofNumber("value1"))],["value2",new P("value2",N.ofNumber("value2"))]])];class pr extends Ie{constructor(e,t,r=1,...s){super(),s&&s.length||(s=[c.DOUBLE]),this.parametersNumber=r,this.mathFunction=t,this.signature=new j(e).setNamespace(a.MATH).setParameters(lr[r-1]()).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new N).setType(O.of(...s)).setName("value")]]))]))}getSignature(){return this.signature}async internalExecute(e){let t,r=Nt.findPrimitiveNumberType(e.getArguments()?.get(1==this.parametersNumber?"value":"value1")).getT2();return 2==this.parametersNumber&&(t=Nt.findPrimitiveNumberType(e.getArguments()?.get("value2")).getT2()),new $([H.outputOf(new Map([["value",this.mathFunction.call(this,r,t)]]))])}}class hr extends Ie{static SIGNATURE=new j("Hypotenuse").setNamespace(a.MATH).setParameters(new Map([["value",new P("value",N.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",(new N).setType(O.of(c.DOUBLE)).setName("value")]]))]));constructor(){super()}getSignature(){return hr.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 mr=new j("Maximum").setNamespace(a.MATH).setParameters(new Map([["value",new P("value",N.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",N.ofNumber("value")]]))]));const cr=new j("Minimum").setNamespace(a.MATH).setParameters(new Map([["value",new P("value",N.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([k.outputEventMapEntry(new Map([["value",N.ofNumber("value")]]))]));var gr={};t(gr,"MapUtil",(()=>fr)),t(gr,"MapEntry",(()=>Er));class fr{static of(e,t,r,s,n,a,i,o,l,p,h,m,c,g,f,E,T,A,d,S){const w=new Map;return u(e)||u(t)||w.set(e,t),u(r)||u(s)||w.set(r,s),u(n)||u(a)||w.set(n,a),u(i)||u(o)||w.set(i,o),u(l)||u(p)||w.set(l,p),u(h)||u(m)||w.set(h,m),u(c)||u(g)||w.set(c,g),u(f)||u(E)||w.set(f,E),u(T)||u(A)||w.set(T,A),u(d)||u(S)||w.set(d,S),w}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 Er(e,t)}static ofEntries(...e){const t=new Map;for(const r of e)t.set(r.k,r.v);return t}constructor(){}}class Er{constructor(e,t){this.k=e,this.v=t}}class Tr extends Ie{static SIGNATURE=new j("Random").setNamespace(a.MATH).setEvents(new Map([k.outputEventMapEntry(fr.of("value",N.ofDouble("value")))]));getSignature(){return Tr.SIGNATURE}async internalExecute(e){return new $([H.outputOf(new Map([["value",Math.random()]]))])}}const Ar={Absolute:new pr("Absolute",(e=>Math.abs(e)),1,c.INTEGER,c.LONG,c.FLOAT,c.DOUBLE),ACosine:new pr("ArcCosine",(e=>Math.acos(e))),ASine:new pr("ArcSine",(e=>Math.asin(e))),ATangent:new pr("ArcTangent",(e=>Math.atan(e))),Ceiling:new pr("Ceiling",(e=>Math.ceil(e))),Cosine:new pr("Cosine",(e=>Math.cos(e))),CosineH:new pr("HyperbolicCosine",(e=>Math.cosh(e))),CubeRoot:new pr("CubeRoot",(e=>Math.cbrt(e))),Exponential:new pr("Exponential",(e=>Math.exp(e))),Expm1:new pr("ExponentialMinus1",(e=>Math.expm1(e))),Floor:new pr("Floor",(e=>Math.floor(e))),Log:new pr("LogNatural",(e=>Math.log(e))),Log10:new pr("Log10",(e=>Math.log10(e))),Round:new pr("Round",(e=>Math.round(e)),1,c.INTEGER,c.LONG),Sine:new pr("Sine",(e=>Math.sin(e))),SineH:new pr("HyperbolicSine",(e=>Math.sinh(e))),Tangent:new pr("Tangent",(e=>Math.tan(e))),TangentH:new pr("HyperbolicTangent",(e=>Math.tanh(e))),ToDegrees:new pr("ToDegrees",(e=>e*(Math.PI/180))),ToRadians:new pr("ToRadians",(e=>e*(180/Math.PI))),SquareRoot:new pr("SquareRoot",(e=>Math.sqrt(e))),ArcTangent:new pr("ArcTangent2",((e,t)=>Math.atan2(e,t)),2),Power:new pr("Power",((e,t)=>Math.pow(e,t)),2),Add:new class extends Ie{getSignature(){return ur}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 hr,Maximum:new class extends Ie{getSignature(){return mr}async internalExecute(e){let t=e.getArguments()?.get("value");return new $([H.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>!e&&0!==e||t>e?t:e)))]]))])}},Minimum:new class extends Ie{getSignature(){return cr}async internalExecute(e){let t=e.getArguments()?.get("value");return new $([H.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>!e&&0!==e||t<e?t:e)))]]))])}},Random:new Tr};class dr{find(e,t){if(e==a.MATH)return Ar[t]}}var Sr={};t(Sr,"HybridRepository",(()=>wr));class wr{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 Or(e){return[e.getSignature().getName(),e]}const Nr=new Map([[a.SYSTEM_CTX,new Map([Or(new class extends Ie{getSignature(){return ye}async internalExecute(e){const t=e?.getArguments()?.get("name");if(e?.getContext()?.has(t))throw new U(Q.format("Context already has an element for '$' ",t));let r=N.from(e?.getArguments()?.get("schema"));if(!r)throw new U("Schema is not supplied.");return e.getContext().set(t,new q(r,u(r.getDefaultValue())?void 0:r.getDefaultValue())),new $([H.outputOf(new Map)])}}),Or(new class extends Ie{getSignature(){return xe}async internalExecute(e){const t=e?.getArguments()?.get("name");if(!e.getContext()?.has(t))throw new U(Q.format("Context don't have an element for '$' ",t));return new $([H.outputOf(new Map(["value",e.getContext()?.get(t)?.getElement()]))])}}),Or(new class extends Ie{getSignature(){return sr}async internalExecute(e){let t=e?.getArguments()?.get("name");if(ee.isNullOrBlank(t))throw new U("Empty string is not a valid name for the context element");let r=e?.getArguments()?.get("value");const s=new Ye(t),n=s.getTokens().peekLast();if(!n.getExpression().startsWith("Context")||n instanceof Ye||n instanceof je&&!n.getElement().toString().startsWith("Context"))throw new Pe(Q.format("The context path $ is not a valid path in context",t));for(const e of s.getOperations().toArray())if(e!=He.ARRAY_OPERATOR&&e!=He.OBJECT_OPERATOR)throw new Pe(Q.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 Ye&&s.getTokens().set(r,new je(t,new rr(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 U(Q.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(),l=a.removeLast(),p=n.removeLast(),h=p instanceof je?p.getElement():p.getExpression();for(u(o)&&(o=l==He.OBJECT_OPERATOR?{}:[],i.setElement(o));!a.isEmpty();)o=l==He.OBJECT_OPERATOR?this.getDataFromObject(o,h,a.peekLast()):this.getDataFromArray(o,h,a.peekLast()),l=a.removeLast(),p=n.removeLast(),h=p instanceof je?p.getElement():p.getExpression();return l==He.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 U(Q.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new U(Q.format("Expected an array index but found $",t));if(s<0)throw new U(Q.format("Array index is out of bound - $",t));let n=e[s];return u(n)&&(n=r==He.OBJECT_OPERATOR?{}:[],e[s]=n),n}getDataFromObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new U(Q.format("Expected an object but found $",e));let s=e[t];return u(s)&&(s=r==He.OBJECT_OPERATOR?{}:[],e[t]=s),s}putDataInArray(e,t,r){if(!Array.isArray(e))throw new U(Q.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new U(Q.format("Expected an array index but found $",t));if(s<0)throw new U(Q.format("Array index is out of bound - $",t));e[s]=r}putDataInObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new U(Q.format("Expected an object but found $",e));e[t]=r}})])],[a.SYSTEM_LOOP,new Map([Or(new class extends Ie{getSignature(){return or}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 $({next(){if(i)return;if(n&&a>=r||!n&&a<=r)return i=!0,H.outputOf(new Map([["value",a]]));const e=H.of(k.ITERATION,new Map([["index",a]]));return a+=s,e}})}}),Or(new class extends Ie{getSignature(){return ir}async internalExecute(e){let t=e.getArguments()?.get("count"),r=0;return new $({next(){if(r>=t)return H.outputOf(new Map([["value",r]]));const e=H.of(k.ITERATION,new Map([["index",r]]));return++r,e}})}})])],[a.SYSTEM,new Map([Or(new ar),Or(new class extends Ie{getSignature(){return nr}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 U("Expect a value object");let s=r.value;return r.isExpression&&(s=new rr(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 Rr extends wr{constructor(){super({find:(e,t)=>Nr.get(e)?.get(t)},new dr)}}var vr={};t(vr,"ArrayUtil",(()=>Ir));class Ir{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 yr={};t(yr,"StatementExecution",(()=>Pr));var xr={};t(xr,"StatementMessage",(()=>Mr));class Mr{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 Pr{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 Mr(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof Pr))return!1;return e.statement.equals(this.statement)}}var _r={};t(_r,"ContextTokenValueExtractor",(()=>Lr));class Lr extends Zt{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(Zt.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 Lr.PREFIX}}var Cr={};t(Cr,"OutputMapTokenValueExtractor",(()=>br));class br extends Zt{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(Zt.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 br.PREFIX}}var Ur={};t(Ur,"ArgumentsTokenValueExtractor",(()=>Vr));class Vr extends Zt{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(Zt.REGEX_DOT);return this.retrieveElementFrom(e,t,2,this.args.get(t[1]))}getPrefix(){return Vr.PREFIX}}var Br={};t(Br,"GraphVertex",(()=>kr));var Dr={};t(Dr,"ExecutionGraph",(()=>Gr));class Gr{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 kr(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 Ce(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 kr{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 se(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new se(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 Gr(!0);var r=new Ce(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 Fr={};t(Fr,"KIRuntime",(()=>zr));var Hr={};t(Hr,"JsonExpression",(()=>Yr));class Yr{constructor(e){this.expression=e}getExpression(){return this.expression}}var $r={};let Wr;var jr;t($r,"ParameterReferenceType",(()=>Wr)),(jr=Wr||(Wr={})).VALUE="VALUE",jr.EXPRESSION="EXPRESSION";var Xr={};t(Xr,"FunctionExecutionParameters",(()=>qr));class qr{count=0;valueExtractors=new Map;getContext(){return this.context}setContext(e){this.context=e;let t=new Lr(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new Vr(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 br(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}}var Jr={};let Qr;var Kr;t(Jr,"StatementMessageType",(()=>Qr)),(Kr=Qr||(Qr={})).ERROR="ERROR",Kr.WARNING="WARNING",Kr.MESSAGE="MESSAGE";class zr extends Ie{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;constructor(e,t,r){if(super(),this.fd=e,this.fd.getVersion()>zr.VERSION)throw new U("Runtime is at a lower version "+zr.VERSION+" and trying to run code from version "+this.fd.getVersion()+".");this.fRepo=t,this.sRepo=r}getSignature(){return this.fd}async getExecutionPlan(e){let t=new Gr;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(e,r));let r=this.makeEdges(t);if(r.length)throw new U(Q.format("Found these unresolved dependencies : $ ",r.map((e=>Q.format("Steps.$.$",e.getT1(),e.getT2())))));return t}async internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map);let t=await this.getExecutionPlan(e.getContext()),r=t.getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(r?.length)throw new U("Please fix the errors in the function definition before execution : \n"+r.join(",\n"));return await this.executeGraph(t,e)}async executeGraph(e,t){let r=new Ce;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new Ce;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()==zr.MAX_EXECUTION_ITERATIONS)throw new U("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new U("No events raised");return new $(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>H.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):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{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(),await this.resolveInternalExpressions(s.getResult(),e)))}while(s&&s.getName()!=k.OUTPUT);s?.getName()==k.OUTPUT&&n.getOutVertices().has(k.OUTPUT)&&(n?.getOutVertices()?.get(k.OUTPUT)??[]).forEach((e=>t.add(e)))}async executeVertex(e,t,r,s){let n=e.getData().getStatement(),a=this.fRepo.find(n.getNamespace(),n.getName());if(!a)throw new U(Q.format("$.$ function is not found.",n.getNamespace(),n.getName()));let i=a?.getSignature().getParameters(),o=this.getArgumentsFromParametersMap(t,n,i??new Map),u=t.getContext(),l=await a.execute((new qr).setContext(u).setArguments(o).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),p=l.next();if(!p)throw new U(Q.format("Executing $ returned no events",n.getStatementName()));let h=p.getName()==k.OUTPUT;if(t.getSteps()?.has(n.getStatementName())||t.getSteps().set(n.getStatementName(),new Map),t.getSteps().get(n.getStatementName()).set(p.getName(),this.resolveInternalExpressions(p.getResult(),t)),h){let t=e.getOutVertices().get(k.OUTPUT);t&&t.forEach((e=>s.add(e)))}else{let t=e.getSubGraphOfType(p.getName()),s=this.makeEdges(t);r.push(new ae(t,s,l,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new se(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 Yr){return new rr(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=t[1];if(!n?.length)return new se(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 se(t[0],s)):new se(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()==Wr.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==Wr.EXPRESSION&&!ee.isNullOrBlank(t.getExpression())){r=new rr(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t){let r=new Pr(t),s=this.fRepo.find(t.getNamespace(),t.getName());if(!s)throw new U(Q.format("$.$ was not available",t.getNamespace(),t.getName()));let n=new Map(s.getSignature().getParameters());for(let s of Array.from(t.getParameterMap().entries())){let t=n.get(s[0]);if(!t)continue;let a=s[1];if(a.length){if(t.isVariableArgument())for(let s of a)this.parameterReferenceValidation(e,r,t,s);else{let s=a[0];this.parameterReferenceValidation(e,r,t,s)}n.delete(t.getParameterName())}else u(ue.getDefaultValue(t.getSchema(),this.sRepo))&&r.addMessage(Qr.ERROR,Q.format(zr.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}if(!u(r.getStatement().getDependentStatements()))for(let e of r.getStatement().getDependentStatements())r.addDependency(e);if(n.size)for(let e of Array.from(n.values()))u(ue.getDefaultValue(e.getSchema(),this.sRepo))&&r.addMessage(Qr.ERROR,Q.format(zr.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return r}parameterReferenceValidation(e,t,r,s){if(s){if(s.getType()==Wr.VALUE){u(s.getValue())&&u(ue.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Qr.ERROR,Q.format(zr.PARAMETER_NEEDS_A_VALUE,r.getParameterName()));let e=new Ce;for(e.push(new se(r.getSchema(),s.getValue()));!e.isEmpty();){let r=e.pop();if(r.getT2()instanceof Yr)this.addDependencies(t,r.getT2().getExpression());else{if(u(r.getT1())||u(r.getT1().getType()))continue;if(r.getT1().getType()?.contains(c.ARRAY)&&Array.isArray(r.getT2())){let t=r.getT1().getItems();if(!t)continue;if(t.isSingleType())for(let s of r.getT2())e.push(new se(t.getSingleSchema(),s));else{let s=r.getT2();for(let r=0;r<s.length;r++)e.push(new se(t.getTupleSchema()[r],s[r]))}}else if(r.getT1().getType()?.contains(c.OBJECT)&&"object"==typeof r.getT2()){let s=r.getT1();if(s.getName()===P.EXPRESSION.getName()&&s.getNamespace()===P.EXPRESSION.getNamespace()){let e=r.getT2();e.isExpression&&this.addDependencies(t,e.value)}else if(s.getProperties())for(let t of Object.entries(r.getT2()))s.getProperties().has(t[0])&&e.push(new se(s.getProperties().get(t[0]),t[1]))}}}}else if(s.getType()==Wr.EXPRESSION)if(ee.isNullOrBlank(s.getExpression()))u(ue.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Qr.ERROR,Q.format(zr.PARAMETER_NEEDS_A_VALUE,r.getParameterName()));else try{this.addDependencies(t,s.getExpression())}catch(e){t.addMessage(Qr.ERROR,Q.format("Error evaluating $ : $",s.getExpression(),e))}}else u(ue.getDefaultValue(r.getSchema(),this.sRepo))&&t.addMessage(Qr.ERROR,Q.format(zr.PARAMETER_NEEDS_A_VALUE,r.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(zr.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 se(a,o));let u=e.getNodeMap().get(a);u&&s.addInEdgeTo(u,o)}return r}}var Zr={};t(Zr,"KIRunConstants",(()=>es));class es{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}var ts={};t(ts,"Position",(()=>rs));class rs{static SCHEMA_NAME="Position";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(rs.SCHEMA_NAME).setType(O.of(c.OBJECT)).setProperties(new Map([["left",N.ofFloat("left")],["top",N.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 rs(e.left,e.top):new rs(-1,-1)}}var ss={};t(ss,"FunctionDefinition",(()=>cs));var ns={};t(ns,"Statement",(()=>ls));var as={};t(as,"AbstractStatement",(()=>is));class is{getComment(){return this.comment}setComment(e){return this.comment=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 os={};t(os,"ParameterReference",(()=>us));class us{static SCHEMA_NAME="ParameterReference";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(us.SCHEMA_NAME).setType(O.of(c.OBJECT)).setProperties(new Map([["value",N.ofAny("value")],["expression",N.ofString("expression")],["type",N.ofString("type").setEnums(["EXPRESSION","VALUE"])]]));constructor(e){this.type=e}getType(){return this.type}setType(e){return this.type=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){return new us(Wr.EXPRESSION).setExpression(e)}static ofValue(e){return new us(Wr.VALUE).setValue(e)}static from(e){return e?Array.from(e).map((e=>new us(e.type).setValue(e.value).setExpression(e.expression))):[]}}class ls extends is{static SCHEMA_NAME="Statement";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(ls.SCHEMA_NAME).setType(O.of(c.OBJECT)).setProperties(new Map([["statementName",N.ofString("statementName")],["comment",N.ofString("comment")],["description",N.ofString("description")],["namespace",N.ofString("namespace")],["name",N.ofString("name")],["dependentStatements",N.ofArray("dependentstatement",N.ofString("dependentstatement"))],["parameterMap",(new N).setName("parameterMap").setAdditionalProperties((new h).setSchemaValue(N.ofArray("parameterReference",us.SCHEMA)))],["position",rs.SCHEMA]]));constructor(e,t,r){super(),this.statementName=e,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??[]}setDependentStatements(e){return this.dependentStatements=e,this}equals(e){if(!(e instanceof ls))return!1;return e.statementName==this.statementName}static ofEntry(e){return[e.statementName,e]}static from(e){return new ls(e.statementName,e.namespace,e.name).setParameterMap(new Map(Object.entries(e.parameterMap??{}).map((([e,t])=>[e,us.from(t)])))).setDependentStatements(e.dependentStatements).setPosition(rs.from(e.position)).setComment(e.comment).setDescription(e.description)}}var ps={};t(ps,"StatementGroup",(()=>hs));class hs extends is{static SCHEMA_NAME="StatementGroup";static SCHEMA=(new N).setNamespace(a.SYSTEM).setName(hs.SCHEMA_NAME).setType(O.of(c.OBJECT)).setProperties(new Map([["statementGroupName",N.ofString("statementGroupName")],["comment",N.ofString("comment")],["description",N.ofString("description")],["position",rs.SCHEMA]]));constructor(e){super(),this.statementGroupName=e}getStatementGroupName(){return this.statementGroupName}setStatementGroupName(e){return this.statementGroupName=e,this}static from(e){return new hs(e.statementGroupName).setPosition(rs.from(e.position)).setComment(e.comment).setDescription(e.description)}}const ms=(new N).setNamespace(a.SYSTEM).setName("FunctionDefinition").setProperties(new Map([["name",N.ofString("name")],["namespace",N.ofString("namespace")],["parameters",N.ofArray("parameters",P.SCHEMA)],["events",N.ofObject("events").setAdditionalProperties((new h).setSchemaValue(k.SCHEMA))],["steps",N.ofObject("steps").setAdditionalProperties((new h).setSchemaValue(ls.SCHEMA))]]));ms.getProperties()?.set("parts",N.ofArray("parts",ms));class cs extends j{static SCHEMA=ms;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 cs(e.name).setSteps(new Map(Object.values(e.steps??{}).filter((e=>!!e)).map((e=>[e.statementName,ls.from(e)])))).setStepGroups(new Map(Object.values(e.stepGroups??{}).filter((e=>!!e)).map((e=>[e.statementGroupName,hs.from(e)])))).setParts(Array.from(e.parts??[]).filter((e=>!!e)).map((e=>cs.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,P.from(e)])))):new cs("unknown")}}var gs={};t(gs,"Argument",(()=>fs));class fs{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 fs(0,e,t)}}var Es={};e(Es,Ft),e(Es,Wt),e(Es,Xt),e(Es,Jt),e(Es,Ht);var Ts={};e(Ts,Xe),e(Ts,Ke),e(Ts,Ze),e(Ts,tt),e(Ts,st),e(Ts,at),e(Ts,ot),e(Ts,qe),e(Ts,lt),e(Ts,ht),e(Ts,ct),e(Ts,ft),e(Ts,Tt),e(Ts,dt),e(Ts,wt),e(Ts,vt),e(Ts,yt),e(Ts,Mt),e(Ts,_t),e(Ts,Ut),e(Ts,Ct),e(Ts,Bt),e(Ts,Gt),e(module.exports,r),e(module.exports,C),e(module.exports,{}),e(module.exports,Ot),e(module.exports,gr),e(module.exports,o),e(module.exports,Le),e(module.exports,Ue),e(module.exports,J),e(module.exports,Z),e(module.exports,re),e(module.exports,vr),e(module.exports,yr),e(module.exports,xr),e(module.exports,X),e(module.exports,_r),e(module.exports,Cr),e(module.exports,Ur),e(module.exports,Br),e(module.exports,{}),e(module.exports,Dr),e(module.exports,Fr),e(module.exports,Jr),e(module.exports,Xr),e(module.exports,_e),e(module.exports,zt),e(module.exports,Kt),e(module.exports,$e),e(module.exports,Fe),e(module.exports,Ge),e(module.exports,Be),e(module.exports,We),e(module.exports,{}),e(module.exports,K),e(module.exports,n),e(module.exports,Hr),e(module.exports,s),e(module.exports,Ae),e(module.exports,ge),e(module.exports,Ee),e(module.exports,me),e(module.exports,le),e(module.exports,Oe),e(module.exports,Se),e(module.exports,z),e(module.exports,ie),e(module.exports,v),e(module.exports,he),e(module.exports,i),e(module.exports,S),e(module.exports,f),e(module.exports,E),e(module.exports,T),e(module.exports,m),e(module.exports,p),e(module.exports,te),e(module.exports,V),e(module.exports,Sr),e(module.exports,Zr),e(module.exports,R),e(module.exports,Y),e(module.exports,ts),e(module.exports,ss),e(module.exports,$r),e(module.exports,F),e(module.exports,as),e(module.exports,ns),e(module.exports,{}),e(module.exports,ps),e(module.exports,W),e(module.exports,G),e(module.exports,y),e(module.exports,gs),e(module.exports,os),e(module.exports,Me),e(module.exports,b),e(module.exports,Es),e(module.exports,Ts);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|