UNPKG

entropy-engine

Version:
2 lines 247 kB
/*! For license information please see 0.0.11.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.es=t():e.es=t()}(this||window,(function(){return(()=>{var e={768:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{CONFIG_FILE_NAME:()=>p,CompileResult:()=>ne,Context:()=>Z,ESArray:()=>q,ESBoolean:()=>V,ESErrorPrimitive:()=>A,ESFunction:()=>R,ESJSBinding:()=>$,ESNamespace:()=>N,ESNull:()=>P,ESNumber:()=>z,ESObject:()=>O,ESPrimitive:()=>I,ESString:()=>W,ESSymbol:()=>J,ESType:()=>G,EndIterator:()=>We,Error:()=>Me,IS_NODE_INSTANCE:()=>l,IllegalCharError:()=>$e,ImportError:()=>De,IndexError:()=>Fe,InterpretResult:()=>te,InvalidOperationError:()=>Ue,InvalidRuntimeError:()=>Le,InvalidSyntaxError:()=>Be,MissingNativeDependencyError:()=>qe,N_array:()=>he,N_binOp:()=>ie,N_break:()=>ke,N_class:()=>ge,N_continue:()=>Ee,N_destructAssign:()=>ae,N_for:()=>ue,N_functionCall:()=>fe,N_functionDefinition:()=>de,N_if:()=>ce,N_indexed:()=>ye,N_namespace:()=>we,N_number:()=>xe,N_objectLiteral:()=>_e,N_primitiveWrapper:()=>Ie,N_return:()=>ve,N_statements:()=>pe,N_string:()=>Se,N_tryCatch:()=>be,N_unaryOp:()=>se,N_undefined:()=>Ce,N_varAssign:()=>oe,N_variable:()=>Te,N_while:()=>le,N_yield:()=>me,Node:()=>re,PermissionRequiredError:()=>Ve,Position:()=>r,ReferenceError:()=>Ge,TestFailed:()=>ze,TypeError:()=>je,VERSION:()=>_,colours:()=>Y,config:()=>Ze,generateRandomSymbol:()=>Re,global:()=>o,indent:()=>Oe,init:()=>dt,initPrimitiveTypes:()=>B,isDigit:()=>Ae,libs:()=>v,now:()=>y,parse:()=>mt,parseConfig:()=>nt,refreshPerformanceNow:()=>g,run:()=>vt,runningInNode:()=>u,setGlobalContext:()=>a,sleep:()=>Pe,str:()=>Ne,strip:()=>H,wrap:()=>Q});var n={};e.r(n),e.d(n,{EndIterator:()=>We,Error:()=>Me,IllegalCharError:()=>$e,ImportError:()=>De,IndexError:()=>Fe,InvalidOperationError:()=>Ue,InvalidRuntimeError:()=>Le,InvalidSyntaxError:()=>Be,MissingNativeDependencyError:()=>qe,PermissionRequiredError:()=>Ve,ReferenceError:()=>Ge,TestFailed:()=>ze,TypeError:()=>je});class r{constructor(e,t,n,r="(unknown)"){this.idx=e,this.ln=t,this.col=n,this.file=r}advance(e=""){return this.idx++,this.col++,"\n"===e&&(this.ln++,this.col=0),this}get clone(){return new r(this.idx,this.ln,this.col,this.file)}get str(){return this.isUnknown?"unknown":`File ${this.file}, ${this.ln+1}:${this.col+1}`}get isUnknown(){return-2===this.idx}static get void(){return new r(-2,-2,-2,"(unknown)")}}const i="0123456789",s="_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let o;const a=e=>{o=e},c=["'","`",'"'];let l="undefined"==typeof window;const u=()=>{l=!0},h=["let"],_="3.0.4f",p="esconfig.json",f=["utf8","ucs2","utf16le","latin1","ascii","base64","base64url","hex"],d={},v={},m=["class","abstract"];let y=()=>process.hrtime()[1]/Math.pow(10,6)+process.hrtime()[0]*Math.pow(10,3);function g(e=l){y=e?()=>process.hrtime()[1]/Math.pow(10,6)+process.hrtime()[0]*Math.pow(10,3):()=>{try{return null===performance||void 0===performance?void 0:performance.now()}catch(e){return process.hrtime()[1]/Math.pow(10,6)+process.hrtime()[0]*Math.pow(10,3)}}}var w;g(),function(e){e[e.NUMBER=0]="NUMBER",e[e.STRING=1]="STRING",e[e.END_STATEMENT=2]="END_STATEMENT",e[e.IDENTIFIER=3]="IDENTIFIER",e[e.COMMA=4]="COMMA",e[e.ASSIGN=5]="ASSIGN",e[e.ADD=6]="ADD",e[e.SUB=7]="SUB",e[e.ASTRIX=8]="ASTRIX",e[e.DIV=9]="DIV",e[e.POW=10]="POW",e[e.MOD=11]="MOD",e[e.OPAREN=12]="OPAREN",e[e.CPAREN=13]="CPAREN",e[e.OBRACES=14]="OBRACES",e[e.CBRACES=15]="CBRACES",e[e.OSQUARE=16]="OSQUARE",e[e.CSQUARE=17]="CSQUARE",e[e.EQUALS=18]="EQUALS",e[e.NOT_EQUALS=19]="NOT_EQUALS",e[e.NOT=20]="NOT",e[e.GT=21]="GT",e[e.LT=22]="LT",e[e.GTE=23]="GTE",e[e.LTE=24]="LTE",e[e.AND=25]="AND",e[e.OR=26]="OR",e[e.COLON=27]="COLON",e[e.DOT=28]="DOT",e[e.EOF=29]="EOF",e[e.PIPE=30]="PIPE",e[e.AMPERSAND=31]="AMPERSAND",e[e.BITWISE_NOT=32]="BITWISE_NOT",e[e.QM=33]="QM",e[e.DOUBLE_QM=34]="DOUBLE_QM",e[e.OGENERIC=35]="OGENERIC",e[e.CGENERIC=36]="CGENERIC"}(w||(w={}));const b=w,x={[b.NUMBER]:"ESNumber",[b.STRING]:"String",[b.END_STATEMENT]:";",[b.IDENTIFIER]:"Identifier",[b.COMMA]:",",[b.OBRACES]:"{",[b.CBRACES]:"}",[b.OPAREN]:"(",[b.CPAREN]:")",[b.OSQUARE]:"[",[b.CSQUARE]:"]",[b.ASSIGN]:"=",[b.ADD]:"+",[b.SUB]:"-",[b.ASTRIX]:"*",[b.DIV]:"/",[b.POW]:"^",[b.MOD]:"%",[b.EQUALS]:"==",[b.NOT_EQUALS]:"!=",[b.NOT]:"!",[b.GT]:">",[b.LT]:"<",[b.GTE]:">=",[b.LTE]:"<=",[b.AND]:"&&",[b.OR]:"||",[b.COLON]:":",[b.DOT]:".",[b.EOF]:"End of File",[b.AMPERSAND]:"&",[b.PIPE]:"|",[b.BITWISE_NOT]:"~",[b.QM]:"?",[b.DOUBLE_QM]:"??",[b.OGENERIC]:"<|",[b.CGENERIC]:"|>"},S={"*":b.ASTRIX,"/":b.DIV,"+":b.ADD,"-":b.SUB,"(":b.OPAREN,")":b.CPAREN,"^":b.POW,"%":b.MOD,"{":b.OBRACES,"}":b.CBRACES,",":b.COMMA,"[":b.OSQUARE,"]":b.CSQUARE,";":b.END_STATEMENT,":":b.COLON,".":b.DOT,"=":b.ASSIGN,">":b.GT,"<":b.LT,"!":b.NOT,"|":b.PIPE,"&":b.AMPERSAND,"~":b.BITWISE_NOT,"?":b.QM},T={"==":b.EQUALS,"!=":b.NOT_EQUALS,">=":b.GTE,"<=":b.LTE,"+=":b.ASSIGN,"-=":b.ASSIGN,"*=":b.ASSIGN,"/=":b.ASSIGN,"&&":b.AND,"||":b.OR,"<|":b.OGENERIC,"|>":b.CGENERIC,"??":b.DOUBLE_QM},C={},k=["__add__","__subtract__","__multiply__","__divide__","__pow__","__eq__","__gt__","__lt__","__and__","__or__","__pipe__","__ampersand__","__bool__","__set__","__get__","__call__","__iter__","__next__","__iterable__"],E=["let global IIterable = interface({\n __iterable__: true,\n __iter__: Func,\n len: Func,\n});","module('test', namespace {\n func assert (value: Bool) {\n if !value {\n throw(TestFailed());\n }\n }\n})"];class I{constructor(e,t=d.any){this.__iterable__=!1,this.__null__=!1,this._=this,this.__add__=(e,t)=>new Ue("+",this),this.__subtract__=(e,t)=>new Ue("-",this),this.__multiply__=(e,t)=>new Ue("*",this),this.__divide__=(e,t)=>new Ue("/",this),this.__pow__=(e,t)=>new Ue("^",this),this.__mod__=(e,t)=>new Ue("%",this),this.__eq__=(e,t)=>new Ue("==",this),this.__gt__=(e,t)=>new Ue(">",this),this.__lt__=(e,t)=>new Ue("<",this),this.__and__=(e,t)=>new Ue("&&",this),this.__or__=(e,t)=>new Ue("||",this),this.__bool__=e=>new Ue("__bool__",this),this.__pipe__=(e,t)=>new Ue("|",this),this.__ampersand__=(e,t)=>new Ue("&",this),this.__set__=(e,t,n)=>new Ue("__set__",this,`[${Ne(t)}] = ${Ne(n)}`),this.__call__=(e,...t)=>new Ue("__call__",this),this.__generic__=(e,...t)=>new Ue("__generic__",this),this.__iter__=e=>new Ue("__iter__",this),this.__next__=e=>new Ue("__next__",this),this.__nilish__=(e,t)=>this.__null__?t:this,this.isa=(e,t)=>t.__includes__(e,this),this.is=(e,t)=>new V(t===this),this.__type_name__=()=>Ne(this.__type__),this.has_property=(e,t)=>new V(Ne(t)in this),this.describe=(e,t)=>{this.__info__.builtin||(this.__info__.description=Ne(t))},this.detail=(e,t)=>{if(this.__info__.builtin)return;const n=H(t,e);if("object"!=typeof n)return new je("object",this.__type_name__(),Ne(this));this.__info__=Object.assign(Object.assign({},this.__info__),n),this.__info__.builtin=!1},this.__type__=t||this,this.__value__=e,this.__info__={}}}class A extends I{constructor(e=new Me("Unknown","Error not specified")){super(e,d.error),this.__get__=(e,t)=>{switch(Ne(t)){case"name":return new W(this.__value__.name);case"details":return new W(this.__value__.details);case"traceback":return new q(this.__value__.traceback.map((e=>new W(`${e.position.str} : ${e.line}`))));default:return Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this)}},this.cast=()=>new Me("TypeError","Cannot cast type 'error'"),this.str=()=>new W(`<Error: ${this.__value__.str}>`),this.__eq__=(e,t)=>new V(t instanceof A&&this.__value__.name===t.__value__.name),this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.clone=()=>new A(this.__value__),this.__includes__=()=>new Ue("type check",this,"Cannot type check against an error instance"),this.__subtype_of__=(e,t)=>Object.is(t,d.any)?new V(!0):new Ue("type check",this,"Cannot type check against an error instance"),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>[...Object.keys(this),"name","traceback","details"].map((e=>new W(e)))}}class P extends I{constructor(){super(void 0,d.undefined),this.__null__=!0,this.cast=()=>new Me("TypeError","Cannot cast type 'Null'"),this.str=()=>new W("nil"),this.__eq__=(e,t)=>new V(t instanceof P||void 0===t||void 0===t.__value__),this.__bool__=()=>new V,this.bool=this.__bool__,this.clone=()=>new P,this.__get__=(e,t)=>Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this),this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.undefined)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>Object.keys(this).map((e=>new W(e))),this.__info__={name:"undefined",description:"Not defined, not a value.",file:"built-in",builtin:!0}}}class O extends I{constructor(e={}){super(e,d.object),this.__iterable__=!0,this.cast=(e,t)=>t===d.number?new z(this.__value__?1:0):new Me("TypeError",`Cannot cast boolean to type '${Ne(t.__type_name__())}'`),this.str=(e,t=new z)=>{let n=Ne(this.__value__,t.__value__);return"\n"===n[n.length-1]&&(n=n.substr(0,n.length-1)),new W(n)},this.keys=()=>Object.keys(this.__value__).map((e=>new W(e))),this.__eq__=(e,t)=>{if(!(t instanceof O))return new V;if(t.keys().length!==this.keys().length)return new V;for(const n of this.keys()){const r=n.__value__,i=this.__value__[r],s=t.__value__[r];if(!i){if(s)return new V;continue}if(!i.__eq__)return new V;const o=i.__eq__(e,s);if(o instanceof Me)return o;if(!o.__value__)return new V}return new V(!0)},this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.__add__=(e,t)=>{if(!(t instanceof O))return new je("Object",t.__type_name__(),Ne(t));const n={};for(const t of this.keys()){const r=t.__value__;if(r in this)continue;const i=this.__get__(e,t);if(i instanceof Me)return i;n[r]=i}for(const r of t.keys()){const i=r.__value__;if(i in n)continue;const s=t.__get__(e,r);if(s instanceof Me)return s;n[i]=s}const r=new O(n);return r.__type_map__=Object.assign(Object.assign({},this.__type_map__),t.__type_map__),r},this.__subtract__=(e,t)=>{let n=[];if(t instanceof W)n=[Ne(t)];else{if(!(t instanceof q))return new je("Array | String",t.__type_name__(),Ne(t));n=H(t,e)}if(!Array.isArray(n))return new je("Array | String",t.__type_name__(),Ne(t));const r={};for(const t of this.keys()){const i=t.__value__;if(-1===n.indexOf(i)){const n=this.__get__(e,t);if(n instanceof Me)return n;r[i]=n}}return new O(r)},this.__get__=(e,t)=>{if(!(t instanceof W||t instanceof z))return new je("String | ESNumber",t.__type_name__(),Ne(t));const n=t.__value__;return n in this.__value__?this.__value__[n]:n in this?Q(this._[Ne(n)],!0):new Fe(Ne(n),this)},this.__set__=(e,t,n)=>{if("string"!=typeof t)return t instanceof W?void(this.__value__[t.__value__]=n):new je("String",t.__type_name__(),Ne(t));this.__value__[t]=n},this.has_property=(e,t)=>t instanceof W||t instanceof z?t.__value__ in this.__value__?new V(!0):new V(t.__value__ in this):new V,this.clone=()=>{const e=new O,t={},n=this.__value__;for(const e of Object.keys(n))t[e]=n[e];return e.__value__=t,e},this.__includes__=(e,t)=>{var n,r;if(!(t instanceof O))return new V;if(Object.keys(this.__value__).length<Object.keys(t.__value__).length)return new V;for(const i of Object.keys(this.__value__)){const s=null!==(n=this.__value__[i])&&void 0!==n?n:new P,o=null!==(r=t.__value__[i])&&void 0!==r?r:new P,a=s.__includes__(e,o);if(a instanceof Me)return a;if(!a.__value__)return new V}return new(0,this.constructor)(!0)},this.__subtype_of__=(e,t)=>{var n,r;if(Object.is(t,d.any)||Object.is(t,d.object))return new V(!0);if(!(t instanceof O))return new V;if(Object.keys(this.__value__).length<Object.keys(t.__value__).length)return new V;for(const i of Object.keys(this.__value__)){const s=null!==(n=this.__value__[i])&&void 0!==n?n:new P,o=null!==(r=t.__value__[i])&&void 0!==r?r:new P,a=s.__subtype_of__(e,o);if(a instanceof Me)return a;if(!a.__value__)return new V}return new(0,this.constructor)(!0)},this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.__iter__=()=>new q(Object.keys(this.__value__).map((e=>new W(e)))),this.len=()=>new z(Object.keys(this.__value__).length),this.contains=this.has_property}}class R extends I{constructor(e=(()=>{}),t=[],n="(anon)",r=new O,i=d.any,s,a=!1,c=!1,l=!1,u=[]){super(e,d.function),this.__generic_types__=[],this.cast=()=>new Me("TypeError","Cannot cast type 'function'"),this.clone=()=>new R(this.__value__,this.__args__,this.name,this.__this__,this.__returns__,this.__closure__),this.valueOf=()=>this,this.str=()=>new W(`<Func: ${this.name}>`),this.__eq__=(e,t)=>new V(t instanceof R&&this.__value__===t.__value__),this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.__call__=({context:e,kwargs:t,dontTypeCheck:n},...r)=>{let i=e;return this.takeCallContextAsClosure||(i=this.__closure__,i.path=e.path),function(e,t,n=[],r={},i=!1){var s;const o=e;t.takeCallContextAsClosure||(e=t.__closure__),e.path=o.path;const a=t.__value__,c=function(e,t,n,r,i){const s=new Z;s.parent=r;const o=e.__args__.filter((e=>!e.isKwarg));if(!e.__allow_args__&&t.length>o.length)return new Me("TypeError",`Too many arguments. Expected ${o.length} but got ${t.length}`);for(let e=0;e<t.length||e<o.length;e++){let n=new P,a=d.any;if(!o[e])continue;const c=o[e];if(t[e]instanceof I&&(a=t[e].__type__,n=t[e]),c.defaultValue&&t.length<=e)s.setOwn(c.name,c.defaultValue,{forceThroughConst:!0});else{if(!i){const i=c.type.__includes__({context:r},t[e]);if(i instanceof Me)return i;if(!i.__value__)return new je(Ne(c.type),Ne(a),Ne(n))}s.setOwn(c.name,n,{forceThroughConst:!0})}}let a=s.setOwn("args",new q(t),{forceThroughConst:!0});if(a instanceof Me)return a;const c=[];for(const t of e.__args__.filter((e=>e.isKwarg))){let e=n[t.name];if(!e){if(!t.defaultValue)return new je("Any","Undefined");e=t.defaultValue}if(!i){const n=e.__type__,i=t.type.__includes__({context:r},e);if(i instanceof Me)return i;if(!i.__value__)return new je(Ne(t.type),Ne(n),Ne(e))}s.setOwn(t.name,e,{forceThroughConst:!0}),c.push(t.name)}if(!e.__allow_kwargs__)for(const t of Object.keys(n))if(-1===c.indexOf(t))return new Me("TypeError",`Kwarg '${Object.keys(n)[0]}' is not a parameter of '${e.name}'`);return a=s.setOwn("kwargs",new O(n),{forceThroughConst:!0}),a instanceof Me?a:s}(t,n,r,e,i);if(c instanceof Me)return c;const l=null!==(s=t.__this__)&&void 0!==s?s:new O,u=c.setOwn("this",l);return u instanceof Me?u:a instanceof re?function(e,t,n,r){var i,s;const o=n.interpret(t);if(o.error)return o.error;if(void 0!==o.funcReturn&&(o.val=o.funcReturn,o.funcReturn=void 0),!r){const n=e.__returns__.__includes__({context:t},o.val);if(n instanceof Me)return n;if(!1===n.__value__)return new je(Ne(e.__returns__),(null===(i=o.val)||void 0===i?void 0:i.__type_name__())||"undefined",null===(s=o.val)||void 0===s?void 0:s.str({context:t},new z).__value__,"(from function return)")}return o.val?o.val:new P}(t,c,a,i):"function"==typeof a?function(e,t,n,r,i,s){for(let e=n.length;e<r.length;e++)n.push(new P);const o=r({context:t,kwargs:i,dontTypeCheck:s},...n);return o instanceof Me||o instanceof I?o:new P}(0,c,n,a,r,i):new je("function",typeof a)}(i,this,r,t,n)},this.__get__=(e,t)=>Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this),this.__includes__=(e,t)=>{var n;if(!(t instanceof R))return new V;const r=t.__args__.filter((e=>!e.isKwarg)),i=this.__args__.filter((e=>!e.isKwarg));if(!this.__allow_kwargs__&&t.__allow_kwargs__)return new V;if(!this.__allow_args__&&t.__allow_args__)return new V;if(!this.__allow_args__){if(r.length!==i.length)return new V;for(let t=0;t<r.length;t++){const n=i[t].type.__subtype_of__(e,r[t].type);if(n instanceof Me)return n;if(!n.__value__)return new V}}if(!this.__allow_kwargs__){const r=t.__args__.filter((e=>e.isKwarg)),i=this.__args__.filter((e=>e.isKwarg));if(r.length!==i.length&&!this.__allow_kwargs__)return new V;for(const t of i.map((e=>e.name))){const s=r.find((e=>e.name===t));if(!s)return new V;const o=null===(n=i.find((e=>e.name===t)))||void 0===n?void 0:n.type.__subtype_of__(e,s.type);if(o instanceof Me)return o;if(!(null==o?void 0:o.__value__))return new V}}const s=this.__call__(Object.assign(Object.assign({},e),{dontTypeCheck:!0}));if(s instanceof Me)return s;const o=t.__returns__.__subtype_of__(e,s);return o instanceof Me?o:new V(o.__value__)},this.__subtype_of__=(e,t)=>{var n;if(Object.is(t,d.any)||Object.is(t,d.function))return new V(!0);if(!(t instanceof R))return new V;const r=t.__args__.filter((e=>!e.isKwarg)),i=this.__args__.filter((e=>!e.isKwarg));if(!this.__allow_args__){if(r.length!==i.length)return new V;for(let t=0;t<r.length;t++){const n=r[t].type.__subtype_of__(e,i[t].type);if(n instanceof Me)return n;if(!n.__value__)return new V}}if(!this.__allow_kwargs__){const r=t.__args__.filter((e=>e.isKwarg)),i=this.__args__.filter((e=>e.isKwarg));if(r.length!==i.length&&!this.__allow_kwargs__)return new V;for(const t of i.map((e=>e.name))){const s=r.find((e=>e.name===t));if(!s)return new V;const o=null===(n=i.find((e=>e.name===t)))||void 0===n?void 0:n.type;if(!o)return new V;const a=s.type.__subtype_of__(e,o);if(a instanceof Me)return a;if(!(null==a?void 0:a.__value__))return new V}}const s=this.__call__(Object.assign(Object.assign({},e),{dontTypeCheck:!0}));if(s instanceof Me)return s;const o=t.__call__(Object.assign(Object.assign({},e),{dontTypeCheck:!0}));if(o instanceof Me)return o;const a=o.__subtype_of__(e,s);return a instanceof Me?a:new V(a.__value__)},this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>Object.keys(this).map((e=>new W(e))),this.__generic__=(e,...t)=>{const n=this.clone();return e.dontTypeCheck||(n.__generic_types__=t),n},this.__args__=t,this.__gargs__=u,this.__info__.name=n,this.__this__=r,this.__returns__=i,s?this.__closure__=s:(this.__closure__=new Z,this.__closure__.parent=o),this.takeCallContextAsClosure=a,this.__info__.returnType=Ne(i),this.__info__.args=t.map((e=>({name:e.name,default_value:Ne(e.defaultValue),type:e.type.__info__.name,required:!0}))),this.__allow_args__=c,this.__allow_kwargs__=l}get name(){var e;return null!==(e=this.__info__.name)&&void 0!==e?e:"(anonymous)"}set name(e){this.__info__.name=e}}class N extends I{constructor(e,t,n=!1){super(t,d.object),this.__iterable__=!0,this.cast=()=>new Me("TypeError","Cannot cast type 'namespace'"),this.clone=()=>{const e={},t=this.__value__;for(const n of Object.keys(t))e[n]=t[n];return new N(this.name,e)},this.str=()=>{const e=Object.keys(this.__value__);return new W(`<Namespace ${Ne(this.name)}${e.length>0?": ":""}${e.slice(0,5)}${e.length>=5?"...":""}>`)},this.__eq__=(e,t)=>new V(this===t),this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.__get__=(e,t)=>{if(t instanceof W&&t.__value__ in this.__value__){const e=this.__value__[t.__value__];if(e.isAccessible)return e.value}return t instanceof W?Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this._):new je("string",t.__type_name__())},this.__set__=(e,t,n)=>{if("string"==typeof t&&(t=new W(t)),!(t instanceof W))return new je("string",t.__type_name__(),Ne(t));const r=Ne(t);if(!this.__mutable__)return new je("mutable","immutable",`${Ne(this.name)}`);const i=this.__value__[r];return i?i.isConstant?new je("mutable","immutable",`${Ne(this.name)}[${r}]`):i.isAccessible?void(i.value=n):new je("accessible","inaccessible",`${Ne(this.name)}[${r}]`):new Me("SymbolError",`Symbol ${r} is not declared in namespace ${Ne(this.name)}.`)},this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.object)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.__iter__=e=>new q(Object.keys(this.__value__).map((e=>new W(e)))),this.len=()=>new z(Object.keys(this.__value__).length),this.keys=()=>[...Object.keys(this),...Object.keys(this.__value__)].map((e=>new W(e))),this.contains=this.has_property,this.__info__.name=Ne(e),this.__mutable__=n}get name(){return new W(this.__info__.name)}set name(e){this.__info__.name=e.__value__}}function M(e,t,n,r,i,s){if("function"!=typeof t[n])return new je("Func",typeof t[n],Ne(t[n]));let o;if(e)try{o=new t[n](r,...i)}catch(e){if(!(e instanceof TypeError))return new Me(e.name,e.toString());try{o=t[n](r,...i)}catch(e){return new Me("",e.toString())}}else try{o=new t[n](...i.map((e=>H(e,r))))}catch(e){if(!(e instanceof TypeError))return new Me(e.name,e.toString());try{o=t[n](...i.map((e=>H(e,r))))}catch(e){return new Me("",e.toString())}}return o instanceof Me&&s?new A(o):Q(o)}class $ extends I{constructor(e,t="<AnonNative>",n=!1,r=!1){super(e,"function"==typeof e?d.function:d.object),this.__iterable__=!0,this.cast=()=>new Me("ESTypeError","Cannot cast native object"),this.clone=()=>new $(this.__value__),this.str=(e,t=new z)=>new W(Ne(this.__value__,t.__value__)),this.__eq__=(e,t)=>new V(this===t),this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.__get__=(e,t)=>{const n=Ne(t),r=this.__value__,i=r[n];if(void 0===i)return n in this?Q(this._[n],!0):new Fe(n,this);if(i instanceof I)return i;if("function"==typeof i){const e=this.functionsTakeProps,t=new R(((t,...i)=>M(e,r,n,t,i,this.catchErrorsToPrimitive)));return t.__allow_kwargs__=!0,t.__allow_args__=!0,t}return Q(i)},this.__set__=(e,t,n)=>{const r=Ne(t);r in this?this._[Ne(r)]=n:this._.__value__[r]=H(n,e)},this.__call__=(e,...t)=>"function"!=typeof this.__value__?new je("function",typeof this.__value__,Ne(this)):M(this.functionsTakeProps,this,"__value__",e,t,this.catchErrorsToPrimitive),this.has_property=(e,t)=>new V(!(this.__get__(e,t)instanceof Me)),this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.object)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.__iter__=()=>new q(Object.keys(this.__value__).map((e=>new W(e)))),this.len=()=>new z(Object.keys(this.__value__).length),this.keys=()=>[...Object.keys(this),...Object.keys(this.__value__)].map((e=>new W(e))),this.contains=this.has_property,this.__info__.name=Ne(t),this.functionsTakeProps=n,this.catchErrorsToPrimitive=r}}function B(){d.type=new G(!0,"Type"),d.undefined=new G(!0,"Null"),d.string=new G(!0,"Str"),d.array=new G(!0,"Arr"),d.number=new G(!0,"Num"),d.any=new G(!0,"Any"),d.function=new G(!0,"Func"),d.bool=new G(!0,"Bool"),d.object=new G(!0,"Obj"),d.error=new G(!0,"Err"),d.any.__info__={name:"Any",description:"Matches any other type",file:"built-in",builtin:!0},d.number.__info__={name:"Num",description:"The ES ESNumber type. Is a a double-precision 64-bit binary format IEEE 754 value, like double in Java and C#",file:"built-in",builtin:!0},d.string.__info__={name:"Str",description:"The ES String type. Holds an array of characters, and can be defined with any of ', \" and `. Can be indexed like an array.",file:"built-in",builtin:!0},d.bool.__info__={name:"Bool",description:"The ES Bool type. Exactly two instances exist, true and false.",file:"built-in",builtin:!0},d.function.__info__={name:"Func",description:"The ES Function type. Is a block of code which executes when called and takes in 0+ parameters.",file:"built-in",builtin:!0},d.array.__info__={name:"Arr",description:"The ES Array type. Defines a set of items of any type which can be accessed by an index with [].",file:"built-in",builtin:!0},d.object.__info__={name:"Obj",description:"The ES Object type. Similar to JS objects or python dictionaries.",file:"built-in",builtin:!0},d.error.__info__={name:"Err",description:"The ES Error type. Call to throw an error.",file:"built-in",builtin:!0},d.type.__info__={name:"Type",description:"The ES Type type. Call to get the type of a value at a string.",file:"built-in",builtin:!0}}function j(e,t,n,r){if(!(t instanceof G))return new je("Type",typeof t,t);if(t.__primordial__)return;const i=new R((({context:e},...i)=>{const s=new Z;if(s.parent=e,t.__extends__){const e=j(s,t.__extends__,n,r);if(e instanceof Me)return e}const o=null==t?void 0:t.__get_init__();if(!o)return;o.__this__=n,o.__closure__=s;const a=o.__call__({context:s},...i);return a instanceof Me?a:void 0}),void 0,"super",n),s=null==t?void 0:t.__get_init__();i.__allow_kwargs__=(null==s?void 0:s.__allow_kwargs__)||!1,i.__allow_args__=(null==s?void 0:s.__allow_args__)||!1,i.__args__=(null==s?void 0:s.__args__)||[];const o=e.setOwn("super",i);if(o instanceof Me)return o;const a=D(t,{context:e},[],[],!1,n);return a instanceof Me?a:void 0}function D(e,t,n,r,i=!0,s=new O){const{context:o}=t;if(e.__primordial__)return function(e,t,n){var r,i;switch(t.__name__){case"Null":return new P;case"Type":return e.length<1?new G:new W(null===(r=e[0])||void 0===r?void 0:r.__type_name__());case"Str":return e.length<1?new W:e[0].cast(n,d.string);case"Arr":if(e.length<1)return new q;const t=[];for(const r of e){const e=r.__iter__(n);if(e instanceof Me)return e;for(;;){const r=e.__next__(n);if(r instanceof Me)return r;if(r instanceof A&&"EndIterator"===(null===(i=r.__value__)||void 0===i?void 0:i.name))break;t.push(r)}}return new q(t);case"Num":return e.length<1?new z:e[0].cast(n,d.number);case"Func":return e.length<1?new R:e[0].cast(n,d.function);case"Bool":return e.length<1?new V:e[0].cast(n,d.boolean);default:return Q(e[0])}}(n,e,t);const a=e.__get_init__(),c=new Z;c.parent=null==a?void 0:a.__closure__;for(const n of e.__gargs__){let i=r.shift();if(i||(i=n.defaultValue),!i)return new Me("ArgumentError",`Not enough generic arguments provided for type ${e.__name__}`);s.__set__(t,n.name,i)}if(e.__extends__){const t=j(c,e.__extends__,s,o);if(t instanceof Me)return t}for(const n of e.__methods__){const e=n.clone();e.__this__=s,s.__set__(t,new W(n.name),e),-1!==k.indexOf(n.name)&&(s[n.name]=e.__call__)}if(i&&a){a.__this__=s,a.__closure__=c;const e=a.__call__({context:c},...n);if(e instanceof Me)return e}return s.__type__=e,s}class G extends I{constructor(e=!1,t="(anon)",n=[],r={},i,s=[],o=!1){super(void 0,null==d?void 0:d.type),this.__generic_types__=[],this.clone=()=>new G(this.__primordial__,this.__name__,this.__methods__,this.__properties__,this.__extends__,this.__gargs__,this.__abstract__),this.isa=(e,t)=>new V(t===d.type),this.cast=()=>new Ue("cast",this),this.__includes__=(e,t)=>{if(!t)return new V;const n=t.__type__;return this===d.any||n===d.any||this===n?new V(!0):n.__subtype_of__(e,this)},this.__subtype_of__=(e,t)=>{if(Object.is(t,d.any))return new V(!0);if(!(t instanceof G))return new V;if(this===d.any||this===t)return new V(!0);for(let n=0;n<t.__generic_types__.length;n++){let r=d.any;this.__generic_types__.length-1<=n&&(r=this.__generic_types__[n]);const i=t.__generic_types__[n],s=r.__subtype_of__(e,i);if(s instanceof Me)return s;if(!s.__value__)return new V}return this.__extends__?this.__extends__.__subtype_of__(e,t):new V},this.__eq__=(e,t)=>new V(t===this),this.__call__=(e,...t)=>{if(this.__abstract__)return new Me("TypeError","Cannot construct abstract class");const n=D(this,e,t||[],this.__generic_types__);if(n instanceof Me)return n;if(!this.__primordial__){if(!(n instanceof O))return new je("Obj",n.__type_name__(),Ne(n),"Constructors must return an object");let t=Object.assign({},this.__properties__),r=this.__extends__;for(;r;)t=Object.assign(Object.assign({},t),r.__properties__),r=r.__extends__;t.init=new F(d.function,d.undefined);const i=n.isa(e,new O(t));if(i instanceof Me)return i;if(!i.__value__)return new Me("TypeError","Initializer incorrectly assigned properties")}return n},this.str=()=>new W(this.__name__),this.__bool__=()=>new V(!0),this.bool=this.__bool__,this.__get__=(e,t)=>{const n=t.__value__;return n in this?Q(this._[n],!0):new Fe(Ne(t),this)},this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>Object.keys(this).map((e=>new W(e))),this.__get_init__=()=>{const e=this.__methods__.filter((e=>"init"===e.name));if(e)return e[0]},this.__generic__=(e,...t)=>{const n=this.clone();return e.dontTypeCheck||(n.__generic_types__=t),n},this.__primordial__=e,this.__name__=t,this.__info__.name=t,this.__extends__=i,this.__methods__=n,this.__properties__=r,this.__gargs__=s,this.__abstract__=o,d.type||(this.__type__=this)}}class F extends G{constructor(e,t){super(!1,`(${Ne(e)}) | (${Ne(t)})`),this.__call__=()=>new Ue("__call__",this),this.__includes__=(e,t)=>{const n=this.__left__.__includes__(e,t),r=this.__right__.__includes__(e,t);return n instanceof Me?n:r instanceof Me?r:new V(n.__value__||r.__value__)},this.__subtype_of__=(e,t)=>{if(Object.is(t,d.any))return new V(!0);const n=this.__eq__(e,t);if(n instanceof Me)return n;if(n.__value__)return new V(!0);const r=this.__left__.__subtype_of__(e,t),i=this.__right__.__subtype_of__(e,t);return r instanceof Me?r:i instanceof Me?i:new V(r.__value__&&i.__value__)},this.clone=()=>new F(this.__left__,this.__right__),this.__eq__=(e,t)=>{if(!(t instanceof F))return new V;const n=this.__left__.__eq__(e,t.__left__);if(n instanceof Me)return n;const r=this.__right__.__eq__(e,t.__right__);return r instanceof Me?r:new V(n.__value__&&r.__value__)},this.__generic__=()=>new Ue("__generic__",this),this.__left__=e,this.__right__=t}}class U extends G{constructor(e){super(!1,`~(${Ne(e)})`),this.__call__=()=>new Ue("__call__",this),this.__includes__=(e,t)=>{const n=this.__val__.__includes__(e,t);return n instanceof Me?n:new V(!n.__value__)},this.__subtype_of__=(e,t)=>{if(Object.is(t,d.any))return new V(!0);if(t instanceof F||t instanceof L){const n=t.__left__.__subtype_of__(e,this.__val__);if(n instanceof Me)return n;if(n.__value__)return new V;const r=t.__right__.__subtype_of__(e,this.__val__);return r instanceof Me?r:r.__value__?new V:new V(!0)}const n=this.__val__.__subtype_of__(e,t);return n instanceof Me?n:new V(!n.__value__)},this.clone=()=>new U(this.__val__),this.__eq__=(e,t)=>{if(!(t instanceof U))return new V;const n=this.__val__.__eq__(e,t.__val__);return n instanceof Me?n:new V(!0===n.__value__)},this.__generic__=()=>new Ue("__generic__",this),this.__val__=e}}class L extends G{constructor(e,t){super(!1,`(${Ne(e)}) & (${Ne(t)})`),this.__call__=()=>new Ue("__call__",this),this.__includes__=(e,t)=>{const n=this.__left__.__includes__(e,t),r=this.__right__.__includes__(e,t);return n instanceof Me?n:r instanceof Me?r:new V(n.__value__&&r.__value__)},this.__subtype_of__=(e,t)=>{if(t===d.any)return new V(!0);const n=this.__eq__(e,t);if(n instanceof Me)return n;if(n.__value__)return new V(!0);const r=this.__left__.__subtype_of__(e,t),i=this.__right__.__subtype_of__(e,t);return r instanceof Me?r:i instanceof Me?i:new V(r.__value__||i.__value__)},this.clone=()=>new L(this.__left__,this.__right__),this.__eq__=(e,t)=>{if(!(t instanceof L))return new V;const n=this.__left__.__eq__(e,t.__left__);if(n instanceof Me)return n;const r=this.__right__.__eq__(e,t.__right__);return r instanceof Me?r:new V(n.__value__&&r.__value__)},this.__generic__=()=>new Ue("__generic__",this),this.__left__=e,this.__right__=t}}class z extends I{constructor(e=0){super(e,d.number),this.cast=(e,t)=>{switch(t){case d.number:return this;case d.string:return this.str();case d.array:return new q(new Array(this.__value__));default:return new Me("TypeError",`Cannot cast to type '${Ne(t.__type_name__())}'`)}},this.str=()=>new W(this.__value__.toString()),this.__add__=(e,t)=>t instanceof z?new z(this.__value__+t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__subtract__=(e,t)=>t instanceof z?new z(this.__value__-t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__multiply__=(e,t)=>t instanceof z?new z(this.__value__*t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__divide__=(e,t)=>t instanceof z?new z(this.__value__/t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__pow__=(e,t)=>t instanceof z?new z(Math.pow(this.__value__,t.__value__)):new je("Num",t.__type_name__(),t.__value__),this.__mod__=(e,t)=>t instanceof z?new z(this.__value__%t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__eq__=(e,t)=>new V(t instanceof z&&this.__value__===t.__value__),this.__gt__=(e,t)=>t instanceof z?new V(this.__value__>t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__lt__=(e,t)=>t instanceof z?new V(this.__value__<t.__value__):new je("Num",t.__type_name__(),t.__value__),this.__bool__=()=>new V(this.__value__>0),this.bool=this.__bool__,this.clone=()=>new z(this.__value__),this.__get__=(e,t)=>Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this),this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.number)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>Object.keys(this).map((e=>new W(e)))}}class V extends I{constructor(e=!1){super(Boolean(e),d.bool),this.__get__=(e,t)=>Ne(t)in this?Q(this._[Ne(t)],!0):new Fe(t.__value__,this),this.cast=(e,t)=>t===d.number?new z(this.__value__?1:0):new Me("TypeError",`Cannot cast boolean to type '${Ne(t.__type_name__())}'`),this.__eq__=(e,t)=>t instanceof V?new V(this.__value__===t.__value__):new je("Boolean",t.__type_name__(),t.__value__),this.__bool__=()=>this,this.__and__=(e,t)=>{var n;return new V(this.__value__&&!0===(null===(n=t.bool(e))||void 0===n?void 0:n.__value__))},this.__or__=(e,t)=>new V(this.__value__||!0===t.bool(e).__value__),this.str=()=>new W(this.__value__?"true":"false"),this.clone=()=>new V(this.__value__),this.bool=()=>this,this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.boolean)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.keys=()=>Object.keys(this).map((e=>new W(e))),this.__info__={name:Ne(e),description:`Boolean global constant which evaluates to ${Ne(e)}, the opposite of ${Ne(!e)}`,file:"built-in",builtin:!0,helpLink:"https://en.wikipedia.org/wiki/Boolean_expression"}}}class q extends I{constructor(e=[]){super(e,d.array),this.__iterable__=!0,this.len=()=>new z(this.__value__.length),this.cast=(e,t)=>{switch(t){case d.number:return new z(this.len().__value__);case d.boolean:return this.bool();case d.string:return this.str(e);default:return new Me("TypeError",`Cannot cast 'Arr' to '${Ne(t)}'`)}},this.str=(e,t=new z)=>new W(Ne(this.__value__,t.__value__)),this.__eq__=(e,t)=>{if(!(t instanceof q))return new V;if(t.len().__value__!==this.len().__value__)return new V;for(let n=0;n<this.len().__value__;n++){const r=this.__value__[n],i=t.__value__[n];if(!r){if(i)return new V;continue}if(!r.__eq__)return new V;const s=r.__eq__(e,i);if(s instanceof Me)return s;if(!s.__value__)return new V}return new V(!0)},this.__add__=(e,t)=>{if(!t.__iterable__)return new je("IIterable",t.__type_name__(),Ne(t));const n=this.clone(),r=t.__iter__(e);if(r instanceof Me)return r;for(;;){const t=r.__next__(e);if(t instanceof Me)return t;if(t instanceof A&&"EndIterator"===t.__value__.name)break;n.add(e,t)}return n},this.__bool__=()=>new V(this.__value__.length>0),this.bool=this.__bool__,this.__get__=(e,t)=>{if(t instanceof W&&Ne(t)in this._)return Q(this._[Ne(t)],!0);if(!(t instanceof z))return new P;let n=t.__value__;for(;n<0;)n=this.__value__.length+n;return n<this.__value__.length?this.__value__[n]:new P},this.__set__=(e,t,n)=>{if(!(t instanceof z))return;let r=t.__value__;for(;r<0;)r=this.__value__.length+r;this.__value__[r]=n},this.contains=(e,t)=>{for(const n of this.__value__)if(t.__eq__(e,n))return new V(!0);return new V},this.clone=()=>new q([...this.__value__]),this.__includes__=(e,t)=>{if(!(t instanceof q)||this.len().__value__!==t.len().__value__)return new V;for(let n=0;n<this.__value__.length;n++){const r=this.__value__[n].__includes__(e,t.__value__[n]);if(r instanceof Me)return r;if(!r.__value__)return new V}return new V(!0)},this.__subtype_of__=(e,t)=>{if(!(t instanceof q)||this.len().__value__!==t.len().__value__)return new V;for(let n=0;n<this.__value__.length;n++){const r=this.__value__[n].__subtype_of__(e,t.__value__[n]);if(r instanceof Me)return r;if(!r.__value__)return new V}return new V(!0)},this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.__iter__=this.clone,this.__next__=()=>this.__value__.length>0?Q(this.__value__.shift()):new A(new We),this.keys=()=>{const e=Object.keys(this._).map((e=>new W(e)));return e.push(...Object.keys(this.__value__).map((e=>new z(parseInt(e))))),e},this.add=(e,...t)=>{this.__value__.push(...t)}}}class W extends I{constructor(e=""){super(e.toString(),d.string),this.__iterable__=!0,this.str=()=>this,this.cast=(e,t)=>{switch(t){case d.number:const e=parseFloat(this.__value__);return isNaN(e)?new Me("TypeError","This string is not a valid number"):new z(e);case d.string:return this;case d.array:return new q(this.__value__.split("").map((e=>new W(e))));default:return new Me("TypeError",`Cannot cast to type '${Ne(t.__type_name__())}'`)}},this.__add__=(e,t)=>t instanceof W?new W(this.__value__+t.__value__):new je("Str",t.__type_name__(),t.__value__),this.__multiply__=(e,t)=>t instanceof z?new W(this.__value__.repeat(t.__value__)):new je("ESNumber",t.__type_name__(),t.__value__),this.__eq__=(e,t)=>new V(t instanceof W&&this.__value__===t.__value__),this.__gt__=(e,t)=>t instanceof W?new V(this.__value__.length>t.__value__.length):new je("Str",t.__type_name__(),t.__value__),this.__lt__=(e,t)=>t instanceof W?new V(this.__value__.length<t.__value__.length):new je("Str",t.__type_name__(),t.__value__),this.__bool__=()=>new V(this.__value__.length>0),this.bool=this.__bool__,this.len=()=>new z(this.__value__.length),this.clone=()=>new W(this.__value__),this.__get__=(e,t)=>{if(t instanceof W&&this._.hasOwnProperty(Ne(t)))return Q(this._[Ne(t)],!0);if(!(t instanceof z))return new W;let n=t.__value__;for(;n<0;)n=this.__value__.length+n;return n<this.__value__.length?new W(this.__value__[n]):new W},this.__set__=(e,t,n)=>{if(!(t instanceof z))return;n instanceof W||(n=new W(Ne(n)));let r=t.__value__;for(;r<0;)r=this.__value__.length+r;const i=n.str(e,new z).__value__,s=this.__value__.substr(0,r),o=this.__value__.substr(r+i.length);this.__value__=s+i+o},this.__includes__=this.__eq__,this.__subtype_of__=(e,t)=>Object.is(t,d.any)||Object.is(t,d.string)?new V(!0):this.__eq__(e,t),this.__pipe__=(e,t)=>new F(this,t),this.__ampersand__=(e,t)=>new L(this,t),this.__iter__=()=>{const e=this.__value__.split("");return new q(e.map((e=>new W(e))))},this.keys=()=>{const e=Object.keys(this._).map((e=>new W(e)));return e.push(...Object.keys(this.__value__).map((e=>new z(parseInt(e))))),e},this.contains=(e,t)=>t instanceof W?new V(this.__value__.includes(t.__value__)):new je("Str",t.__type_name__(),t.__value__)}}class J{constructor(e,t,n={}){var r,i,s;this.clone=e=>new J(this.value.clone(e),this.identifier,{isConstant:this.isConstant,isAccessible:this.isAccessible}),this.str=()=>new W(`<Symbol: ${this.identifier}>`),this.value=e,this.identifier=t,this.isConstant=null!==(r=n.isConstant)&&void 0!==r&&r,this.isAccessible=null===(i=n.isAccessible)||void 0===i||i,this.type=null!==(s=n.type)&&void 0!==s?s:e.__type__}}function Q(e,t=!1){return e instanceof I?e:null==e?new P:e instanceof Me?new A(e):e instanceof J?e.value:"number"==typeof e?new z(e):"string"==typeof e?new W(e):"boolean"==typeof e?new V(e):"bigint"==typeof e?new z(Number(e)):"symbol"==typeof e?new W(String(e)):Array.isArray(e)?new q(e.map((e=>Q(e,t)))):new $(e,void 0,t)}function H(e,t){if(!(e instanceof I))return e;if(e instanceof q)return e.__value__.map((e=>H(e,t)),t);if(e instanceof O){const n={};for(const r in e.__value__)n[r]=H(e.__value__[r],t);return n}return e instanceof P?void 0:e instanceof R?(...n)=>{const r=e.__call__(t,...n.map((e=>Q(e))));return r instanceof Me?(console.error(r.str),r):H(r,t)}:e instanceof G?e:e.__value__}const K={red:31,yellow:33,green:32,cyan:36,blue:34,grey:2},X={};for(const e of Object.keys(K))X[e]=t=>(t||(t=""),l?`[${K[e]}m`+t+"":`<span style="color: ${e}">${t}</span>`);const Y=X;class Z{constructor(){this.symbolTable={},this.initialisedAsGlobal=!1,this.deleted=!1,this.path_=""}get path(){return this.path_||!this.parent?this.path_:this.parent.path}set path(e){this.path_=e}get parent(){return this.parent_}set parent(e){e!=this?this.parent_=e:console.error(Y.red("Setting context parent to self"))}has(e){return!!e&&void 0!==this.get(e)}hasOwn(e){return this.symbolTable[e]instanceof J}get(e){const t=this.getSymbol(e);return t instanceof Me||null==t?t:t.value}getSymbolTableAsDict(){const e={};for(const t in this.symbolTable)e[t]=this.symbolTable[t];return e}getSymbol(e){let t=this.symbolTable[e];if(t&&!t.isAccessible)return new je("assessable","inaccessible",t.identifier);if(!t&&this.parent){const n=this.parent.getSymbol(e);if(n instanceof Me)return n;t=n}return t}set(e,t,n={}){let r=this;if(n.global)r=this.root;else{for(;!r.hasOwn(e)&&void 0!==r.parent;)r=r.parent;r.hasOwn(e)||(r=this)}return r.setOwn(e,t,n)}setOwn(e,t,n={}){if(t instanceof I||(t=Q(t)),n.global)return n.global=!1,void this.root.setOwn(e,t,n);if(!n.forceThroughConst){const t=this.symbolTable[e];if(null==t?void 0:t.isConstant)return new je("dynamic","constant",e)}this.symbolTable[e]=new J(t,e,n)}remove(e){return this.hasOwn(e)?(delete this.symbolTable[e],!0):this.parent?this.parent.remove(e):new Ge(e)}clear(){for(const e in this.symbolTable)this.remove(e);this.parent=void 0,this.deleted=!0}get root(){let e=this;for(;e.parent;)e=e.parent;return e}get keys(){return Object.keys(this.symbolTable)}clone(){const e=new Z;return e.parent=this.parent,e.deleted=this.deleted,e.initialisedAsGlobal=this.initialisedAsGlobal,e.symbolTable=Object.assign(Object.assign({},e.symbolTable),this.symbolTable),e}log(){console.log("---- CONTEXT ----");for(const e in this.symbolTable){const t=this.symbolTable[e];let n=e;t.isConstant&&(n+=" (CONST)"),t.isAccessible||(n+=" (INACCESSIBLE)"),n+=": ",n+=Ne(this.symbolTable[e].value),console.log(n)}console.log("-----------------")}}function ee(e,t){var n;const r=e.type.interpret(t);if(r.error)return r.error;let i;if(e.defaultValue){const r=null===(n=e.defaultValue)||void 0===n?void 0:n.interpret(t);if(r.error)return r.error;r.val instanceof I&&(i=r.val)}return{name:e.name,type:r.val,defaultValue:i,isKwarg:e.isKwarg}}class te{constructor(e){this.val=new P,this.shouldBreak=!1,this.shouldContinue=!1,e instanceof Me?this.error=e:e&&(this.val=e)}}class ne{constructor(e){this.val="",this.hoisted="","string"==typeof e?this.val=e:e&&(this.error=e)}register(e,t){const n=e.compilePy(t);return this.hoisted+=n.hoisted,n.error?(this.error=n.error,""):n.val}}class re{constructor(e,t=!1){this.pos=e,this.isTerminal=t}interpret(e){var t;const n=y(),r=new te,i=this.interpret_(e);i instanceof Me?r.error=i:i instanceof te?(r.val=i.val,r.error=i.error,r.funcReturn=i.funcReturn,r.shouldBreak=i.shouldBreak,r.shouldContinue=i.shouldContinue):r.val=i,r.error&&r.error.pos.isUnknown&&(r.error.pos=this.pos),r.val instanceof I||(r.error=new je("Primitive","Native JS value",Ne(r.val)),r.val=new P),(t=r.val.__info__).file||(t.file=this.pos.file),re.interprets++;const s=y()-n;return re.totalTime+=s,s>re.maxTime&&(re.maxTime=s),r}}re.interprets=0,re.totalTime=0,re.maxTime=0;class ie extends re{constructor(e,t,n,r){super(e),this.left=t,this.opTok=n,this.right=r}interpret_(e){const t=this.left.interpret(e);if(t.error)return t.error;const n=this.right.interpret(e);if(n.error)return n.error;const r=t.val,i=n.val;if(void 0===r)return new je("~nil","nil",r,"N_binOp.interpret_").position(this.opTok.pos);if(void 0===i)return new je("~nil","nil",i,"N_binOp.interpret_").position(this.opTok.pos);switch(this.opTok.type){case b.LTE:{const t=r.__lt__({context:e},i),n=r.__eq__({context:e},i);return t instanceof Me?t:n instanceof Me?n:new te(t.__or__({context:e},n))}case b.GTE:{const t=r.__gt__({context:e},i),n=r.__eq__({context:e},i);return t instanceof Me?t:n instanceof Me?n:new te(t.__or__({context:e},n))}case b.NOT_EQUALS:{const t=r.__eq__({context:e},i);return t instanceof Me?t:new te(new V(!t.bool().__value__))}case b.ADD:return new te(r.__add__({context:e},i));case b.SUB:return new te(r.__subtract__({context:e},i));case b.ASTRIX:return new te(r.__multiply__({context:e},i));case b.DIV:return new te(r.__divide__({context:e},i));case b.POW:return new te(r.__pow__({context:e},i));case b.MOD:return new te(r.__mod__({context:e},i));case b.EQUALS:return new te(r.__eq__({context:e},i));case b.LT:return new te(r.__lt__({context:e},i));case b.GT:return new te(r.__gt__({context:e},i));case b.AND:return new te(r.__and__({context:e},i));case b.OR:return new te(r.__or__({context:e},i));case b.AMPERSAND:return new te(r.__ampersand__({context:e},i));case b.PIPE:return new te(r.__pipe__({context:e},i));case b.DOUBLE_QM:return new te(r.__nilish__({context:e},i));case b.IDENTIFIER:if("in"===this.opTok.value)return i.__iterable__&&"contains"in i?new te(i.contains({context:e},r)):new je("Iterable",i.__type_name__(),Ne(i));default:return new Be(`Invalid binary operator: ${this.opTok.str()}`).position(this.opTok.pos)}}compileJS(e){const t=this.left.compileJS(e);if(t.error)return t;const n=this.right.compileJS(e);return n.error?n:e.minify?new ne(`${t.val}${this.opTok.str()}${n.val}`):new ne(`${t.val} ${this.opTok.str()} ${n.val}`)}compilePy(e){const t=this.left.compilePy(e);if(t.error)return t;const n=this.right.compilePy(e);if(n.error)return n;const r={"&&":"and","||":"or","^":"**"};let i=x[this.opTok.type];return i in r&&(i=r[i]),new ne(`${t.val} ${i} ${n.val}`)}str(){return`(${this.left.str()} ${this.opTok.str()} ${this.right.str()})`}}class se extends re{constructor(e,t,n){super(e),this.a=t,this.opTok=n}interpret_(e){var t,n,r;const i=this.a.interpret(e);if(i.error)return i.error;switch(this.opTok.type){case b.SUB:case b.ADD:if(!(i.val instanceof z))return new je("ESNumber",(null===(t=i.val)||void 0===t?void 0:t.__type_name__().toString())||"undefined_",null===(n=i.val)||void 0===n?void 0:n.__value__).position(this.pos);const s=i.val.__value__;return new te(new z(this.opTok.type===b.SUB?-s:Math.abs(s)));case b.NOT:return new te(new V(!(null===(r=null==i?void 0:i.val)||void 0===r?void 0:r.bool({context:e}).__value__)));case b.BITWISE_NOT:return new te(new U(i.val));case b.QM:return new te(new F(d.undefined,i.val));default:return new Be(`Invalid unary operator: ${this.opTok.str()}`).position(this.opTok.pos)}}compileJS(e){const t=this.a.compileJS(e);return t.error?t:new ne(`${this.opTok.str()}${t.val}`)}compilePy(e){const t=this.a.compilePy(e);return t.error?t:new ne(`${this.opTok.str()}${t.val}`)}str(){return`(${this.opTok.str()}${this.a.str()})`}}class oe extends re{constructor(e,t,n,r="=",i=!1,s=!1,o=!1,a=d.any){super(e),this.value=n,this.varNameTok=t,this.isGlobal=i,this.assignType=r,this.isConstant=s,this.isDeclaration=o,this.type=a instanceof I?new Ie(a):a}interpret_(e){var t,n;if(this.isDeclaration){if(e.hasOwn(this.varNameTok.value))return new Be(`Symbol '${this.varNameTok.value}' already exists, and cannot be redeclared`).position(this.pos);if("="!==this.assignType)return new Be(`Cannot declare variable with operator '${this.assignType}'`).position(this.pos)}const r=this.value.interpret(e),i=this.type.interpret(e);if(r.error)return r.error;if(i.error)return i.error;if(!i.val)return new je("Type","nil").position(this.varNameTok.pos);if(!r.val)return new je("~nil","nil","N_varAssign.interpret_").position(this.varNameTok.pos);const s=i.val.__includes__({context:e},r.val);if(s instanceof Me)return s;if(!s.bool().__value__)return new je(Ne(i.val),Ne(null===(t=r.val)||void 0===t?void 0:t.__type_name__()),Ne(r.val)).position(this.varNameTok.pos);if(this.isDeclaration)return e.setOwn(this.varNameTok.value,r.val,{global:!1,isConstant:this.isConstant,type:i.val}),new te(r.val);if(e.has(this.varNameTok.value)){const t=e.getSymbol(this.varNameTok.value);if(t instanceof Me)return t;if(t){const i=t.type.__includes__({context:e},r.val);if(i instanceof Me)return i;if(!i.__value__)return new je(Ne(t.type),null===(n=r.val)||void 0===n?void 0:n.__type_name__(),Ne(r.val)).position(this.varNameTok.pos)}}if("="===this.assignType){let t=r.val;void 0===t&&(t=new P);const n=e.getSymbol(this.varNameTok.value);if(n instanceof Me)return n;if(!n)return new Be("Cannot declare variable without keyword").position(this.pos);const i=n.type.__includes__({context:e},r.val);if(i instanceof Me)return i;if(!i.bool().__value__)return new je(Ne(n.type),Ne(r.val.__type__),Ne(r.val));const s=e.set(this.varNameTok.value,t,{global:this.isGlobal,isConstant:this.isConstant,type:n.type});if(s instanceof Me)return s}else{const t=e.get(this.varNameTok.value);if(t instanceof Me)return t;if(null==t)return new Be(`Cannot declare variable with operator '${this.assignType}'`).position(this.pos);let n;const i=r.val;switch(this.assignType[0]){case"*":n=t.__multiply__({context:e},i);break;case"/":n=t.__divide__({context:e},i);break;case"+":n=t.__add__({context:e},i);break;case"-":n=t.__subtract__({context:e},i);break;default:return new Me("AssignError",`Cannot find assignType of ${this.assignType[0]}`).position(this.pos)}if(n instanceof Me)return n;const s=e.set(this.varNameTok.value,n,{global:this.isGlobal,isConstant:this.isConstant,type:n.__type__});if(s instanceof Me)return s;r.val=n}return"(anonymous)"!==r.val.__info__.name&&r.val.__info__.name||(r.val.__info__.name=this.varNameTok.value),r}compileJS(e){const t=this.value.compileJS(e);if(t.error)return t;let n="";this.isDeclaration&&(n=this.isGlobal?"var":this.isConstant?"const":"let");let r=this.assignType;return"="!==r&&(r+="="),e.minify?new ne(`${n} ${this.varNameTok.value}${r}${t.val}`):new ne(`${n} ${this.varNameTok.value} ${r} ${t.val}`)}compilePy(e){const t=new ne,n=this.value.compilePy(e);if(n.error)return n;t.hoisted+=n.hoisted;let r=this.assignType;return"="!==r&&(r+="="